Search in sources :

Example 26 with MethodCall

use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.

the class AriesApplicationManagerImplTest method createUpdateDepMf.

private DeploymentMetadata createUpdateDepMf() {
    DeploymentMetadata depMf = Skeleton.newMock(DeploymentMetadata.class);
    Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationSymbolicName"), "org.apache.aries.application.management.test");
    Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationVersion"), new Version("1.0.0"));
    return depMf;
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) Version(org.osgi.framework.Version) MethodCall(org.apache.aries.unittest.mocks.MethodCall)

Example 27 with MethodCall

use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.

the class AriesApplicationManagerImplTest method testUpdateWithIncorrectDepMf.

@Test(expected = IllegalArgumentException.class)
public void testUpdateWithIncorrectDepMf() throws Exception {
    AriesApplication app = createApplication(TEST_EBA);
    DeploymentMetadata depMf = Skeleton.newMock(DeploymentMetadata.class);
    Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationSymbolicName"), "random.app");
    Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationVersion"), new Version("1.0.0"));
    AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
    _appMgr.setApplicationContextManager(ctxMgr);
    _appMgr.update(app, depMf);
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) AriesApplicationContextManager(org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager) Version(org.osgi.framework.Version) AriesApplication(org.apache.aries.application.management.AriesApplication) MethodCall(org.apache.aries.unittest.mocks.MethodCall) Test(org.junit.Test)

Example 28 with MethodCall

use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.

the class AriesApplicationManagerImplTest method testFailedUpdate.

@Test
public void testFailedUpdate() throws Exception {
    AriesApplication app = createApplication(TEST_EBA);
    DeploymentMetadata depMf = createUpdateDepMf();
    AriesApplicationContext ctx = Skeleton.newMock(AriesApplicationContext.class);
    Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(AriesApplicationContext.class, "getApplication"), app);
    AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
    Skeleton.getSkeleton(ctxMgr).setReturnValue(new MethodCall(AriesApplicationContextManager.class, "getApplicationContexts"), Collections.singleton(ctx));
    Skeleton.getSkeleton(ctxMgr).setThrows(new MethodCall(AriesApplicationContextManager.class, "update", AriesApplication.class, DeploymentMetadata.class), new UpdateException("", null, false, null));
    _appMgr.setApplicationContextManager(ctxMgr);
    try {
        _appMgr.update(app, depMf);
        fail("Update should have failed.");
    } catch (UpdateException e) {
        assertTrue("Deployment.mf should have been updated", app.getDeploymentMetadata() == depMf);
    }
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) AriesApplicationContextManager(org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplication(org.apache.aries.application.management.AriesApplication) UpdateException(org.apache.aries.application.management.UpdateException) MethodCall(org.apache.aries.unittest.mocks.MethodCall) Test(org.junit.Test)

Example 29 with MethodCall

use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.

the class EJBLocatorTest method assertXML.

private void assertXML(boolean b) {
    Skeleton s = Skeleton.getSkeleton(registry);
    MethodCall mc = new MethodCall(EJBRegistry.class, "addEJBView", "XML", "SINGLETON", "local.Iface", false);
    if (b)
        s.assertCalledExactNumberOfTimes(mc, 1);
    else
        s.assertNotCalled(mc);
    mc = new MethodCall(EJBRegistry.class, "addEJBView", "XML", "SINGLETON", "remote.Iface", true);
    if (b)
        s.assertCalledExactNumberOfTimes(mc, 1);
    else
        s.assertNotCalled(mc);
}
Also used : EJBRegistry(org.apache.aries.ejb.modelling.EJBRegistry) Skeleton(org.apache.aries.unittest.mocks.Skeleton) MethodCall(org.apache.aries.unittest.mocks.MethodCall)

Example 30 with MethodCall

use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.

the class EJBModellerTest method testModelServicesEmptyExportEJB.

@Test
public void testModelServicesEmptyExportEJB() throws ModellerException {
    Manifest man = new Manifest();
    setBasicHeaders(man);
    man.getMainAttributes().putValue("Export-EJB", "");
    modeller.modelServices(new BundleManifest(man), bundleLocation);
    ejbLocator.assertCalled(new MethodCall(EJBLocator.class, "findEJBs", BundleManifest.class, bundleLocation, ParsedEJBServices.class));
}
Also used : BundleManifest(org.apache.aries.util.manifest.BundleManifest) Manifest(java.util.jar.Manifest) BundleManifest(org.apache.aries.util.manifest.BundleManifest) EJBLocator(org.apache.aries.ejb.modelling.EJBLocator) MethodCall(org.apache.aries.unittest.mocks.MethodCall) Test(org.junit.Test)

Aggregations

MethodCall (org.apache.aries.unittest.mocks.MethodCall)41 Test (org.junit.Test)30 Properties (java.util.Properties)13 BundleContext (org.osgi.framework.BundleContext)13 Hashtable (java.util.Hashtable)12 InitialContext (javax.naming.InitialContext)11 AriesApplication (org.apache.aries.application.management.AriesApplication)10 Context (javax.naming.Context)9 BundleMock (org.apache.aries.mocks.BundleMock)8 Name (javax.naming.Name)7 ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)7 ObjectFactory (javax.naming.spi.ObjectFactory)6 Content (org.apache.aries.application.Content)6 DeployedBundles (org.apache.aries.application.modelling.DeployedBundles)6 ModelledResource (org.apache.aries.application.modelling.ModelledResource)6 Skeleton (org.apache.aries.unittest.mocks.Skeleton)6 ArrayList (java.util.ArrayList)5 Manifest (java.util.jar.Manifest)5 Reference (javax.naming.Reference)5 ServiceRegistration (org.osgi.framework.ServiceRegistration)5