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  
29  import javax.annotation.Nonnull;
30  import javax.annotation.Nullable;
31  import java.io.File;
32  import java.util.Map;
33  import java.util.Properties;
34  
35  /**
36   * Configuration for forking tests.
37   */
38  public abstract class ForkConfiguration
39  {
40      static final String DEFAULT_PROVIDER_CLASS = ForkedBooter.class.getName();
41  
42      @Nonnull public abstract File getTempDirectory();
43      @Nullable protected abstract String getDebugLine();
44      @Nonnull protected abstract File getWorkingDirectory();
45      @Nonnull protected abstract Properties getModelProperties();
46      @Nullable protected abstract String getArgLine();
47      @Nonnull protected abstract Map<String, String> getEnvironmentVariables();
48      protected abstract boolean isDebug();
49      protected abstract int getForkCount();
50      protected abstract boolean isReuseForks();
51      @Nonnull protected abstract Platform getPluginPlatform();
52      @Nonnull protected abstract JdkAttributes getJdkForTests();
53      @Nonnull protected abstract Classpath getBooterClasspath();
54  
55      /**
56       * @param config               The startup configuration
57       * @param forkNumber           index of forked JVM, to be the replacement in the argLine
58       * @param dumpLogDirectory     directory for dump log file
59       * @return CommandLine able to flush entire command going to be sent to forked JVM
60       * @throws org.apache.maven.surefire.booter.SurefireBooterForkException
61       *          when unable to perform the fork
62       */
63      @Nonnull
64      public abstract OutputStreamFlushableCommandline createCommandLine( @Nonnull StartupConfiguration config,
65                                                                          int forkNumber,
66                                                                          @Nonnull File dumpLogDirectory )
67              throws SurefireBooterForkException;
68  }