JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", true, PlainJavaBean.class);
ear1.addModule(ejbJar1);
MockArchiveManifest.addManifest(ear1);
DeploymentUnit unit = assertDeploy(ear1);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
Deployment deployment1 = initializeDeploymentBean(unit);
// simple2.ear
EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
ear2.addModule(ejbJar2);
MockArchiveManifest.addManifest(ear2);
unit = assertDeploy(ear2);
Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
Class<?> businessInterface = getClass(BusinessInterface.class, unit);
Deployment deployment2 = initializeDeploymentBean(unit);
BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
// double invocation should yield the same result
assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
}