Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.runtime.test
Class NXRuntimeTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jmock.core.VerifyingTestCase
              extended by org.jmock.core.MockObjectSupportTestCase
                  extended by org.jmock.MockObjectTestCase
                      extended by org.nuxeo.runtime.test.NXRuntimeTestCase
All Implemented Interfaces:
junit.framework.Test, RuntimeHarness
Direct Known Subclasses:
SQLRepositoryTestCase

public class NXRuntimeTestCase
extends org.jmock.MockObjectTestCase
implements RuntimeHarness

Abstract base class for test cases that require a test runtime service.

The runtime service itself is conveniently available as the runtime instance variable in derived classes.

Author:
Bogdan Stefanescu

Field Summary
 
Fields inherited from class org.jmock.core.MockObjectSupportTestCase
ANYTHING, NOT_NULL, NULL
 
Constructor Summary
NXRuntimeTestCase()
           
NXRuntimeTestCase(String name)
           
 
Method Summary
 void addWorkingDirectoryConfigurator(WorkingDirectoryConfigurator config)
           
 void deploy(String contrib)
          Deprecated. use deployContrib() instead
 void deployBundle(String bundle)
          Deploys a whole OSGI bundle.
 void deployContrib(String contrib)
          Deprecated. use the less ambiguous deployContrib(BundleFile,String)
 void deployContrib(String bundle, String contrib)
          Deploys a contribution from a given bundle.
 void deployFolder(File folder, ClassLoader loader)
           
 RuntimeContext deployTestContrib(String bundle, String contrib)
          Deploy an XML contribution from outside a bundle.
 RuntimeContext deployTestContrib(String bundle, URL contrib)
           
 void fireFrameworkStarted()
          Fire the event FrameworkEvent.STARTED.
 RuntimeContext getContext()
          Runtime context for deployment
 OSGiAdapter getOSGiAdapter()
          OSGI bridge
 Properties getProperties()
          Framework properties for variable injections
static URL getResource(String resource)
           
 File getWorkingDir()
          Gets the framework working directory.
 boolean isStarted()
           
 BundleFile lookupBundle(String bundleName)
           
 void setUp()
           
 void start()
           
 void stop()
           
 void tearDown()
           
 void undeploy(String contrib)
          Deprecated. use undeployContrib(String, String) instead
 void undeployContrib(String contrib)
          Deprecated. use undeployContrib(String, String) instead
 void undeployContrib(String bundle, String contrib)
          Undeploys a contribution from a given bundle.
 
Methods inherited from class org.jmock.MockObjectTestCase
atLeastOnce, atMostOnce, defaultMockNameForType, doAll, doAll, doAll, doAll, exactly, mock, mock, never, never, newDummy, newDummy, newDummy, once, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, returnIterator, returnIterator, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, throwException
 
Methods inherited from class org.jmock.core.MockObjectSupportTestCase
and, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, collectionContaining, collectionContaining, compatibleType, contains, endsWith, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, hasProperty, hasProperty, isA, isIn, isIn, mapContaining, mapContaining, mapWithKey, mapWithKey, mapWithValue, mapWithValue, not, or, same, startsWith, stringContains, toString
 
Methods inherited from class org.jmock.core.VerifyingTestCase
registerToVerify, runBare, unregisterToVerify, verify
 
Methods inherited from class junit.framework.TestCase
countTestCases, getName, run, run, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NXRuntimeTestCase

public NXRuntimeTestCase()

NXRuntimeTestCase

public NXRuntimeTestCase(String name)
Method Detail

addWorkingDirectoryConfigurator

public void addWorkingDirectoryConfigurator(WorkingDirectoryConfigurator config)
Specified by:
addWorkingDirectoryConfigurator in interface RuntimeHarness

getWorkingDir

public File getWorkingDir()
Description copied from interface: RuntimeHarness
Gets the framework working directory.

Specified by:
getWorkingDir in interface RuntimeHarness

start

public void start()
           throws Exception
Specified by:
start in interface RuntimeHarness
Throws:
Exception

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

fireFrameworkStarted

public void fireFrameworkStarted()
                          throws Exception
Fire the event FrameworkEvent.STARTED.

Specified by:
fireFrameworkStarted in interface RuntimeHarness
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

stop

public void stop()
          throws Exception
Specified by:
stop in interface RuntimeHarness
Throws:
Exception

isStarted

public boolean isStarted()
Specified by:
isStarted in interface RuntimeHarness

getResource

public static URL getResource(String resource)

deploy

@Deprecated
public void deploy(String contrib)
Deprecated. use deployContrib() instead

Specified by:
deploy in interface RuntimeHarness

deployContrib

@Deprecated
public void deployContrib(String contrib)
Deprecated. use the less ambiguous deployContrib(BundleFile,String)

Deploys a contribution file by looking for it in the class loader.

The first contribution file found by the class loader will be used. You have no guarantee in case of name collisions.

Specified by:
deployContrib in interface RuntimeHarness
Parameters:
contrib - the relative path to the contribution file

deployContrib

public void deployContrib(String bundle,
                          String contrib)
                   throws Exception
Deploys 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:
deployContrib in interface RuntimeHarness
Parameters:
bundle - the name of the bundle to peek the contrib in
contrib - the path to contrib in the bundle.
Throws:
Exception

deployTestContrib

public RuntimeContext deployTestContrib(String bundle,
                                        String contrib)
                                 throws Exception
Deploy 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:
deployTestContrib in interface RuntimeHarness
Parameters:
bundle - the bundle that becomes the contribution owner
contrib - the contribution to deploy as part of the given bundle
Throws:
Exception

deployTestContrib

public RuntimeContext deployTestContrib(String bundle,
                                        URL contrib)
                                 throws Exception
Specified by:
deployTestContrib in interface RuntimeHarness
Throws:
Exception

undeploy

@Deprecated
public void undeploy(String contrib)
Deprecated. use undeployContrib(String, String) instead

Specified by:
undeploy in interface RuntimeHarness

undeployContrib

@Deprecated
public void undeployContrib(String contrib)
Deprecated. use undeployContrib(String, String) instead

Specified by:
undeployContrib in interface RuntimeHarness

undeployContrib

public void undeployContrib(String bundle,
                            String contrib)
                     throws Exception
Undeploys 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:
undeployContrib in interface RuntimeHarness
Parameters:
bundle - the bundle
contrib - the contribution
Throws:
Exception

deployBundle

public void deployBundle(String bundle)
                  throws Exception
Deploys a whole OSGI bundle.

The lookup is first done on symbolic name, as set in MANIFEST.MF and then falls back to the bundle url (e.g., nuxeo-platform-search-api) for backwards compatibility.

Specified by:
deployBundle in interface RuntimeHarness
Parameters:
bundle - the symbolic name
Throws:
Exception

lookupBundle

public BundleFile lookupBundle(String bundleName)
                        throws Exception
Throws:
Exception

deployFolder

public void deployFolder(File folder,
                         ClassLoader loader)
                  throws Exception
Specified by:
deployFolder in interface RuntimeHarness
Throws:
Exception

getProperties

public Properties getProperties()
Description copied from interface: RuntimeHarness
Framework properties for variable injections

Specified by:
getProperties in interface RuntimeHarness
Returns:

getContext

public RuntimeContext getContext()
Description copied from interface: RuntimeHarness
Runtime context for deployment

Specified by:
getContext in interface RuntimeHarness
Returns:

getOSGiAdapter

public OSGiAdapter getOSGiAdapter()
Description copied from interface: RuntimeHarness
OSGI bridge

Specified by:
getOSGiAdapter in interface RuntimeHarness
Returns:

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.