use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class DeploymentPackageBuilderTest method testCreateMinimalTwoBundleResourcesOk.
/**
* Tests that we can build a deployment package with two bundle resources.
*/
@Test
public void testCreateMinimalTwoBundleResourcesOk() throws Exception {
DeploymentPackageBuilder dpBuilder = DeploymentPackageBuilder.create("dp-test", "1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle2")));
JarInputStream jis = new JarInputStream(dpBuilder.generate());
assertNotNull(jis);
Manifest manifest = jis.getManifest();
assertManifestHeader(manifest, "DeploymentPackage-SymbolicName", "dp-test");
assertManifestHeader(manifest, "DeploymentPackage-Version", "1.0.0");
String filename = getBundleName("bundle1");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.bundle1");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.0.0");
filename = getBundleName("bundle2");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.bundle2");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.0.0");
int count = countJarEntries(jis);
assertEquals("Expected two entries in the JAR!", 2, count);
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class DeploymentPackageBuilderTest method testCreateMinimalSingleBundleResourceOk.
/**
* Tests that we can build a deployment package with a bundle resource.
*/
@Test
public void testCreateMinimalSingleBundleResourceOk() throws Exception {
DeploymentPackageBuilder dpBuilder = DeploymentPackageBuilder.create("dp-test", "1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundle("bundle1")));
JarInputStream jis = new JarInputStream(dpBuilder.generate());
assertNotNull(jis);
Manifest manifest = jis.getManifest();
assertManifestHeader(manifest, "DeploymentPackage-SymbolicName", "dp-test");
assertManifestHeader(manifest, "DeploymentPackage-Version", "1.0.0");
String filename = getBundleName("bundle1");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.bundle1");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.0.0");
int count = countJarEntries(jis);
assertEquals("Expected two entries in the JAR!", 1, count);
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class DeploymentPackageBuilderTest method testCreateMinimalSingleResourceAndProcessorOk.
/**
* Tests that we can build a deployment package with a "plain" resource and resource processor.
*/
@Test
public void testCreateMinimalSingleResourceAndProcessorOk() throws Exception {
DeploymentPackageBuilder dpBuilder = DeploymentPackageBuilder.create("dp-test", "1.0.0");
dpBuilder.add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundle("rp1"))).add(dpBuilder.createResource().setResourceProcessorPID("org.apache.felix.deploymentadmin.test.rp1").setUrl(getTestResource("test-config1.xml")));
JarInputStream jis = new JarInputStream(dpBuilder.generate());
assertNotNull(jis);
Manifest manifest = jis.getManifest();
assertManifestHeader(manifest, "DeploymentPackage-SymbolicName", "dp-test");
assertManifestHeader(manifest, "DeploymentPackage-Version", "1.0.0");
String filename = getBundleName("rp1");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.rp1");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.0.0");
filename = "test-config1.xml";
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Resource-Processor", "org.apache.felix.deploymentadmin.test.rp1");
int count = countJarEntries(jis);
assertEquals("Expected two entries in the JAR!", 2, count);
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundleWithDependencyInSeparatePackageOk.
/**
* Tests that installing a bundle with a dependency installed by another deployment package is not started, but is
* resolved.
*/
@Test
public void testInstallBundleWithDependencyInSeparatePackageOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
awaitRefreshPackagesEvent();
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
// We shouldn't be able to resolve the deps for bundle2...
assertFalse(resolveBundles(dp1.getBundle(getSymbolicName("bundle2"))));
assertTrue(isBundleInstalled(dp1.getBundle(getSymbolicName("bundle2"))));
dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// as missing bundle1...
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
// Now we should be able to resolve the dependencies for bundle2...
assertTrue(resolveBundles(dp1.getBundle(getSymbolicName("bundle2"))));
assertTrue(isBundleActive(dp2.getBundle(getSymbolicName("bundle1"))));
assertTrue(isBundleResolved(dp1.getBundle(getSymbolicName("bundle2"))));
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundleWithOtherArtifactsOk.
/**
* Tests that installing a bundle along with other (non-bundle) artifacts succeeds.
*/
@Test
public void testInstallBundleWithOtherArtifactsOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
// Though the commit failed; the package should be installed...
assertBundleExists(getSymbolicName("rp1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
Aggregations