/** * Deploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void deploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!raa.getName().endsWith(".rar")) throw new IllegalArgumentException(raa.getName() + " doesn't end with .rar"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); if (shrinkwrapDeployments != null && shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " already deployed"); if (raaFile.exists()) recursiveDelete(raaFile); raa.as(ZipExporter.class).exportTo(raaFile, true); if (shrinkwrapDeployments == null) shrinkwrapDeployments = new ArrayList<File>(1); shrinkwrapDeployments.add(raaFile); log.debugf("Deploying: %s", raaFile); kernel.getMainDeployer().deploy(raaFile.toURI().toURL()); }
public static ResourceAdapterArchive createMockResourceAdapterArchive() { JavaArchive ja = ShrinkWrap.create(JavaArchive.class, LIB_JAR_NAME); ja.addClasses(MessageListener.class, MockActivationSpec.class, MockConnection.class, MockConnectionFactory.class, MockConnectionManager.class, MockManagedConnection.class, MockManagedConnectionFactory.class, MockResourceAdapter.class, MockXAResource.class, InteractionListener.class, MockInteraction.class, MockRecordFactory.class, MockMappedRecord.class, MockIndexedRecord.class); try { return ShrinkWrap.create(ResourceAdapterArchive.class, ADAPTER_ARCHIVE_NAME) .addAsLibrary(ja) .setResourceAdapterXML(Classes.getResource(RESOURCE_ADAPTER_XML)) .addAsManifestResource(IRONJACAMAR_XML, "ironjacamar.xml"); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * Undeploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void undeploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); log.debugf("Undeploying: %s", raaFile); if (shrinkwrapDeployments == null || !shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " not deployed"); kernel.getMainDeployer().undeploy(raaFile.toURI().toURL()); removeDeployment(raaFile); }
@Deployment public static EnterpriseArchive createTestArchive() { EnterpriseArchive enterpriseArchive = new EnterpriseArchiveBuilder().withTestClass(ResourceAdapterArchiveTest.class) .build(); ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class); // JCA spec 20.2.0.1 Resource Adapter Archive rar.addAsLibrary(ShrinkWrap .create(JavaArchive.class) .addClasses(Translator.class, TestResourceAdapter.class) .addAsManifestResource(new StringAsset(Descriptors.create(BeansDescriptor.class) .beanDiscoveryMode(BeanDiscoveryMode._ALL.toString()).version(Versions.v1_1) .exportAsString()), "beans.xml")); rar.addAsManifestResource( new StringAsset(Descriptors.create(ConnectorDescriptor.class).version("1.6").displayName("Test RA") .vendorName("Red Hat Middleware LLC").eisType("Test RA").resourceadapterVersion("0.1") .getOrCreateResourceadapter().resourceadapterClass(TestResourceAdapter.class.getName()) .getOrCreateOutboundResourceadapter().transactionSupport("NoTransaction") .reauthenticationSupport(false).up().up().exportAsString()), "ra.xml"); enterpriseArchive.addAsModule(rar); return enterpriseArchive; }
/** * Undeploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void undeploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); log.debugf("Undeploying: %s", raaFile); if (shrinkwrapDeployments == null || !shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " not deployed"); kernel.getMainDeployer().undeploy(raaFile.toURI().toURL()); removeDeployment(raaFile); }
/** * Deploy * @param raa The resource adapter archive * @exception Throwable If an error occurs */ public void deploy(ResourceAdapterArchive raa) throws Throwable { if (raa == null) throw new IllegalArgumentException("Url is null"); if (!raa.getName().endsWith(".rar")) throw new IllegalArgumentException(raa.getName() + " doesn't end with .rar"); if (!started) throw new IllegalStateException("Container not started"); File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir")); File raaFile = new File(parentDirectory, raa.getName()); if (shrinkwrapDeployments != null && shrinkwrapDeployments.contains(raaFile)) throw new IOException(raa.getName() + " already deployed"); if (raaFile.exists()) recursiveDelete(raaFile); raa.as(ZipExporter.class).exportTo(raaFile, true); if (shrinkwrapDeployments == null) shrinkwrapDeployments = new ArrayList<File>(1); shrinkwrapDeployments.add(raaFile); log.debugf("Deploying: %s", raaFile); kernel.getMainDeployer().deploy(raaFile.toURI().toURL()); }
@Test public void shouldCreateArchiveWithCorrectExtensionForResourceAdapterArchive() throws Exception { ResourceAdapterArchive resourceAdapterArchive = ShrinkWrap.create(ResourceAdapterArchive.class); String archiveExtension = resourceAdapterArchive.getName().substring( resourceAdapterArchive.getName().lastIndexOf(".")); Assert.assertEquals("ResourceAdapterArchive should have proper extension", ".rar", archiveExtension); }
@Test public void shouldCreateResourceAdapterArchiveWithGivenName() throws Exception { String archiveName = "testArchive"; ResourceAdapterArchive resourceAdapterArchive = ShrinkWrap.create(ResourceAdapterArchive.class, archiveName); Assert.assertEquals("ResourceAdapterArchive should have given name", archiveName, resourceAdapterArchive.getName()); }