@Test public void testRecoverBundleImplicitTypeAndVersion() throws DeploymentException, IOException { StubBundleContext bundleContext = new StubBundleContext(); StubBundleContext userRegionBundleContext = new StubBundleContext(); expect(this.osgiFramework.getBundleContext()).andReturn(bundleContext).anyTimes(); replayMocks(); StandardInstallArtifactRefreshHandler refreshHelper = new StandardInstallArtifactRefreshHandler(installEnvironmentFactory, refreshPipeline); StandardArtifactIdentityDeterminer artifactIdentityDeterminer = new StandardArtifactIdentityDeterminer(testArtifactBridges); bundleContext.registerService( InstallArtifactTreeFactory.class.getName(), new BundleInstallArtifactTreeFactory( this.osgiFramework, bundleContext, refreshHelper, this.bundleStarter, this.tracingService, this.packageAdminUtil, userRegionBundleContext, new MockEventLogger(), null), null); this.installArtifactFactory = new StandardInstallArtifactTreeInclosure( this.artifactStorageFactory, bundleContext, this.repository, new MockEventLogger(), artifactIdentityDeterminer); Tree<InstallArtifact> installArtifactTree = this.installArtifactFactory.createInstallTree(new File(this.bundleURI)); checkBundleImplicitTypeAndVersion(installArtifactTree.getValue()); DeploymentOptions deploymentOptions = new DeploymentOptions(/* recoverable */ true, /* deployerOwned */ false, true); Tree<InstallArtifact> recoveredInstallTree = this.installArtifactFactory.recoverInstallTree(new File(this.bundleURI), deploymentOptions); checkBundleImplicitTypeAndVersion(recoveredInstallTree.getValue()); verifyMocks(); resetMocks(); }
@Test public void testNoBSNBundleImplicitTypeAndVersion() throws DeploymentException { StubBundleContext bundleContext = new StubBundleContext(); StubBundleContext userRegionBundleContext = new StubBundleContext(); expect(this.osgiFramework.getBundleContext()).andReturn(bundleContext).anyTimes(); replayMocks(); StandardArtifactIdentityDeterminer artifactIdentityDeterminer = new StandardArtifactIdentityDeterminer(testArtifactBridges); StandardInstallArtifactRefreshHandler refreshHelper = new StandardInstallArtifactRefreshHandler(installEnvironmentFactory, refreshPipeline); bundleContext.registerService( InstallArtifactTreeFactory.class.getName(), new BundleInstallArtifactTreeFactory( this.osgiFramework, bundleContext, refreshHelper, this.bundleStarter, this.tracingService, this.packageAdminUtil, userRegionBundleContext, new MockEventLogger(), null), null); this.installArtifactFactory = new StandardInstallArtifactTreeInclosure( this.artifactStorageFactory, bundleContext, this.repository, new MockEventLogger(), artifactIdentityDeterminer); Tree<InstallArtifact> installArtifactTree = this.installArtifactFactory.createInstallTree( new File("src/test/resources/artifacts/nobsn.jar")); InstallArtifact installArtifact = installArtifactTree.getValue(); assertNotNull(installArtifact); assertTrue(installArtifact instanceof BundleInstallArtifact); assertEquals("nobsn", installArtifact.getName()); assertEquals(new Version("0"), installArtifact.getVersion()); verifyMocks(); resetMocks(); }