Refine search
protected String getSystemProperty(String key) { SystemPropertyOption[] systemProperties = examSystem.getOptions(SystemPropertyOption.class); if (systemProperties != null) { for (SystemPropertyOption systemPropertyOption : systemProperties) { if (key.equals(systemPropertyOption.getKey())) { return systemPropertyOption.getValue(); } } } return null; } }
@Override public void stop() { try { remoteFramework.stop(); system.clear(); } catch (RemoteException | BundleException exc) { throw new TestContainerException(exc); } frameworkFactory.join(); system.clear(); }
private Map<String, Object> createFrameworkProperties() throws IOException { final Map<String, Object> p = new HashMap<String, Object>(); p.put(FRAMEWORK_STORAGE, system.getTempFolder().getAbsolutePath()); SystemPackageOption[] systemPackageOptions = system.getOptions(SystemPackageOption.class); if (systemPackageOptions.length > 0) { p.put(FRAMEWORK_SYSTEMPACKAGES_EXTRA, join(systemPackageOptions)); } p.put(FRAMEWORK_BOOTDELEGATION, join(system.getOptions(BootDelegationOption.class))); for (FrameworkPropertyOption option : system.getOptions(FrameworkPropertyOption.class)) { p.put(option.getKey(), option.getValue()); } for (SystemPropertyOption option : system.getOptions(SystemPropertyOption.class)) { System.setProperty(option.getKey(), option.getValue()); } return p; }
public EclipsePlatformTestContainer(ExamSystem system) throws ExamConfigurationException { this.system = system; application = system.getRequiredOption(EclipseApplicationOption.class); cleanCaches = system.getOption(CleanCachesOption.class); ignoreItems = system.getOption(IgnoreItems.class); }
private void setFrameworkStartLevel() throws RemoteException, ExamConfigurationException { FrameworkStartLevelOption startLevelOption = system.getOption(FrameworkStartLevelOption.class); int startLevel = startLevelOption == null ? START_LEVEL_TEST_BUNDLE : startLevelOption .getStartLevel(); LOG.debug("Jump to startlevel [{}]", startLevel); long timeout = system.getTimeout().getValue(); boolean startLevelReached = remoteFramework.setFrameworkStartLevel(startLevel, timeout); if (!startLevelReached) { String msg = String.format("start level %d has not been reached within %d ms", startLevel, timeout); throw new TestContainerException(msg); } }
String name = m_system.createID( RUNNER_TEST_CONTAINER ); ExamSystem m_subsystem = m_system.fork( options( systemProperty( Constants.RMI_HOST_PROPERTY ).value( m_reg.getHost() ), systemProperty( Constants.RMI_PORT_PROPERTY ).value( "" + m_reg.getPort() ), systemProperty( Constants.RMI_NAME_PROPERTY ).value( name ) m_target = new RBCRemoteTarget( name, m_reg.getPort(), m_subsystem.getTimeout() ); LOG.info( "Wait for test container to finish its initialization " + ( m_subsystem.getTimeout() ) ); if( m_subsystem.getOptions( ServerModeOption.class ).length == 0 ) { waitForState( SYSTEM_BUNDLE, Bundle.ACTIVE, m_subsystem.getTimeout() );
try { port = new FreePort(20000, 21000); system = system.fork(new Option[] { systemProperty("java.protocol.handler.pkgs").value("org.ops4j.pax.url"), systemProperty(EXAM_INVOKER_PORT).value(Integer.toString(port.getPort())) }); List<String> vmArgs = createVmArguments(); .getOptions(BootClasspathLibraryOption.class); throw new TestContainerException(exc); throw new TestContainerException("Problem in test container configuration", e);
&& carbonHomeDirectoryOption.getDistributionMavenURL() == null && carbonHomeDirectoryOption.getDistributionZipPath() == null) { throw new TestContainerException("Distribution path need to be set."); String name = system.createID(CARBON_TEST_CONTAINER); ExamSystem subsystem = system.fork(options(systemProperty(RMI_HOST_PROPERTY).value(host), systemProperty(RMI_PORT_PROPERTY).value(Integer.toString(port)), systemProperty(RMI_NAME_PROPERTY).value(name), systemProperty(EXAM_INJECT_PROPERTY).value("true"))); target = new RBCRemoteTarget(name, port, subsystem.getTimeout()); System.setProperty("java.protocol.handler.pkgs", "org.ops4j.pax.url"); DebugOption debugOption = system.getSingleOption(DebugOption.class); if (debugOption != null) { options.add(debugOption.getDebugConfiguration()); runner.exec(environment, targetDirectory.resolve("wso2").resolve("default"), options); logger.debug("Wait for test container to finish its initialization " + subsystem.getTimeout()); waitForState(0, Bundle.ACTIVE, subsystem.getTimeout()); started = true; } catch (IOException e) { throw new TestContainerException("Problem starting container", e);
@Override public void start() throws IOException { try { String examVersion = skipSnapshotFlag(Info.getPaxExamVersion()); system = system.fork(new Option[] { systemPackage("org.ops4j.pax.exam;version=" + examVersion), systemPackage("org.ops4j.pax.exam.options;version=" + examVersion), systemPackage("org.ops4j.pax.exam.util;version=" + examVersion), systemProperty("java.protocol.handler.pkgs").value("org.ops4j.pax.url") }); setSystemProperties(); createFramework(createFrameworkProperties()); installAndStartBundles(); startFramework(); } catch (BundleException exc) { throw new TestContainerException("Problem starting test container.", exc); } catch (ExamConfigurationException e) { throw new TestContainerException("Problem in test container configuration", e); } }
/** * Copy files specified in the carbon file copy option to the destination path. * * @param carbonHome carbon home */ private void copyFiles(Path carbonHome) { Arrays.asList(system.getOptions(CopyFileOption.class)).forEach(option -> { try { Files.copy(option.getSourcePath(), carbonHome.resolve(option.getDestinationPath()), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new TestContainerException("Error while copying configuration files", e); } }); }
private boolean shouldDeleteRuntime() { boolean deleteRuntime = true; KeepRuntimeFolderOption[] keepRuntimeFolder = system .getOptions(KeepRuntimeFolderOption.class); if (keepRuntimeFolder != null && keepRuntimeFolder.length != 0) { deleteRuntime = false; } return deleteRuntime; }
private String localize(String url) { try { URL realUrl = new URL(url); if (realUrl.getProtocol().equals("reference")) { // must be "reference:file:..." return new URL(realUrl.getPath()).getPath(); } else if (realUrl.getProtocol().equals("file")) { return realUrl.getPath(); } File artifact = platform.download(system.getTempFolder(), realUrl, url, false, false, false, false); return artifact.getCanonicalPath(); } catch (MalformedURLException exc) { throw new TestContainerException(exc); } catch (IOException exc) { throw new TestContainerException(exc); } }
private void stopOrAbort() throws BundleException, InterruptedException { framework.stop(); long timeout = system.getTimeout().getValue(); Thread stopper = new Stopper(timeout); stopper.start(); stopper.join(timeout + 500); // If the framework is not stopped, then we're in trouble anyway, so we do not worry // about stopping the worker thread. if (framework.getState() != Bundle.RESOLVED) { String message = "Framework has not yet stopped after " + timeout + " ms. waitForStop did not return"; throw new TestContainerException(message); } }
private Option getInvokerConfiguration() { KarafExamSystemConfigurationOption[] internalConfigurationOptions = system .getOptions(KarafExamSystemConfigurationOption.class); Option invokerConfiguration = systemProperty("pax.exam.invoker").value("junit"); if (internalConfigurationOptions != null && internalConfigurationOptions.length != 0) { invokerConfiguration = systemProperty("pax.exam.invoker").value( internalConfigurationOptions[0].getInvoker()); } return invokerConfiguration; }
private void setProbeClassLoader() { JarProbeOption probeOption = system.getSingleOption(JarProbeOption.class); if (probeOption == null) { return; } probeDir = new File(system.getTempFolder(), UUID.randomUUID().toString()); probeDir.mkdir(); JarBuilder builder = new JarBuilder(probeDir, probeOption); URI jar = builder.buildJar(); try { URLClassLoader classLoader = new URLClassLoader(new URL[] { jar.toURL() }); contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); } catch (MalformedURLException exc) { throw new TestContainerException(exc); } }
private void setFrameworkStartLevel(BundleContext context, final FrameworkStartLevel sl) { FrameworkStartLevelOption startLevelOption = system .getSingleOption(FrameworkStartLevelOption.class); final int startLevel = startLevelOption == null ? START_LEVEL_TEST_BUNDLE : startLevelOption.getStartLevel(); long timeout = system.getTimeout().getValue(); if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { String msg = String.format("start level %d has not been reached within %d ms", startLevel, timeout); throw new TestContainerException(msg); throw new TestContainerException(e);
@Override public void clear() { delegate.clear(); } }
public WarProbeOption getLatestWarProbeOption() { try { return subsystems.peek().getOption(WarProbeOption.class); } catch (ExamConfigurationException e) { throw new TestContainerException(e.getMessage(), e); } } }
private Map<String, String> createFrameworkProperties() throws ExamConfigurationException { final Map<String, String> p = new HashMap<>(); CleanCachesOption cleanCaches = system.getOption(CleanCachesOption.class); if (cleanCaches != null && cleanCaches.getValue() != null && cleanCaches.getValue()) { p.put(FRAMEWORK_STORAGE_CLEAN, FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); } p.put(FRAMEWORK_STORAGE, system.getTempFolder().getAbsolutePath()); p.put(FRAMEWORK_SYSTEMPACKAGES_EXTRA, join(system.getOptions(SystemPackageOption.class))); p.put(FRAMEWORK_BOOTDELEGATION, join(system.getOptions(BootDelegationOption.class))); for (FrameworkPropertyOption option : system.getOptions(FrameworkPropertyOption.class)) { p.put(option.getKey(), (String) option.getValue()); } if (LOG.isDebugEnabled()) { logFrameworkProperties(p); } return p; }
String options = ""; List<String> environment = new ArrayList<>(); EnvironmentOption[] environmentOptions = subsystem.getOptions(EnvironmentOption.class); for (EnvironmentOption environmentOption : environmentOptions) { environment.add(environmentOption.getEnvironment()); + " millis"); LOGGER.info("Wait for test container to finish its initialization " + subsystem.getTimeout()); if (subsystem.getOptions(ServerModeOption.class).length == 0) { waitForState(org.ops4j.pax.exam.karaf.container.internal.Constants.SYSTEM_BUNDLE, Bundle.ACTIVE, subsystem.getTimeout());