View Javadoc
1   package org.apache.maven.plugin.surefire.booterclient;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.plugin.surefire.JdkAttributes;
23  import org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline;
24  import org.apache.maven.surefire.booter.Classpath;
25  import org.apache.maven.surefire.booter.ForkedBooter;
26  import org.apache.maven.surefire.booter.StartupConfiguration;
27  import org.apache.maven.surefire.booter.SurefireBooterForkException;
28  import org.apache.maven.surefire.extensions.ForkNodeFactory;
29  
30  import javax.annotation.Nonnull;
31  import javax.annotation.Nullable;
32  import java.io.File;
33  import java.util.Map;
34  import java.util.Properties;
35  
36  /**
37   * Configuration for forking tests.
38   */
39  public abstract class ForkConfiguration
40  {
41      static final String DEFAULT_PROVIDER_CLASS = ForkedBooter.class.getName();
42  
43      @Nonnull public abstract ForkNodeFactory getForkNodeFactory();
44      @Nonnull public abstract File getTempDirectory();
45      @Nullable protected abstract String getDebugLine();
46      @Nonnull protected abstract File getWorkingDirectory();
47      @Nonnull protected abstract Properties getModelProperties();
48      @Nullable protected abstract String getArgLine();
49      @Nonnull protected abstract Map<String, String> getEnvironmentVariables();
50      @Nonnull protected abstract String[] getExcludedEnvironmentVariables();
51      protected abstract boolean isDebug();
52      protected abstract int getForkCount();
53      protected abstract boolean isReuseForks();
54      @Nonnull protected abstract Platform getPluginPlatform();
55      @Nonnull protected abstract JdkAttributes getJdkForTests();
56      @Nonnull protected abstract Classpath getBooterClasspath();
57  
58      /**
59       * @param config               The startup configuration
60       * @param forkNumber           index of forked JVM, to be the replacement in the argLine
61       * @param dumpLogDirectory     directory for dump log file
62       * @return CommandLine able to flush entire command going to be sent to forked JVM
63       * @throws org.apache.maven.surefire.booter.SurefireBooterForkException
64       *          when unable to perform the fork
65       */
66      @Nonnull
67      public abstract OutputStreamFlushableCommandline createCommandLine( @Nonnull StartupConfiguration config,
68                                                                          int forkNumber,
69                                                                          @Nonnull File dumpLogDirectory )
70              throws SurefireBooterForkException;
71  }