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