/** * Processes two sequences of options and combines them into a single sequence. */ public static Option[] options(final Option[] options1, final Option... options2) { return options(OptionUtils.combine(options1, options2)); }
/** * Create a new system based on *this*. The forked System remembers the forked instances in * order to clear resources up (if desired). */ @Override public ExamSystem fork(Option[] options) { try { ExamSystem sys = new DefaultExamSystem(combine(combinedOptions, options)); subsystems.add(sys); return sys; } catch (IOException exc) { throw new TestContainerException(exc); } }
/** * Return an array of options for setting up a pax-exam test environment for karaf. * * @param sysOptions test-specific system property options * @return an array of pax-exam options */ public static Option[] getDefaultOptions(SystemPropertyOption... sysOptions) { return combine(getDefaultConfigOptions(sysOptions), getDefaultProvisioningOptions()); }
/** * Return an array of options for setting up a pax-exam test environment for karaf. * * @param sysOptions test-specific system property options * @return an array of pax-exam options */ public static Option[] getDefaultOptions(SystemPropertyOption... sysOptions) { return combine(getDefaultConfigOptions(sysOptions), getDefaultProvisioningOptions()); }
public static ExamSystem createServerSystem(Option... options) throws IOException { return DefaultExamSystem.create(OptionUtils.combine(options, defaultServerSystemOptions())); }
public static ExamSystem createTestSystem(Option... options) throws IOException { return DefaultExamSystem.create(OptionUtils.combine(options, defaultTestSystemOptions())); }
/** * Constructor. * * @param testMethod test method (cannot be null) * @param testClass test class (cannot be null) * @param frameworkOption framework option (on which framework the test method should be run) (can be null = default * framework) * @param userOptions user options (can be null) */ public JUnit4TestMethod( final Method testMethod, final TestClass testClass, final FrameworkOption frameworkOption, final Option... userOptions ) { super( testMethod, testClass ); validateNotNull( testMethod, "Test method" ); validateNotNull( testClass, "Test class" ); m_testMethod = testMethod; m_options = OptionUtils.combine( userOptions, frameworkOption ); m_name = calculateName( testMethod.getName(), frameworkOption ); m_testBundleUrl = getTestBundleUrl( testClass.getName(), m_testMethod.getName() ); }
/** * Top level option combinator that adds platform fixes as needed * @param params * @return */ public static Option[] testOptions(Object ... params) { // We need to add pax-exam-junit here when running with the ibm // jdk to avoid the following exception during the test run: // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration // We also need to pass through local repository properties return combine(flatOptions(params), when(System.getProperty("maven.repo.local") != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + System.getProperty("maven.repo.local"))), when(System.getProperty("org.ops4j.pax.url.mvn.localRepository") != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + System.getProperty("org.ops4j.pax.url.mvn.localRepository"))), when("IBM Corporation".equals(System.getProperty("java.vendor"))) .useOptions(wrappedBundle(mavenBundle("org.ops4j.pax.exam", "pax-exam-junit"))), mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit") ); }
return combine( remove( ProvisionOption.class, options ), processed.toArray( new Option[processed.size()] ) );
combinedOptions = combine(combinedOptions, work);
@Override public TestProbeBuilder createProbe() throws IOException { WarProbeOption warProbeOption = getSingleOption(WarProbeOption.class); if (warProbeOption == null) { LOG.debug("creating default probe"); TestProbeBuilderImpl testProbeBuilder = new TestProbeBuilderImpl(cache, store); testProbeBuilder.setHeader("Bundle-SymbolicName", "PAXEXAM-PROBE-" + createID("created probe")); return testProbeBuilder; } else { ConfigurationFactory configurationFactory = ServiceProviderFinder .findAnyServiceProvider(ConfigurationFactory.class); LOG.debug("creating WAR probe"); if (configurationFactory == null) { return new WarTestProbeBuilderImpl(getTempFolder(), this); } else { Option[] configuration = configurationFactory.createConfiguration(); Option[] tempOptions = combine(combinedOptions, configuration); warProbeOption = getSingleOption(WarProbeOption.class, tempOptions); return new WarTestProbeBuilderImpl(getTempFolder(), warProbeOption); } } }
/** * Constructor. * * @param javaRunner java runner to be used to start up Pax Runner * @param options user startup options */ PaxRunnerTestContainer( final DefaultJavaRunner javaRunner, final Option... options ) { m_javaRunner = javaRunner; m_startTimeout = getTestContainerStartTimeout( options ); int registryPort = createRegistry(); m_remoteBundleContextClient = new RemoteBundleContextClient( registryPort, getRMITimeout( options ) ); m_arguments = new ArgumentsBuilder( wrap( expand( combine( options, localOptions() ) ) ) ); m_customizers = new CompositeCustomizer( m_arguments.getCustomizers() ); m_store = StoreFactory.sharedLocalStore(); m_cache = new HashMap<String, Handle>(); }
@Configuration public Option[] config() { Option[] options = new Option[] { when(Boolean.getBoolean(KARAF_DEBUG_PROP)) .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)), karafDistributionConfiguration().frameworkUrl(getKarafDistro()) .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY)) .useDeployFolder(false), when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()), features(getFeatureRepo(), getFeatureName()), getLoggingOption(), mvnLocalRepoOption(), editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j.rootLogger", "INFO, stdout, osgi:*")}; return OptionUtils.combine(options, getAdditionalOptions()); }
/** * Creates default pax exam configuration for Karaf. * @return the default configuration */ public Option[] createConfig() { final Option[] base = options( cleanCaches(), karafDistributionConfiguration() .frameworkUrl( maven().groupId("org.apache.karaf").artifactId("apache-karaf") .type("zip").versionAsInProject()) .name("Apache Karaf") .karafVersion( MavenUtils.getArtifactVersion("org.apache.karaf", "apache-karaf")) .unpackDirectory(new File("target/exam/unpack/")), keepRuntimeFolder(), junitBundles(), addCodeCoverageOption(), addMavenSettingsOptions(), mavenReposURLOptions(), loggingLevel(), addExtraOptions(), featureToTest()); final Option[] baseAndJVM = OptionUtils.combine(base, addJVMOptions()); final Option vmOption = (paxRunnerVmOption != null) ? CoreOptions .vmOption(paxRunnerVmOption) : null; return OptionUtils.combine(baseAndJVM, vmOption); } /**
/** * Creates default pax exam configuration for Karaf. * @return the default configuration */ public Option[] createConfig() { final Option[] base = options( cleanCaches(), karafDistributionConfiguration() .frameworkUrl( maven().groupId("org.apache.karaf").artifactId("apache-karaf") .type("zip").versionAsInProject()) .name("Apache Karaf") .karafVersion( MavenUtils.getArtifactVersion("org.apache.karaf", "apache-karaf")) .unpackDirectory(new File("target/exam/unpack/")), keepRuntimeFolder(), junitBundles(), addCodeCoverageOption(), addMavenSettingsOptions(), mavenReposURLOptions(), loggingLevel(), addExtraOptions(), featureToTest()); final Option[] baseAndJVM = OptionUtils.combine(base, addJVMOptions()); final Option vmOption = (paxRunnerVmOption != null) ? CoreOptions .vmOption(paxRunnerVmOption) : null; return OptionUtils.combine(baseAndJVM, vmOption); } /**
return OptionUtils.combine(baseConfig, new VMOption[] { new VMOption("--add-reads=java.xml=java.logging"), new VMOption("--add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED"),
/** * Creates default pax exam configuration for Karaf. * @return the default configuration */ public Option[] createConfig() { final Option[] base = options( cleanCaches(), karafDistributionConfiguration() .frameworkUrl( maven().groupId("org.apache.karaf").artifactId("apache-karaf") .type("zip").versionAsInProject()) .name("Apache Karaf") .karafVersion( MavenUtils.getArtifactVersion("org.apache.karaf", "apache-karaf")) .unpackDirectory(new File("target/exam/unpack/")), keepRuntimeFolder(), cleanCaches(), junitBundles(), addCodeCoverageOption(), addMavenSettingsOptions(), mavenReposURLOptions(), loggingLevel(), addExtraOptions(), featureToTest()); final Option[] baseAndJVM = OptionUtils.combine(base, addJVMOptions()); final Option vmOption = (paxRunnerVmOption != null) ? CoreOptions .vmOption(paxRunnerVmOption) : null; return OptionUtils.combine(baseAndJVM, vmOption); } /**
final String karafVersion = MavenUtils.getArtifactVersion("org.apache.karaf.features", "org.apache.karaf.features.core"); options = OptionUtils.combine(options, new VMOption[] { new VMOption("--add-reads=java.xml=java.logging"), new VMOption("--add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED"), return OptionUtils.combine(options, getAdditionalOptions());