Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.test/src/test')
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractDeployerIntegrationTest.java125
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractParTests.java84
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java45
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ActivatorTcclTests.java34
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ApplicationContextUtils.java61
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleActivationPolicyTests.java68
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleDeployerIntegrationTests.java50
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleLifecycleTests.java155
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleRefreshTests.java155
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ClasspathScanningTests.java70
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/CommonsDbcpTests.java50
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ConfigurationDeploymentTests.java234
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerEdgeTests.java272
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerLogMessageTests.java123
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/HotDeploymentTests.java100
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportMergeDiagnosticsTests.java68
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportPromotionTests.java44
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/InterdependentBundleDeploymentTests.java66
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JpaLtwParTests.java47
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LibraryScopingTests.java32
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LoadableClasses.java20
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ManualSpringContextTests.java33
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MissingImportLibraryTests.java29
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MultiBundleApplicationDeploymentTests.java260
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java802
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java110
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java79
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParRefreshTests.java363
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java214
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerTimeOutTests.java90
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentTests.java179
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PropertiesArtifactMBeanTests.java100
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/QuartzSchedulerTests.java81
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java270
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java135
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java97
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java44
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java43
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RedeployRefreshTests.java110
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RefreshTests.java263
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RepositoryDeploymentTests.java33
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServicePublishingFromRepoTests.java26
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java205
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/SimpleBundleApplicationDeploymentTests.java48
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/Spring256ABundleTests.java87
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubInstallArtifactLifecycleListener.java138
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ThreadContextClassLoaderTests.java36
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/TransitiveConstraintFailureDiagnosisTests.java131
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModule.java132
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleExport.java156
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleImport.java105
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/BundlesAndConfig.parbin0 -> 1243 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ExporterC.jarbin0 -> 713 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotion.parbin0 -> 3196 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotionViaLibrary.parbin0 -> 3189 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/LibraryC.libd2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF29
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties62
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties65
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ParRefreshPar.parbin0 -> 1083 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/activator-tccl.jarbin0 -> 1775 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app0.parbin0 -> 1338 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4.parbin0 -> 1925 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4clash.parbin0 -> 1814 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app5.parbin0 -> 2035 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app6.parbin0 -> 2281 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/app7.parbin0 -> 2230 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-activation-policy.parbin0 -> 2558 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporter.jarbin0 -> 1274 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv2.jarbin0 -> 1819 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv3.jarbin0 -> 2387 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshImporter.jarbin0 -> 4046 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashing.exports.in.a.scope.parbin0 -> 1648 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashinguses.parbin0 -> 710 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/classpath-scanning.parbin0 -> 2857 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.brits.parbin0 -> 76877 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.deployer.testbundle.jarbin0 -> 1144 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.test.commons-dbcp.jarbin0 -> 1518 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config-admin-test.jarbin0 -> 1828 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.properties5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties92
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.medic.properties6
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.repository.properties39
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/serviceability.xml52
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/configTimeout/org.eclipse.virgo.kernel.properties9
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/empty.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/t.properties2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployedArtifactJmxBeanTests/test.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/ClassNotFoundException.jarbin0 -> 949 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/malformed-application-context.parbin0 -> 942 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-bundle.parbin0 -> 715 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-library.parbin0 -> 720 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-package.parbin0 -> 719 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy-library.libd3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy.jarbin0 -> 848 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummymodified.jarbin0 -> 852 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/fragment.plan12
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle.jarbin0 -> 369 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/test.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP1.libd3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP2.libd3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2.jar/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2ViaLibraries.jar/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP1.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP2.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/initial-artifact-plan/com.springsource.kernel.deployer.test.userregion.springdm.plan10
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/jpa-ltw-sample-update.parbin0 -> 606244 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/library-deployment-test.parbin0 -> 973 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/manual-context.jarbin0 -> 1834 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/spring/context.xml11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/nondm/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/spring/context.xml11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.jarbin0 -> 1016 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.parbin0 -> 1016 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.jarbin0 -> 920 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.parbin0 -> 920 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/bundle.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/bundle.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/org.aspectj-library.libd6
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test.jarbin0 -> 865 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test2.jarbin0 -> 965 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/child.jarbin0 -> 388 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/com.foo.bar.properties3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/global.jarbin0 -> 389 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/parent.jarbin0 -> 422 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/one.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/some-config.properties0
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/three.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/two.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.one.jarbin0 -> 591 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.two.jarbin0 -> 591 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.fragment.one.jarbin0 -> 640 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties.plan13
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties/bundle/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.a.jarbin0 -> 3578 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.b.jarbin0 -> 3579 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same1.jarbin0 -> 3614 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same2.jarbin0 -> 3612 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/initial.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/initial.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/one/foo.txt0
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/one/foo.txt0
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-name.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-version.jar/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/no-bsn-no-version.jar/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/parent-test.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/test.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/test.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test-refresh.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-par-refresh/refresh.par/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.plan10
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.properties0
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/bad/simple.module.jarbin0 -> 607 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple.module.jarbin0 -> 588 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple2.module.jarbin0 -> 613 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh-import-bundle.parbin0 -> 4404 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh.parbin0 -> 6818 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parWithInternalRequireBundle.parbin0 -> 1055 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parrequirebundlethree.jarbin0 -> 362 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/scoped-test-with-par.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/consumer.jarbin0 -> 1103 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/publisher.jarbin0 -> 1117 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/spring/context.xml12
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/service-scoping-nested.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/spring/context.xml10
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/scoping.service.global.jarbin0 -> 1150 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-engine-1265.parbin0 -> 3393 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-platform-183.parbin0 -> 2533 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.parbin0 -> 4819 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.plan12
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.256A.sample.jarbin0 -> 2404 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.libd5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring_instrumented.libd5
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/tccltest.parbin0 -> 3667 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-refresh.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-with-par.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.plan13
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.properties1
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomic.plan13
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.jarbin0 -> 431 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.parbin0 -> 882 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmA.jarbin0 -> 527 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmB.jarbin0 -> 360 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmC.jarbin0 -> 356 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmD.jarbin0 -> 352 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/twoBundlesThatImportTheSameLibrary.parbin0 -> 1114 bytes
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/waralientokernel.war0
200 files changed, 7000 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractDeployerIntegrationTest.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractDeployerIntegrationTest.java
new file mode 100644
index 00000000..26080dc6
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractDeployerIntegrationTest.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.framework.SurrogateBundle;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import org.eclipse.virgo.kernel.osgi.framework.OsgiFramework;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.test.framework.dmkernel.DmKernelTestRunner;
+
+@RunWith(DmKernelTestRunner.class)
+@SuppressWarnings("deprecation")
+public abstract class AbstractDeployerIntegrationTest {
+
+ protected final BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
+
+ protected volatile OsgiFramework framework;
+
+ protected volatile ApplicationDeployer deployer;
+
+ protected volatile BundleContext kernelContext;
+
+ protected volatile PackageAdmin packageAdmin;
+
+ @Before
+ public void setup() {
+ ServiceReference serviceReference = context.getServiceReference(OsgiFramework.class.getName());
+ if (serviceReference != null) {
+ this.framework = (OsgiFramework) context.getService(serviceReference);
+ }
+
+ serviceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.deployer = (ApplicationDeployer) this.context.getService(serviceReference);
+
+ Bundle bundle = this.context.getBundle(1);
+ if (bundle instanceof SurrogateBundle) {
+ this.kernelContext = ((SurrogateBundle)bundle).getCompositeBundleContext();
+ }
+
+ serviceReference = context.getServiceReference(PackageAdmin.class.getName());
+ if (serviceReference != null) {
+ this.packageAdmin = (PackageAdmin) context.getService(serviceReference);
+ }
+ }
+
+ @BeforeClass
+ public static void awaitKernelStartup() throws Exception {
+ MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ int sleepCount = 600;
+ while (!"STARTED".equals(platformMBeanServer.getAttribute(new ObjectName("org.eclipse.virgo.kernel:type=KernelStatus"), "Status"))) {
+ Thread.sleep(50);
+ if(--sleepCount==0) break;
+ }
+ assertFalse("Waited for Kernel too long.", sleepCount==0);
+ }
+
+ protected static void assertDeploymentIdentityEquals(DeploymentIdentity deploymentIdentity, String name, String type, String symbolicName, String version) {
+ String header = String.format("DeploymentIdentity('%s').", name);
+
+ assertEquals(header+"type is incorrect", type, deploymentIdentity.getType());
+ assertEquals(header+"symbolicName is incorrect", symbolicName, deploymentIdentity.getSymbolicName());
+ assertEquals(header+"version is incorrect", new Version(version), new Version(deploymentIdentity.getVersion()));
+ }
+
+ protected Configuration getConfiguration(String pid) throws IOException, InvalidSyntaxException {
+ ServiceReference serviceReference = this.context.getServiceReference(ConfigurationAdmin.class.getName());
+ ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) this.context.getService(serviceReference);
+ try {
+ Configuration[] listConfigurations = configurationAdmin.listConfigurations(null);
+
+ Configuration match = null;
+
+ for (Configuration configuration : listConfigurations) {
+ if (pid.equals(configuration.getPid())) {
+ match = configuration;
+ }
+ }
+ return match;
+ } finally {
+ this.context.ungetService(serviceReference);
+ }
+ }
+
+ protected Bundle getBundle(String symbolicName, Version version) {
+ Bundle[] bundles = this.context.getBundles();
+ for (Bundle bundle : bundles) {
+ if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractParTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractParTests.java
new file mode 100644
index 00000000..94ed47e0
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractParTests.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.jar.JarFile;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.osgi.framework.ServiceRegistration;
+
+import org.eclipse.virgo.kernel.module.ModuleContextEvent;
+import org.eclipse.virgo.kernel.module.ModuleContextEventListener;
+import org.eclipse.virgo.kernel.module.ModuleContextFailedEvent;
+
+/**
+ */
+public abstract class AbstractParTests extends AbstractDeployerIntegrationTest {
+
+ protected DeploymentIdentity deploy(File file) throws Throwable {
+ String appSymbolicName = getApplicationSymbolicName(file);
+
+ FailureTrackingListener listener = new FailureTrackingListener(appSymbolicName);
+ ServiceRegistration registration = this.context.registerService(ModuleContextEventListener.class.getName(), listener, null);
+
+ try {
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(file.toURI());
+ if (listener.cause != null) {
+ throw listener.cause;
+ }
+ return deploymentIdentity;
+ } finally {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+ }
+
+ private String getApplicationSymbolicName(File par) throws Exception {
+ JarFile jar = null;
+ try {
+ jar = new JarFile(par);
+ String name = jar.getManifest().getMainAttributes().getValue("Application-SymbolicName");
+ if (name == null) {
+ name = jar.getManifest().getMainAttributes().getValue("Bundle-SymbolicName");
+ }
+ jar.close();
+ assertTrue("Application-SymbolicName or Bundle-SymbolicName cannot be found for file: " + par, name != null && name.length() > 0);
+ return name;
+ } finally {
+ if (jar != null) {
+ jar.close();
+ }
+ }
+ }
+
+ private final class FailureTrackingListener implements ModuleContextEventListener {
+
+ private final String appName;
+
+ private Throwable cause;
+
+ private FailureTrackingListener(String appName) {
+ this.appName = appName;
+ }
+
+ public void onEvent(ModuleContextEvent moduleContextEvent) {
+ String symbolicName = moduleContextEvent.getBundle().getSymbolicName();
+ if (symbolicName.startsWith(this.appName) && moduleContextEvent instanceof ModuleContextFailedEvent) {
+ this.cause = ((ModuleContextFailedEvent) moduleContextEvent).getFailureCause();
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java
new file mode 100644
index 00000000..cb73e82b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/AbstractRAMIntegrationTests.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
+import org.osgi.framework.Version;
+
+import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
+
+public class AbstractRAMIntegrationTests extends AbstractDeployerIntegrationTest {
+
+ public ManageableArtifact getManageableArtifact(DeploymentIdentity deploymentIdentity) {
+ return getManageableArtifact(deploymentIdentity.getType(), deploymentIdentity.getSymbolicName(), new Version(deploymentIdentity.getVersion()));
+ }
+
+ public ManageableArtifact getManageableArtifact(String type, String name, Version version) {
+ RuntimeArtifactModelObjectNameCreator objectNameCreator = OsgiFrameworkUtils.getService(this.kernelContext, RuntimeArtifactModelObjectNameCreator.class).getService();
+ ObjectName objectName = objectNameCreator.create(type, name, version);
+
+ return getManageableArtifact(objectName);
+ }
+
+ private ManageableArtifact getManageableArtifact(ObjectName objectName) {
+ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+ ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
+ return artifact;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ActivatorTcclTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ActivatorTcclTests.java
new file mode 100644
index 00000000..6d63f887
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ActivatorTcclTests.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+
+
+
+/**
+ *
+ */
+public class ActivatorTcclTests extends AbstractDeployerIntegrationTest {
+
+ @Test
+ public void tcclDuringBundleActivation() throws DeploymentException {
+ // Bundle will fail to start if the TCCL is not the bundle's class loader during activator start()
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/activator-tccl.jar").toURI());
+ // Bundle will fail to stop if the TCCL is not the bundle's class loader during activator stop()
+ this.deployer.undeploy(deployed);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ApplicationContextUtils.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ApplicationContextUtils.java
new file mode 100644
index 00000000..aebcc4d0
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ApplicationContextUtils.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.springframework.context.ApplicationContext;
+
+final class ApplicationContextUtils {
+
+ static void assertApplicationContextContainsExpectedBeanDefinitions(ApplicationContext applicationContext, String... beanNames) {
+ for (String beanName : beanNames) {
+ assertTrue("A definition for a bean named " + beanName + " was not found in the application context", applicationContext.containsBeanDefinition(beanName));
+ }
+ }
+
+ static ApplicationContext getApplicationContext(BundleContext bundleContext, String symbolicName) {
+ ServiceReference[] serviceReferences = null;
+
+ try {
+ serviceReferences = bundleContext.getServiceReferences(ApplicationContext.class.getName(), "(Bundle-SymbolicName=" + symbolicName + ")");
+ } catch (InvalidSyntaxException e) {
+ fail(e.toString());
+ }
+
+ if (serviceReferences != null) {
+ assertEquals("Found " + serviceReferences.length + " matching service references when only 1 was expected", 1, serviceReferences.length);
+ return (ApplicationContext) bundleContext.getService(serviceReferences[0]);
+ }
+
+ return null;
+ }
+
+ static void awaitApplicationContext(BundleContext bundleContext, String symbolicName, long timeout) {
+ long endTime = System.currentTimeMillis() + (timeout * 1000);
+
+ ApplicationContext applicationContext = null;
+
+ while (applicationContext == null && System.currentTimeMillis() < endTime) {
+ applicationContext = getApplicationContext(bundleContext, symbolicName);
+ }
+
+ if (applicationContext == null) {
+ fail("ApplicationContext for bundle with symbolic name '" + symbolicName + "' was not published within " + (timeout * 1000) + " seconds.");
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleActivationPolicyTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleActivationPolicyTests.java
new file mode 100644
index 00000000..e7cb43d9
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleActivationPolicyTests.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ */
+@Ignore("Bundle activation policy is current ignored by the pipelined deployer")
+public class BundleActivationPolicyTests extends AbstractParTests {
+
+ private static final String MODULE_A_BUNDLE_SYMBOLIC_NAME = "bundle.activation.policy.module.a";
+ private static final String MODULE_B_BUNDLE_SYMBOLIC_NAME = "bundle.activation.policy.module.b";
+
+ @Test
+ public void lazyActivationPolicy() throws Throwable {
+ deploy(new File("src/test/resources/bundle-activation-policy.par"));
+ Bundle[] bundles = this.framework.getBundleContext().getBundles();
+ Bundle moduleA = null;
+ Bundle moduleB = null;
+
+ for (Bundle bundle : bundles) {
+ String bundleSymbolicName = (String)bundle.getHeaders().get("Bundle-SymbolicName");
+ if (bundleSymbolicName != null) {
+ if (bundleSymbolicName.endsWith(MODULE_A_BUNDLE_SYMBOLIC_NAME)) {
+ moduleA = bundle;
+ if (moduleB != null) {
+ break;
+ }
+ } else if (bundleSymbolicName.endsWith(MODULE_B_BUNDLE_SYMBOLIC_NAME)) {
+ moduleB = bundle;
+ if (moduleA != null) {
+ break;
+ }
+ }
+ }
+ }
+
+ assertNotNull(moduleA);
+ assertNotNull(moduleB);
+
+ assertTrue(moduleA.getState() == Bundle.ACTIVE);
+ assertTrue(moduleB.getState() == Bundle.STARTING);
+
+ Class<?> clazz = moduleA.loadClass("a.UseBundleB");
+ Object instance = clazz.newInstance();
+ assertNotNull(clazz.getMethod("getClassInBundleB", (Class[])null).invoke(instance, (Object[])null));
+
+ assertTrue(moduleA.getState() == Bundle.ACTIVE);
+ assertTrue(moduleB.getState() == Bundle.ACTIVE);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleDeployerIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleDeployerIntegrationTests.java
new file mode 100644
index 00000000..ab3a1caf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleDeployerIntegrationTests.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+
+
+/**
+ * Test deploying a bundle devoid of personality.
+ *
+ */
+public class BundleDeployerIntegrationTests extends AbstractDeployerIntegrationTest {
+
+ private static final String TEST_BUNDLE_TYPE = "bundle";
+
+ private static final String TEST_BUNDLE_SYMBOLIC_NAME = "com.springsource.kernel.deployer.testbundle";
+
+ private static final String TEST_BUNDLE_VERSION = "2.0.0.build-20080229163630";
+
+ @Test
+ public void testDeployer() throws Exception {
+ File file = new File("src/test/resources/com.springsource.platform.deployer.testbundle.jar");
+
+ DeploymentIdentity deploymentId = this.deployer.deploy(file.toURI());
+
+ assertDeploymentIdentityEquals(deploymentId, "testbundle.jar", TEST_BUNDLE_TYPE, TEST_BUNDLE_SYMBOLIC_NAME, TEST_BUNDLE_VERSION);
+
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_SYMBOLIC_NAME));
+
+ this.deployer.undeploy(deploymentId.getType(), deploymentId.getSymbolicName(), deploymentId.getVersion());
+
+ // Check that the test bundle's application context is destroyed.
+ assertNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_SYMBOLIC_NAME));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleLifecycleTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleLifecycleTests.java
new file mode 100644
index 00000000..cf549ee1
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleLifecycleTests.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
+
+/**
+ * Test bundle state when listening to deployer lifecycle events.
+ *
+ */
+public class BundleLifecycleTests extends AbstractDeployerIntegrationTest {
+
+ @Before
+ public void setUp() throws Exception {
+ this.context.registerService(InstallArtifactLifecycleListener.class.getName(), new Listener(), null);
+ }
+
+ @Test public void testDeployer() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(file.toURI());
+
+
+ this.deployer.undeploy(deploymentIdentity);
+
+ }
+
+ private class Listener extends InstallArtifactLifecycleListenerSupport {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onInstalled(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.INSTALLED);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onInstalling(InstallArtifact installArtifact) {
+ assertNoBundle(installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResolved(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.RESOLVED);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResolving(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.INSTALLED);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStarted(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.ACTIVE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStarting(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.STARTING);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStopped(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.RESOLVED);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStopping(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.STOPPING);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUninstalled(InstallArtifact installArtifact) {
+ assertNoBundle(installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUninstalling(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.RESOLVED);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUnresolved(InstallArtifact installArtifact) {
+ assertBundleState(installArtifact, Bundle.INSTALLED);
+ }
+
+
+ }
+
+ public void assertBundleState(InstallArtifact installArtifact, int expectedBundleState) {
+ Assert.assertTrue(installArtifact instanceof BundleInstallArtifact);
+ BundleInstallArtifact bundleInstallArtifact = (BundleInstallArtifact)installArtifact;
+ Bundle bundle = bundleInstallArtifact.getBundle();
+ Assert.assertNotNull(bundle);
+ Assert.assertEquals(expectedBundleState, bundle.getState());
+ }
+
+ public void assertNoBundle(InstallArtifact installArtifact) {
+ Assert.assertTrue(installArtifact instanceof BundleInstallArtifact);
+ BundleInstallArtifact bundleInstallArtifact = (BundleInstallArtifact)installArtifact;
+ Bundle bundle = bundleInstallArtifact.getBundle();
+ Assert.assertNull(bundle);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleRefreshTests.java
new file mode 100644
index 00000000..1f3b0970
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/BundleRefreshTests.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test refreshing single bundles.
+ * <p />
+ *
+ */
+public class BundleRefreshTests extends AbstractDeployerIntegrationTest {
+
+ private final String TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME = "RefreshImporter";
+
+ @Test
+ public void testBundleRefresh() throws DeploymentException, InterruptedException {
+ UninstallTrackingInstallArtifactLifecycleListener listener = new UninstallTrackingInstallArtifactLifecycleListener();
+ ServiceRegistration listenerRegistration = this.context.registerService(InstallArtifactLifecycleListener.class.getName(), listener, null);
+
+ new PathReference("./target/bundle-refresh").createDirectory();
+
+ PathReference exporterSource = new PathReference("./src/test/resources/bundle-refresh/RefreshExporter.jar");
+ PathReference exporter = new PathReference("./target/bundle-refresh/RefreshExporter.jar");
+ exporter.delete();
+ exporterSource.copy(exporter);
+
+ this.deployer.deploy(exporter.toURI());
+
+ PathReference importer = new PathReference("./src/test/resources/bundle-refresh/RefreshImporter.jar");
+ this.deployer.deploy(importer.toURI());
+
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME));
+
+ checkV1Classes();
+
+ PathReference exporterv2Source = new PathReference("./src/test/resources/bundle-refresh/RefreshExporterv2.jar");
+ exporter.delete();
+ exporterv2Source.copy(exporter);
+
+ this.deployer.refresh(exporter.toURI(), "RefreshExporter");
+
+ Thread.sleep(1000); // wait for appCtx to be properly closed before waiting for it to be created.
+
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV2Classes();
+
+ assertEquals(0, listener.getUninstalledArtifacts().size());
+
+ PathReference exporterv3Source = new PathReference("./src/test/resources/bundle-refresh/RefreshExporterv3.jar");
+ exporter.delete();
+ exporterv3Source.copy(exporter);
+
+ this.deployer.refresh(exporter.toURI(), "RefreshExporter");
+ Thread.sleep(1000); // wait for appCtx to be properly closed before waiting for it to be created.
+
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV3Classes();
+
+ assertEquals(0, listener.getUninstalledArtifacts().size());
+
+ listenerRegistration.unregister();
+ }
+
+ private void checkV1Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ Assert.assertFalse(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ Assert.assertFalse(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private void checkV2Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ Assert.assertFalse(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private void checkV3Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ Assert.assertTrue(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private BundleContext getApplicationBundleContext() {
+ Bundle[] bundles = this.context.getBundles();
+ for (Bundle bundle : bundles) {
+ String symbolicName = bundle.getSymbolicName();
+ if (symbolicName.contains("RefreshImporter")) {
+ System.out.println(bundle.getSymbolicName());
+ return bundle.getBundleContext();
+ }
+ }
+ fail("Cannot find bundle context");
+ return null;
+ }
+
+ private final class UninstallTrackingInstallArtifactLifecycleListener extends InstallArtifactLifecycleListenerSupport {
+
+ private final List<InstallArtifact> uninstalledArtifacts = new ArrayList<InstallArtifact>();
+
+ private final Object monitor = new Object();
+
+ @Override
+ public void onUninstalled(InstallArtifact installArtifact) throws DeploymentException {
+ synchronized (this.monitor) {
+ this.uninstalledArtifacts.add(installArtifact);
+ }
+ }
+
+ private List<InstallArtifact> getUninstalledArtifacts() {
+ synchronized (this.monitor) {
+ return new ArrayList<InstallArtifact>(this.uninstalledArtifacts);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ClasspathScanningTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ClasspathScanningTests.java
new file mode 100644
index 00000000..5727760c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ClasspathScanningTests.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.PathReference;
+
+public class ClasspathScanningTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ @Before
+ public void setUp() throws Exception {
+ cleanUp();
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ cleanUp();
+ }
+
+ @Test
+ public void testComponentAnnotatedClassesFromImportedPackagesArePresentInApplicationContext() throws Exception {
+ DeploymentIdentity identity = this.appDeployer.deploy(new File("src/test/resources/classpath-scanning.par").toURI());
+
+ String symbolicName = "ClasspathScanning-1-com.foo.app";
+
+ ApplicationContextUtils.assertApplicationContextContainsExpectedBeanDefinitions(ApplicationContextUtils.getApplicationContext(this.context,
+ symbolicName), "dependencyOne", "dependencyTwo");
+
+ this.appDeployer.undeploy(identity);
+ }
+
+ private void cleanUp() {
+ cleanDirectory("./target/org.eclipse.virgo.kernel");
+ cleanDirectory("./target/install");
+ cleanDirectory("./target/locationCache");
+ }
+
+ private void cleanDirectory(String dir) {
+ PathReference prd = new PathReference(dir);
+ prd.delete(true);
+ prd.createDirectory();
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/CommonsDbcpTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/CommonsDbcpTests.java
new file mode 100644
index 00000000..6d7c4cc5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/CommonsDbcpTests.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.hsqldb.Server;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.eclipse.virgo.util.io.FileSystemUtils;
+
+public class CommonsDbcpTests extends AbstractDeployerIntegrationTest {
+
+ private static Server server;
+
+ @BeforeClass
+ public static void setupDatabase() {
+ FileSystemUtils.deleteRecursively(new File("target/db"));
+ server = new Server();
+ server.setDatabasePath(0, "target/db/commons-dbcp-test-db");
+ server.setDatabaseName(0, "");
+ server.setSilent(true);
+ server.start();
+ }
+
+ @AfterClass
+ public static void stopDatabase() {
+ if (server != null) {
+ server.stop();
+ }
+ }
+
+ @Test
+ public void testCommonsDbcpClassLoading() throws Exception {
+ this.deployer.deploy(new File("../ivy-cache/repository/org.apache.commons/com.springsource.org.apache.commons.dbcp/1.2.2.osgi/com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar").toURI());
+ this.deployer.deploy(new File("src/test/resources/com.springsource.platform.test.commons-dbcp.jar").toURI());
+ ApplicationContextUtils.assertApplicationContextContainsExpectedBeanDefinitions(ApplicationContextUtils.getApplicationContext(this.context, "com.springsource.server.test.commons-dbcp"), "dataSourceTest");
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ConfigurationDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ConfigurationDeploymentTests.java
new file mode 100644
index 00000000..2854323f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ConfigurationDeploymentTests.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Dictionary;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.FileCopyUtils;
+
+/**
+ * Test deploying a configuration properties file.
+ *
+ */
+public class ConfigurationDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private ServiceReference configAdminServiceReference;
+
+ private ConfigurationAdmin configAdmin;
+
+ @Before
+ public void setUp() throws Exception {
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ this.configAdminServiceReference = this.context.getServiceReference(ConfigurationAdmin.class.getName());
+ this.configAdmin = (ConfigurationAdmin) this.context.getService(this.configAdminServiceReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ if (this.configAdminServiceReference != null) {
+ this.context.ungetService(this.configAdminServiceReference);
+ }
+ }
+
+ @Test
+ public void testDeployConfig() throws Exception {
+ File file = new File("src/test/resources/configuration.deployment/t.properties");
+
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(file.toURI());
+
+ assertDeploymentIdentityEquals(deploymentIdentity, "t.properties", "configuration", "t", "0");
+ Assert.assertTrue(isInDeploymentIdentities(deploymentIdentity));
+ checkConfigAvailable();
+
+ this.appDeployer.undeploy(deploymentIdentity);
+ Assert.assertFalse(isInDeploymentIdentities(deploymentIdentity));
+ checkConfigUnavailable();
+
+ // Check that the configuration can be deployed again after being undeployed
+ this.appDeployer.deploy(file.toURI());
+ Assert.assertTrue(isInDeploymentIdentities(deploymentIdentity));
+ checkConfigAvailable();
+
+ // And that a deploy while deployed works as well
+ this.appDeployer.deploy(file.toURI());
+ Assert.assertTrue(isInDeploymentIdentities(deploymentIdentity));
+ checkConfigAvailable();
+
+ this.appDeployer.undeploy(deploymentIdentity);
+ Assert.assertFalse(isInDeploymentIdentities(deploymentIdentity));
+ checkConfigUnavailable();
+ }
+
+ @Test
+ public void testHotDeployConfig() throws Exception {
+ File source = new File("src/test/resources/configuration.deployment/t.properties");
+ File target = new File("target/pickup/t.properties");
+
+ if (target.exists()) {
+ assertTrue(target.delete());
+ }
+
+ try {
+ FileCopyUtils.copy(source, target);
+ pollUntilInDeploymentIdentities("configuration", "t", "0.0.0");
+
+ checkConfigAvailable();
+
+ target.delete();
+ pollUntilNotInDeploymentIdentities("configuration", "t", "0.0.0");
+ checkConfigUnavailable();
+
+ // Check that the configuration can be deployed again after being undeployed
+ FileCopyUtils.copy(source, target);
+ pollUntilInDeploymentIdentities("configuration", "t", "0.0.0");
+ checkConfigAvailable();
+
+ // Trigger a redeploy of the file by the hot deployer and sleep till
+ // the redeploy has taken effect.
+ target.setLastModified(System.currentTimeMillis() + 1000);
+ Thread.sleep(3000);
+ pollUntilInDeploymentIdentities("configuration", "t", "0.0.0");
+ checkConfigAvailable();
+
+ target.delete();
+ pollUntilNotInDeploymentIdentities("configuration", "t", "0.0.0");
+ checkConfigUnavailable();
+ } finally {
+ target.delete();
+ }
+ }
+
+ private void pollUntilInDeploymentIdentities(String type, String name, String version) throws InterruptedException {
+ long start = System.currentTimeMillis();
+
+ while (!isInDeploymentIdentities(type, name, version)) {
+ long delta = System.currentTimeMillis() - start;
+ if (delta > 30000) {
+ fail("Deployment identity was not available within 30 seconds");
+ }
+ Thread.sleep(100);
+ }
+ }
+
+ private void pollUntilNotInDeploymentIdentities(String type, String name, String version) throws InterruptedException {
+ long start = System.currentTimeMillis();
+
+ while (isInDeploymentIdentities(type, name, version)) {
+ long delta = System.currentTimeMillis() - start;
+ if (delta > 30000) {
+ fail("Deployment identity was still available after 30 seconds");
+ }
+ Thread.sleep(100);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDeployEmptyConfig() throws Exception {
+ File file = new File("src/test/resources/configuration.deployment/empty.properties");
+
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(file.toURI());
+ Assert.assertEquals("configuration", deploymentIdentity.getType());
+ Assert.assertEquals("empty", deploymentIdentity.getSymbolicName());
+ Assert.assertEquals(Version.emptyVersion, new Version(deploymentIdentity.getVersion()));
+
+ Assert.assertTrue(isInDeploymentIdentities(deploymentIdentity));
+ Configuration configuration = this.configAdmin.getConfiguration("empty", null);
+ Dictionary<Object, Object> dictionary = configuration.getProperties();
+ Assert.assertEquals(1, dictionary.size());
+ Assert.assertEquals("empty", dictionary.get("service.pid"));
+
+ this.appDeployer.undeploy(deploymentIdentity);
+ Assert.assertFalse(isInDeploymentIdentities(deploymentIdentity));
+ configuration = this.configAdmin.getConfiguration("empty", null);
+ Assert.assertNull(configuration.getProperties());
+ }
+
+ private boolean isInDeploymentIdentities(DeploymentIdentity deploymentIdentity) {
+ boolean found = false;
+ for (DeploymentIdentity id : this.appDeployer.getDeploymentIdentities()) {
+ if (deploymentIdentity.equals(id)) {
+ found = true;
+ }
+ }
+ return found;
+ }
+
+ private boolean isInDeploymentIdentities(String type, String name, String version) {
+ for (DeploymentIdentity id : this.appDeployer.getDeploymentIdentities()) {
+ if (id.getType().equals(type) && id.getSymbolicName().equals(name) && id.getVersion().equals(version)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isInConfigurationAdmin() throws IOException, InvalidSyntaxException {
+ Configuration[] configurations = this.configAdmin.listConfigurations(null);
+ for (Configuration configuration : configurations) {
+ if ("t".equals(configuration.getPid())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkConfigAvailable() throws IOException, InvalidSyntaxException, InterruptedException {
+ long start = System.currentTimeMillis();
+
+ while (!isInConfigurationAdmin()) {
+ long delta = System.currentTimeMillis() - start;
+ if (delta > 30000) {
+ fail("Configuration was not available in ConfigAdmin within 30 seconds");
+ }
+ Thread.sleep(100);
+ }
+
+ Configuration configuration = this.configAdmin.getConfiguration("t", null);
+ Dictionary<Object, Object> dictionary = configuration.getProperties();
+ Assert.assertEquals("t", dictionary.get("service.pid"));
+ Assert.assertEquals("b", dictionary.get("a"));
+ }
+
+ private void checkConfigUnavailable() throws IOException, InvalidSyntaxException {
+ assertFalse(isInConfigurationAdmin());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerEdgeTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerEdgeTests.java
new file mode 100644
index 00000000..ad4bb4d5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerEdgeTests.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URI;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test various usages of the deployer interface for edge cases.
+ * <p />
+ *
+ */
+public class DeployerEdgeTests extends AbstractDeployerIntegrationTest {
+
+ private final String TEST_PAR_BUNDLE_SYMBOLIC_NAME = "MyApp-1-com.springsource.kernel.deployer.testbundle";
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private PathReference parCopy1, parCopy2, parCopy3;
+
+ private PathReference par;
+
+ private PathReference jarCopy1, jarCopy2, jarCopy3;
+
+ private PathReference jar;
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/org.eclipse.virgo.kernel");
+ pr.delete(true);
+ pr.createDirectory();
+ pr = new PathReference("./target/deployer-edge-test");
+ pr.delete(true);
+ pr.createDirectory();
+ pr = new PathReference("./target/deployer-edge-test/other");
+ pr.createDirectory();
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+
+ parCopy1 = new PathReference("./target/deployer-edge-test/app0.par");
+ parCopy2 = new PathReference("./target/deployer-edge-test/app0copy.par");
+ parCopy3 = new PathReference("./target/deployer-edge-test/other/app0.par");
+ par = new PathReference("src/test/resources/app0.par");
+
+ jarCopy1 = new PathReference("./target/deployer-edge-test/dummy.jar");
+ jarCopy2 = new PathReference("./target/deployer-edge-test/dummycopy.jar");
+ jarCopy3 = new PathReference("./target/deployer-edge-test/other/dummy.jar");
+ jar = new PathReference("src/test/resources/dummy.jar");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ PathReference pr = new PathReference("./target/org.eclipse.virgo.kernel");
+ pr.delete(true);
+ pr = new PathReference("./target/deployer-edge-test");
+ pr.delete(true);
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testNonExistentFile() throws DeploymentException {
+ PathReference noPar = new PathReference("./blah");
+
+ this.appDeployer.deploy(noPar.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testNonExistentJar() throws DeploymentException {
+ PathReference noJar = new PathReference("./blah.jar");
+
+ this.appDeployer.deploy(noJar.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDuplicateAppFromDifferentLocation() throws DeploymentException {
+ parCopy1.delete(true);
+ par.copy(parCopy1);
+
+ this.appDeployer.deploy(parCopy1.toURI());
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_PAR_BUNDLE_SYMBOLIC_NAME));
+
+ parCopy2.delete(true);
+ par.copy(parCopy2);
+
+ this.appDeployer.deploy(parCopy2.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDuplicateJarFromDifferentLocation() throws DeploymentException {
+ jarCopy1.delete(true);
+ jar.copy(jarCopy1);
+
+ this.appDeployer.deploy(jarCopy1.toURI());
+
+ jarCopy2.delete(true);
+ jar.copy(jarCopy2);
+
+ this.appDeployer.deploy(jarCopy2.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDuplicateAppSameFileNameDifferentLocation() throws DeploymentException {
+ parCopy1.delete(true);
+ par.copy(parCopy1);
+
+ this.appDeployer.deploy(parCopy1.toURI());
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_PAR_BUNDLE_SYMBOLIC_NAME));
+
+ parCopy3.delete(true);
+ par.copy(parCopy3);
+
+ this.appDeployer.deploy(parCopy3.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDuplicateJarSameFileNameDifferentLocation() throws DeploymentException {
+ jarCopy1.delete(true);
+ jar.copy(jarCopy1);
+
+ this.appDeployer.deploy(jarCopy1.toURI());
+
+ jarCopy3.delete(true);
+ jar.copy(jarCopy3);
+
+ this.appDeployer.deploy(jarCopy3.toURI());
+ }
+
+ @Test
+ public void testDifferentAppSameLocation() throws Exception {
+ parCopy1.delete(true);
+ par.copy(parCopy1);
+
+ this.appDeployer.deploy(parCopy1.toURI());
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_PAR_BUNDLE_SYMBOLIC_NAME));
+
+ parCopy1.delete(true);
+ new PathReference("src/test/resources/app4.par").copy(parCopy1);
+
+ this.appDeployer.deploy(parCopy1.toURI());
+ }
+
+ @Test
+ public void testDifferentJarSameLocation() throws Exception {
+ jarCopy1.delete(true);
+ jar.copy(jarCopy1);
+
+ this.appDeployer.deploy(jarCopy1.toURI());
+
+ jarCopy1.delete(true);
+ new PathReference("src/test/resources/ExporterC.jar").copy(jarCopy1);
+
+ this.appDeployer.deploy(jarCopy1.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDifferentAppSameFileNameDifferentLocation() throws Exception {
+ parCopy1.delete(true);
+ par.copy(parCopy1);
+
+ this.appDeployer.deploy(parCopy1.toURI());
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_PAR_BUNDLE_SYMBOLIC_NAME));
+
+ parCopy3.delete(true);
+ new PathReference("src/test/resources/app4.par").copy(parCopy3);
+
+ this.appDeployer.deploy(parCopy3.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testDifferentJarSameFileNameDifferentLocation() throws Exception {
+ jarCopy1.delete(true);
+ jar.copy(jarCopy1);
+
+ this.appDeployer.deploy(jarCopy1.toURI());
+
+ jarCopy3.delete(true);
+ new PathReference("src/test/resources/ExporterC.jar").copy(jarCopy3);
+
+ this.appDeployer.deploy(jarCopy3.toURI());
+ }
+
+ @Test
+ public void testParWithoutManifest() throws Exception {
+ File f = new File("src/test/resources/nomanifest.par");
+ DeploymentIdentity deployed = this.appDeployer.deploy(f.toURI());
+
+ assertEquals("par", deployed.getType());
+ assertEquals("nomanifest", deployed.getSymbolicName());
+ assertEquals("0.0.0", deployed.getVersion());
+ }
+
+ @Test
+ public void testJarWithoutManifest() throws Exception {
+ File f = new File("src/test/resources/nomanifest.jar");
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(f.toURI());
+ this.appDeployer.undeploy(deploymentIdentity);
+ }
+
+ @Test
+ public void testParWithoutMetaInf() throws Exception {
+ File f = new File("src/test/resources/nometainf.par");
+ DeploymentIdentity deployed = this.appDeployer.deploy(f.toURI());
+
+ assertEquals("par", deployed.getType());
+ assertEquals("nometainf", deployed.getSymbolicName());
+ assertEquals("0.0.0", deployed.getVersion());
+ }
+
+ @Test
+ public void testJarWithoutMetaInf() throws Exception {
+ File f = new File("src/test/resources/nometainf.jar");
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(f.toURI());
+ this.appDeployer.undeploy(deploymentIdentity);
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testParWithClashingExports() throws Exception {
+ File f = new File("src/test/resources/clashing.exports.in.a.scope.par");
+ this.appDeployer.deploy(f.toURI());
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testUnsupportedURIScheme() throws Exception {
+ URI httpURI = new URI("http://www.springsource.com");
+
+ this.appDeployer.deploy(httpURI);
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testNonBundleDirectory() throws Exception {
+ URI dirURI = new File("target").toURI();
+ this.appDeployer.deploy(dirURI);
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testWar() throws Exception {
+ URI warURI = new File("src/test/resources/waralientokernel.war").toURI();
+
+ this.appDeployer.deploy(warURI);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerLogMessageTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerLogMessageTests.java
new file mode 100644
index 00000000..7a85be47
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/DeployerLogMessageTests.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.virgo.kernel.deployer.core.DeployerLogEvents;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ */
+public class DeployerLogMessageTests extends AbstractParTests {
+
+ private static final File LOG_FILE = new File("target/serviceability/eventlog/eventlog.log");
+
+ private int existingLines;
+
+ @Before
+ public void countExistingLogLines() throws IOException {
+ BufferedReader reader = new BufferedReader(new FileReader(LOG_FILE));
+ String line = reader.readLine();
+ existingLines = 0;
+ while (line != null) {
+ existingLines++;
+ line = reader.readLine();
+ }
+ }
+
+ private List<String> findLogMessages(String logCode) throws IOException {
+ List<String> logMessages = new ArrayList<String>();
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+
+ }
+
+ BufferedReader reader = new BufferedReader(new FileReader(LOG_FILE));
+ String line;
+ int lines = 0;
+ while ((line = reader.readLine()) != null) {
+ lines++;
+ if (lines > existingLines) {
+ int index = line.indexOf(logCode);
+ if (index > -1) {
+ logMessages.add(line.substring(index));
+ }
+ }
+ }
+ return logMessages;
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void unsatisfiablePackageImport() throws Throwable {
+ try {
+ deploy(new File("src/test/resources/deployer-log-message-tests/missing-package.par"));
+ } finally {
+ List<String> logMessages = findLogMessages("<" + DeployerLogEvents.INSTALL_FAILURE.getEventCode() + ">");
+ assertTrue(logMessages.size() == 1);
+ }
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void unsatisfiableBundleImport() throws Throwable {
+ try {
+ deploy(new File("src/test/resources/deployer-log-message-tests/missing-bundle.par"));
+ } finally {
+ List<String> logMessages = findLogMessages("<" + DeployerLogEvents.INSTALL_FAILURE.getEventCode() + ">");
+ assertTrue(logMessages.size() == 1);
+ }
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void unsatisfiableLibraryImport() throws Throwable {
+ try {
+ deploy(new File("src/test/resources/deployer-log-message-tests/missing-library.par"));
+ } finally {
+ List<String> logMessages = findLogMessages("<" + DeployerLogEvents.INSTALL_FAILURE.getEventCode() + ">");
+ assertTrue(logMessages.size() == 1);
+ }
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void malformedApplicationContext() throws Throwable {
+ try {
+ deploy(new File("src/test/resources/deployer-log-message-tests/malformed-application-context.par"));
+ } finally {
+ List<String> logMessages = findLogMessages("<" + DeployerLogEvents.CONFIG_FILE_ERROR.getEventCode() + ">");
+ assertEquals(1, logMessages.size());
+ assertTrue(logMessages.get(0).contains("my.bundle"));
+ }
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void classNotFoundException() throws Throwable {
+ try {
+ deploy(new File("src/test/resources/deployer-log-message-tests/ClassNotFoundException.jar"));
+ } finally {
+ List<String> logMessages = findLogMessages("<AG0000E>");
+ assertTrue(logMessages.size() == 1);
+ assertTrue(logMessages.get(0).contains("com.does.not.exist.NothingToSeeHere"));
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/HotDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/HotDeploymentTests.java
new file mode 100644
index 00000000..0b58d7a8
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/HotDeploymentTests.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.JMException;
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.junit.Test;
+
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.eclipse.virgo.util.io.PathReference;
+
+
+/**
+ */
+public class HotDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private static final long TIMEOUT = 10000;
+
+ private final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+
+ @Test
+ public void programmaticUndeployDeletesHotDeployedPropertiesFile() throws DeploymentException {
+ PathReference pathReference = new PathReference("src/test/resources/hot-deployment-tests/test.properties");
+ doTest(pathReference, "configuration", "test", "0.0.0");
+ }
+
+ @Test
+ public void programmaticUndeployDeletesHotDeployedExplodedBundle() throws DeploymentException {
+ PathReference pathReference = new PathReference("src/test/resources/hot-deployment-tests/bundle");
+ doTest(pathReference, "bundle", "test", "1.0.0");
+ }
+
+ @Test
+ public void programmaticUndeployDeletesHotDeployedBundle() throws DeploymentException {
+ PathReference pathReference = new PathReference("src/test/resources/hot-deployment-tests/bundle.jar");
+ doTest(pathReference, "bundle", "test", "1.0.0");
+ }
+
+ private void doTest(PathReference artifact, String type, String name, String version) throws DeploymentException {
+ PathReference copyInPickup = artifact.copy(new PathReference("target/pickup"), true);
+
+ try {
+ while (!this.deployer.isDeployed(copyInPickup.toURI())) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException _) {
+ }
+ }
+
+ awaitActive(type, name, version);
+
+ this.deployer.undeploy(type, name, version);
+
+ assertFalse(copyInPickup.toFile().exists());
+
+ } finally {
+ copyInPickup.delete();
+ }
+ }
+
+ private void awaitActive(String type, String name, String version) {
+ try {
+ ObjectName objectName = new ObjectName("org.eclipse.virgo.kernel:type=Model,artifact-type=" + type + ",name=" + name + ",version=" + version);
+ ManageableArtifact artifact = JMX.newMXBeanProxy(this.mBeanServer, objectName, ManageableArtifact.class);
+
+ long startTime = System.currentTimeMillis();
+
+ while (!"ACTIVE".equals(artifact.getState())) {
+ if (System.currentTimeMillis() - startTime > TIMEOUT) {
+ fail("Artifact " + type + " " + name + " " + version + " was not active within " + TIMEOUT + "ms.");
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException _) {
+ }
+ }
+ } catch (JMException jme) {
+ fail(jme.getMessage());
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportMergeDiagnosticsTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportMergeDiagnosticsTests.java
new file mode 100644
index 00000000..6f89ad97
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportMergeDiagnosticsTests.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ * Test diagnostics for the merging of imports.
+ *
+ */
+public class ImportMergeDiagnosticsTests extends AbstractDeployerIntegrationTest {
+
+ @Test
+ public void testImportClashingBundles() throws DeploymentException {
+ DeploymentIdentity p1Identity = this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestP1.jar").toURI());
+ DeploymentIdentity p2Identity = this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestP2.jar").toURI());
+ try {
+ this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestImportP1P2.jar").toURI());
+ } catch (DeploymentException e) {
+ System.out.println(e);
+ Throwable ime = e.getCause();
+ String message = ime.getMessage();
+ Assert.assertEquals(
+ "Incorrect message text",
+ "cannot merge imports of package 'p' from sources 'Import-Bundle 'TestP1' version '0.0.0', Import-Bundle 'TestP2' version '0.0.0'' because of conflicting values 'TestP2', 'TestP1' of attribute 'bundle-symbolic-name'",
+ message);
+ } finally {
+ this.deployer.undeploy(p1Identity);
+ this.deployer.undeploy(p2Identity);
+ }
+ }
+
+ @Test
+ public void testImportClashingLibraries() throws DeploymentException {
+ DeploymentIdentity p1Identity = this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestP1.jar").toURI());
+ DeploymentIdentity p2Identity = this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestP2.jar").toURI());
+ try {
+ this.deployer.deploy(new File("src/test/resources/importMergeDiagnostics/TestImportP1P2ViaLibraries.jar").toURI());
+ } catch (DeploymentException e) {
+ System.out.println(e);
+ Throwable ime = e.getCause();
+ String message = ime.getMessage();
+ Assert.assertEquals(
+ "Incorrect message text",
+ "cannot merge imports of package 'p' from sources 'Import-Library 'LibraryImportingP1' version '1.0.0'(Import-Bundle 'TestP1' version '0.0.0'), Import-Library 'LibraryImportingP2' version '1.0.0'(Import-Bundle 'TestP2' version '0.0.0')' because of conflicting values 'TestP2', 'TestP1' of attribute 'bundle-symbolic-name'",
+ message);
+ } finally {
+ this.deployer.undeploy(p1Identity);
+ this.deployer.undeploy(p2Identity);
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportPromotionTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportPromotionTests.java
new file mode 100644
index 00000000..189be03a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ImportPromotionTests.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.junit.Test;
+
+/**
+ * Test the promotion of a bundle import across the bundles of a PAR file.
+ *
+ */
+public class ImportPromotionTests extends AbstractParTests {
+
+ private static final String BUNDLE_SYMBOLIC_NAME = "ImportPromotion-1-ImporterA";
+
+ private static final String BUNDLE_SYMBOLIC_NAME_2 = "ImportPromotionViaLibrary-1-ImporterA";
+
+ @Test
+ public void testImportPromotion() throws Throwable {
+ File par = new File("src/test/resources/ImportPromotion.par");
+ deploy(par);
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_SYMBOLIC_NAME));
+ this.deployer.refresh(par.toURI(), "ImporterA");
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_SYMBOLIC_NAME));
+ }
+
+ @Test
+ public void testImportPromotionViaLibrary() throws Throwable {
+ deploy(new File("src/test/resources/ImportPromotionViaLibrary.par"));
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_SYMBOLIC_NAME_2));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/InterdependentBundleDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/InterdependentBundleDeploymentTests.java
new file mode 100644
index 00000000..81ae057d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/InterdependentBundleDeploymentTests.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test deploying bundles that depend on each other.
+ *
+ */
+public class InterdependentBundleDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ @Before public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/org.eclipse.virgo.kernel");
+ pr.delete(true);
+ pr.createDirectory();
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ }
+
+ @After public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ @Test public void testImportBundleDependency() throws Exception {
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(new File("src/test/resources/osgi_test.jar").toURI());
+ DeploymentIdentity deploymentIdentity2 = this.appDeployer.deploy(new File("src/test/resources/osgi_test2.jar").toURI());
+ this.appDeployer.undeploy(deploymentIdentity2);
+ this.appDeployer.undeploy(deploymentIdentity);
+ }
+
+ @Test
+// @Ignore("Fails intermittently due to problem described in ENGINE-1755")
+ public void testUndeploymentOrder() throws Exception {
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(new File("src/test/resources/osgi_test.jar").toURI());
+ DeploymentIdentity deploymentIdentity2 = this.appDeployer.deploy(new File("src/test/resources/osgi_test2.jar").toURI());
+ this.appDeployer.undeploy(deploymentIdentity);
+ this.appDeployer.undeploy(deploymentIdentity2);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JpaLtwParTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JpaLtwParTests.java
new file mode 100644
index 00000000..37c2ea42
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/JpaLtwParTests.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ */
+@Ignore("Uses TopLink Essentials which leaks a file handle and breaks the build on Windows")
+public class JpaLtwParTests extends AbstractParTests {
+
+ @Test public void testDeployApp() throws Throwable {
+ doTest(new File("src/test/resources/jpa-ltw-sample-update.par"));
+ }
+
+ void doTest(File f) throws Throwable {
+ DeploymentIdentity deploymentIdentity = deploy(f);
+ try {
+ ObjectName oname = ObjectName.getInstance("bean:name=addressSupport");
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ int size = (Integer) server.getAttribute(oname, "AddressesSize");
+ assertEquals(3, size);
+ } finally {
+ this.deployer.undeploy(deploymentIdentity);
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LibraryScopingTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LibraryScopingTests.java
new file mode 100644
index 00000000..c962af3e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LibraryScopingTests.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.junit.Test;
+
+
+// TODO This description is wrong, the test doesn't deploy a library, i.e. there isn't one in the par
+/**
+ * Test deploying a library as part of an application and then deploying an application which depends on the library.
+ *
+ */
+public class LibraryScopingTests extends AbstractParTests {
+
+ @Test(expected = DeploymentException.class) public void testLibraryClash() throws Throwable {
+ File file = new File("src/test/resources/clashinguses.par");
+ deploy(file);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LoadableClasses.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LoadableClasses.java
new file mode 100644
index 00000000..e56913aa
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/LoadableClasses.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.util.Set;
+
+public interface LoadableClasses {
+
+ Set<String> getLoadableClasses();
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ManualSpringContextTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ManualSpringContextTests.java
new file mode 100644
index 00000000..d1891bed
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ManualSpringContextTests.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+
+
+public class ManualSpringContextTests extends AbstractDeployerIntegrationTest {
+
+ @Test
+ public void testManualContextDefinitionWithBadImports() throws Exception {
+ DeploymentIdentity id = this.deployer.deploy(new File("src/test/resources/manual-context.jar").toURI());
+ try {
+ assertNotNull(id);
+ } finally {
+ this.deployer.undeploy(id);
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MissingImportLibraryTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MissingImportLibraryTests.java
new file mode 100644
index 00000000..7fe5f657
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MissingImportLibraryTests.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.junit.Test;
+
+
+
+/**
+ */
+public class MissingImportLibraryTests extends AbstractParTests {
+
+ @Test(expected=DeploymentException.class)
+ public void testInvalidBrits() throws Throwable {
+ deploy(new File("src/test/resources/com.springsource.brits.par"));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MultiBundleApplicationDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MultiBundleApplicationDeploymentTests.java
new file mode 100644
index 00000000..add24507
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/MultiBundleApplicationDeploymentTests.java
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploymentEvent;
+import org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarted;
+import org.eclipse.virgo.kernel.deployer.core.event.ApplicationDeploymentEvent;
+import org.eclipse.virgo.kernel.deployer.core.event.DeploymentListener;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+
+/**
+ * Test deploying an OSGi application containing a simple bundle.
+ *
+ */
+public class MultiBundleApplicationDeploymentTests extends AbstractDeployerIntegrationTest implements DeploymentListener {
+
+ private static final String TEST_BUNDLE_P_SYMBOLIC_NAME = "MultiBundleApp-1-com.springsource.server.apps.app4.p";
+
+ private static final String TEST_BUNDLE_Q_SYMBOLIC_NAME = "MultiBundleApp-1-com.springsource.server.apps.app4.q";
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private ServiceRegistration listenerRegistration = null;
+
+ private List<EventInfo> events = null;
+
+ @Before
+ public void setUp() throws Exception {
+ this.listenerRegistration =
+ this.context.registerService("org.eclipse.virgo.kernel.deployer.core.event.DeploymentListener", this, null);
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ this.events = new ArrayList<EventInfo>();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.listenerRegistration != null) {
+ this.listenerRegistration.unregister();
+ }
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ @Test
+ public void testDeployer() throws Exception {
+
+ File file = new File("src/test/resources/app4.par");
+ URI fileURI = file.toURI();
+ assertFalse("File " + file + " deployed before test!", this.appDeployer.isDeployed(fileURI));
+
+ DeploymentIdentity deploymentId = this.appDeployer.deploy(fileURI);
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_P_SYMBOLIC_NAME));
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_Q_SYMBOLIC_NAME));
+
+ assertTrue("File " + file + " not deployed.", this.appDeployer.isDeployed(fileURI));
+
+ this.appDeployer.undeploy(deploymentId.getType(), deploymentId.getSymbolicName(), deploymentId.getVersion());
+ // Check that the test bundle's application contexts are destroyed.
+ assertNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_P_SYMBOLIC_NAME));
+ assertNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_Q_SYMBOLIC_NAME));
+
+ assertFalse("File " + file + " deployed after test!", this.appDeployer.isDeployed(fileURI));
+
+ @SuppressWarnings("unused")
+ String[] expectedEvents = {
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationDeploying MultiBundleApp 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationDeployed MultiBundleApp 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationUndeploying MultiBundleApp 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.q",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed MultiBundleApp 1 MultiBundleApp-1-com.springsource.server.apps.app4.p",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed MultiBundleApp 1 MultiBundleApp-1-MultiBundleApp-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationUndeployed MultiBundleApp 1" };
+ // TODO: [DMS-1388] reinstate checkEvents(expectedEvents);
+ }
+
+ @Test
+ public void installAParWithInternalRequireBundle() throws Exception {
+ File file = new File("src/test/resources/requirebundle/bundles/parWithInternalRequireBundle.par");
+ URI fileURI = file.toURI();
+
+ assertFalse("File " + file + " deployed before test!", this.appDeployer.isDeployed(fileURI));
+ DeploymentIdentity deploymentId = this.appDeployer.deploy(fileURI);
+ assertTrue("File " + file + " not deployed.", this.appDeployer.isDeployed(fileURI));
+
+ this.appDeployer.undeploy("par", deploymentId.getSymbolicName(), deploymentId.getVersion());
+ assertFalse("File " + file + " not undeployed.", this.appDeployer.isDeployed(fileURI));
+ }
+
+ @Test(expected = DeploymentException.class)
+ public void testClashDetection() throws Exception {
+ File file = new File("src/test/resources/app4clash.par");
+ assertFalse("File " + file + " deployed before test!", this.appDeployer.isDeployed(file.toURI()));
+
+ this.appDeployer.deploy(file.toURI());
+ }
+
+// @Ignore
+ @Test
+ public void installAParWithTwoBundlesThatImportTheSameLibrary() throws DeploymentException {
+
+ File par = new File("src/test/resources/twoBundlesThatImportTheSameLibrary.par");
+ URI parURI = par.toURI();
+ assertFalse("File " + par + " deployed before test!", this.appDeployer.isDeployed(parURI));
+
+ DeploymentIdentity deploymentId = this.appDeployer.deploy(parURI);
+
+ assertTrue("File " + par + " not deployed.", this.appDeployer.isDeployed(parURI));
+
+ this.appDeployer.undeploy("par", deploymentId.getSymbolicName(), deploymentId.getVersion());
+
+ assertFalse("File " + par + " deployed after undeploy.", this.appDeployer.isDeployed(parURI));
+
+ @SuppressWarnings("unused")
+ String[] expectedEvents = {
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationDeploying TwoBundlesThatImportTheSameLibrary 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStarting TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleDeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationDeployed TwoBundlesThatImportTheSameLibrary 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationUndeploying TwoBundlesThatImportTheSameLibrary 1",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-one",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-two",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeploying TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopping TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleStopped TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationBundleUndeployed TwoBundlesThatImportTheSameLibrary 1 TwoBundlesThatImportTheSameLibrary-1-TwoBundlesThatImportTheSameLibrary-synthetic.context",
+ "org.eclipse.virgo.kernel.deployer.core.event.ApplicationUndeployed TwoBundlesThatImportTheSameLibrary 1" };
+ //FIXME: [DMS-1388] reinstate checkEvents(expectedEvents);
+ // NB: no onEvent() calls are made.
+ }
+
+ @SuppressWarnings("unused")
+ private void checkEvents(String[] expectedEvents) {
+ /*
+ * Previously this checked the sequence of events and was far too fragile. Given that start is now asynchronous
+ * to install, the only option is to sort the events and compare.
+ */
+ Arrays.sort(expectedEvents);
+ String[] actualEvents = new String[this.events.size()];
+ int i = 0;
+ for (EventInfo eventInfo : this.events) {
+ actualEvents[i++] = eventInfo.toString();
+ }
+ Arrays.sort(actualEvents);
+ Assert.assertArrayEquals(expectedEvents, actualEvents);
+ }
+
+ public void onEvent(ApplicationDeploymentEvent event) {
+ if (event instanceof ApplicationBundleDeploymentEvent) {
+ // Skip bundle started events as these are sent asynchronously and therefore in unpredictable order
+ if (!(event instanceof ApplicationBundleStarted)) {
+ String symbolicName = ((ApplicationBundleDeploymentEvent) event).getBundle().getSymbolicName();
+ // Focus on test bundles and the synthetic context.
+ if (symbolicName.endsWith("-synthetic.context") || symbolicName.contains(".apps.") || symbolicName.contains("-one")
+ || symbolicName.contains("-two")) {
+ this.events.add(new EventInfo(event.getClass().getName(), event.getApplicationSymbolicName(),
+ event.getApplicationVersion().toString(), symbolicName));
+ }
+ }
+ } else {
+ this.events.add(new EventInfo(event.getClass().getName(), event.getApplicationSymbolicName(), event.getApplicationVersion().toString()));
+ }
+ }
+
+ static class EventInfo {
+
+ private String eventClass;
+
+ private String appName;
+
+ private String appVersion;
+
+ private String bundleName;
+
+ EventInfo(String eventClass, String appName, String appVersion) {
+ this(eventClass, appName, appVersion, null);
+ }
+
+ EventInfo(String eventClass, String appName, String appVersion, String bundleName) {
+ this.eventClass = eventClass;
+ this.appName = appName;
+ this.appVersion = appVersion;
+ this.bundleName = bundleName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.eventClass + " " + this.appName + " " + this.appVersion + (this.bundleName == null ? "" : (" " + this.bundleName));
+ }
+
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
new file mode 100644
index 00000000..6856a7f2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/NestedPlanIntegrationTests.java
@@ -0,0 +1,802 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.Artifact;
+import org.eclipse.virgo.kernel.model.ArtifactState;
+import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.ExportedPackage;
+
+
+/**
+ * These tests cover parent and child plans in all combinations of scoped/unscoped and atomic/non-atomic.
+ * <p/>
+ * A bundle "global" exports the package "global". A bundle "parent" in the parent plans exports the package "parent"
+ * imports the bundle "global" with application import scope. A bundle "child" in the child plans exports the package
+ * "child".
+ * <p/>
+ * An inner class called {@link Model} encapsulates how the various combinations should work in terms of scoping and
+ * atomicity.
+ * <p/>
+ * When scoping occurs, the tests check the synthetic context bundle and the promotion of the "global" package when
+ * appropriate. The lifecycle dependence or independence is checked between the bundles "parent" and "child" and between
+ * the parent and child plans.
+ *
+ */
+public class NestedPlanIntegrationTests extends AbstractDeployerIntegrationTest {
+
+ private static final String GLOBAL_PACKAGE = "global";
+
+ private static final String PARENT_PACKAGE_NAME = "parent";
+
+ private static final String CHILD_PACKAGE_NAME = "child";
+
+ private static final String SCOPE_SEPARATOR = "-";
+
+ private static final String SYNTHETIC_CONTEXT_BSN_SUFFIX = "-synthetic.context";
+
+ private static final String PLAN_TYPE = "plan";
+
+ private static final String BUNDLE_TYPE = "bundle";
+
+ private static final int WATCH_INTERVAL_MS = 1000;
+
+ /*
+ * An artifact must be present in a watched repository directory for up to two watch intervals before it will be
+ * processed. Then it will take a while (a surprisingly long while on some operating systems) to be scheduled and
+ * complete processing.
+ */
+ private static final int WATCH_WAIT_INTERVAL_MS = 2 * WATCH_INTERVAL_MS + 1000;
+
+ private static final String TEST_RESOURCES_DIRECTORY = "src/test/resources/plan-deployment/";
+
+ private static final String GENERATED_PLAN_DIRECTORY = "target/watched/";
+
+ private static final String PLAN_EXTENSION = ".plan";
+
+ private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+
+ private static final String NAMESPACES = " xmlns=\"http://www.springsource.org/schema/dm-server/plan\" \n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n xsi:schemaLocation=\" http://www.springsource.org/schema/dm-server/plan http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd\"";
+
+ private static final Version DEFAULT_VERSION = new Version("0");
+
+ private static TestArtifactInfo GLOBAL_BUNDLE_INFO = new TestArtifactInfo("bundle", GLOBAL_PACKAGE, DEFAULT_VERSION);
+
+ private static TestArtifactInfo PARENT_BUNDLE_INFO = new TestArtifactInfo("bundle", PARENT_PACKAGE_NAME, DEFAULT_VERSION);
+
+ private static TestArtifactInfo CHILD_BUNDLE_INFO = new TestArtifactInfo("bundle", CHILD_PACKAGE_NAME, DEFAULT_VERSION);
+
+ static {
+ GLOBAL_BUNDLE_INFO.setFile(new File(TEST_RESOURCES_DIRECTORY + "global.jar"));
+ }
+
+ private RuntimeArtifactRepository ram;
+
+ private static TestPlanArtifactInfo[] PARENTS;
+
+ private DeploymentIdentity globalBundleDeploymentIdentity;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ File generatedPlanDirectory = new File(GENERATED_PLAN_DIRECTORY);
+ generatedPlanDirectory.mkdirs();
+
+ generatePlans();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ServiceReference serviceReference = context.getServiceReference(RuntimeArtifactRepository.class.getName());
+ if (serviceReference != null) {
+ this.ram = (RuntimeArtifactRepository) context.getService(serviceReference);
+ }
+
+ globalBundleDeploymentIdentity = deploy(GLOBAL_BUNDLE_INFO);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.globalBundleDeploymentIdentity != null) {
+ this.deployer.undeploy(this.globalBundleDeploymentIdentity);
+ this.globalBundleDeploymentIdentity = null;
+ }
+ }
+
+ @Test
+ public void testUnscopedNonatomicParentOfUnscopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.nonatomic.parentOf.unscoped.nonatomic.child");
+ }
+
+ @Test
+ public void testUnscopedAtomicParentOfUnscopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.atomic.parentOf.unscoped.nonatomic.child");
+ }
+
+ @Test
+ public void testScopedNonatomicParentOfUnscopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.nonatomic.parentOf.unscoped.nonatomic.child");
+ }
+
+ @Test
+ public void testScopedAtomicParentOfUnscopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.atomic.parentOf.unscoped.nonatomic.child");
+ }
+
+ @Test
+ public void testUnscopedNonatomicParentOfUnscopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.nonatomic.parentOf.unscoped.atomic.child");
+ }
+
+ @Test
+ public void testUnscopedAtomicParentOfUnscopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.atomic.parentOf.unscoped.atomic.child");
+ }
+
+ @Test
+ public void testScopedNonatomicParentOfUnscopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.nonatomic.parentOf.unscoped.atomic.child");
+ }
+
+ @Test
+ public void testScopedAtomicParentOfUnscopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.atomic.parentOf.unscoped.atomic.child");
+ }
+
+ @Test
+ public void testUnscopedNonatomicParentOfScopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.nonatomic.parentOf.scoped.nonatomic.child");
+ }
+
+ @Test
+ public void testUnscopedAtomicParentOfScopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.atomic.parentOf.scoped.nonatomic.child");
+ }
+
+ @Test
+ public void testScopedNonatomicParentOfScopedNonatomiChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.nonatomic.parentOf.scoped.nonatomic.child");
+ }
+
+ @Test
+ public void testScopedAtomicParentOfScopedNonatomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.atomic.parentOf.scoped.nonatomic.child");
+ }
+
+ @Test
+ public void testUnscopedNonatomicParentOfScopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.nonatomic.parentOf.scoped.atomic.child");
+ }
+
+ @Test
+ public void testUnscopedAtomicParentOfScopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("unscoped.atomic.parentOf.scoped.atomic.child");
+ }
+
+ @Test
+ public void testScopedNonatomicParentOfScopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.nonatomic.parentOf.scoped.atomic.child");
+ }
+
+ @Test
+ public void testScopedAtomicParentOfScopedAtomicChild() throws IOException, DeploymentException, InterruptedException {
+ testParent("scoped.atomic.parentOf.scoped.atomic.child");
+ }
+
+ /**
+ * @throws IOException
+ * @throws DeploymentException
+ * @throws InterruptedException
+ */
+ private void testParent(String parentName) throws IOException, DeploymentException, InterruptedException {
+ for (int p = 0; p < PARENTS.length; p++) {
+ TestPlanArtifactInfo parent = PARENTS[p];
+ if (parentName.equals(parent.getName())) {
+ testParent(parent);
+ }
+ }
+ }
+
+ private void testParent(TestPlanArtifactInfo parent) {
+ Model model = new Model(parent);
+
+ boolean expectDeployOk = model.shouldDeployOk();
+
+ try {
+ DeploymentIdentity parentId = deploy(parent);
+
+ // Fail the test if the plan should not have deployed ok.
+ assertTrue(expectDeployOk);
+
+ checkScoping(parent, model);
+
+ checkAtomicity(parent, model);
+
+ this.deployer.undeploy(parentId);
+ } catch (DeploymentException e) {
+ // Fail the test if the plan should have deployed ok.
+ assertFalse(expectDeployOk);
+ }
+ }
+
+ private static void generatePlans() throws IOException, InterruptedException {
+ // Generate the child plans
+ TestPlanArtifactInfo[] children = generateChildPlans();
+
+ // Wait for watched directory interval to pass.
+ Thread.sleep(WATCH_WAIT_INTERVAL_MS);
+
+ PARENTS = generateParentPlans(children);
+ }
+
+ private void checkScoping(TestPlanArtifactInfo parent, Model model) {
+
+ if (model.shouldHaveScope()) {
+ checkSyntheticContextBundle(model);
+ checkImportPromotion(model);
+ checkPlanScoping(parent, model);
+ } else {
+ checkNoSyntheticContextBundle();
+ checkNoImportPromotion(model);
+ }
+ }
+
+ private void checkPlanScoping(TestPlanArtifactInfo parent, Model model) {
+ if (parent.isScoped()) {
+ Artifact parentPlan = getPlan(parent);
+ for (Artifact child : parentPlan.getDependents()) {
+ if (PLAN_TYPE.equals(child.getType())) {
+ String childPlanName = child.getName();
+ String unscopedChildPlanName = parent.getChildPlan().getName();
+ String expectedChildPlanName = model.getScopeName() + SCOPE_SEPARATOR + unscopedChildPlanName;
+ assertEquals(expectedChildPlanName, childPlanName);
+ }
+ }
+ }
+
+ }
+
+ private void checkSyntheticContextBundle(Model model) {
+ Bundle syntheticContextBundle = getSyntheticContextBundle(model.getScopeName());
+ assertNotNull(syntheticContextBundle);
+
+ if (model.syntheticContextShouldIncludeParent()) {
+ assertTrue(contains(getBundlesImportingPackage(PARENT_PACKAGE_NAME), syntheticContextBundle));
+ }
+
+ if (model.syntheticContextShouldIncludeChild()) {
+ assertTrue(contains(getBundlesImportingPackage(CHILD_PACKAGE_NAME), syntheticContextBundle));
+ }
+ }
+
+ private static boolean contains(Bundle[] importingBundles, Bundle syntheticContextBundle) {
+ if (importingBundles != null) {
+ for (Bundle bundle : importingBundles) {
+ if (bundle == syntheticContextBundle) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private Bundle[] getBundlesImportingPackage(String pkg) {
+ ExportedPackage[] exportedPackages = this.packageAdmin.getExportedPackages(pkg);
+
+ // The tests should not export a package from multiple bundles at any point in time.
+ assertEquals(1, exportedPackages.length);
+
+ ExportedPackage parentExportedPackage = exportedPackages[0];
+ Bundle[] importingBundles = parentExportedPackage.getImportingBundles();
+ return importingBundles;
+ }
+
+ private void checkNoSyntheticContextBundle() {
+ Bundle[] bundles = this.framework.getBundleContext().getBundles();
+ for (Bundle bundle : bundles) {
+ assertFalse(bundle.getSymbolicName().endsWith(SYNTHETIC_CONTEXT_BSN_SUFFIX));
+ }
+ }
+
+ private Bundle getSyntheticContextBundle(String scopeName) {
+ String bsn = scopeName + SYNTHETIC_CONTEXT_BSN_SUFFIX;
+ Bundle[] bundles = this.packageAdmin.getBundles(bsn, null);
+ assertTrue(bundles.length <= 1);
+ return bundles.length == 0 ? null : bundles[0];
+ }
+
+ private void checkImportPromotion(Model model) {
+ if (model.importShouldBePromoted()) {
+ assertTrue(globalImportHasBeenPromoted(model));
+ }
+ }
+
+ private void checkNoImportPromotion(Model model) {
+ assertFalse(globalImportHasBeenPromoted(model));
+ }
+
+ private boolean globalImportHasBeenPromoted(Model model) {
+ // The global import has been promoted if and only if the child bundle imports it.
+ Bundle childBundle = model.getChildBundle();
+ Bundle[] bundlesImportingGlobalPackage = getBundlesImportingPackage(GLOBAL_PACKAGE);
+ return contains(bundlesImportingGlobalPackage, childBundle);
+ }
+
+ private void checkAtomicity(TestPlanArtifactInfo parent, Model model) {
+ TestPlanArtifactInfo childPlan = parent.getChildPlan();
+
+ Artifact parentArtifact = getPlan(parent);
+ Artifact childArtifact;
+
+ if (parent.isScoped()) {
+ childArtifact = getPlan(childPlan.getType(), model.getScopeName() + SCOPE_SEPARATOR + childPlan.getName(), childPlan.getVersion());
+ } else {
+ childArtifact = getPlan(childPlan);
+ }
+
+ if (parent.isAtomic() && childPlan.isAtomic()) {
+ checkParentAndChildBundleLifecyclesAreTied(model.getParentBundle(), model.getChildBundle(), parentArtifact, childArtifact);
+ } else {
+ checkParentAndChildBundleLifecyclesAreIndependent(parent.isAtomic(), model.getParentBundle(), model.getChildBundle(), parentArtifact, childArtifact);
+ }
+
+ if (parent.isAtomic()) {
+ checkParentAndChildPlanLifecyclesAreTied(parentArtifact, childArtifact);
+ } else {
+ checkParentAndChildPlanLifecyclesAreIndependent(parentArtifact, childArtifact);
+ }
+ }
+
+ private Artifact getPlan(TestPlanArtifactInfo plan) {
+ return getPlan(plan.getType(), plan.getName(), plan.getVersion());
+ }
+
+ private Artifact getPlan(String type, String name, Version version) {
+ Artifact planArtifact = this.ram.getArtifact(type, name, version);
+ assertNotNull(planArtifact);
+ return planArtifact;
+ }
+
+ private void checkParentAndChildPlanLifecyclesAreTied(Artifact parentPlan, Artifact childPlan) {
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+
+ parentPlan.stop();
+ assertEquals(ArtifactState.RESOLVED, parentPlan.getState());
+ assertEquals(ArtifactState.RESOLVED, childPlan.getState());
+
+ parentPlan.start();
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+
+ childPlan.stop();
+ assertEquals(ArtifactState.RESOLVED, parentPlan.getState());
+ assertEquals(ArtifactState.RESOLVED, childPlan.getState());
+
+ childPlan.start();
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ }
+
+ private void checkParentAndChildPlanLifecyclesAreIndependent(Artifact parentPlan, Artifact childPlan) {
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+
+ parentPlan.stop();
+ assertEquals(ArtifactState.RESOLVED, parentPlan.getState());
+ // Stopping the parent plan stops the child plan regardless of the parent's atomicity.
+ assertEquals(ArtifactState.RESOLVED, childPlan.getState());
+
+ parentPlan.start();
+ waitUntilActive(parentPlan);
+ // Starting the parent plan stops the child plan regardless of the parent's atomicity.
+ waitUntilActive(childPlan);
+
+ childPlan.stop();
+ assertEquals(ArtifactState.ACTIVE, parentPlan.getState());
+ assertEquals(ArtifactState.RESOLVED, childPlan.getState());
+
+ childPlan.start();
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ }
+
+ private void waitUntilActive(Artifact parentPlan) {
+ int i = 0;
+ while (parentPlan.getState() != ArtifactState.ACTIVE) {
+ if (i++ > 10) {
+ // Took too long - give up.
+ assertTrue(false);
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ private void checkParentAndChildBundleLifecyclesAreTied(Bundle parentBundle, Bundle childBundle, Artifact parentPlan, Artifact childPlan) {
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ try {
+ parentBundle.stop();
+ assertEquals(Bundle.RESOLVED, parentBundle.getState());
+ assertEquals(Bundle.RESOLVED, childBundle.getState());
+
+ parentBundle.start();
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+
+ childBundle.stop();
+ assertEquals(Bundle.RESOLVED, parentBundle.getState());
+ assertEquals(Bundle.RESOLVED, childBundle.getState());
+
+ childBundle.start();
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ } catch (BundleException e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ private void checkParentAndChildBundleLifecyclesAreIndependent(boolean atomicParentPlan, Bundle parentBundle, Bundle childBundle,
+ Artifact parentPlan, Artifact childPlan) {
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ try {
+ parentBundle.stop();
+ assertEquals(Bundle.RESOLVED, parentBundle.getState());
+ // Stopping the parent bundle stops parent plan if the parent is atomic which stops the child plan, and its
+ // bundles.
+ assertEquals(atomicParentPlan ? Bundle.RESOLVED : Bundle.ACTIVE, childBundle.getState());
+
+ parentBundle.start();
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+
+ childBundle.stop();
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.RESOLVED, childBundle.getState());
+
+ childBundle.start();
+ assertEquals(Bundle.ACTIVE, parentBundle.getState());
+ assertEquals(Bundle.ACTIVE, childBundle.getState());
+ waitUntilActive(parentPlan);
+ waitUntilActive(childPlan);
+ } catch (BundleException e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ private Bundle getSpecificBundle(String bsn, Version version) {
+ Bundle[] bundles = packageAdmin.getBundles(bsn, "[" + version.toString() + ", " + version.toString() + "]");
+ assertNotNull(bundles);
+ assertEquals(1, bundles.length);
+ return bundles[0];
+ }
+
+ /**
+ * The Model class encapsulates the expected behaviour of this testcase.
+ */
+ private final class Model {
+
+ private final TestPlanArtifactInfo parent;
+
+ private final TestPlanArtifactInfo child;
+
+ public Model(TestPlanArtifactInfo parent) {
+ this.parent = parent;
+
+ TestPlanArtifactInfo[] childPlans = parent.getChildPlans();
+ assertEquals(1, childPlans.length);
+ this.child = childPlans[0];
+ }
+
+ public boolean importShouldBePromoted() {
+ return this.parent.isScoped();
+ }
+
+ public boolean shouldDeployOk() {
+ // A parent and child should deploy ok if and only if they are not both scoped.
+ return !(this.parent.isScoped() && this.child.isScoped());
+ }
+
+ public boolean shouldHaveScope() {
+ return shouldChildBeScoped();
+ }
+
+ public String getScopeName() {
+ assertTrue(shouldHaveScope());
+ return getScopeName(this.parent.isScoped() ? this.parent : this.child);
+ }
+
+ private String getScopeName(TestPlanArtifactInfo scopedPlan) {
+ assertTrue(scopedPlan.isScoped());
+ StringBuffer scopeName = new StringBuffer();
+ scopeName.append(scopedPlan.getName() + SCOPE_SEPARATOR + versionToShortString(scopedPlan.getVersion()));
+ return scopeName.toString();
+ }
+
+ private String versionToShortString(Version version) {
+ String result = version.toString();
+ while (result.endsWith(".0")) {
+ result = result.substring(0, result.length() - 2);
+ }
+ return result;
+ }
+
+ public boolean syntheticContextShouldIncludeParent() {
+ return this.parent.isScoped();
+ }
+
+ public boolean syntheticContextShouldIncludeChild() {
+ return shouldChildBeScoped();
+ }
+
+ private boolean shouldChildBeScoped() {
+ return this.parent.isScoped() || this.child.isScoped();
+ }
+
+ public Bundle getParentBundle() {
+ return getBundle(this.parent, this.parent.isScoped() ? getScopeName() : null);
+ }
+
+ public Bundle getChildBundle() {
+ return getBundle(this.child, shouldChildBeScoped() ? getScopeName() : null);
+ }
+
+ private Bundle getBundle(TestPlanArtifactInfo planContainingBundle, String scopeName) {
+ TestArtifactInfo[] childBundles = planContainingBundle.getChildBundles();
+ assertEquals(1, childBundles.length);
+ TestArtifactInfo childBundle = childBundles[0];
+
+ String bsn = childBundle.getName();
+ Version version = childBundle.getVersion();
+
+ if (scopeName != null) {
+ return getSpecificBundle(scopeName + SCOPE_SEPARATOR + bsn, version);
+ } else {
+ return getSpecificBundle(bsn, version);
+ }
+ }
+
+ }
+
+ private static TestPlanArtifactInfo[] generateParentPlans(TestArtifactInfo[] children) throws IOException {
+ TestPlanArtifactInfo[] parents = new TestPlanArtifactInfo[16];
+ int p = 0;
+ for (int c = 0; c < children.length; c++) {
+ for (int s = 0; s < 2; s++) {
+ boolean scopedParent = s == 1;
+ for (int a = 0; a < 2; a++) {
+ boolean atomicParent = a == 1;
+ TestArtifactInfo childPlan = children[c];
+ String parentName = parentPlanName(scopedParent, atomicParent, childPlan);
+ parents[p++] = createPlanFile(parentName, DEFAULT_VERSION, scopedParent, atomicParent, PARENT_BUNDLE_INFO, childPlan);
+ }
+ }
+ }
+ return parents;
+ }
+
+ private static TestPlanArtifactInfo[] generateChildPlans() throws IOException {
+ TestPlanArtifactInfo[] children = new TestPlanArtifactInfo[4];
+ int c = 0;
+ for (int s = 0; s < 2; s++) {
+ boolean scopedChild = s == 1;
+ for (int a = 0; a < 2; a++) {
+ boolean atomicChild = a == 1;
+ String childName = childPlanName(scopedChild, atomicChild);
+ children[c++] = createPlanFile(childName, DEFAULT_VERSION, scopedChild, atomicChild, CHILD_BUNDLE_INFO);
+ }
+ }
+ return children;
+ }
+
+ private static String childPlanName(boolean scopedChild, boolean atomicChild) {
+ return scopingAtomicityName(scopedChild, atomicChild) + ".child";
+ }
+
+ private static String parentPlanName(boolean scopedParent, boolean atomicParent, TestArtifactInfo childPlan) {
+ return scopingAtomicityName(scopedParent, atomicParent) + ".parentOf." + childPlan.getName();
+ }
+
+ private static String scopingAtomicityName(boolean scoped, boolean atomic) {
+ return (scoped ? "scoped" : "unscoped") + "." + (atomic ? "atomic" : "nonatomic");
+ }
+
+ private DeploymentIdentity deploy(TestArtifactInfo i) throws DeploymentException {
+ DeploymentIdentity identity = this.deployer.deploy(i.getFile().toURI());
+ Assert.assertEquals(i.getType(), identity.getType());
+ Assert.assertEquals(i.getName(), identity.getSymbolicName());
+ Assert.assertEquals(i.getVersion(), new Version(identity.getVersion()));
+ return identity;
+ }
+
+ public static TestPlanArtifactInfo createPlanFile(String planName, Version planVersion, boolean scoped, boolean atomic,
+ TestArtifactInfo... children) throws IOException {
+ StringBuffer planContent = new StringBuffer(1024);
+ planContent.append(XML_HEADER);
+ planContent.append("<plan name=\"" + planName + "\" version=\"" + planVersion + "\" scoped=\"" + new Boolean(scoped) + "\" atomic=\""
+ + new Boolean(atomic) + "\" \n" + NAMESPACES + ">\n");
+
+ for (TestArtifactInfo childInfo : children) {
+ Version childVersion = childInfo.getVersion();
+ planContent.append(" <artifact type=\"" + childInfo.getType() + "\" name=\"" + childInfo.getName() + "\" version=\"[" + childVersion
+ + ", " + childVersion + "]\"/>\n");
+ }
+
+ planContent.append("</plan>");
+
+ TestPlanArtifactInfo info = new TestPlanArtifactInfo(planName, planVersion, scoped, atomic, children);
+
+ String fileName = planName + "-" + planVersion + PLAN_EXTENSION;
+ File planFile = new File(GENERATED_PLAN_DIRECTORY + fileName);
+ Writer writer = new FileWriter(planFile);
+ try {
+ writer.write(planContent.toString());
+ } finally {
+ writer.close();
+ }
+
+ info.setFile(planFile);
+
+ return info;
+ }
+
+ private static final class TestPlanArtifactInfo extends TestArtifactInfo {
+
+ private static final TestPlanArtifactInfo[] EMPTY_CHILD_PLAN_ARRAY = new TestPlanArtifactInfo[0];
+
+ private final boolean scoped;
+
+ private final boolean atomic;
+
+ public TestPlanArtifactInfo(String name, Version version, Boolean scoped, Boolean atomic, TestArtifactInfo[] children) {
+ super(PLAN_TYPE, name, version, children);
+ this.scoped = scoped;
+ this.atomic = atomic;
+ }
+
+ public TestPlanArtifactInfo[] getChildPlans() {
+ List<TestPlanArtifactInfo> childPlans = new ArrayList<TestPlanArtifactInfo>();
+ for (TestArtifactInfo child : getChildren()) {
+ if (child instanceof TestPlanArtifactInfo) {
+ childPlans.add((TestPlanArtifactInfo) child);
+ }
+ }
+ return childPlans.toArray(EMPTY_CHILD_PLAN_ARRAY);
+ }
+
+ public TestPlanArtifactInfo getChildPlan() {
+ TestPlanArtifactInfo[] childPlans = getChildPlans();
+ assertEquals(1, childPlans.length);
+ return childPlans[0];
+ }
+
+ public boolean isScoped() {
+ return scoped;
+ }
+
+ public boolean isAtomic() {
+ return atomic;
+ }
+
+ }
+
+ private static class TestArtifactInfo {
+
+ private static final TestArtifactInfo[] EMPTY_CHILD_ARRAY = new TestArtifactInfo[0];
+
+ private final String type;
+
+ private final String name;
+
+ private final Version version;
+
+ private File file;
+
+ private TestArtifactInfo[] children;
+
+ public TestArtifactInfo(String type, String name, Version version, TestArtifactInfo[] children) {
+ this.type = type;
+ this.name = name;
+ this.version = version;
+ this.children = children == null ? EMPTY_CHILD_ARRAY : children;
+ }
+
+ public TestArtifactInfo(String type, String name, Version version) {
+ this(type, name, version, null);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+
+ public TestArtifactInfo[] getChildren() {
+ return this.children;
+ }
+
+ public TestArtifactInfo[] getChildBundles() {
+ List<TestArtifactInfo> childBundles = new ArrayList<TestArtifactInfo>();
+ for (TestArtifactInfo child : getChildren()) {
+ if (BUNDLE_TYPE.equals(child.getType())) {
+ childBundles.add(child);
+ }
+ }
+ return childBundles.toArray(EMPTY_CHILD_ARRAY);
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ public File getFile() {
+ if (this.file == null) {
+ throw new IllegalStateException("TestArtifactInfo file not set");
+ }
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return /* "TestArtifactInfo [type=" + type + ", name=" + */name /* + ", version=" + version + "]" */;
+ }
+
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java
new file mode 100644
index 00000000..e74f5d4a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/OnStartedFailureTests.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+import org.osgi.framework.ServiceRegistration;
+
+import org.eclipse.virgo.kernel.install.artifact.BundleInstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+
+
+/**
+ *
+ * Integration tests for handling failures from the onStarted lifecycle event.
+ *
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread-safe.
+ *
+ */
+public class OnStartedFailureTests extends AbstractRAMIntegrationTests {
+
+ private final OnStartedFailureLifecycleListener lifecycleListener = new OnStartedFailureLifecycleListener();
+
+ private volatile ServiceRegistration registration;
+
+ private void registerListener() {
+ this.registration = this.context.registerService(InstallArtifactLifecycleListener.class.getName(), this.lifecycleListener, null);
+ }
+
+ private void unregisterListener() {
+ ServiceRegistration localRegistration = this.registration;
+ if (localRegistration != null) {
+ localRegistration.unregister();
+ }
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void standaloneBundleFailsDuringDeployment() throws DeploymentException {
+ registerListener();
+
+ try {
+ this.deployer.deploy(new File("src/test/resources/onstarted-failure-tests/bundle.jar").toURI());
+ } finally {
+ unregisterListener();
+ }
+ }
+
+ @Test
+ public void standaloneBundleFailsWhenStartedUsingTheRAM() throws DeploymentException {
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/onstarted-failure-tests/bundle.jar").toURI());
+
+ registerListener();
+
+ try {
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ manageableArtifact.stop();
+
+ try {
+ manageableArtifact.start();
+ fail("Start of artifact did not throw an exception");
+ } catch (RuntimeException re) {
+ re.printStackTrace();
+ }
+ } finally {
+ unregisterListener();
+ }
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void bundleWithinParFailsDuringDeployment() throws DeploymentException {
+ registerListener();
+
+ try {
+ this.deployer.deploy(new File("src/test/resources/onstarted-failure-tests/started-failure.par").toURI());
+ } finally {
+ unregisterListener();
+ }
+ }
+
+ private static final class OnStartedFailureLifecycleListener extends InstallArtifactLifecycleListenerSupport {
+
+ @Override
+ public void onStarted(InstallArtifact installArtifact) throws DeploymentException {
+ if (installArtifact instanceof BundleInstallArtifact) {
+ throw new DeploymentException("onStarted failure");
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java
new file mode 100644
index 00000000..cc4b50e7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParDeploymentTests.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
+import org.osgi.service.cm.Configuration;
+
+
+/**
+ */
+public class ParDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private static final File PAR_FILE = new File("src/test/resources/BundlesAndConfig.par");
+
+ private static final String BUNDLE_SYMBOLIC_NAME = "appA-1-bundleA";
+ private static final Version BUNDLE_VERSION = new Version(1,0,0);
+
+ @Test
+ public void deployParContainingBundlesAndProperties() throws DeploymentException, IOException, InvalidSyntaxException {
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(PAR_FILE.toURI());
+
+ Configuration configuration = getConfiguration("foo");
+ assertNotNull(configuration);
+ assertEquals("bar", configuration.getProperties().get("foo"));
+
+ assertBundlePresent(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
+
+ this.deployer.undeploy(deploymentIdentity);
+
+ configuration = getConfiguration("foo");
+ assertNull(configuration);
+
+ assertBundleNotPresent(BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION);
+ }
+
+ private void assertBundlePresent(String symbolicName, Version version) {
+ Bundle[] bundles = this.context.getBundles();
+
+ for (Bundle bundle : bundles) {
+ if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
+ return;
+ }
+ }
+
+ fail("The bundle " + symbolicName + " " + version + " was not found.");
+ }
+
+ private void assertBundleNotPresent(String symbolicName, Version version) {
+ Bundle[] bundles = this.context.getBundles();
+
+ for (Bundle bundle : bundles) {
+ if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
+ fail("Bundle " + bundle + " should not be present");
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParRefreshTests.java
new file mode 100644
index 00000000..3b392247
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ParRefreshTests.java
@@ -0,0 +1,363 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListenerSupport;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.math.Sets;
+
+/**
+ * Test refresh of artifacts in a Par
+ *
+ */
+public class ParRefreshTests extends AbstractDeployerIntegrationTest {
+
+ private static final File PAR_FILE = new File("src/test/resources/ParRefreshPar.par");
+ private static final String PAR_SYMBOLIC_NAME = "RefreshPar";
+ private static final Version PAR_VERSION = new Version(1,0,0);
+
+ private static final String BUNDLE_A_SYMBOLIC_NAME = PAR_SYMBOLIC_NAME + "-1-bundleA";
+ private static final String BUNDLE_B_SYMBOLIC_NAME = PAR_SYMBOLIC_NAME + "-1-bundleB";
+ private static final Version BUNDLE_VERSION = new Version(1,0,0);
+
+ private static final String SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME = PAR_SYMBOLIC_NAME + "-1-synthetic.context";
+
+ private ArtifactListener artifactListener = new ArtifactListener();
+
+ @Before
+ public void parRefreshSetup() throws Exception {
+ this.context.registerService(InstallArtifactLifecycleListener.class.getName(), artifactListener, null);
+ }
+
+ @Test
+ public void testRefreshOfBundleInPar() throws DeploymentException {
+
+ DeploymentIdentity parIdentity = this.deployer.deploy(PAR_FILE.toURI());
+
+ assertBundlePresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+
+ this.artifactListener.clear();
+
+ Set<ArtifactLifecycleEvent> expectedEventSet = new HashSet<ArtifactLifecycleEvent>();
+ //events expected due to explicit refresh;
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPING, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPED, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.UNRESOLVED, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.RESOLVED, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTING, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTED, "bundle", BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION));
+
+ //events caused by PackageAdmin propagation
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPING, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPED, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.UNRESOLVED, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.RESOLVED, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTING, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTED, "bundle", SYNTHETIC_CONTEXT_BUNDLE_SYMBOLIC_NAME, BUNDLE_VERSION));
+ // bundleB depends on (imports) bundleA
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPING, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.UNRESOLVED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.RESOLVED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTING, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+
+ // Refresh the bundle, get back 'new' par identity
+ DeploymentIdentity newIdentity = this.deployer.refresh(PAR_FILE.toURI(), BUNDLE_A_SYMBOLIC_NAME);
+
+ waitForAndCheckEventsReceived(expectedEventSet, 10000L); // ten seconds backstop
+
+ Set<ArtifactLifecycleEvent> actualEventSet = new HashSet<ArtifactLifecycleEvent>(artifactListener.extract());
+
+ Set<ArtifactLifecycleEvent> extraEvents = Sets.difference(actualEventSet, expectedEventSet);
+ Set<ArtifactLifecycleEvent> missingEvents = Sets.difference(expectedEventSet, actualEventSet);
+
+ assertTrue("Extra events were received: " + extraEvents, extraEvents.isEmpty());
+ assertTrue("Events were missing: " + missingEvents, missingEvents.isEmpty());
+
+ assertBundlePresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+
+ assertDeploymentIdentityEquals(newIdentity, PAR_SYMBOLIC_NAME, "par", PAR_SYMBOLIC_NAME, PAR_VERSION.toString());
+
+ this.deployer.undeploy(parIdentity);
+
+ assertBundleNotPresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+ }
+
+ @Test
+ public void testRefreshOfDependentBundleInPar() throws DeploymentException {
+
+ DeploymentIdentity parIdentity = this.deployer.deploy(PAR_FILE.toURI());
+
+ assertBundlePresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+ assertBundlePresent(BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION);
+
+ this.artifactListener.clear();
+
+ Set<ArtifactLifecycleEvent> expectedEventSet = new HashSet<ArtifactLifecycleEvent>();
+ //events expected due to explicit refresh;
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPING, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STOPPED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.UNRESOLVED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.RESOLVED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTING, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+ expectedEventSet.add(new ArtifactLifecycleEvent(TestLifecycleEvent.STARTED, "bundle", BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION));
+
+ // Refresh the configuration, get back 'new' par identity
+ DeploymentIdentity newIdentity = this.deployer.refresh(PAR_FILE.toURI(), BUNDLE_B_SYMBOLIC_NAME);
+
+ waitForAndCheckEventsReceived(expectedEventSet, 10000L); // ten seconds backstop
+
+ assertBundlePresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+ assertBundlePresent(BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION);
+
+ assertDeploymentIdentityEquals(newIdentity, PAR_SYMBOLIC_NAME, "par", PAR_SYMBOLIC_NAME, PAR_VERSION.toString());
+
+ this.deployer.undeploy(parIdentity);
+
+ assertBundleNotPresent(BUNDLE_A_SYMBOLIC_NAME, BUNDLE_VERSION);
+ assertBundleNotPresent(BUNDLE_B_SYMBOLIC_NAME, BUNDLE_VERSION);
+ }
+
+ private void waitForAndCheckEventsReceived(Set<ArtifactLifecycleEvent> expectedEventSet, long timeout) {
+ artifactListener.waitForEvents(expectedEventSet, timeout);
+
+ Set<ArtifactLifecycleEvent> actualEventSet = new HashSet<ArtifactLifecycleEvent>(this.artifactListener.extract());
+
+ Set<ArtifactLifecycleEvent> extraEvents = Sets.difference(actualEventSet, expectedEventSet);
+ Set<ArtifactLifecycleEvent> missingEvents = Sets.difference(expectedEventSet, actualEventSet);
+
+ assertTrue("Extra events were received: " + extraEvents, extraEvents.isEmpty());
+ assertTrue("Events were missing: " + missingEvents, missingEvents.isEmpty());
+ }
+
+ private void assertBundlePresent(String symbolicName, Version version) {
+ Bundle[] bundles = this.context.getBundles();
+
+ for (Bundle bundle : bundles) {
+ if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
+ return;
+ }
+ }
+
+ fail("The bundle " + symbolicName + " " + version + " was not found.");
+ }
+
+ private void assertBundleNotPresent(String symbolicName, Version version) {
+ Bundle[] bundles = this.context.getBundles();
+
+ for (Bundle bundle : bundles) {
+ if (symbolicName.equals(bundle.getSymbolicName()) && version.equals(bundle.getVersion())) {
+ fail("Bundle " + bundle + " should not be present");
+ }
+ }
+ }
+
+ private static enum TestLifecycleEvent {
+ INSTALLED, INSTALLING, RESOLVED, RESOLVING, STARTED, STARTING, STOPPED, STOPPING, UNINSTALLED, UNINSTALLING, UNRESOLVED
+ }
+
+ private static class ArtifactLifecycleEvent {
+ public ArtifactLifecycleEvent(TestLifecycleEvent lifecycleEvent, String type, String name, Version version) {
+ this.lifeCycleEvent = lifecycleEvent;
+ this.type = type;
+ this.name = name;
+ this.version = version;
+ }
+ public boolean equals(Object obj) {
+ if (obj instanceof ArtifactLifecycleEvent) {
+ ArtifactLifecycleEvent other = (ArtifactLifecycleEvent) obj;
+ return (this.lifeCycleEvent.equals(other.lifeCycleEvent)
+ && this.type.equals(other.type)
+ && this.name.equals(other.name)
+ && this.version.equals(other.version));
+ }
+ return false;
+ }
+ public int hashCode() {
+ final int prime = 17;
+ int result = this.lifeCycleEvent.hashCode() + prime
+ * (this.name.hashCode() + prime * (this.type.hashCode() + prime * (this.version.hashCode())));
+ return result;
+ }
+ public String toString() {
+ StringBuilder sb = new StringBuilder("[");
+ sb.append(this.lifeCycleEvent).append(", ");
+ sb.append(this.type).append(", ");
+ sb.append(this.name).append(", ");
+ sb.append(this.version).append("]");
+ return sb.toString();
+ }
+
+ private final TestLifecycleEvent lifeCycleEvent;
+ private final String type;
+ private final String name;
+ private final Version version;
+ }
+
+ private static class ArtifactListener extends InstallArtifactLifecycleListenerSupport {
+
+ private final Object monitor = new Object();
+
+ List<ArtifactLifecycleEvent> eventList = new ArrayList<ArtifactLifecycleEvent>();
+
+ public void clear() {
+ synchronized (this.monitor) {
+ this.eventList.clear();
+ }
+ }
+
+ public boolean waitForEvents(final Set<ArtifactLifecycleEvent> expectedEventSet, long timeout) {
+ boolean allReceived = eventsReceived(expectedEventSet);
+ while (!allReceived && timeout>0) {
+ timeout -= 50L;
+ try {
+ Thread.sleep(50L);
+ } catch (InterruptedException _) {
+ // do nothing
+ }
+ allReceived = eventsReceived(expectedEventSet);
+ }
+ return allReceived;
+ }
+
+ private boolean eventsReceived(Set<ArtifactLifecycleEvent> eventSet) {
+ synchronized (this.monitor) {
+ for (ArtifactLifecycleEvent event : eventSet) {
+ if (!this.eventList.contains(event)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ public List<ArtifactLifecycleEvent> extract() {
+ synchronized (this.monitor) {
+ return new ArrayList<ArtifactLifecycleEvent>(this.eventList);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onInstalled(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.INSTALLED, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onInstalling(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.INSTALLING, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResolved(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.RESOLVED, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResolving(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.RESOLVING, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStarted(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.STARTED, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStarting(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.STARTING, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStopped(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.STOPPED, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onStopping(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.STOPPING, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUninstalled(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.UNINSTALLED, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUninstalling(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.UNINSTALLING, installArtifact);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onUnresolved(InstallArtifact installArtifact) {
+ addEvent(TestLifecycleEvent.UNRESOLVED, installArtifact);
+ }
+
+ private void addEvent(TestLifecycleEvent event, InstallArtifact installArtifact) {
+ synchronized (this.monitor) {
+ this.eventList.add(new ArtifactLifecycleEvent(event, installArtifact.getType(), installArtifact.getName(),
+ installArtifact.getVersion()));
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java
new file mode 100644
index 00000000..7a7acf1f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceRegistration;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer.DeploymentOptions;
+import org.eclipse.virgo.util.io.FileCopyUtils;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test the generic deployer using a test deployer. This doesn't check OSGi behaviour but will detect clashes in the
+ * file system during deployment.
+ *
+ */
+public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceRegistration dummyModuleDeployerServiceRegistration;
+
+ private final PathReference pickup = new PathReference("./target/pickup");
+
+ private final PathReference target = new PathReference("./target");
+
+ private StubInstallArtifactLifecycleListener lifecycleListener;
+
+ private ServiceRegistration lifecycleListenerRegistration;
+
+ private DeploymentIdentity deploymentIdentity;
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/deployer");
+ pr.delete(true);
+ pr.createDirectory();
+
+ clearPickup();
+
+ this.lifecycleListener = new StubInstallArtifactLifecycleListener();
+ this.lifecycleListenerRegistration = this.kernelContext.registerService(InstallArtifactLifecycleListener.class.getName(),
+ this.lifecycleListener, null);
+ }
+
+ private void clearPickup() {
+ File[] contents = this.pickup.toFile().listFiles();
+ for (File file : contents) {
+ file.delete();
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ undeploy();
+ clearPickup();
+ if (this.dummyModuleDeployerServiceRegistration != null) {
+ this.dummyModuleDeployerServiceRegistration.unregister();
+ }
+ if (this.lifecycleListenerRegistration != null) {
+ this.lifecycleListenerRegistration.unregister();
+ }
+ }
+
+ private void undeploy() throws DeploymentException {
+ if (this.deploymentIdentity != null) {
+ this.deployer.undeploy(this.deploymentIdentity);
+ this.deploymentIdentity = null;
+ }
+ }
+
+ @Test
+ public void testDeployer() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ this.deployer.undeploy(this.deploymentIdentity);
+ this.deploymentIdentity = null;
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ }
+
+ @Test
+ public void testDeployerCleanup() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+
+ File workDir = new File("target/work/org.eclipse.virgo.kernel/Module/dummy.jar-0");
+ assertFalse(workDir.exists());
+ }
+
+ @Test
+ public void testAwaitRecovery() throws Exception {
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = ObjectName.getInstance("org.eclipse.virgo.kernel:category=Control,type=RecoveryMonitor");
+ assertTrue(server.isRegistered(objectName));
+ assertTrue((Boolean) server.getAttribute(objectName, "RecoveryComplete"));
+ }
+
+ @Test
+ public void testRepeatDeployment() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 1, 1);
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
+ }
+
+ @Test
+ public void testDuplicateDeployment() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 1, 1);
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
+ }
+
+ @Test
+ public void testHotDeploy() throws Exception {
+ PathReference dummy = new PathReference("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ PathReference deployed = dummy.copy(this.pickup);
+ Thread.sleep(10000);
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ deployed.delete();
+ Thread.sleep(6000);
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ }
+
+ @Test
+ public void testDeployerOwned() throws Exception {
+ File dummyCopy = new File(this.target.toFile(), "dummy.jar");
+ if (dummyCopy.exists()) {
+ dummyCopy.delete();
+ }
+
+ PathReference dummy = new PathReference("src/test/resources/dummy.jar");
+ PathReference copy = dummy.copy(this.target);
+ assertTrue(copy.exists());
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(copy.toURI(), new DeploymentOptions(false, true, true));
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ assertFalse(copy.exists());
+
+ copy = dummy.copy(this.target);
+ this.deploymentIdentity = this.deployer.deploy(copy.toURI(), new DeploymentOptions(false, true, true));
+ copy.delete();
+ undeploy();
+ }
+
+ @Test
+ public void testRedeployDeployerOwned() throws Exception {
+ File dummyCopy = new File(this.target.toFile(), "dummy.jar");
+ if (dummyCopy.exists()) {
+ dummyCopy.delete();
+ }
+
+ PathReference dummy = new PathReference("src/test/resources/dummy.jar");
+ PathReference copy = dummy.copy(this.target);
+ assertTrue(copy.exists());
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(copy.toURI(), new DeploymentOptions(false, true, true));
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+
+ File dummyModifiedFile = (new PathReference("src/test/resources/dummymodified.jar")).toFile().getAbsoluteFile();
+ FileCopyUtils.copy(dummyModifiedFile, copy.toFile().getAbsoluteFile()); //force direct overwrite
+
+ // simulate action on MODIFIED
+ this.deploymentIdentity = this.deployer.deploy(copy.toURI(), new DeploymentOptions(false, true, true));
+
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 1, 1);
+ assertTrue(copy.exists());
+
+ undeploy();
+ this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
+ assertFalse(copy.exists());
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerTimeOutTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerTimeOutTests.java
new file mode 100644
index 00000000..c844716e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerTimeOutTests.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test the generic deployer using a test deployer. This doesn't check OSGi behaviour but will detect clashes in the
+ * file system during deployment.
+ *
+ */
+// TODO Additional config paths in the new test framework
+// @AdditionalConfigPaths("src/test/resources/configTimeout/")
+// TODO This test is not robust: it passes without the change to the configured timeout value
+public class PipelinedDeployerTimeOutTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private final PathReference pickup = new PathReference("./target/pickup");
+
+ private StubInstallArtifactLifecycleListener lifecycleListener;
+
+ private ServiceRegistration lifecycleListenerRegistration;
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/deployer");
+ pr.delete(true);
+ pr.createDirectory();
+
+ clearPickup();
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ this.lifecycleListener = new StubInstallArtifactLifecycleListener();
+ this.lifecycleListenerRegistration = this.context.registerService(InstallArtifactLifecycleListener.class.getName(), this.lifecycleListener,
+ null);
+ }
+
+ private void clearPickup() {
+ File[] contents = this.pickup.toFile().listFiles();
+ for (File file : contents) {
+ file.delete();
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ clearPickup();
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ if (this.lifecycleListenerRegistration != null) {
+ this.lifecycleListenerRegistration.unregister();
+ }
+ }
+
+ @Test
+ public void testZeroTimeoutDeployer() throws Exception {
+ File file = new File("src/test/resources/ExporterC.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ this.appDeployer.undeploy(deploymentIdentity);
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentTests.java
new file mode 100644
index 00000000..d05de1b2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentTests.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+
+public class PlanDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference configAdminServiceReference;
+
+ private ConfigurationAdmin configAdmin;
+
+ @Test
+ public void planReferencingAPar() throws Exception {
+ testPlanDeployment(new File("src/test/resources/test-with-par.plan"), null, "par-deployed-by-plan-1-one");
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void scopedPlanReferencingAPar() throws Exception {
+ testPlanDeployment(new File("src/test/resources/scoped-test-with-par.plan"), null);
+ }
+
+ @Test
+ public void scopedBundlesAndConfig() throws Exception {
+ String oneBsn = "simple.bundle.one";
+ String twoBsn = "simple.bundle.two";
+
+ testPlanDeployment(new File("src/test/resources/test.plan"), new File("src/test/resources/plan-deployment/com.foo.bar.properties"), oneBsn, twoBsn);
+ }
+
+ @Test
+ public void testSimpleBundleWithFragment() throws Exception {
+ String oneBsn = "simple.bundle.one";
+ String twoBsn = "simple.fragment.one";
+
+ testPlanDeployment(new File("src/test/resources/fragment.plan"), null, oneBsn, twoBsn);
+ }
+
+ @Test
+ public void testUnscopedNonAtomicPlan() throws Exception {
+ String oneBsn = "simple.bundle.one";
+ String twoBsn = "simple.bundle.two";
+
+ testPlanDeployment(new File("src/test/resources/testunscopednonatomic.plan"), new File("src/test/resources/plan-deployment/com.foo.bar.properties"), oneBsn, twoBsn);
+ }
+
+ @Test
+ public void testPlanWithProperties() throws Exception {
+ this.deployer.deploy(new File("src/test/resources/properties.plan").toURI());
+ Bundle[] bundles = this.context.getBundles();
+ boolean found = false;
+ for (Bundle bundle : bundles) {
+ if("bundle.properties".equals(bundle.getSymbolicName())) {
+ found = true;
+ assertEquals("foo", bundle.getHeaders().get("Test-Header"));
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ this.configAdminServiceReference = this.context.getServiceReference(ConfigurationAdmin.class.getName());
+ this.configAdmin = (ConfigurationAdmin) this.context.getService(this.configAdminServiceReference);
+ }
+
+ private void testPlanDeployment(File plan, File propertiesFile, String... candidateBsns) throws Exception {
+ Bundle[] beforeDeployBundles = this.context.getBundles();
+ assertBundlesNotInstalled(beforeDeployBundles, candidateBsns);
+
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(plan.toURI());
+ Bundle[] afterDeployBundles = this.context.getBundles();
+ assertBundlesInstalled(afterDeployBundles, candidateBsns);
+
+ String pid = null;
+
+ if (propertiesFile != null) {
+ pid = propertiesFile.getName().substring(0, propertiesFile.getName().length() - ".properties".length());
+ checkConfigAvailable(pid, propertiesFile);
+ }
+
+ this.deployer.undeploy(deploymentIdentity);
+ Bundle[] afterUndeployBundles = this.context.getBundles();
+ assertBundlesNotInstalled(afterUndeployBundles, candidateBsns);
+
+ if (propertiesFile != null) {
+ checkConfigUnavailable(pid);
+ }
+ }
+
+ private void assertBundlesNotInstalled(Bundle[] bundles, String... candidateBsns) {
+ List<String> installedBsns = getInstalledBsns(bundles);
+ for (String candidateBsn : candidateBsns) {
+ for (String installedBsn : installedBsns) {
+ if (installedBsn.contains(candidateBsn)) {
+ fail(candidateBsn + " was installed");
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkConfigAvailable(String pid, File propertiesFile) throws IOException {
+ Configuration configuration = this.configAdmin.getConfiguration(pid, null);
+ Dictionary<Object, Object> dictionary = configuration.getProperties();
+
+ Properties properties = new Properties();
+ properties.load(new FileReader(propertiesFile));
+
+ Set<Entry<Object, Object>> entrySet = properties.entrySet();
+
+ for (Entry<Object, Object> entry : entrySet) {
+ Assert.assertEquals(entry.getValue(), dictionary.get(entry.getKey()));
+ }
+
+ Assert.assertEquals(pid, dictionary.get("service.pid"));
+ }
+
+ private void checkConfigUnavailable(String pid) throws IOException {
+ Configuration configuration = this.configAdmin.getConfiguration(pid, null);
+ Assert.assertNull(configuration.getProperties());
+ }
+
+ private void assertBundlesInstalled(Bundle[] bundles, String... candidateBsns) {
+ List<String> installedBsns = getInstalledBsns(bundles);
+ for (String candidateBsn : candidateBsns) {
+ boolean found = false;
+ for (String installedBsn : installedBsns) {
+ if (installedBsn.contains(candidateBsn)) {
+ found = true;
+ }
+ }
+ assertTrue(candidateBsn + " was not installed", found);
+ }
+ }
+
+ private List<String> getInstalledBsns(Bundle[] bundles) {
+ List<String> installedBsns = new ArrayList<String>(bundles.length);
+ for (Bundle bundle : bundles) {
+ installedBsns.add(bundle.getSymbolicName());
+ }
+
+ return installedBsns;
+ }
+
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PropertiesArtifactMBeanTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PropertiesArtifactMBeanTests.java
new file mode 100644
index 00000000..a07bb233
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PropertiesArtifactMBeanTests.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.URI;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.junit.Test;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.cm.Configuration;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.util.io.FileCopyUtils;
+
+
+/**
+ */
+public class PropertiesArtifactMBeanTests extends AbstractDeployerIntegrationTest {
+
+ private final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+
+ private final ObjectName objectName;
+ {
+ try {
+ objectName = new ObjectName("org.eclipse.virgo.kernel:type=Model,artifact-type=configuration,name=test,version=0.0.0");
+ } catch (JMException jme) {
+ throw new RuntimeException(jme);
+ }
+ }
+
+ @Test
+ public void lifecycle() throws DeploymentException, IOException, InvalidSyntaxException, JMException {
+ File artifactFile = new File("target/test.properties");
+
+ FileCopyUtils.copy(new File("src/test/resources/test.properties"), artifactFile);
+
+ URI artifactUri = artifactFile.toURI();
+
+ this.deployer.deploy(artifactUri);
+
+ assertConfigurationPresentAndCorrect("foo", "bar");
+
+ mBeanServer.invoke(objectName, "stop", null, null);
+
+ assertConfigurationNotPresent();
+
+ mBeanServer.invoke(objectName, "start", null, null);
+
+ assertConfigurationPresentAndCorrect("foo", "bar");
+
+ mBeanServer.invoke(objectName, "uninstall", null, null);
+
+ assertConfigurationNotPresent();
+ assertMBeanNotPresent();
+ assertFalse(this.deployer.isDeployed(artifactUri));
+ }
+
+ private void assertConfigurationPresentAndCorrect(String key, String value) throws IOException, InvalidSyntaxException {
+ Configuration configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals(value, configuration.getProperties().get(key));
+ }
+
+ private void assertConfigurationNotPresent() throws IOException, InvalidSyntaxException {
+ Configuration configuration = getConfiguration("test");
+ assertNull(configuration);
+ }
+
+ private void assertMBeanNotPresent() throws IntrospectionException, ReflectionException {
+ try {
+ mBeanServer.getMBeanInfo(objectName);
+ fail("MBean still present after uninstall");
+ } catch (InstanceNotFoundException infe) {
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/QuartzSchedulerTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/QuartzSchedulerTests.java
new file mode 100644
index 00000000..cdb1fe7f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/QuartzSchedulerTests.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+import java.io.File;
+
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Integration tests for <em>OSGi-ready</em> Quartz Scheduler configuration with Spring 2.5.6 and higher.
+ *
+ * <p>
+ * See <a href="http://jira.springframework.org/browse/SPR-5220" target="_blank">SPR-5220</a> for details.
+ * </p>
+ *
+ */
+public class QuartzSchedulerTests extends AbstractParTests {
+
+ private static final String SCHEDULER_FACTORY_BEAN_NAME = "schedulerFactoryBean";
+
+ private static final File BUNDLE_SAME1 = new File("src/test/resources/quartz/quartz.bundle.same1.jar");
+
+ private static final String BSN_SAME1 = "quartz.bundle.same1";
+
+ private static final File BUNDLE_SAME2 = new File("src/test/resources/quartz/quartz.bundle.same2.jar");
+
+ private static final String BSN_SAME2 = "quartz.bundle.same2";
+
+ private static final File BUNDLE_A = new File("src/test/resources/quartz/quartz.bundle.a.jar");
+
+ private static final String BSN_A = "quartz.bundle.a";
+
+ private static final String QUARTZ_SCHEDULER_A = "QuartzScheduler-A";
+
+ private static final File BUNDLE_B = new File("src/test/resources/quartz/quartz.bundle.b.jar");
+
+ private static final String BSN_B = "quartz.bundle.b";
+
+ private static final String QUARTZ_SCHEDULER_B = "QuartzScheduler-B";
+
+ private Object verifySchedulerConfiguration(final String bsn, final File bundle, final String expectedSchedulerName) throws Throwable {
+ deploy(bundle);
+
+ ApplicationContext appCtx = ApplicationContextUtils.getApplicationContext(this.context, bsn);
+
+ Object scheduler = appCtx.getBean(SCHEDULER_FACTORY_BEAN_NAME);
+ assertEquals("Verifying the name of the Quartz Scheduler for " + bsn, expectedSchedulerName, scheduler.getClass().getMethod(
+ "getSchedulerName").invoke(scheduler));
+
+ return scheduler;
+ }
+
+ @Test
+ public void testQuartzSchedulerSupportForBundlesWithSameAppCtxConfig() throws Throwable {
+ Object schedulerSame1 = verifySchedulerConfiguration(BSN_SAME1, BUNDLE_SAME1, SCHEDULER_FACTORY_BEAN_NAME);
+ Object schedulerSame2 = verifySchedulerConfiguration(BSN_SAME2, BUNDLE_SAME2, SCHEDULER_FACTORY_BEAN_NAME);
+ assertNotSame("The QuartzSchedulers for bundles " + BSN_SAME1 + " and " + BSN_SAME2 + " should not be the same.", schedulerSame1,
+ schedulerSame2);
+ }
+
+ @Test
+ public void testQuartzSchedulerSupportForBundlesWithDifferentAppCtxConfig() throws Throwable {
+ Object schedulerA = verifySchedulerConfiguration(BSN_A, BUNDLE_A, QUARTZ_SCHEDULER_A);
+ Object schedulerB = verifySchedulerConfiguration(BSN_B, BUNDLE_B, QUARTZ_SCHEDULER_B);
+ assertNotSame("The QuartzSchedulers for bundles " + BSN_A + " and " + BSN_B + " should not be the same.", schedulerA, schedulerB);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java
new file mode 100644
index 00000000..c07bb8a7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMBundleRefreshTests.java
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.ExportedPackage;
+
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Tests for refreshing a bundle via its entry in the runtime artifact model (RAM).
+ * <p />
+ *
+ */
+public class RAMBundleRefreshTests extends AbstractRAMIntegrationTests {
+
+ @Test
+ public void refresh() throws DeploymentException {
+ PathReference copyToDeploy = new PathReference("target/initial.jar");
+ if (copyToDeploy.exists() && !copyToDeploy.delete(true)) {
+ fail("Failed to delete " + copyToDeploy);
+ }
+
+ PathReference original = new PathReference("src/test/resources/ram-bundle-refresh/initial.jar");
+ original.copy(copyToDeploy, true);
+
+ DeploymentIdentity deployed = this.deployer.deploy(copyToDeploy.toURI());
+
+ assertStateOfInitialBundle();
+
+ PathReference refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-entry.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ ManageableArtifact artifact = getManageableArtifact(deployed);
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ assertStateOfNewEntryBundle();
+
+ refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-export.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+ assertStateOfNewExportBundle();
+
+ refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-name.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ assertFalse(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-version.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ assertFalse(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ this.deployer.undeploy(deployed);
+
+ assertNull(getBundle("refresh", new Version(1,0,0)));
+ }
+
+ @Test
+ public void refreshWithinAnUnscopedPlan() throws DeploymentException, InterruptedException {
+ PathReference watchedRepository = new PathReference("target/watched");
+ if (watchedRepository.exists() && ! watchedRepository.delete(true)) {
+ fail("Failed to delete watched repository");
+ }
+
+ watchedRepository.createDirectory();
+
+ PathReference copyToDeploy = new PathReference("target/watched/refresh.jar");
+ PathReference original = new PathReference("src/test/resources/ram-bundle-refresh/initial.jar");
+ original.copy(copyToDeploy, true);
+
+ Thread.sleep(2000);
+
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-bundle-refresh/test.plan").toURI());
+
+ assertStateOfInitialBundle();
+
+ PathReference refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-entry.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ ManageableArtifact artifact = getManageableArtifact("bundle", "refresh", new Version(1,0,0));
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ assertStateOfNewEntryBundle();
+
+ refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-export.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ assertStateOfNewExportBundle();
+
+ this.deployer.undeploy(deployed);
+ assertNull(getBundle("refresh", new Version(1,0,0)));
+ }
+
+ @Test
+ public void refreshWithinAPar() throws DeploymentException {
+ PathReference copyToDeploy = new PathReference("target/bundle-refresh.par");
+ if (copyToDeploy.exists() && !copyToDeploy.delete(true)) {
+ fail("Failed to delete " + copyToDeploy);
+ }
+
+ PathReference original = new PathReference("src/test/resources/ram-bundle-refresh/bundle-refresh.par");
+ original.copy(copyToDeploy, true);
+
+ DeploymentIdentity deployed = this.deployer.deploy(copyToDeploy.toURI());
+
+ assertStateOfScopedInitialBundle();
+
+ PathReference refreshSource = new PathReference("src/test/resources/ram-bundle-refresh/new-entry.jar");
+ PathReference refreshTarget = new PathReference("target/bundle-refresh.par/initial.jar");
+ refreshTarget.delete(true);
+ refreshSource.copy(refreshTarget, true);
+
+ ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0));
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ assertStateOfScopedNewEntryBundle();
+
+ refreshSource = new PathReference("src/test/resources/ram-bundle-refresh/new-export.jar");
+ refreshTarget.delete(true);
+ refreshSource.copy(refreshTarget, true);
+
+ assertFalse(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ this.deployer.undeploy(deployed);
+ assertNull(getBundle("refresh", new Version(1,0,0)));
+ }
+
+ @Test
+ public void refreshWithDefaultSymbolicNameAndVersion() throws DeploymentException {
+ PathReference original = new PathReference("src/test/resources/ram-bundle-refresh/no-bsn-no-version.jar");
+
+ DeploymentIdentity deployed = this.deployer.deploy(original.toURI());
+ assertEquals("no-bsn-no-version", deployed.getSymbolicName());
+ assertEquals("0.0.0", deployed.getVersion());
+
+ ManageableArtifact artifact = getManageableArtifact(deployed);
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ this.deployer.undeploy(deployed);
+ }
+
+ @Test
+ public void refreshWithinAnUnscopedPlanWithAScopedParent() throws DeploymentException, InterruptedException {
+ PathReference watchedRepository = new PathReference("target/watched");
+ if (watchedRepository.exists() && ! watchedRepository.delete(true)) {
+ fail("Failed to delete watched repository");
+ }
+
+ watchedRepository.createDirectory();
+
+ PathReference copyToDeploy = new PathReference("target/watched/refresh.jar");
+ PathReference original = new PathReference("src/test/resources/ram-bundle-refresh/initial.jar");
+ original.copy(copyToDeploy, true);
+
+ new PathReference("src/test/resources/ram-bundle-refresh/test.plan").copy(new PathReference("target/watched/test.plan"));
+
+ Thread.sleep(2000);
+
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-bundle-refresh/parent-test.plan").toURI());
+
+ assertStateOfScopedInitialBundle();
+
+ PathReference refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-entry.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ ManageableArtifact artifact = getManageableArtifact("bundle", "bundle-refresh-1-refresh", new Version(1,0,0));
+ assertTrue(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ assertStateOfScopedNewEntryBundle();
+
+ refresh = new PathReference("src/test/resources/ram-bundle-refresh/new-export.jar");
+ copyToDeploy.delete(true);
+ refresh.copy(copyToDeploy, true);
+
+ assertFalse(artifact.refresh());
+ assertEquals("ACTIVE", artifact.getState());
+
+ this.deployer.undeploy(deployed);
+ assertNull(getBundle("refresh", new Version(1,0,0)));
+ }
+
+ private void assertStateOfNewExportBundle() {
+ Bundle bundle = getBundle("refresh", new Version(1,0,0));
+ ExportedPackage[] exportedPackages = this.packageAdmin.getExportedPackages(bundle);
+
+ assertEquals(2, exportedPackages.length);
+ }
+
+ private void assertStateOfNewEntryBundle() {
+ Bundle bundle = getBundle("refresh", new Version(1,0,0));
+ assertStateOfNewEntryBundle(bundle);
+ }
+
+ private void assertStateOfScopedNewEntryBundle() {
+ Bundle bundle = getBundle("bundle-refresh-1-refresh", new Version(1,0,0));
+ assertStateOfNewEntryBundle(bundle);
+ }
+
+ private void assertStateOfNewEntryBundle(Bundle bundle) {
+ assertNotNull(bundle);
+ assertNotNull(bundle.getEntry("one/foo.txt"));
+
+ ExportedPackage[] exportedPackages = this.packageAdmin.getExportedPackages(bundle);
+
+ assertEquals(1, exportedPackages.length);
+ }
+
+ private void assertStateOfInitialBundle() {
+ Bundle bundle = getBundle("refresh", new Version(1,0,0));
+ assertStateOfInitialBundle(bundle);
+ }
+
+ private void assertStateOfScopedInitialBundle() {
+ Bundle bundle = getBundle("bundle-refresh-1-refresh", new Version(1,0,0));
+ assertStateOfInitialBundle(bundle);
+ }
+
+ private void assertStateOfInitialBundle(Bundle initialBundle) {
+ assertNotNull(initialBundle);
+ assertNull(initialBundle.getEntry("one/foo.txt"));
+
+ ExportedPackage[] exportedPackages = this.packageAdmin.getExportedPackages(initialBundle);
+ assertEquals(1, exportedPackages.length);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java
new file mode 100644
index 00000000..008cc97b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMConfigurationRefreshTests.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.Test;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
+import org.osgi.service.cm.Configuration;
+
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.eclipse.virgo.util.io.PathReference;
+
+
+/**
+ * Tests for refreshing a configuration artifact via the runtime artifact model (RAM).
+ * <p />
+ *
+ */
+public class RAMConfigurationRefreshTests extends AbstractRAMIntegrationTests {
+
+ @Test
+ public void refresh() throws DeploymentException, IOException, InvalidSyntaxException {
+ PathReference copyToDeploy = new PathReference("target/test.properties");
+ if (copyToDeploy.exists() && !copyToDeploy.delete()) {
+ fail("Failed to delete " + copyToDeploy);
+ }
+
+ PathReference original = new PathReference("src/test/resources/test.properties");
+ original.copy(copyToDeploy);
+
+ DeploymentIdentity deployed = this.deployer.deploy(copyToDeploy.toURI());
+
+ Configuration configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bar", configuration.getProperties().get("foo"));
+
+ PathReference refresh = new PathReference("src/test/resources/test-refresh.properties");
+ copyToDeploy.delete();
+ refresh.copy(copyToDeploy);
+
+ ManageableArtifact artifact = getManageableArtifact(deployed);
+ artifact.refresh();
+
+ configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bravo", configuration.getProperties().get("alpha"));
+ }
+
+ @Test
+ public void refreshWithinAPar() throws DeploymentException, IOException, InvalidSyntaxException {
+ PathReference copyToDeploy = new PathReference("target/config-refresh.par");
+ if (copyToDeploy.exists() && !copyToDeploy.delete(true)) {
+ fail("Failed to delete " + copyToDeploy);
+ }
+
+ PathReference original = new PathReference("src/test/resources/ram-config-refresh/config-refresh.par");
+ original.copy(copyToDeploy, true);
+
+ DeploymentIdentity parIdentity = this.deployer.deploy(copyToDeploy.toURI());
+
+ Configuration configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bar", configuration.getProperties().get("foo"));
+
+ PathReference refresh = new PathReference("src/test/resources/ram-config-refresh/test-refresh.properties");
+ PathReference propertiesToRefresh = new PathReference(new File(copyToDeploy.toFile(), "test.properties"));
+ propertiesToRefresh.delete();
+ refresh.copy(propertiesToRefresh);
+
+ ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0));
+ artifact.refresh();
+
+ configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bravo", configuration.getProperties().get("alpha"));
+
+ this.deployer.undeploy(parIdentity);
+ }
+
+ @Test
+ public void refreshWithinAPlan() throws DeploymentException, IOException, InvalidSyntaxException, InterruptedException {
+ PathReference watchedRepository = new PathReference("target/watched");
+ if (watchedRepository.exists() && ! watchedRepository.delete(true)) {
+ fail("Failed to delete watched repository");
+ }
+
+ watchedRepository.createDirectory();
+
+ PathReference copyToDeploy = new PathReference("target/watched/test.properties");
+ if (copyToDeploy.exists() && !copyToDeploy.delete(true)) {
+ fail("Failed to delete " + copyToDeploy);
+ }
+
+ PathReference configurationCopy = new PathReference("target/watched/test.properties");
+ new PathReference("src/test/resources/ram-config-refresh/test.properties").copy(configurationCopy);
+
+ Thread.sleep(2000);
+
+ this.deployer.deploy(new File("src/test/resources/ram-config-refresh/test.plan").toURI());
+
+ Configuration configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bar", configuration.getProperties().get("foo"));
+
+ PathReference refresh = new PathReference("src/test/resources/test-refresh.properties");
+ configurationCopy.delete();
+ refresh.copy(configurationCopy);
+
+ ManageableArtifact artifact = getManageableArtifact("configuration", "test", new Version(0,0,0));
+ artifact.refresh();
+
+ configuration = getConfiguration("test");
+ assertNotNull(configuration);
+ assertEquals("bravo", configuration.getProperties().get("alpha"));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
new file mode 100644
index 00000000..f3d910c2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMDeploymentIntegrationTests.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+import org.eclipse.virgo.kernel.model.Artifact;
+import org.eclipse.virgo.kernel.model.RuntimeArtifactRepository;
+
+/**
+ * Test the interactions between the Runtime Artifact Model (RAM) and the deployer.
+ *
+ */
+public class RAMDeploymentIntegrationTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceRegistration dummyModuleDeployerServiceRegistration;
+
+ private StubInstallArtifactLifecycleListener lifecycleListener;
+
+ private ServiceRegistration lifecycleListenerRegistration;
+
+ private DeploymentIdentity deploymentIdentity;
+
+ private ServiceReference ramReference;
+
+ private RuntimeArtifactRepository ram;
+
+ @Before
+ public void setUp() throws Exception {
+ this.lifecycleListener = new StubInstallArtifactLifecycleListener();
+ this.lifecycleListenerRegistration = this.kernelContext.registerService(InstallArtifactLifecycleListener.class.getName(),
+ this.lifecycleListener, null);
+
+ this.ramReference = this.kernelContext.getServiceReference(RuntimeArtifactRepository.class.getName());
+ this.ram = (RuntimeArtifactRepository) this.kernelContext.getService(ramReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.dummyModuleDeployerServiceRegistration != null) {
+ this.dummyModuleDeployerServiceRegistration.unregister();
+ }
+ if (this.lifecycleListenerRegistration != null) {
+ this.lifecycleListenerRegistration.unregister();
+ }
+ if (this.ramReference != null) {
+ this.ram = null;
+ this.kernelContext.ungetService(this.ramReference);
+ this.ramReference = null;
+ }
+ }
+
+ @Test
+ public void testRAMUndeployment() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.lifecycleListener.assertLifecycleCounts(0, 0, 0, 0);
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 0, 0);
+ Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(this.deploymentIdentity.getVersion()));
+ assertNotNull(artifact);
+ artifact.uninstall();
+ this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void testRAMUndeploymentFollowedByDeployerUndeployment() throws Exception {
+ File file = new File("src/test/resources/dummy.jar");
+ this.deploymentIdentity = this.deployer.deploy(file.toURI());
+ Artifact artifact = this.ram.getArtifact(this.deploymentIdentity.getType(), this.deploymentIdentity.getSymbolicName(), new Version(this.deploymentIdentity.getVersion()));
+ artifact.uninstall();
+
+ // The following deployer operation should throw DeploymentException.
+ this.deployer.undeploy(this.deploymentIdentity);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java
new file mode 100644
index 00000000..23a944c2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMParRefreshTests.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.junit.Test;
+
+
+
+/**
+ * Tests for refreshing a PAR via its entry in the runtime artifact model
+ *
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread-safe.
+ *
+ */
+public class RAMParRefreshTests extends AbstractRAMIntegrationTests {
+
+ @Test
+ public void refreshNotSupported() throws DeploymentException {
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-par-refresh/refresh.par").toURI());
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ assertFalse(manageableArtifact.refresh());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java
new file mode 100644
index 00000000..44e022d0
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RAMPlanRefreshTests.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
+import org.junit.Test;
+
+
+
+/**
+ * Tests for refreshing a plan via its entry in the runtime artifact model
+ *
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread-safe.
+ *
+ */
+public class RAMPlanRefreshTests extends AbstractRAMIntegrationTests {
+
+ @Test
+ public void refreshNotSupported() throws DeploymentException {
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/ram-plan-refresh/test.plan").toURI());
+ ManageableArtifact manageableArtifact = getManageableArtifact(deployed);
+ assertFalse(manageableArtifact.refresh());
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RedeployRefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RedeployRefreshTests.java
new file mode 100644
index 00000000..3bf263f4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RedeployRefreshTests.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer.DeploymentOptions;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test deploying a simple bundle, then a bad version, then a good version again.
+ *
+ */
+public class RedeployRefreshTests extends AbstractDeployerIntegrationTest {
+
+ private static final DeploymentOptions OPTIONS_NON_RECOVERABLE = new DeploymentOptions(false, false, true);
+
+ private static final DeploymentOptions OPTIONS_OWNED = new DeploymentOptions(false, true, true);
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private PathReference simpleModule;
+
+ @Before
+ public void setUp() throws Exception {
+ // The following races with server startup and causes unpleasantness on
+ // the console, but is unfortunately
+ // necessary until the test framework cold starts the server.
+ PathReference pr = new PathReference("./target/redeploy-refresh");
+ pr.delete(true);
+ pr.createDirectory();
+ simpleModule = pr.newChild("simple.module.jar");
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ @Test
+ public void testRedeployRefresh() throws Exception {
+ PathReference goodModule = new PathReference("src/test/resources/redeploy-refresh/good/simple.module.jar");
+ goodModule.copy(this.simpleModule);
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(this.simpleModule.toURI(), OPTIONS_NON_RECOVERABLE);
+
+ PathReference badModule = new PathReference("src/test/resources/redeploy-refresh/bad/simple.module.jar");
+ this.simpleModule.delete();
+ badModule.copy(this.simpleModule);
+ try {
+ deploymentIdentity = this.appDeployer.deploy(this.simpleModule.toURI(), OPTIONS_NON_RECOVERABLE);
+ Assert.assertTrue(false);
+ } catch (DeploymentException e) {
+ // Expected
+ }
+
+ this.simpleModule.delete();
+ goodModule.copy(this.simpleModule);
+ deploymentIdentity = this.appDeployer.deploy(this.simpleModule.toURI(), OPTIONS_NON_RECOVERABLE);
+
+ this.appDeployer.undeploy(deploymentIdentity);
+ }
+
+ @Test
+ public void testRedeployRefreshOwned() throws Exception {
+ PathReference goodModule = new PathReference("src/test/resources/redeploy-refresh/good/simple.module.jar");
+ goodModule.copy(this.simpleModule);
+
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(this.simpleModule.toURI(), OPTIONS_OWNED);
+ String symbolicName = deploymentIdentity.getSymbolicName();
+
+ PathReference good2Module = new PathReference("src/test/resources/redeploy-refresh/good/simple2.module.jar");
+ this.simpleModule.delete();
+ good2Module.copy(this.simpleModule);
+
+ DeploymentIdentity newDeploymentIdentity = this.appDeployer.refresh(this.simpleModule.toURI(), symbolicName); // should redeploy
+
+ assertEquals("Refreshed application doesn't have correct version", "2.0.0.BUILD-20090219114136", newDeploymentIdentity.getVersion());
+
+ this.appDeployer.undeploy(newDeploymentIdentity.getType(), newDeploymentIdentity.getSymbolicName(), newDeploymentIdentity.getVersion());
+
+ assertFalse("File should not exist", this.simpleModule.exists());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RefreshTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RefreshTests.java
new file mode 100644
index 00000000..831cb6bd
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RefreshTests.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.util.io.JarUtils;
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * Test refreshing individual modules of a deployed application.
+ * <p />
+ *
+ */
+public class RefreshTests extends AbstractDeployerIntegrationTest {
+
+ private static final String REFRESH_IMPORTER_VERSION = "1.0.0.BUILD-20100310081114";
+
+ private static final String REFRESH_EXPORTER_VERSION = "1.0.0.BUILD-20100310081114";
+
+ private static final File LOG_FILE = new File("target/serviceability/eventlog/eventlog.log");
+
+ private final String TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME = "RefreshTest-1-RefreshImporter";
+
+ private final String TEST_IMPORT_BUNDLE_IMPORTER_BUNDLE_SYMBOLIC_NAME = "RefreshTest-Import-Bundle-1-RefreshImporter";
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ private PathReference explodedPar;
+
+ private PathReference par;
+
+ private PathReference parImportBundle;
+
+ private int existingLines;
+
+ public void countExistingLogLines() throws IOException {
+ BufferedReader reader = new BufferedReader(new FileReader(LOG_FILE));
+ String line = reader.readLine();
+ existingLines = 0;
+ while (line != null) {
+ existingLines++;
+ line = reader.readLine();
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/org.eclipse.virgo.kernel");
+ pr.delete(true);
+ pr.createDirectory();
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+
+ explodedPar = new PathReference("./target/refresh-test/refresh.par");
+ explodedPar.delete(true);
+
+ par = new PathReference("src/test/resources/refresh.par");
+ JarUtils.unpackTo(par, explodedPar);
+
+ parImportBundle = new PathReference("src/test/resources/refresh-import-bundle.par");
+
+ countExistingLogLines();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ @Test
+ public void testBasicRefresh() throws DeploymentException, InterruptedException, IOException {
+ explodedPar.delete(true);
+ JarUtils.unpackTo(par, explodedPar);
+
+ this.appDeployer.deploy(explodedPar.toURI());
+ // Check that the test bundle's application contexts are created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME));
+
+ checkV1Classes();
+
+ PathReference exporter = new PathReference("./target/refresh-test/refresh.par/RefreshExporter.jar");
+ PathReference v2 = new PathReference("./target/refresh-test/refresh.par/build/RefreshExporterv2.jar");
+ exporter.delete();
+ v2.copy(exporter);
+ this.appDeployer.refresh(explodedPar.toURI(), "RefreshExporter");
+ Thread.sleep(1000); // wait for appCtx to be properly closed before waiting for it to be created.
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV2Classes();
+
+ PathReference v3 = new PathReference("./target/refresh-test/refresh.par/build/RefreshExporterv3.jar");
+ exporter.delete();
+ v3.copy(exporter);
+ this.appDeployer.refresh(explodedPar.toURI(), "RefreshExporter");
+ Thread.sleep(1000); // wait for appCtx to be properly closed before waiting for it to be created.
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV3Classes();
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void testRefreshOfUndeployedApplication() throws DeploymentException, IOException {
+ explodedPar.delete(true);
+ JarUtils.unpackTo(par, explodedPar);
+
+ // Ensure application isn't already deployed.
+ this.appDeployer.undeploy("par", "RefreshTest", "1");
+
+ this.appDeployer.refresh(explodedPar.toURI(), "RefreshExporter");
+ }
+
+ @Test
+ public void testRefreshWithImportBundle() throws DeploymentException, InterruptedException, IOException {
+ explodedPar.delete(true);
+ JarUtils.unpackTo(parImportBundle, explodedPar);
+
+ this.appDeployer.deploy(explodedPar.toURI());
+ // Check that the test bundle's application contexts are created.
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORT_BUNDLE_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV1Classes();
+
+ this.appDeployer.refresh(explodedPar.toURI(), "RefreshImporter");
+ Thread.sleep(1000); // wait for appCtx to be properly closed before waiting for it to be created.
+ ApplicationContextUtils.awaitApplicationContext(this.context, TEST_IMPORT_BUNDLE_IMPORTER_BUNDLE_SYMBOLIC_NAME, 10);
+
+ checkV1Classes();
+ }
+
+
+ @Test
+ public void testRedeployOfDependentBundles() throws DeploymentException, IOException {
+ explodedPar.delete(true);
+ JarUtils.unpackTo(par, explodedPar);
+
+ PathReference exporterJar = explodedPar.newChild("RefreshExporter.jar");
+ PathReference explodedExporterJar = explodedPar.newChild("explode").newChild("RefreshExporter.jar");
+ explodedExporterJar.delete(true);
+ JarUtils.unpackTo(exporterJar, explodedExporterJar);
+
+ PathReference importerJar = explodedPar.newChild("RefreshImporter.jar");
+ PathReference explodedImporterJar = explodedPar.newChild("explode").newChild("RefreshImporter.jar");
+ explodedImporterJar.delete(true);
+ JarUtils.unpackTo(importerJar, explodedImporterJar);
+
+ // Ensure bundles are not already deployed.
+ try {
+ this.appDeployer.undeploy("bundle", "RefreshExporter.jar", REFRESH_EXPORTER_VERSION);
+ } catch (DeploymentException e) {
+ }
+ try {
+ this.appDeployer.undeploy("bundle", "RefreshImporter.jar", REFRESH_IMPORTER_VERSION);
+ } catch (DeploymentException e) {
+ }
+
+ DeploymentIdentity diExporter = this.appDeployer.deploy(explodedExporterJar.toURI());
+ DeploymentIdentity diImporter = this.appDeployer.deploy(explodedImporterJar.toURI());
+
+ assertDeploymentIdentityEquals(diExporter, "RefreshExporter", "bundle", "RefreshExporter", REFRESH_EXPORTER_VERSION);
+ assertDeploymentIdentityEquals(diImporter, "RefreshImporter", "bundle", "RefreshImporter", REFRESH_IMPORTER_VERSION);
+
+ // Check that the test bundle's application contexts are created.
+ ApplicationContextUtils.awaitApplicationContext(this.context, "RefreshImporter", 10);
+
+ // Save the importer's manifest and overwrite it with the exporter's
+ PathReference importerManifest = explodedImporterJar.newChild("META-INF").newChild("MANIFEST.MF");
+ PathReference importerManifestSave = explodedImporterJar.newChild("META-INF").newChild("MANIFEST.MF.SAVED");
+ importerManifest.copy(importerManifestSave);
+ PathReference exporterManifest = explodedExporterJar.newChild("META-INF").newChild("MANIFEST.MF");
+ importerManifest.delete();
+ exporterManifest.copy(importerManifest);
+
+ // Redeploy the importer which will fail because of a duplicate bundle.
+ try {
+ this.appDeployer.deploy(explodedImporterJar.toURI());
+ assertFalse("deploy should fail because of a duplicate bundle", true);
+ } catch (DeploymentException e) {
+ assertTrue("Message did not report clash: " + e.getMessage(), e.getMessage().contains("clashes"));
+ }
+
+ // Restore the importer's manifest
+ importerManifest.delete();
+ importerManifestSave.copy(importerManifest);
+
+ // Redeploy the importer which should now succeed.
+ DeploymentIdentity deploymentIdentity = this.appDeployer.deploy(explodedImporterJar.toURI());
+ assertDeploymentIdentityEquals(deploymentIdentity, "RefreshImporter", "bundle", "RefreshImporter", REFRESH_IMPORTER_VERSION);
+ }
+
+ private void checkV1Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ assertFalse(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ assertFalse(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private void checkV2Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ assertTrue(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ assertFalse(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private void checkV3Classes() {
+ LoadableClasses loadableClasses = (LoadableClasses) getApplicationBundleContext().getService(
+ getApplicationBundleContext().getServiceReference("org.eclipse.virgo.kernel.deployer.test.LoadableClasses"));
+ Set<String> loadableClassNames = loadableClasses.getLoadableClasses();
+ assertTrue(loadableClassNames.contains("refresh.exporter.b1.B11"));
+ assertTrue(loadableClassNames.contains("refresh.exporter.b1.B12"));
+ assertTrue(loadableClassNames.contains("refresh.exporter.b2.B21"));
+ }
+
+ private BundleContext getApplicationBundleContext() {
+ Bundle[] bundles = this.context.getBundles();
+ for (Bundle bundle : bundles) {
+ String symbolicName = bundle.getSymbolicName();
+ if (symbolicName.contains("RefreshTest")) {
+ System.out.println(bundle.getSymbolicName());
+ return bundle.getBundleContext();
+ }
+ }
+ fail("Cannot find bundle context");
+ return null;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RepositoryDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RepositoryDeploymentTests.java
new file mode 100644
index 00000000..ee7a4504
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/RepositoryDeploymentTests.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.net.URI;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+
+
+public class RepositoryDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ @Test
+ public void repositoryDeployment() throws Exception {
+ DeploymentIdentity deployed = this.deployer.deploy(URI.create("repository:configuration/com.foo.bar/0"));
+ this.deployer.undeploy(deployed);
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void repositoryDeploymentOfNonExistentArtifact() throws Exception {
+ this.deployer.deploy(URI.create("repository:configuration/com.foo.bar/1"));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServicePublishingFromRepoTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServicePublishingFromRepoTests.java
new file mode 100644
index 00000000..cbfa4aed
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServicePublishingFromRepoTests.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.junit.Test;
+
+
+/**
+ */
+public class ServicePublishingFromRepoTests extends AbstractParTests {
+ @Test
+ public void publicationOfServiceByBundleInRepository() throws Throwable {
+ deploy(new File("src/test/resources/service-publication-from-repo/consumer.jar"));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java
new file mode 100644
index 00000000..e8da9dab
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ServiceScopingTests.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+import org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository;
+
+/**
+ */
+public class ServiceScopingTests extends AbstractParTests {
+
+ @Test
+ public void testServiceScoping() throws Throwable {
+ File bundle = new File("src/test/resources/service-scoping/scoping.service.global.jar");
+ assertTrue(bundle.exists());
+ File par = new File("src/test/resources/service-scoping/service-scoping.par");
+
+ DeploymentIdentity bundleDeploymentIdentity = deploy(bundle);
+ DeploymentIdentity parDeploymentIdentity = deploy(par);
+
+ BundleContext context = this.framework.getBundleContext();
+
+ // check global is wired to b
+ ServiceReference[] refs = context.getServiceReferences(Appendable.class.getName(), "(provider=global)");
+ assertNotNull(refs);
+ assertEquals(1, refs.length);
+ Bundle[] usingBundles = refs[0].getUsingBundles();
+ assertEquals(1, usingBundles.length);
+ Bundle b = usingBundles[0];
+ assertNotNull(b);
+ assertTrue(b.getSymbolicName().endsWith("scoping.service.module.b"));
+
+ Bundle[] bundles = context.getBundles();
+ for (Bundle bund : bundles) {
+ if (bund.getSymbolicName().contains("scoping.service.module.a")) {
+ assertContainsServiceReference(bund.getServicesInUse(), "(&(objectClass=java.lang.Appendable)(provider=local))");
+ } else if (bund.getSymbolicName().contains("scoping.service.module.b")) {
+ assertContainsServiceReference(bund.getServicesInUse(), "(&(objectClass=java.lang.Appendable)(provider=global))");
+ }
+ }
+
+ // check unable to access scoped service from unscoped view
+ refs = context.getServiceReferences(Appendable.class.getName(), "(provider=local)");
+ assertNull("refs should not be null", refs);
+
+ // check able to publish into global from app
+ ServiceReference serviceReference = context.getServiceReference(CharSequence.class.getName());
+ assertNotNull("cannot see service in global scope", serviceReference);
+
+ this.deployer.undeploy(parDeploymentIdentity);
+ this.deployer.undeploy(bundleDeploymentIdentity);
+ }
+
+ @Test
+ public void testGlobalListenerCannotSeeAppServices() throws Throwable {
+ BundleContext context = this.framework.getBundleContext();
+ final AtomicInteger counter = new AtomicInteger();
+ ServiceListener listener = new ServiceListener() {
+
+ public void serviceChanged(ServiceEvent event) {
+ if (event.getType() == ServiceEvent.REGISTERED) {
+ counter.incrementAndGet();
+ }
+ }
+
+ };
+ context.addServiceListener(listener, "(provider=local)");
+ File bundle = new File("src/test/resources/service-scoping/scoping.service.global.jar");
+ assertTrue(bundle.exists());
+ File par = new File("src/test/resources/service-scoping/service-scoping.par");
+
+ DeploymentIdentity bundleDeploymentIdentity = deploy(bundle);
+ DeploymentIdentity parDeploymentIdentity = deploy(par);
+
+ assertEquals("listener should not have seen the service", 0, counter.get());
+ this.deployer.undeploy(parDeploymentIdentity);
+ this.deployer.undeploy(bundleDeploymentIdentity);
+ }
+
+ @Test
+ public void testApplicationListener() throws Throwable {
+ File bundle = new File("src/test/resources/service-scoping/scoping.service.global.jar");
+ assertTrue(bundle.exists());
+ File par = new File("src/test/resources/service-scoping/service-scoping.par");
+
+ DeploymentIdentity bundleDeploymentIdentity = deploy(bundle);
+ DeploymentIdentity parDeploymentIdentity = deploy(par);
+
+ ObjectName oname = ObjectName.getInstance("scoping.test:type=Listener");
+
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ Integer count = (Integer) server.getAttribute(oname, "Count");
+ assertEquals(0, count.intValue());
+
+ server.invoke(oname, "registerService", null, null);
+
+ count = (Integer) server.getAttribute(oname, "Count");
+ assertEquals(1, count.intValue());
+
+ Dictionary<String, String> properties = new Hashtable<String, String>();
+ properties.put("test-case", "app-listener");
+ this.context.registerService(CharSequence.class.getName(), "foo", properties);
+
+ count = (Integer) server.getAttribute(oname, "Count");
+ assertEquals(2, count.intValue());
+
+ assertFalse(knownScopes().isEmpty());
+
+ this.deployer.undeploy(parDeploymentIdentity);
+ this.deployer.undeploy(bundleDeploymentIdentity);
+
+ assertTrue(knownScopes().isEmpty());
+ }
+
+ @Test
+ public void testEngine1265() throws Throwable {
+ File par = new File("src/test/resources/service-scoping/service-scoping-engine-1265.par");
+ assertTrue(par.exists());
+ DeploymentIdentity identity = deploy(par);
+ this.deployer.undeploy(identity);
+ }
+
+ @Test
+ public void testPlatform183() throws Throwable {
+ File par = new File("src/test/resources/service-scoping/service-scoping-platform-183.par");
+ assertTrue(par.exists());
+ DeploymentIdentity identity = deploy(par);
+ this.deployer.undeploy(identity);
+ }
+
+ @Test
+ public void serviceScopingOfNestedPlan() throws Throwable {
+ DeploymentIdentity deployed = this.deployer.deploy(new File("src/test/resources/service-scoping/service-scoping.plan").toURI());
+
+ Bundle bundle = getBundle("service-scoping-1-service.scoping.two", new Version(1, 0, 0));
+ assertNotNull(bundle);
+
+ // Check that bundle two is wired to the service from bundle one.
+ ServiceReference serviceReference = bundle.getBundleContext().getServiceReference(List.class.getName());
+ assertEquals("service-scoping-1-service.scoping.one", serviceReference.getBundle().getSymbolicName());
+
+ // Check that the service is not visible outside the scope
+ serviceReference = this.context.getServiceReference(List.class.getName());
+ assertNull(serviceReference);
+
+ this.deployer.undeploy(deployed);
+ }
+
+ private void assertContainsServiceReference(ServiceReference[] refs, String filter) throws InvalidSyntaxException {
+ Filter f = FrameworkUtil.createFilter(filter);
+ for (ServiceReference serviceReference : refs) {
+ if (f.match(serviceReference)) {
+ return;
+ }
+ }
+ fail("No service with filter '" + filter + "'");
+ }
+
+ private Set<String> knownScopes() throws Exception {
+ BundleContext context = this.framework.getBundleContext();
+ ServiceReference reference = context.getServiceReference(ScopeServiceRepository.class.getName());
+ ScopeServiceRepository scopeServiceRepository = (ScopeServiceRepository)context.getService(reference);
+ Set<String> knownScopes = scopeServiceRepository.knownScopes();
+ context.ungetService(reference);
+ return knownScopes;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/SimpleBundleApplicationDeploymentTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/SimpleBundleApplicationDeploymentTests.java
new file mode 100644
index 00000000..f78f44bb
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/SimpleBundleApplicationDeploymentTests.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+
+
+/**
+ * Test deploying an OSGi application containing a simple bundle.
+ *
+ */
+public class SimpleBundleApplicationDeploymentTests extends AbstractDeployerIntegrationTest {
+
+ private static final String TEST_BUNDLE_SYMBOLIC_NAME = "MyApp-1-com.springsource.kernel.deployer.testbundle";
+
+ @Test public void testDeployer() throws Exception {
+ File file = new File("src/test/resources/app0.par");
+
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(file.toURI());
+ // Check that the test bundle's application context is created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_SYMBOLIC_NAME));
+
+ this.deployer.undeploy(deploymentIdentity);
+ // Check that the test bundle's application context is destroyed.
+ assertNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_SYMBOLIC_NAME));
+
+ // Check that the application can be deployed again after being undeployed
+ this.deployer.deploy(file.toURI());
+ // Check that the test bundle's application context is created.
+ assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, TEST_BUNDLE_SYMBOLIC_NAME));
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/Spring256ABundleTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/Spring256ABundleTests.java
new file mode 100644
index 00000000..f1cac0ee
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/Spring256ABundleTests.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import org.osgi.framework.ServiceReference;
+import org.springframework.context.ApplicationContext;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.eclipse.virgo.test.framework.ConfigLocation;
+import org.eclipse.virgo.util.io.PathReference;
+
+@ConfigLocation("META-INF/spring256.test.config.properties")
+public class Spring256ABundleTests extends AbstractDeployerIntegrationTest {
+
+ private static final String BUNDLE_SYMBOLIC_NAME = "spring.256A.sample";
+
+ private static final String BEAN_NAME = "sampleBean";
+
+ private static final String expectedUserName = "admin";
+
+ private static final String SPRING_256A_BUNDLE_SYMBOLIC_NAME = "spring.256A.sample";
+
+ private static final String SPRING_256A_BUNDLE_VERSION = "1.0.0.BUILD-20090921151600";
+
+ private ApplicationDeployer appDeployer;
+
+ private ServiceReference appDeployerServiceReference;
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/work/org.eclipse.virgo.kernel");
+ pr.delete(true);
+
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ @Test
+ public void testDeploymentOfBundleHavingSpring256A() throws Exception {
+ File file = new File("src/test/resources/spring.256A.sample.jar");
+ DeploymentIdentity deploymentId = this.appDeployer.deploy(file.toURI());
+
+ assertDeploymentIdentityEquals(deploymentId, "spring.256A.sample.war", "bundle", SPRING_256A_BUNDLE_SYMBOLIC_NAME, SPRING_256A_BUNDLE_VERSION);
+
+ ApplicationContext appCtx = ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_SYMBOLIC_NAME);
+
+ assertNotNull(appCtx);
+ assertTrue(appCtx.containsBean(BEAN_NAME));
+
+ Object beanName = appCtx.getBean(BEAN_NAME);
+ assertEquals("UserName Value Getting from Bean is " + BUNDLE_SYMBOLIC_NAME, expectedUserName,
+ beanName.getClass().getMethod("getUsername").invoke(beanName));
+
+ this.appDeployer.undeploy(deploymentId.getType(), deploymentId.getSymbolicName(), deploymentId.getVersion());
+
+ // Check that the spring 256A bundle's application context is destroyed.
+ assertNull(ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_SYMBOLIC_NAME));
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubInstallArtifactLifecycleListener.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubInstallArtifactLifecycleListener.java
new file mode 100644
index 00000000..70a9f243
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubInstallArtifactLifecycleListener.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifact;
+import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener;
+
+final class StubInstallArtifactLifecycleListener implements InstallArtifactLifecycleListener {
+
+ private final AtomicInteger startingCount = new AtomicInteger();
+
+ private final AtomicInteger startedCount = new AtomicInteger();
+
+ private final AtomicInteger stoppingCount = new AtomicInteger();
+
+ private final AtomicInteger stoppedCount = new AtomicInteger();
+
+ public void assertLifecycleCounts(int starting, int started, int stopping, int stopped) {
+ assertEquals("Incorrect starting count", starting, this.startingCount.get());
+ assertEquals("Unexpected started count", started, this.startedCount.get());
+ assertEquals("Unexpected stopping count", stopping, this.stoppingCount.get());
+ assertEquals("Unexpected stopped count", stopped, this.stoppedCount.get());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onInstalling(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onInstallFailed(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onInstalled(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onResolving(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onResolveFailed(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onResolved(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStarting(InstallArtifact installArtifact) {
+ this.startingCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStartFailed(InstallArtifact installArtifact, Throwable cause) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStarted(InstallArtifact installArtifact) {
+ this.startedCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStopping(InstallArtifact installArtifact) {
+ this.stoppingCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStopFailed(InstallArtifact installArtifact, Throwable cause) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStopped(InstallArtifact installArtifact) {
+ this.stoppedCount.incrementAndGet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onUnresolved(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onUninstalling(InstallArtifact installArtifact) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onUninstallFailed(InstallArtifact installArtifact, Throwable cause) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onUninstalled(InstallArtifact installArtifact) {
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ThreadContextClassLoaderTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ThreadContextClassLoaderTests.java
new file mode 100644
index 00000000..e0034c44
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/ThreadContextClassLoaderTests.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test deploying an application which has one module which checks that an exported package from the other module is available via the thread
+ * context class loader.
+ *
+ */
+@Ignore("All tests ignored")
+public class ThreadContextClassLoaderTests extends AbstractParTests {
+
+ private static final String BUNDLE_A_SYMBOLIC_NAME = "tccltest-1-BundleA";
+
+ @Ignore("Fails as Spring-DM replaces TCCL with bundle's classloader during start processing")
+ @Test public void testThreadContextClassLoader() throws Throwable {
+ File file = new File("src/test/resources/tccltest.par");
+ deploy(file);
+ Assert.assertNotNull(ApplicationContextUtils.getApplicationContext(this.context, BUNDLE_A_SYMBOLIC_NAME));
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/TransitiveConstraintFailureDiagnosisTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/TransitiveConstraintFailureDiagnosisTests.java
new file mode 100644
index 00000000..82da8f8c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/TransitiveConstraintFailureDiagnosisTests.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URI;
+
+import org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.kernel.deployer.test.modules.TesterModule;
+import org.eclipse.virgo.kernel.deployer.test.modules.TesterModuleExport;
+import org.eclipse.virgo.kernel.deployer.test.modules.TesterModuleImport;
+
+/**
+ * Test detection and diagnosis of transitive uses constraint failures.
+ *
+ */
+public class TransitiveConstraintFailureDiagnosisTests extends AbstractDeployerIntegrationTest {
+
+ private ServiceReference appDeployerServiceReference;
+
+ private ApplicationDeployer appDeployer;
+
+ @Before
+ public void setUp() throws Exception {
+ this.appDeployerServiceReference = this.context.getServiceReference(ApplicationDeployer.class.getName());
+ this.appDeployer = (ApplicationDeployer) this.context.getService(this.appDeployerServiceReference);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (this.appDeployerServiceReference != null) {
+ this.context.ungetService(this.appDeployerServiceReference);
+ }
+ }
+
+ /**
+ * Modules and their manifest headers.
+ * A: import r;version="[1,2)",p
+ * B: export p;uses="q"
+ * import q
+ * C: export q;uses="r",r;version=0
+ * D: export r;version=1
+ *
+ * A should fail to resolve because the transitive uses constraint prevents wiring r to A from D
+ * because of the version clash with r from C exposed by the transitive uses directives.
+ * @throws Exception if run-time errors
+ */
+ @Test
+ public void listTesterModuleHeaders() throws Exception {
+ TesterModule tmA = new TesterModule.Builder("a")
+ .addImport(new TesterModuleImport.Builder("r").versionRange("[1,2)").build())
+ .addImport(new TesterModuleImport.Builder("p").build())
+ .build();
+
+ TesterModule tmB = new TesterModule.Builder("b")
+ .addExport(new TesterModuleExport.Builder("p").uses("q").build())
+ .addImport(new TesterModuleImport.Builder("q").build())
+ .build();
+
+ TesterModule tmC = new TesterModule.Builder("c")
+ .addExport(new TesterModuleExport.Builder("q").uses("r").build())
+ .addExport(new TesterModuleExport.Builder("r").version("0").build())
+ .build();
+
+ TesterModule tmD = new TesterModule.Builder("d")
+ .addExport(new TesterModuleExport.Builder("r").version("1").build())
+ .build();
+
+ printHeaders(tmA);
+ printHeaders(tmB);
+ printHeaders(tmC);
+ printHeaders(tmD);
+ }
+
+ private static void printHeaders(TesterModule tm) {
+ System.out.println("All headers for '" + tm.getName() + "'--------------");
+ for (String hdr : tm.getAllHeaders()) {
+ System.out.println(hdr);
+ }
+ System.out.println("-----------------------------------------\n");
+ }
+
+ @Test(expected=DeploymentException.class)
+ public void testConstraint() throws Exception {
+
+ DeploymentIdentity depIdD = deployJar("src/test/resources/transitiveconstraint/tmD.jar");
+ assertEquals("d", depIdD.getSymbolicName());
+
+ DeploymentIdentity depIdC = deployJar("src/test/resources/transitiveconstraint/tmC.jar");
+ assertEquals("c", depIdC.getSymbolicName());
+
+ DeploymentIdentity depIdB = deployJar("src/test/resources/transitiveconstraint/tmB.jar");
+ assertEquals("b", depIdB.getSymbolicName());
+
+ DeploymentIdentity depIdA = deployJar("src/test/resources/transitiveconstraint/tmA.jar");
+ assertEquals("a", depIdA.getSymbolicName());
+ }
+
+ private DeploymentIdentity deployJar(String jarFilePath) throws DeploymentException {
+ File file = new File(jarFilePath);
+ URI jarURI = file.toURI();
+
+ assertFalse("File " + file + " deployed before test!", this.appDeployer.isDeployed(jarURI));
+
+ DeploymentIdentity depId = this.appDeployer.deploy(jarURI);
+
+ assertTrue("File " + file + " not deployed.", this.appDeployer.isDeployed(jarURI));
+
+ return depId;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModule.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModule.java
new file mode 100644
index 00000000..fb7d30ee
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModule.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test.modules;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.virgo.kernel.osgi.common.Version;
+
+
+/**
+ * A module for testing deployment/resolution problems.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * thread-safe
+ *
+ */
+public class TesterModule {
+ private final String moduleName;
+ private final Version moduleVersion;
+
+ private final Set<TesterModuleImport> moduleImports;
+ private final Set<TesterModuleExport> moduleExports;
+
+ public static class Builder {
+ private final String moduleName;
+ private Version moduleVersion = Version.MINIMUM_VERSION;
+ private Set<TesterModuleImport> moduleImports = new HashSet<TesterModuleImport>();
+ private Set<TesterModuleExport> moduleExports = new HashSet<TesterModuleExport>();
+
+ public Builder(String name) {
+ this.moduleName = name;
+ }
+
+ public Builder version(String version) {
+ this.moduleVersion = new Version(version);
+ return this;
+ }
+ public Builder addImport(TesterModuleImport imp) {
+ this.moduleImports.add(imp);
+ return this;
+ }
+ public Builder addExport(TesterModuleExport exp) {
+ this.moduleExports.add(exp);
+ return this;
+ }
+
+ public TesterModule build() {
+ return new TesterModule(this);
+ }
+ }
+
+ private TesterModule(Builder builder) {
+ this.moduleName = builder.moduleName;
+ this.moduleVersion = builder.moduleVersion;
+ this.moduleImports = builder.moduleImports;
+ this.moduleExports = builder.moduleExports;
+ }
+
+ public String getName() {
+ return this.moduleName;
+ }
+ public Version getVersion() {
+ return this.moduleVersion;
+ }
+ public Set<TesterModuleImport> getImports() {
+ return this.moduleImports;
+ }
+ public Set<TesterModuleExport> getExports() {
+ return this.moduleExports;
+ }
+
+ public String getImportsEntry() {
+ return importsList(this.moduleImports);
+ }
+
+ public String getExportsEntry() {
+ return exportsList(this.moduleExports);
+ }
+
+ public List<String> getAllHeaders() {
+ List<String> hdrs = new ArrayList<String>();
+ hdrs.add("Manifest-Version: 1.0");
+ hdrs.add("Bundle-ManifestVersion: 2");
+ hdrs.add("Bundle-Name: TesterModule-" + this.moduleName);
+ hdrs.add("Bundle-SymbolicName: " + this.moduleName);
+ if (!this.moduleVersion.equals(Version.MINIMUM_VERSION)) {
+ hdrs.add("Bundle-Version: " + this.moduleVersion);
+ }
+ if (!this.moduleExports.isEmpty()) {
+ hdrs.add("Export-Package: " + exportsList(this.moduleExports));
+ }
+ if (!this.moduleImports.isEmpty()) {
+ hdrs.add("Import-Package: " + importsList(this.moduleImports));
+ }
+
+ return hdrs;
+ }
+
+ private static String importsList(Set<TesterModuleImport> imports) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer();
+ for (TesterModuleImport imp : imports) {
+ if (firstTime) firstTime = false;
+ else sb.append(",");
+ sb.append(imp.headerEntry());
+ }
+ return sb.toString();
+ }
+ private static String exportsList(Set<TesterModuleExport> exports) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer();
+ for (TesterModuleExport exp : exports) {
+ if (firstTime) firstTime = false;
+ else sb.append(",");
+ sb.append(exp.headerEntry());
+ }
+ return sb.toString();
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleExport.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleExport.java
new file mode 100644
index 00000000..368db077
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleExport.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test.modules;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.virgo.kernel.osgi.common.Version;
+
+/**
+ * Export for a {@link TesterModule}
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * thread-safe
+ */
+public class TesterModuleExport {
+ private static final String HEADER_ENTRY_CLAUSE_SEPARATOR = ";";
+ private static final String HEADER_ENTRY_ATTRIBUTE_NAME_SEPARATOR = ",";
+ private final String pkgName;
+ private final Version pkgVersion;
+ private final Map<String,String> pkgAttributes;
+ private final Set<String> pkgMandatoryAttributes;
+ private final Set<String> pkgUses;
+
+ public static class Builder {
+ //Required parameters
+ private final String pkgName;
+ //Optional parameters
+ private Version pkgVersion = Version.MINIMUM_VERSION;
+ private Map<String,String> pkgAttributes = new HashMap<String,String>();
+ private Set<String> pkgMandatoryAttributes = new HashSet<String>();
+ private Set<String> pkgUses = new HashSet<String>();
+
+ public Builder(String pkgName) {
+ this.pkgName = pkgName;
+ }
+ public Builder version(String version) {
+ this.pkgVersion = new Version(version);
+ return this;
+ }
+ public Builder attribute(String name, String value) {
+ this.pkgAttributes.put(name, value);
+ return this;
+ }
+ public Builder mandatoryAttribute(String name, String value) {
+ this.pkgAttributes.put(name, value);
+ this.pkgMandatoryAttributes.add(name);
+ return this;
+ }
+ public Builder uses(String name) {
+ this.pkgUses.add(name);
+ return this;
+ }
+ public TesterModuleExport build() {
+ return new TesterModuleExport(this);
+ }
+ }
+
+ private TesterModuleExport(Builder builder) {
+ this.pkgName = builder.pkgName;
+ this.pkgAttributes = builder.pkgAttributes;
+ this.pkgVersion = builder.pkgVersion;
+ this.pkgMandatoryAttributes = builder.pkgMandatoryAttributes;
+ this.pkgUses = builder.pkgUses;
+ }
+
+ public String getName() {
+ return this.pkgName;
+ }
+
+ public Version getVersion() {
+ return this.pkgVersion;
+ }
+
+ public Map<String,String> getAttributes() {
+ return this.pkgAttributes;
+ }
+
+ public Set<String> getMandatoryAttributes() {
+ return this.pkgMandatoryAttributes;
+ }
+
+ public String headerEntry() {
+ StringBuffer sb = new StringBuffer(this.pkgName);
+ if (!this.pkgVersion.equals(Version.MINIMUM_VERSION)) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(versionClause(this.pkgVersion));
+ }
+ if (!this.pkgAttributes.isEmpty()) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(attributesClause(this.pkgAttributes));
+ }
+ if (!this.pkgMandatoryAttributes.isEmpty()) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(mandatoryAttributesClause(this.pkgMandatoryAttributes));
+ }
+ if (!this.pkgUses.isEmpty()) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(usesDirectiveClause(this.pkgUses));
+ }
+
+ return sb.toString();
+ }
+
+ private static String versionClause(Version vr) {
+ return new StringBuffer("version=\"").append(vr.toString()).append("\"").toString();
+ }
+
+ private static String attributesClause(Map<String,String> attrs) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer();
+ for (Entry<String,String> entry : attrs.entrySet()) {
+
+ if (firstTime) firstTime = false;
+ else sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR);
+
+ sb.append(entry.getKey()).append("=").append("\"").append(entry.getValue()).append("\"");
+ }
+ return sb.toString();
+ }
+
+ private static String mandatoryAttributesClause(Set<String> attrs) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer("mandatory:=\"");
+ for (String attr : attrs) {
+
+ if (firstTime) firstTime = false;
+ else sb.append(HEADER_ENTRY_ATTRIBUTE_NAME_SEPARATOR);
+
+ sb.append(attr);
+ }
+ return sb.append("\"").toString();
+ }
+
+ private static String usesDirectiveClause(Set<String> uses) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer("uses:=\"");
+ for (String use : uses) {
+
+ if (firstTime) firstTime = false;
+ else sb.append(HEADER_ENTRY_ATTRIBUTE_NAME_SEPARATOR);
+
+ sb.append(use);
+ }
+ return sb.append("\"").toString();
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleImport.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleImport.java
new file mode 100644
index 00000000..6efdc379
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/modules/TesterModuleImport.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test.modules;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.osgi.service.resolver.VersionRange;
+
+
+/**
+ * Import for a {@link TesterModule}
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * thread-safe
+ */
+public class TesterModuleImport {
+
+ private static final String HEADER_ENTRY_CLAUSE_SEPARATOR = ";";
+ private final String pkgName;
+ private final VersionRange pkgVersionRange;
+ private final Map<String,String> pkgAttributes;
+
+
+ public static class Builder {
+ //Required parameters
+ private final String pkgName;
+ //Optional parameters
+ private VersionRange pkgVersionRange = VersionRange.emptyRange;
+ private Map<String,String> pkgAttributes = new HashMap<String,String>();
+
+ public Builder(String pkgName) {
+ this.pkgName = pkgName;
+ }
+ public Builder versionRange(String versionRangeString) {
+ this.pkgVersionRange = new VersionRange(versionRangeString);
+ return this;
+ }
+ public Builder attribute(String name, String value) {
+ this.pkgAttributes.put(name, value);
+ return this;
+ }
+
+ public TesterModuleImport build() {
+ return new TesterModuleImport(this);
+ }
+ }
+
+ private TesterModuleImport(Builder builder) {
+ this.pkgName = builder.pkgName;
+ this.pkgAttributes = builder.pkgAttributes;
+ this.pkgVersionRange = builder.pkgVersionRange;
+ }
+
+ public String getName() {
+ return this.pkgName;
+ }
+
+ public VersionRange getVersionRange() {
+ return this.pkgVersionRange;
+ }
+
+ public Map<String,String> getAttributes() {
+ return this.pkgAttributes;
+ }
+
+ public String headerEntry() {
+ StringBuffer sb = new StringBuffer(this.pkgName);
+ if (!this.pkgVersionRange.equals(VersionRange.emptyRange)) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(versionClause(this.pkgVersionRange));
+ }
+ if (!this.pkgAttributes.isEmpty()) {
+ sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR).append(attributesClause(this.pkgAttributes));
+ }
+ return sb.toString();
+ }
+
+ private static String versionClause(VersionRange vr) {
+ return new StringBuffer("version=\"").append(vr.toString()).append("\"").toString();
+ }
+
+ private static String attributesClause(Map<String,String> attrs) {
+ boolean firstTime = true;
+ StringBuffer sb = new StringBuffer();
+ for (Entry<String,String> entry : attrs.entrySet()) {
+
+ if (firstTime) firstTime = false;
+ else sb.append(HEADER_ENTRY_CLAUSE_SEPARATOR);
+
+ sb.append(entry.getKey()).append("=").append("\"").append(entry.getValue()).append("\"");
+ }
+ return sb.toString();
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/BundlesAndConfig.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/BundlesAndConfig.par
new file mode 100644
index 00000000..c5a61d9a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/BundlesAndConfig.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ExporterC.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ExporterC.jar
new file mode 100644
index 00000000..0073386d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ExporterC.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotion.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotion.par
new file mode 100644
index 00000000..ec7e53de
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotion.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotionViaLibrary.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotionViaLibrary.par
new file mode 100644
index 00000000..e1f0fd46
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ImportPromotionViaLibrary.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/LibraryC.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/LibraryC.libd
new file mode 100644
index 00000000..6b740b4e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/LibraryC.libd
@@ -0,0 +1,2 @@
+Library-SymbolicName: LibraryC
+Import-Bundle: ExporterC;import-scope:=application
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..1274b8a2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.virgo.kernel.deployer.test
+Export-Package: org.eclipse.virgo.kernel.deployer.test
+Import-Package: org.eclipse.virgo.kernel.core,
+ org.eclipse.virgo.kernel.deployer.core,
+ org.eclipse.virgo.kernel.deployer.core.event,
+ org.eclipse.virgo.kernel.install.artifact,
+ org.eclipse.virgo.kernel.install.environment,
+ org.eclipse.virgo.kernel.model,
+ org.eclipse.virgo.kernel.model.management,
+ org.eclipse.virgo.kernel.module,
+ org.eclipse.virgo.kernel.osgi.common,
+ org.eclipse.virgo.kernel.osgi.framework,
+ org.eclipse.virgo.kernel.services.work,
+ org.eclipse.virgo.util.io,
+ org.eclipse.virgo.util.math,
+ javax.management,
+ org.eclipse.osgi.service.resolver,
+ org.junit,
+ org.osgi.framework,
+ org.osgi.service.cm,
+ org.osgi.service.framework,
+ org.osgi.service.packageadmin,
+ org.springframework.context,
+ org.springframework.osgi.context,
+ org.springframework.osgi.context.event,
+ org.springframework.util,
+ org.hsqldb
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties
new file mode 100644
index 00000000..fda2c59b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/spring256.test.config.properties
@@ -0,0 +1,62 @@
+launcher.bundles =\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.org.apache.commons.logging/${org.slf4j}/com.springsource.slf4j.org.apache.commons.logging-${org.slf4j}.jar@start,\
+ file:../ivy-cache/repository/org.aspectj/com.springsource.org.aspectj.weaver/${org.aspectj}/com.springsource.org.aspectj.weaver-${org.aspectj}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.medic/org.eclipse.virgo.medic/${org.eclipse.virgo.medic}/org.eclipse.virgo.medic-${org.eclipse.virgo.medic}.jar@start,\
+ file:../ivy-cache/repository/org.apache.felix/org.apache.felix.configadmin/${org.apache.felix}/org.apache.felix.configadmin-${org.apache.felix}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.medic/org.eclipse.virgo.medic.core/${org.eclipse.virgo.medic}/org.eclipse.virgo.medic.core-${org.eclipse.virgo.medic}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/${org.eclipse.virgo.util}/org.eclipse.virgo.util.osgi-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.apache.felix/org.apache.felix.eventadmin/${org.apache.felix.eventadmin}/org.apache.felix.eventadmin-${org.apache.felix.eventadmin}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.common/${org.eclipse.virgo.util}/org.eclipse.virgo.util.common-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.io/${org.eclipse.virgo.util}/org.eclipse.virgo.util.io-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.jmx/${org.eclipse.virgo.util}/org.eclipse.virgo.util.jmx-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.math/${org.eclipse.virgo.util}/org.eclipse.virgo.util.math-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/${org.eclipse.virgo.util}/org.eclipse.virgo.util.parser.manifest-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.apache.commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar@start,\
+ file:../ivy-cache/repository/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.repository/org.eclipse.virgo.repository/${org.eclipse.virgo.repository}/org.eclipse.virgo.repository-${org.eclipse.virgo.repository}.jar@start,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.asm/3.0.0.RELEASE/org.springframework.asm-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.expression/3.0.0.RELEASE/org.springframework.expression-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar,\
+ file:../org.eclipse.virgo.kernel.core/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.agent.dm/target/classes@start,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.core/1.2.1/org.springframework.osgi.core-1.2.1.jar,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.extender/1.2.1/org.springframework.osgi.extender-1.2.1.jar@start,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.io/1.2.1/org.springframework.osgi.io-1.2.1.jar,\
+ file:../ivy-cache/repository/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar,\
+ file:../org.eclipse.virgo.kernel.artifact/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.services/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.osgi/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.deployer/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.dm/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.model/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.kerneldmfragment/target/classes
+
+org.eclipse.virgo.test.properties.include=file:../build.versions,file:../build.properties
+
+#Equinox Configuration
+osgi.parentClassloader=fwk
+osgi.context.bootdelegation=false
+osgi.compatibility.bootdelegation=false
+osgi.clean=true
+osgi.configuration.area=target
+
+osgi.console=2401
+
+org.apache.felix.eventadmin.Timeout=0
+
+osgi.java.profile=file:../build-kernel/lib/java6-server.profile
+osgi.java.profile.bootdelegation=override
+osgi.hook.configurators.include=org.eclipse.virgo.osgi.extensions.equinox.hooks.ExtensionsHookConfigurator
+
+org.eclipse.virgo.kernel.deployer.disableRecovery=true
+
+org.eclipse.virgo.kernel.home=target
+org.eclipse.virgo.kernel.domain=org.eclipse.virgo.kernel
+# Paths are relative to the current working directory
+org.eclipse.virgo.kernel.config=src/test/resources/config
+
+org.eclipse.virgo.medic.log.config.path=src/test/resources/config/serviceability.xml
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
new file mode 100644
index 00000000..2c27962c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/test.config.properties
@@ -0,0 +1,65 @@
+launcher.bundles =\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.api/${org.slf4j}/com.springsource.slf4j.api-${org.slf4j}.jar@start,\
+ file:../ivy-cache/repository/org.slf4j/com.springsource.slf4j.org.apache.commons.logging/${org.slf4j}/com.springsource.slf4j.org.apache.commons.logging-${org.slf4j}.jar@start,\
+ file:../ivy-cache/repository/org.aspectj/com.springsource.org.aspectj.weaver/${org.aspectj}/com.springsource.org.aspectj.weaver-${org.aspectj}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.medic/org.eclipse.virgo.medic/${org.eclipse.virgo.medic}/org.eclipse.virgo.medic-${org.eclipse.virgo.medic}.jar@start,\
+ file:../ivy-cache/repository/org.apache.felix/org.apache.felix.configadmin/${org.apache.felix}/org.apache.felix.configadmin-${org.apache.felix}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.medic/org.eclipse.virgo.medic.core/${org.eclipse.virgo.medic}/org.eclipse.virgo.medic.core-${org.eclipse.virgo.medic}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/${org.eclipse.virgo.util}/org.eclipse.virgo.util.osgi-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.apache.felix/org.apache.felix.eventadmin/${org.apache.felix.eventadmin}/org.apache.felix.eventadmin-${org.apache.felix.eventadmin}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.common/${org.eclipse.virgo.util}/org.eclipse.virgo.util.common-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.io/${org.eclipse.virgo.util}/org.eclipse.virgo.util.io-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.jmx/${org.eclipse.virgo.util}/org.eclipse.virgo.util.jmx-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.math/${org.eclipse.virgo.util}/org.eclipse.virgo.util.math-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.util/org.eclipse.virgo.util.parser.manifest/${org.eclipse.virgo.util}/org.eclipse.virgo.util.parser.manifest-${org.eclipse.virgo.util}.jar@start,\
+ file:../ivy-cache/repository/org.apache.commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar@start,\
+ file:../ivy-cache/repository/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar@start,\
+ file:../ivy-cache/repository/org.eclipse.virgo.repository/org.eclipse.virgo.repository/${org.eclipse.virgo.repository}/org.eclipse.virgo.repository-${org.eclipse.virgo.repository}.jar@start,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.asm/3.0.0.RELEASE/org.springframework.asm-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.expression/3.0.0.RELEASE/org.springframework.expression-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar,\
+ file:../org.eclipse.virgo.kernel.core/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.agent.dm/target/classes@start,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.core/1.2.1/org.springframework.osgi.core-1.2.1.jar,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.extender/1.2.1/org.springframework.osgi.extender-1.2.1.jar@start,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.io/1.2.1/org.springframework.osgi.io-1.2.1.jar,\
+ file:../ivy-cache/repository/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar,\
+ file:../org.eclipse.virgo.kernel.artifact/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.services/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.osgi/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.deployer/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.dm/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.model/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.kerneldmfragment/target/classes
+
+org.eclipse.virgo.test.properties.include=file:../build.versions,file:../build.properties
+
+#Equinox Configuration
+osgi.parentClassloader=fwk
+osgi.context.bootdelegation=false
+osgi.compatibility.bootdelegation=false
+osgi.clean=true
+osgi.configuration.area=target
+
+osgi.console=2401
+
+org.apache.felix.eventadmin.Timeout=0
+
+osgi.java.profile=file:../build-kernel/lib/java6-server.profile
+osgi.java.profile.bootdelegation=override
+osgi.hook.configurators.include=org.eclipse.virgo.osgi.extensions.equinox.hooks.ExtensionsHookConfigurator
+
+org.eclipse.virgo.kernel.deployer.disableRecovery=true
+
+org.eclipse.virgo.kernel.home=target
+org.eclipse.virgo.kernel.domain=org.eclipse.virgo.kernel
+# Paths are relative to the current working directory
+org.eclipse.virgo.kernel.config=src/test/resources/config
+
+org.eclipse.virgo.medic.log.config.path=src/test/resources/config/serviceability.xml
+
+eclipse.bundle.setTCCL=false
+eclipse.enableStateSaver=false
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ParRefreshPar.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ParRefreshPar.par
new file mode 100644
index 00000000..a705b3e8
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ParRefreshPar.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/activator-tccl.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/activator-tccl.jar
new file mode 100644
index 00000000..a714f924
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/activator-tccl.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app0.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app0.par
new file mode 100644
index 00000000..88dcc1d4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app0.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4.par
new file mode 100644
index 00000000..7655dcb1
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4clash.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4clash.par
new file mode 100644
index 00000000..66c6868a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app4clash.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app5.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app5.par
new file mode 100644
index 00000000..c7cac15c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app5.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app6.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app6.par
new file mode 100644
index 00000000..6ddb7da5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app6.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app7.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app7.par
new file mode 100644
index 00000000..7db14c7b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/app7.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-activation-policy.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-activation-policy.par
new file mode 100644
index 00000000..c2391ade
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-activation-policy.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporter.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporter.jar
new file mode 100644
index 00000000..4c3efd83
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporter.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv2.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv2.jar
new file mode 100644
index 00000000..f943c5b0
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv2.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv3.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv3.jar
new file mode 100644
index 00000000..3bff1309
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshExporterv3.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshImporter.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshImporter.jar
new file mode 100644
index 00000000..9d01457a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/bundle-refresh/RefreshImporter.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashing.exports.in.a.scope.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashing.exports.in.a.scope.par
new file mode 100644
index 00000000..aba4ae83
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashing.exports.in.a.scope.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashinguses.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashinguses.par
new file mode 100644
index 00000000..820748d5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/clashinguses.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/classpath-scanning.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/classpath-scanning.par
new file mode 100644
index 00000000..a1e3d144
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/classpath-scanning.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.brits.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.brits.par
new file mode 100644
index 00000000..40e9089e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.brits.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.deployer.testbundle.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.deployer.testbundle.jar
new file mode 100644
index 00000000..a8f61bc5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.deployer.testbundle.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.test.commons-dbcp.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.test.commons-dbcp.jar
new file mode 100644
index 00000000..2a44ee61
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/com.springsource.platform.test.commons-dbcp.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config-admin-test.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config-admin-test.jar
new file mode 100644
index 00000000..0044a85f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config-admin-test.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.properties
new file mode 100644
index 00000000..ef6d516f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.properties
@@ -0,0 +1,5 @@
+deployer.timeout= 300
+deployer.pickupDirectory= target/pickup
+deployer.systemArtifacts=
+shell.enabled= true
+shell.port= 2401
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
new file mode 100644
index 00000000..9a27a7ad
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
@@ -0,0 +1,92 @@
+baseBundles =\
+ file:../ivy-cache/repository/org.springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.asm/3.0.0.RELEASE/org.springframework.asm-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.expression/3.0.0.RELEASE/org.springframework.expression-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.core/1.2.1/org.springframework.osgi.core-1.2.1.jar,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.extender/1.2.1/org.springframework.osgi.extender-1.2.1.jar@start,\
+ file:../ivy-cache/repository/org.springframework.osgi/org.springframework.osgi.io/1.2.1/org.springframework.osgi.io-1.2.1.jar,\
+ file:../ivy-cache/repository/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar,\
+ file:../org.eclipse.virgo.kernel.agent.dm/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.deployer.dm/target/classes@start,\
+ file:../org.eclipse.virgo.kernel.dmfragment/target/classes,\
+ file:../org.eclipse.virgo.kernel.userregion/target/classes@start,\
+ file:../ivy-cache/repository/org.hsqldb/com.springsource.org.hsqldb/1.8.0.9/com.springsource.org.hsqldb-1.8.0.9.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.orm/3.0.0.RELEASE/org.springframework.orm-3.0.0.RELEASE.jar@start,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.transaction/3.0.0.RELEASE/org.springframework.transaction-3.0.0.RELEASE.jar@start,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.jdbc/3.0.0.RELEASE/org.springframework.jdbc-3.0.0.RELEASE.jar@start,\
+ file:../ivy-cache/repository/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-1.0.0.jar,\
+ file:../ivy-cache/repository/org.springframework/org.springframework.orm/3.0.0.RELEASE/org.springframework.orm-3.0.0.RELEASE.jar@start,\
+ file:../ivy-cache/repository/com.oracle.toplink.essentials/com.springsource.oracle.toplink.essentials/2.0.0.b41-beta2/com.springsource.oracle.toplink.essentials-2.0.0.b41-beta2.jar
+
+packageImports =\
+ org.eclipse.virgo.kernel.artifact.*;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.core;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.deployer.core;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.deployer.core.event;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.install.*;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.osgi.*;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.model;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.model.management;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.module;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.serviceability;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.serviceability.dump;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.serviceability.enforcement;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.services.work;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.kernel.shim.*;version="[2.1.0,2.1.1)",\
+ org.eclipse.virgo.medic.*;version="[1.0,2)",\
+ org.eclipse.virgo.repository;version="[2.0,3)",\
+ org.eclipse.virgo.util.*;version="[2.0,3)",\
+ org.apache.commons.logging;version="[1.0.0,2.0.0)",\
+ org.aspectj.*;version="[1.6.5.RELEASE,2.0.0)",\
+ org.junit;version="[4.7.0,5.0.0)",\
+ org.junit.runner;version="[4.7.0,5.0.0)",\
+ org.osgi.service.cm;version="0",\
+ org.osgi.service.event;version="0",\
+ org.slf4j;version="[1.5.10,2)"
+
+serviceImports =\
+ org.eclipse.virgo.kernel.deployer.core.ApplicationDeployer,\
+ org.eclipse.virgo.kernel.deployer.core.DeployUriNormaliser,\
+ org.eclipse.virgo.kernel.install.artifact.ScopeServiceRepository,\
+ org.eclipse.virgo.kernel.services.work.WorkArea,\
+ org.eclipse.virgo.repository.ArtifactBridge,\
+ org.eclipse.virgo.kernel.shell.state.StateService,\
+ org.eclipse.virgo.repository.RepositoryFactory,\
+ org.eclipse.virgo.medic.eventlog.EventLoggerFactory,\
+ org.eclipse.virgo.repository.Repository,\
+ org.eclipse.virgo.kernel.core.Shutdown,\
+ org.osgi.service.cm.ConfigurationAdmin,\
+ org.osgi.service.event.EventAdmin,\
+ org.eclipse.virgo.medic.dump.DumpGenerator,\
+ org.eclipse.virgo.kernel.shim.scope.ScopeFactory,\
+ org.eclipse.virgo.kernel.shim.serviceability.TracingService,\
+ org.eclipse.virgo.kernel.model.RuntimeArtifactRepository
+
+serviceExports =\
+ org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListener,\
+ org.eclipse.virgo.kernel.install.artifact.ArtifactTypeDeterminer,\
+ org.eclipse.virgo.kernel.install.pipeline.stage.transform.Transformer,\
+ org.eclipse.virgo.medic.dump.DumpContributor,\
+ org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory,\
+ org.eclipse.virgo.kernel.osgi.framework.OsgiFramework,\
+ org.eclipse.virgo.kernel.osgi.framework.ImportExpander,\
+ org.eclipse.virgo.kernel.osgi.framework.PackageAdminUtil,\
+ org.osgi.service.event.EventHandler,\
+ org.osgi.service.cm.ConfigurationListener,\
+ org.osgi.service.cm.ManagedService,\
+ org.osgi.service.cm.ManagedServiceFactory
+
+inheritedFrameworkProperties =\
+ eclipse.bundle.setTCCL,\
+ eclipse.enableStateSaver,\
+ osgi.java.profile,\
+ osgi.parentClassloader,\
+ osgi.context.bootdelegation,\
+ osgi.compatibility.bootdelegation,\
+ osgi.java.profile.bootdelegation,\
+ osgi.hook.configurators.include
+
+ osgi.console=2402
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.medic.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.medic.properties
new file mode 100644
index 00000000..1f0972d1
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.medic.properties
@@ -0,0 +1,6 @@
+dump.root.directory=target/serviceability/dump
+log.wrapSysOut=false
+log.wrapSysErr=true
+log.dump.level=DEBUG
+log.dump.bufferSize=10000
+log.dump.pattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-28.28thread %-64.64logger{64} %X{medic.eventCode} %msg %ex%n
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.repository.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.repository.properties
new file mode 100644
index 00000000..0f7502d3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/org.eclipse.virgo.repository.properties
@@ -0,0 +1,39 @@
+bundles.type=external
+bundles.searchPattern=../{bundle}/target/classes
+
+ivy-cache-bundles.type=external
+ivy-cache-bundles.searchPattern=../${ivy.cache::ivy-cache}/repository/{org}/{name}/{version}/{bundle}.jar
+
+ivy-cache-libraries.type=external
+ivy-cache-libraries.searchPattern=../${ivy.cache::ivy-cache}/repository/{org}/{name}/{version}/{library}.libd
+
+target-watched.type=watched
+target-watched.watchDirectory=target/watched
+target-watched.watchInterval=1
+
+src-test-resources-1.type=external
+src-test-resources-1.searchPattern=src/test/resources/importMergeDiagnostics/*.libd
+
+src-test-resources-2.type=external
+src-test-resources-2.searchPattern=src/test/resources/ExporterC.jar
+
+src-test-resources-3.type=external
+src-test-resources-3.searchPattern=src/test/resources/LibraryC.libd
+
+src-test-resources-4.type=external
+src-test-resources-4.searchPattern=src/test/resources/service-publication-from-repo/*.jar
+
+src-test-resources-5.type=external
+src-test-resources-5.searchPattern=src/test/resources/requirebundle/bundles/parrequirebundlethree.jar
+
+src-test-resources-6.type=external
+src-test-resources-6.searchPattern=src/test/resources/plan-deployment/*
+
+src-test-resources-7.type=external
+src-test-resources-7.searchPattern=src/test/resources/properties/*
+
+src-test-resources-8.type=external
+src-test-resources-8.searchPattern=src/test/resources/service-scoping/repository/*
+
+
+chain=target-watched,bundles,ivy-cache-bundles,ivy-cache-libraries,src-test-resources-1,src-test-resources-2,src-test-resources-3,src-test-resources-4,src-test-resources-5,src-test-resources-6,src-test-resources-7,src-test-resources-8
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/serviceability.xml b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/serviceability.xml
new file mode 100644
index 00000000..e576b75f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/config/serviceability.xml
@@ -0,0 +1,52 @@
+<configuration>
+
+ <appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>target/serviceability/log/log.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <FileNamePattern>target/serviceability/log/log_%i.log</FileNamePattern>
+ <MinIndex>1</MinIndex>
+ <MaxIndex>4</MaxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <MaxFileSize>10MB</MaxFileSize>
+ </triggeringPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-24.24thread %msg %ex%n</Pattern>
+ </layout>
+ </appender>
+
+ <appender name="EVENT_LOG_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-24.24thread &lt;%X{medic.eventCode}&gt; %msg %ex%n</Pattern>
+ </layout>
+ </appender>
+
+ <appender name="EVENT_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>target/serviceability/eventlog/eventlog.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <FileNamePattern>target/serviceability/eventlog/eventlog_%i.log</FileNamePattern>
+ <MinIndex>1</MinIndex>
+ <MaxIndex>4</MaxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <MaxFileSize>10MB</MaxFileSize>
+ </triggeringPolicy>
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-24.24thread &lt;%X{medic.eventCode}&gt; %msg %ex%n</Pattern>
+ </layout>
+ </appender>
+
+ <logger level="INFO" additivity="false" name="org.eclipse.virgo.medic.eventlog.localized">
+ <appender-ref ref="EVENT_LOG_STDOUT" />
+ <appender-ref ref="EVENT_LOG_FILE" />
+ </logger>
+
+ <logger level="INFO" additivity="false" name="org.eclipse.virgo.medic.eventlog.default">
+ <appender-ref ref="LOG_FILE" />
+ </logger>
+
+ <root level="WARN">
+ <appender-ref ref="LOG_FILE" />
+ </root>
+
+</configuration>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configTimeout/org.eclipse.virgo.kernel.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configTimeout/org.eclipse.virgo.kernel.properties
new file mode 100644
index 00000000..6d752a49
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configTimeout/org.eclipse.virgo.kernel.properties
@@ -0,0 +1,9 @@
+deployer.timeout= 0
+deployer.pickupDirectory= target/pickup
+io.workDirectory= target/work
+io.dumpDirectory= target/serviceability/dump
+shell.enabled= false
+shell.port= 2401
+profile.name = deployer integration tests
+profile.subsystems=
+profile.optionalSubsystems=
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/empty.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/empty.properties
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/empty.properties
@@ -0,0 +1 @@
+
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/t.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/t.properties
new file mode 100644
index 00000000..20c0243a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/configuration.deployment/t.properties
@@ -0,0 +1,2 @@
+a=b
+c=d
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployedArtifactJmxBeanTests/test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployedArtifactJmxBeanTests/test.plan
new file mode 100644
index 00000000..42376609
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployedArtifactJmxBeanTests/test.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="test.plan" version="1.0.0" scoped="false" atomic="false"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="simple.bundle.one" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/ClassNotFoundException.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/ClassNotFoundException.jar
new file mode 100644
index 00000000..e780bd20
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/ClassNotFoundException.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/malformed-application-context.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/malformed-application-context.par
new file mode 100644
index 00000000..4cad753d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/malformed-application-context.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-bundle.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-bundle.par
new file mode 100644
index 00000000..73ef21e1
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-bundle.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-library.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-library.par
new file mode 100644
index 00000000..b8b363e6
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-library.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-package.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-package.par
new file mode 100644
index 00000000..86090ab7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/deployer-log-message-tests/missing-package.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy-library.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy-library.libd
new file mode 100644
index 00000000..c8ff357a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy-library.libd
@@ -0,0 +1,3 @@
+Library-SymbolicName: dummy
+Library-Version: 1.0
+Import-Bundle: com.springsource.javax.el;version="[1.0,2.0)" \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy.jar
new file mode 100644
index 00000000..aebcad34
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummy.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummymodified.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummymodified.jar
new file mode 100644
index 00000000..1ed12a9a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/dummymodified.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/fragment.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/fragment.plan
new file mode 100644
index 00000000..aa9a11ce
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/fragment.plan
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="fragment" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="simple.bundle.one" version="[1, 2)"/>
+ <artifact type="bundle" name="simple.fragment.one" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle.jar
new file mode 100644
index 00000000..145a8521
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..27d8924e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/bundle/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: test
+Bundle-Version: 1.0
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/test.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/test.properties
new file mode 100644
index 00000000..74d0a43f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/hot-deployment-tests/test.properties
@@ -0,0 +1 @@
+foo=bar
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP1.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP1.libd
new file mode 100644
index 00000000..1a04edac
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP1.libd
@@ -0,0 +1,3 @@
+Library-SymbolicName: LibraryImportingP1
+Library-Version: 1.0
+Import-Bundle: TestP1 \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP2.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP2.libd
new file mode 100644
index 00000000..1d4220a7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/LibraryImportingP2.libd
@@ -0,0 +1,3 @@
+Library-SymbolicName: LibraryImportingP2
+Library-Version: 1.0
+Import-Bundle: TestP2 \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..52d335fa
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: TestImportP1P2
+Import-Bundle: TestP1,TestP2
+
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2ViaLibraries.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2ViaLibraries.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..da527550
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestImportP1P2ViaLibraries.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: TestImportP1P2ViaLibraries
+Import-Library: LibraryImportingP1,LibraryImportingP2
+
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP1.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP1.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..823733b7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP1.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: TestP1
+Export-Package: p
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP2.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP2.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..9f980dab
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/importMergeDiagnostics/TestP2.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: TestP2
+Export-Package: p
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/initial-artifact-plan/com.springsource.kernel.deployer.test.userregion.springdm.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/initial-artifact-plan/com.springsource.kernel.deployer.test.userregion.springdm.plan
new file mode 100644
index 00000000..85230043
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/initial-artifact-plan/com.springsource.kernel.deployer.test.userregion.springdm.plan
@@ -0,0 +1,10 @@
+<plan name="org.eclipse.virgo.kernel.deployer.test.userregion.springdm" version="2.0" scoped="false" atomic="false"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="com.springsource.kernel.agent.dm" version="[2.0, 2.1)"/>
+ <artifact type="bundle" name="org.eclipse.virgo.kernel.deployer.dm" version="[2.0, 2.1)"/>
+</plan>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/jpa-ltw-sample-update.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/jpa-ltw-sample-update.par
new file mode 100644
index 00000000..8e473222
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/jpa-ltw-sample-update.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/library-deployment-test.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/library-deployment-test.par
new file mode 100644
index 00000000..313c7456
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/library-deployment-test.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/manual-context.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/manual-context.jar
new file mode 100644
index 00000000..650e457c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/manual-context.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..0f930257
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: monitor.failure
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/spring/context.xml b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/spring/context.xml
new file mode 100644
index 00000000..ce29a3fe
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/failure/META-INF/spring/context.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <ba
+</beans:beans>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/nondm/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/nondm/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..c3b9ee11
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/nondm/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: monitor.nondm
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..199421b5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: monitor.success
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/spring/context.xml b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/spring/context.xml
new file mode 100644
index 00000000..e6eb8448
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/monitor/success/META-INF/spring/context.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+
+</beans:beans>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.jar
new file mode 100644
index 00000000..a5de4a73
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.par
new file mode 100644
index 00000000..a5de4a73
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nomanifest.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.jar
new file mode 100644
index 00000000..47a74266
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.par
new file mode 100644
index 00000000..47a74266
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/nometainf.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/bundle.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/bundle.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..564b943f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/bundle.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: bundle
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..4ce10b67
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Application-SymbolicName: onstarted-failure
+Application-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/bundle.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/bundle.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..564b943f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/onstarted-failure-tests/started-failure.par/bundle.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: bundle
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/org.aspectj-library.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/org.aspectj-library.libd
new file mode 100644
index 00000000..4540c2c5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/org.aspectj-library.libd
@@ -0,0 +1,6 @@
+Library-SymbolicName: org.aspectj
+Library-Version: 1.6.1
+Library-Name: AspectJ
+Import-Bundle:
+ com.springsource.org.aspectj.runtime;version="[1.6.1 ,1.6.1]",
+ com.springsource.org.aspectj.weaver;version="[1.6.1, 1.6.1]"
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test.jar
new file mode 100644
index 00000000..fa427006
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test2.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test2.jar
new file mode 100644
index 00000000..d1968015
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/osgi_test2.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/child.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/child.jar
new file mode 100644
index 00000000..9c67dc85
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/child.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/com.foo.bar.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/com.foo.bar.properties
new file mode 100644
index 00000000..094a8ed3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/com.foo.bar.properties
@@ -0,0 +1,3 @@
+a=alpha
+b=bravo
+c=charlie
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/global.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/global.jar
new file mode 100644
index 00000000..12817392
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/global.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/parent.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/parent.jar
new file mode 100644
index 00000000..7333a5cc
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/parent.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..58224752
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Application-SymbolicName: par-deployed-by-plan
+Application-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/one.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/one.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..74e806df
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/one.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: one
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/some-config.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/some-config.properties
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/some-config.properties
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/three.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/three.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..25aab648
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/three.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: three
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/two.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/two.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..908c5494
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/plan-deployment.par/two.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: two
+Bundle-Version: 1
+Bundle-ManifestVersion: 2
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.one.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.one.jar
new file mode 100644
index 00000000..35e868e7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.one.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.two.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.two.jar
new file mode 100644
index 00000000..74946ea3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.bundle.two.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.fragment.one.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.fragment.one.jar
new file mode 100644
index 00000000..a1903253
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/plan-deployment/simple.fragment.one.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties.plan
new file mode 100644
index 00000000..95963fb9
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties.plan
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="properties.plan" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="bundle.properties" version="[1, 2)">
+ <property name="header:Test-Header" value="foo"/>
+ </artifact>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties/bundle/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties/bundle/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..f6110942
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/properties/bundle/META-INF/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: bundle.properties
+Bundle-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.a.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.a.jar
new file mode 100644
index 00000000..66580c66
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.a.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.b.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.b.jar
new file mode 100644
index 00000000..05cf362f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.b.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same1.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same1.jar
new file mode 100644
index 00000000..b015cd5f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same1.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same2.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same2.jar
new file mode 100644
index 00000000..3ad58801
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/quartz/quartz.bundle.same2.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..4ebd135c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Application-SymbolicName: bundle-refresh
+Application-Version: 1.0
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/initial.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/initial.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..b94c70a2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/bundle-refresh.par/initial.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: refresh
+Bundle-Version: 1.0
+Bundle-ManifestVersion: 2
+Export-Package: one
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/initial.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/initial.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..b94c70a2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/initial.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: refresh
+Bundle-Version: 1.0
+Bundle-ManifestVersion: 2
+Export-Package: one
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..b94c70a2
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: refresh
+Bundle-Version: 1.0
+Bundle-ManifestVersion: 2
+Export-Package: one
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/one/foo.txt b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/one/foo.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-entry.jar/one/foo.txt
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..a6445335
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: refresh
+Bundle-Version: 1.0
+Bundle-ManifestVersion: 2
+Export-Package: one,two
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/one/foo.txt b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/one/foo.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-export.jar/one/foo.txt
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-name.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-name.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..cebf0076
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-name.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: different
+Bundle-Version: 1.0
+Bundle-ManifestVersion: 2
+Export-Package: one
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-version.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-version.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..a2d3cfef
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/new-version.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1
+Bundle-SymbolicName: refresh
+Bundle-Version: 2.0
+Bundle-ManifestVersion: 2
+Export-Package: one
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/no-bsn-no-version.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/no-bsn-no-version.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..e550bfa5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/no-bsn-no-version.jar/META-INF/MANIFEST.MF
@@ -0,0 +1 @@
+Manifest-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/parent-test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/parent-test.plan
new file mode 100644
index 00000000..e52f0c09
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/parent-test.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="bundle-refresh" version="1.0.0" scoped="true" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="plan" name="unscoped-bundle-refresh" version="[1,1]"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/test.plan
new file mode 100644
index 00000000..35ae2e34
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-bundle-refresh/test.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="unscoped-bundle-refresh" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="refresh" version="[1,1]"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..dd054240
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Application-SymbolicName: config-refresh
+Application-Version: 1.0
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/test.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/test.properties
new file mode 100644
index 00000000..74d0a43f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/config-refresh.par/test.properties
@@ -0,0 +1 @@
+foo=bar
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test-refresh.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test-refresh.properties
new file mode 100644
index 00000000..011da3c9
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test-refresh.properties
@@ -0,0 +1 @@
+alpha=bravo
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.plan
new file mode 100644
index 00000000..ee806c8c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="config-refresh" version="1.0.0" scoped="true" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="configuration" name="test" version="[0,0]"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.properties
new file mode 100644
index 00000000..74d0a43f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-config-refresh/test.properties
@@ -0,0 +1 @@
+foo=bar
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-par-refresh/refresh.par/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-par-refresh/refresh.par/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..6f9bc6ce
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-par-refresh/refresh.par/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Application-SymbolicName: refresh
+Application-Version: 1.0
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.plan
new file mode 100644
index 00000000..979e4eaa
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.plan
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="refresh" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="configuration" name="test" version="[0,0]"/>
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.properties
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/ram-plan-refresh/test.properties
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/bad/simple.module.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/bad/simple.module.jar
new file mode 100644
index 00000000..0065505a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/bad/simple.module.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple.module.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple.module.jar
new file mode 100644
index 00000000..af96e7ce
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple.module.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple2.module.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple2.module.jar
new file mode 100644
index 00000000..ce66b3a9
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/redeploy-refresh/good/simple2.module.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh-import-bundle.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh-import-bundle.par
new file mode 100644
index 00000000..14fe0a4d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh-import-bundle.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh.par
new file mode 100644
index 00000000..8e7cac47
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/refresh.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parWithInternalRequireBundle.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parWithInternalRequireBundle.par
new file mode 100644
index 00000000..b38120c8
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parWithInternalRequireBundle.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parrequirebundlethree.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parrequirebundlethree.jar
new file mode 100644
index 00000000..1dea9d27
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/requirebundle/bundles/parrequirebundlethree.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/scoped-test-with-par.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/scoped-test-with-par.plan
new file mode 100644
index 00000000..415387d3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/scoped-test-with-par.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="test.plan" version="1.0.0" scoped="true" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="par" name="par-deployed-by-plan" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/consumer.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/consumer.jar
new file mode 100644
index 00000000..9120fb70
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/consumer.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/publisher.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/publisher.jar
new file mode 100644
index 00000000..a6778453
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-publication-from-repo/publisher.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..61bdbb0b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: service.scoping.one
+Bundle-ManifestVersion: 2
+Bundle-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/spring/context.xml b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/spring/context.xml
new file mode 100644
index 00000000..84bb0dbf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/one.jar/META-INF/spring/context.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <osgi:service interface="java.util.List">
+ <bean class="java.util.ArrayList"/>
+ </osgi:service>
+
+</beans>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/service-scoping-nested.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/service-scoping-nested.plan
new file mode 100644
index 00000000..82003238
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/service-scoping-nested.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="service-scoping-nested" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="service.scoping.two" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..34404bf3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: service.scoping.two
+Bundle-ManifestVersion: 2
+Bundle-Version: 1
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/spring/context.xml b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/spring/context.xml
new file mode 100644
index 00000000..66d2b1c4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/repository/two.jar/META-INF/spring/context.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <osgi:reference id="testList" interface="java.util.List"/>
+
+</beans>
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/scoping.service.global.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/scoping.service.global.jar
new file mode 100644
index 00000000..44663fc5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/scoping.service.global.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-engine-1265.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-engine-1265.par
new file mode 100644
index 00000000..03f8c0d4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-engine-1265.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-platform-183.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-platform-183.par
new file mode 100644
index 00000000..fc8c1ade
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping-platform-183.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.par
new file mode 100644
index 00000000..e243fe96
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.plan
new file mode 100644
index 00000000..468a7469
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/service-scoping/service-scoping.plan
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="service-scoping" version="1.0.0" scoped="true" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="plan" name="service-scoping-nested" version="[1, 2)"/>
+ <artifact type="bundle" name="service.scoping.one" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.256A.sample.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.256A.sample.jar
new file mode 100644
index 00000000..e466b724
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.256A.sample.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.libd
new file mode 100644
index 00000000..42ef2e9e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring.libd
@@ -0,0 +1,5 @@
+Library-SymbolicName: org.springframework
+Library-Version: 2.5.3
+Import-Bundle: org.springframework.core;version="[2.5.3,3.0.0)",
+ org.springframework.beans;version="[2.5.3,3.0.0)"
+ \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring_instrumented.libd b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring_instrumented.libd
new file mode 100644
index 00000000..7fc9d1ba
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/spring_instrumented.libd
@@ -0,0 +1,5 @@
+Library-SymbolicName: org.springframework
+Library-Version: 2.5.3
+Import-Bundle: org.springframework.core.instrumented;version="[2.5.3,3.0.0)",
+ org.springframework.beans.instrumented;version="[2.5.3,3.0.0)"
+ \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/tccltest.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/tccltest.par
new file mode 100644
index 00000000..b40ef5c3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/tccltest.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-refresh.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-refresh.properties
new file mode 100644
index 00000000..011da3c9
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-refresh.properties
@@ -0,0 +1 @@
+alpha=bravo
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-with-par.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-with-par.plan
new file mode 100644
index 00000000..1972dc47
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test-with-par.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="test.plan" version="1.0.0" scoped="false" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="par" name="par-deployed-by-plan" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.plan
new file mode 100644
index 00000000..b9a4208c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.plan
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="test.plan" version="1.0.0" scoped="true" atomic="true"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="simple.bundle.one" version="[1, 2)"/>
+ <artifact type="bundle" name="simple.bundle.two" version="[1, 2)"/>
+ <artifact type="configuration" name="com.foo.bar" version="[0,0]"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.properties b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.properties
new file mode 100644
index 00000000..74d0a43f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/test.properties
@@ -0,0 +1 @@
+foo=bar
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomic.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomic.plan
new file mode 100644
index 00000000..d863fcaf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomic.plan
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="test.plan" version="1.0.0" scoped="false" atomic="false"
+ xmlns="http://www.springsource.org/schema/dm-server/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springsource.org/schema/dm-server/plan
+ http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
+
+ <artifact type="bundle" name="simple.bundle.one" version="[1, 2)"/>
+ <artifact type="bundle" name="simple.bundle.two" version="[1, 2)"/>
+ <artifact type="configuration" name="com.foo.bar" version="[0,0]"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.jar
new file mode 100644
index 00000000..a3126249
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.par
new file mode 100644
index 00000000..ebd483db
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/trace-config/app.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmA.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmA.jar
new file mode 100644
index 00000000..55fe9332
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmA.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmB.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmB.jar
new file mode 100644
index 00000000..0ad7b28b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmB.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmC.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmC.jar
new file mode 100644
index 00000000..aaf6e54a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmC.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmD.jar b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmD.jar
new file mode 100644
index 00000000..b269ce32
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/transitiveconstraint/tmD.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/twoBundlesThatImportTheSameLibrary.par b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/twoBundlesThatImportTheSameLibrary.par
new file mode 100644
index 00000000..dc67c380
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/twoBundlesThatImportTheSameLibrary.par
Binary files differ
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/waralientokernel.war b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/waralientokernel.war
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/waralientokernel.war

Back to the top