use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.
the class DeploymentGeneratorTest method checkBundleInAppContentAndUseContent.
@Test
public void checkBundleInAppContentAndUseContent() throws Exception {
List<ModelledResource> cmr = new ArrayList<ModelledResource>();
cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
// The second time DeploymentGenerator calls the Resolver, it will provide just
// test.shared. The resolver will return test.shared _plus_ test.isolated.
_resolver.addResult(cmr);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.api", "1.1.0"), mockContent("test.consumer", "1.0.0"), mockContent("test.provider", "1.0.0")));
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getUseBundles"), Arrays.asList(mockContent("test.api", "1.0.0")));
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, Arrays.asList(new ModelledResource[] { cmr.get(0), cmr.get(2), cmr.get(3) }), new ArrayList<Content>());
Manifest mf = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
mf.write(System.out);
assertTrue(mf.getMainAttributes().getValue("Deployed-Content").contains("test.api;deployed-version=1.1.0"));
assertTrue(mf.getMainAttributes().getValue("Deployed-Use-Bundle").contains("test.api;deployed-version=1.0.0"));
}
use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.
the class DeploymentGeneratorTest method checkBundleInAppContentAndProvisionContent.
@Test
public void checkBundleInAppContentAndProvisionContent() throws Exception {
List<ModelledResource> cmr = new ArrayList<ModelledResource>();
cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
// The second time DeploymentGenerator calls the Resolver, it will provide just
// test.shared. The resolver will return test.shared _plus_ test.isolated.
_resolver.addResult(cmr);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.api", "1.1.0"), mockContent("test.consumer", "1.0.0"), mockContent("test.provider", "1.0.0")));
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
try {
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, Arrays.asList(new ModelledResource[] { cmr.get(0), cmr.get(2), cmr.get(3) }), new ArrayList<Content>());
deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
fail("Expected exception because we can't provision an isolated bundle twice");
} catch (ResolverException rx) {
}
}
use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.
the class DeploymentGeneratorTest method setup.
@Before
public void setup() throws Exception {
appMetadata = Skeleton.newMock(ApplicationMetadata.class);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationSymbolicName"), "aries.test");
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationVersion"), new Version("1.0.0"));
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getUseBundles"), Collections.EMPTY_LIST);
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
deplMFMgr = new DeploymentManifestManagerImpl();
deplMFMgr.setResolver(_resolver);
deplMFMgr.setLocalPlatform(localPlatform);
deplMFMgr.setModellingManager(modellingManager);
deplMFMgr.setModellingHelper(modellingHelper);
deplMFMgr.setPreResolveHooks(new ArrayList<PreResolveHook>());
}
use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.
the class SingleServiceTrackerTest method testAfterTheFactService.
@Test
public void testAfterTheFactService() {
createSut();
Skeleton.getSkeleton(listener).assertSkeletonNotCalled();
ctx.registerService("java.lang.String", "uno", null);
Skeleton.getSkeleton(listener).assertCalled(new MethodCall(SingleServiceListener.class, "serviceFound"));
assertEquals("uno", sut.getService());
}
use of org.apache.aries.unittest.mocks.MethodCall in project aries by apache.
the class AriesApplicationManagerImplTest method testRolledbackUpdate.
@Test
public void testRolledbackUpdate() throws Exception {
AriesApplication app = createApplication(TEST_EBA);
DeploymentMetadata depMf = createUpdateDepMf();
DeploymentMetadata oldMf = app.getDeploymentMetadata();
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, true, null));
_appMgr.setApplicationContextManager(ctxMgr);
try {
_appMgr.update(app, depMf);
fail("Update should have failed.");
} catch (UpdateException e) {
assertTrue("Deployment.mf should have been rolled back to the old", app.getDeploymentMetadata() == oldMf);
}
}
Aggregations