public Integer getStartLevel() { return delegate.getStartLevel(); }
public String getURL() { return delegate.getURL(); }
public boolean shouldStart() { return delegate.shouldStart(); }
bundles.append(','); if (ignoreItems != null && ignoreItems.isIgnored(bundle.getURL())) { LOG.info("- Ignore ({}) since it is on the ignore list...", bundle.getURL()); continue; bundles.append(bundle.getURL()); Integer startLevel = bundle.getStartLevel(); if (startLevel == null) { startLevel = defaultStartLevel; if (bundle.shouldStart()) { bundles.append('@'); bundles.append(startLevel);
/** * Returns common scanner options. Ment to be used by subclasses when building the url. * * @param provision provision options to be used (cannot be null) * * @return common scanner options (cannot be null) */ static String getOptions( final ProvisionOption provision ) { final StringBuilder options = new StringBuilder(); if( provision.shouldUpdate() ) { options.append( SEPARATOR_OPTION ).append( OPTION_UPDATE ); } if( !provision.shouldStart() ) { options.append( SEPARATOR_OPTION ).append( OPTION_NO_START ); } if( provision.getStartLevel() != null ) { options.append( SEPARATOR_OPTION ).append( provision.getStartLevel() ); } return options.toString(); }
private void installAndStartBundles() throws BundleException, RemoteException, ExamConfigurationException { File workDir = new File(system.getTempFolder(), "pax-exam-downloads"); workDir.mkdirs(); List<Long> bundleIds = new ArrayList<Long>(); ProvisionOption<?>[] options = system.getOptions(ProvisionOption.class); bundlesById = new HashMap<Long, String>(); for (ProvisionOption<?> bundle : options) { String localUrl = downloadBundle(workDir, bundle.getURL()); long id = remoteFramework.installBundle(localUrl, bundle.shouldStart(),getStartLevel(bundle)); bundlesById.put(id,bundle.getURL()); if (bundle.shouldStart()) { bundleIds.add(id); } } remoteFramework.start(); setFrameworkStartLevel(); verifyThatBundlesAreResolved(bundleIds); }
sw.writeCharacters("\n"); for (ProvisionOption<?> provisionOption : provisionOptions) { if (provisionOption.getURL().startsWith("link") || provisionOption.getURL().startsWith("scan-features")) { if (provisionOption.getStartLevel() != null) { sw.writeAttribute("start-level", provisionOption.getStartLevel().toString()); sw.writeCharacters(provisionOption.getURL()); endElement(sw);
/** * Replacement for {@link CoreOptions#options(Option...)} to workaround Pax-Exam 'feature' * where only the last 'editConfigurationFileExtend' for a given property key is honoured. */ public static Option[] options(final Option... options) { final List<Option> result = new ArrayList<>(); final List<String> nexusFeatures = new ArrayList<>(); for (final Option o : OptionUtils.expand(options)) { // filter out the individual nexus-features values if (o instanceof KarafDistributionConfigurationFileExtendOption) { if ("nexus-features".equals(((KarafDistributionConfigurationFileExtendOption) o).getKey())) { nexusFeatures.add(((KarafDistributionConfigurationFileExtendOption) o).getValue()); continue; } } // provide default start level for any additional test bundles else if (o instanceof ProvisionOption<?> && ((ProvisionOption<?>) o).getStartLevel() == null) { ((ProvisionOption<?>) o).startLevel(NEXUS_TEST_START_LEVEL); } result.add(o); } if (nexusFeatures.size() > 0) { // combine the nexus-features values into a single request result.add(editConfigurationFileExtend(NEXUS_PROPERTIES_FILE, // "nexus-features", Joiner.on(',').join(nexusFeatures))); } return result.toArray(new Option[result.size()]); }
public boolean shouldUpdate() { return delegate.shouldUpdate(); }
public T startLevel(final Integer startLevel) { delegate.startLevel(startLevel); return itself(); }
/** * Wrap provision options that are not already scanner provision bundles with a {@link org.ops4j.pax.exam.options.extra.BundleScannerProvisionOption} * in order to force update. * * @param options options to be wrapped (can be null or an empty array) * * @return eventual wrapped bundles */ private List<ProvisionOption<?>> wrap( ProvisionOption<?>[] options ) { final List<ProvisionOption<?>> processed = new ArrayList<ProvisionOption<?>>(); for( final ProvisionOption<?> provisionOption : options ) { if( !( provisionOption instanceof Scanner ) ) { processed.add( scanBundle( provisionOption ).start( provisionOption.shouldStart() ).startLevel( provisionOption.getStartLevel() ).update( provisionOption.shouldUpdate() ) ); } else { processed.add( provisionOption ); } } return processed; }
private void installAndStartBundle(ProvisionOption<?> bundle) { try { Bundle b = framework.getBundleContext().installBundle(bundle.getURL()); int startLevel = getStartLevel(bundle); BundleStartLevel sl = b.adapt(BundleStartLevel.class); sl.setStartLevel(startLevel); if (bundle.shouldStart()) { b.start(); LOG.debug("+ Install (start@{}) {}", startLevel, bundle); } else { LOG.debug("+ Install (no start) {}", bundle); } } catch (BundleException exc) { throw new TestContainerException("Error starting bundle " + bundle.getURL(), exc); } }
sw.writeCharacters("\n"); for (ProvisionOption<?> provisionOption : provisionOptions) { if (provisionOption.getURL().startsWith("link") || provisionOption.getURL().startsWith("scan-features")) { if (provisionOption.getStartLevel() != null) { sw.writeAttribute("start-level", provisionOption.getStartLevel().toString()); sw.writeCharacters(provisionOption.getURL()); endElement(sw);
public boolean shouldUpdate() { return delegate.shouldUpdate(); }
public T startLevel(final Integer startLevel) { delegate.startLevel(startLevel); return itself(); }
processed.add( scanBundle( provisionOption ).start( provisionOption.shouldStart() ).startLevel( provisionOption.getStartLevel() ).update( provisionOption.shouldUpdate() ) );
private void installAndStartBundles(BundleContext context) throws BundleException { List<Bundle> bundles = new ArrayList<Bundle>(); for (ProvisionOption<?> bundle : system.getOptions(ProvisionOption.class)) { Bundle b = context.installBundle(bundle.getURL()); bundles.add(b); int startLevel = getStartLevel(bundle); BundleStartLevel sl = b.adapt(BundleStartLevel.class); sl.setStartLevel(startLevel); if (bundle.shouldStart()) { try { b.start(); } catch (BundleException e) { throw new BundleException("Error starting bundle " + b.getSymbolicName() + ". " + e.getMessage(), e); } LOG.debug("+ Install (start@{}) {}", startLevel, bundle); } else { LOG.debug("+ Install (no start) {}", bundle); } } // All bundles are installed, we can now start the framework... framework.start(); FrameworkStartLevel fsl = framework.adapt(FrameworkStartLevel.class); setFrameworkStartLevel(context, fsl); verifyThatBundlesAreResolved(bundles); }
public String getURL() { return delegate.getURL(); }
private int getStartLevel(ProvisionOption<?> bundle) { Integer start = bundle.getStartLevel(); if (start == null) { start = Constants.START_LEVEL_DEFAULT_PROVISION; } return start; }
public boolean shouldStart() { return delegate.shouldStart(); }