Class RuntimeHarnessImpl
- java.lang.Object
-
- org.nuxeo.runtime.test.RuntimeHarnessImpl
-
- All Implemented Interfaces:
RuntimeHarness
- Direct Known Subclasses:
NXRuntimeTestCase
public class RuntimeHarnessImpl extends Object implements RuntimeHarness
Default RuntimeHarness implementation.- Since:
- 10.2
-
-
Field Summary
Fields Modifier and Type Field Description protected StandaloneBundleLoaderbundleLoaderprotected Map<String,BundleFile>bundlesprotected booleanframeworkStartedprotected static org.apache.logging.log4j.Loggerlogprotected OSGiAdapterosgiprotected Set<URI>readUrisprotected OSGiRuntimeServiceruntimeprotected org.osgi.framework.BundleruntimeBundleprotected TargetResourceLocatortargetResourceLocatorprotected URL[]urlsprotected List<WorkingDirectoryConfigurator>wdConfigsprotected FileworkingDir
-
Constructor Summary
Constructors Modifier Constructor Description protectedRuntimeHarnessImpl()RuntimeHarnessImpl(Class<?> clazz)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddWorkingDirectoryConfigurator(WorkingDirectoryConfigurator config)voiddeployBundle(String name)Deploys a whole OSGI bundle.voiddeployContrib(String name, String contrib)Deploys a contribution from a given bundle.voiddeployFolder(File folder, ClassLoader loader)Deprecated.RuntimeContextdeployPartial(String name, Set<TargetExtensions> targetExtensions)Deploys a subset of a Bundle defined per the targetExtensions parameterprotected voiddeployPartialComponent(RuntimeContext ctx, Set<TargetExtensions> extensionPoints, StreamRef component)Read a component from his StreamRef and create a new component (suffixed with `-partial`, and the base component name aliased) with only matching contributions of the extensionPoints parameter.RuntimeContextdeployTestContrib(String bundle, String contrib)Deprecated.RuntimeContextdeployTestContrib(String bundle, URL contrib)Deprecated.voidfireFrameworkStarted()Resume the runtimeList<String>getClassLoaderFiles()Deprecated.RuntimeContextgetContext()Runtime context for deploymentOSGiAdaptergetOSGiAdapter()OSGI bridgePropertiesgetProperties()Deprecated.FilegetWorkingDir()Gets the framework working directory.protected voidinitOsgiRuntime()Inits the osgi runtime.protected voidinitUrls()Inits the urls.protected static URL[]introspectClasspath()protected booleanisAnEmptyTestProperty(Map.Entry<Object,Object> entry)booleanisRestart()booleanisStarted()protected Stream<URL>listBundleComponents(org.osgi.framework.Bundle bundle)Listing component's urls of a bundle.protected BundleFilelookupBundle(String bundleName)Lookup bundle.protected StringreadSymbolicName(BundleFile bf)Read symbolic name.voidrestart()voidstart()voidstop()voidundeployContrib(String name, String contrib)Undeploys a contribution from a given bundle.protected voidwipeEmptyTestSystemProperties()Removes Nuxeo test system properties that are empty.protected voidwipeRuntime()Makes sure there is no previous runtime hanging around.
-
-
-
Field Detail
-
log
protected static final org.apache.logging.log4j.Logger log
-
bundleLoader
protected StandaloneBundleLoader bundleLoader
-
bundles
protected Map<String,BundleFile> bundles
-
frameworkStarted
protected boolean frameworkStarted
-
osgi
protected OSGiAdapter osgi
-
runtime
protected OSGiRuntimeService runtime
-
runtimeBundle
protected org.osgi.framework.Bundle runtimeBundle
-
targetResourceLocator
protected TargetResourceLocator targetResourceLocator
-
urls
protected URL[] urls
-
wdConfigs
protected List<WorkingDirectoryConfigurator> wdConfigs
-
workingDir
protected File workingDir
-
-
Constructor Detail
-
RuntimeHarnessImpl
protected RuntimeHarnessImpl()
-
RuntimeHarnessImpl
public RuntimeHarnessImpl(Class<?> clazz)
-
-
Method Detail
-
introspectClasspath
protected static URL[] introspectClasspath()
-
addWorkingDirectoryConfigurator
public void addWorkingDirectoryConfigurator(WorkingDirectoryConfigurator config)
- Specified by:
addWorkingDirectoryConfiguratorin interfaceRuntimeHarness
-
deployBundle
public void deployBundle(String name) throws Exception
Description copied from interface:RuntimeHarnessDeploys a whole OSGI bundle.The lookup is first done on symbolic name, as set in
MANIFEST.MFand then falls back to the bundle url (e.g.,nuxeo-platform-search-api) for backwards compatibility.- Specified by:
deployBundlein interfaceRuntimeHarness- Parameters:
name- the symbolic name- Throws:
Exception
-
deployContrib
public void deployContrib(String name, String contrib) throws Exception
Description copied from interface:RuntimeHarnessDeploys a contribution from a given bundle.The path will be relative to the bundle root. Example:
deployContrib("org.nuxeo.ecm.core", "OSGI-INF/CoreExtensions.xml")For compatibility reasons the name of the bundle may be a jar name, but this use is discouraged and deprecated.
- Specified by:
deployContribin interfaceRuntimeHarness- Parameters:
name- the name of the bundle to peek the contrib incontrib- the path to contrib in the bundle.- Throws:
Exception
-
deployFolder
@Deprecated public void deployFolder(File folder, ClassLoader loader) throws Exception
Deprecated.- Specified by:
deployFolderin interfaceRuntimeHarness- Throws:
Exception
-
deployPartial
public RuntimeContext deployPartial(String name, Set<TargetExtensions> targetExtensions) throws Exception
Description copied from interface:RuntimeHarnessDeploys a subset of a Bundle defined per the targetExtensions parameter- Specified by:
deployPartialin interfaceRuntimeHarness- Parameters:
name- the name of the componenttargetExtensions- Set of allowed TargetExtensions in the final contribution- Throws:
Exception
-
deployTestContrib
@Deprecated public RuntimeContext deployTestContrib(String bundle, String contrib) throws Exception
Deprecated.Description copied from interface:RuntimeHarnessDeploys an XML contribution from outside a bundle.This should be used by tests wiling to deploy test contribution as part of a real bundle.
The bundle owner is important since the contribution may depend on resources deployed in that bundle.
Note that the owner bundle MUST be an already deployed bundle.
- Specified by:
deployTestContribin interfaceRuntimeHarness- Parameters:
bundle- the bundle that becomes the contribution ownercontrib- the contribution to deploy as part of the given bundle- Throws:
Exception
-
deployTestContrib
@Deprecated public RuntimeContext deployTestContrib(String bundle, URL contrib) throws Exception
Deprecated.- Specified by:
deployTestContribin interfaceRuntimeHarness- Throws:
Exception
-
fireFrameworkStarted
public void fireFrameworkStarted()
Description copied from interface:RuntimeHarnessResume the runtime- Specified by:
fireFrameworkStartedin interfaceRuntimeHarness
-
getClassLoaderFiles
@Deprecated public List<String> getClassLoaderFiles() throws URISyntaxException
Deprecated.- Specified by:
getClassLoaderFilesin interfaceRuntimeHarness- Throws:
URISyntaxException
-
getContext
public RuntimeContext getContext()
Description copied from interface:RuntimeHarnessRuntime context for deployment- Specified by:
getContextin interfaceRuntimeHarness
-
getOSGiAdapter
public OSGiAdapter getOSGiAdapter()
Description copied from interface:RuntimeHarnessOSGI bridge- Specified by:
getOSGiAdapterin interfaceRuntimeHarness
-
getProperties
@Deprecated public Properties getProperties()
Deprecated.Description copied from interface:RuntimeHarnessFramework properties for variable injections- Specified by:
getPropertiesin interfaceRuntimeHarness
-
getWorkingDir
public File getWorkingDir()
Description copied from interface:RuntimeHarnessGets the framework working directory.- Specified by:
getWorkingDirin interfaceRuntimeHarness
-
isRestart
public boolean isRestart()
- Specified by:
isRestartin interfaceRuntimeHarness
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceRuntimeHarness
-
restart
public void restart() throws Exception- Specified by:
restartin interfaceRuntimeHarness- Throws:
Exception
-
start
public void start() throws Exception- Specified by:
startin interfaceRuntimeHarness- Throws:
Exception
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceRuntimeHarness- Throws:
Exception
-
undeployContrib
public void undeployContrib(String name, String contrib)
Description copied from interface:RuntimeHarnessUndeploys a contribution from a given bundle.The path will be relative to the bundle root. Example:
undeployContrib("org.nuxeo.ecm.core", "OSGI-INF/CoreExtensions.xml")- Specified by:
undeployContribin interfaceRuntimeHarness- Parameters:
name- the bundlecontrib- the contribution
-
deployPartialComponent
protected void deployPartialComponent(RuntimeContext ctx, Set<TargetExtensions> extensionPoints, StreamRef component) throws IOException
Read a component from his StreamRef and create a new component (suffixed with `-partial`, and the base component name aliased) with only matching contributions of the extensionPoints parameter.- Parameters:
ctx- RuntimeContext in which the new component will be deployedextensionPoints- Set of white listed TargetExtensionscomponent- Reference to the original component- Throws:
IOException- Signals that an I/O exception has occurred.
-
initOsgiRuntime
protected void initOsgiRuntime() throws ExceptionInits the osgi runtime.- Throws:
Exception- the exception
-
initUrls
protected void initUrls()
Inits the urls.
-
listBundleComponents
protected Stream<URL> listBundleComponents(org.osgi.framework.Bundle bundle)
Listing component's urls of a bundle. Inspired from org.nuxeo.runtime.osgi.OSGiRuntimeService#loadComponents but without deploying anything.- Parameters:
bundle- Bundle to be read- Returns:
- the stream
-
lookupBundle
protected BundleFile lookupBundle(String bundleName) throws Exception
Lookup bundle.- Parameters:
bundleName- the bundle name- Returns:
- the bundle file
- Throws:
Exception- the exception
-
readSymbolicName
protected String readSymbolicName(BundleFile bf)
Read symbolic name.- Parameters:
bf- the bf- Returns:
- the string
-
wipeRuntime
protected void wipeRuntime()
Makes sure there is no previous runtime hanging around.This happens for instance if a previous test had errors in its
setUp(), becausetearDown()has not been called.
-
wipeEmptyTestSystemProperties
protected void wipeEmptyTestSystemProperties()
Removes Nuxeo test system properties that are empty.This is needed when using maven surefire > 2.17 because since SUREFIRE-649 surefire propagates empty system properties.
-
-