@Test public void testHornetQExample() throws Exception { ConnectorDescriptor jca10Generated = create() .displayName("Sample Adapter") .description("It is a sample resource adapter") .vendorName("JBoss") .specVersion("1.0") .eisType("Sample") .version("1.0") .getOrCreateLicense() .description("description0") .licenseRequired("true") .up() .getOrCreateResourceadapter() .managedconnectionfactoryClass( "org.jboss.messaging.adapters.jcasample.SampleManagedConnectionFactory") .connectionfactoryInterface("javax.resource.cci.ConnectionFactory") .connectionfactoryImplClass( "org.jboss.messaging.adapters.jcasample.SampleConnectionFactory") .connectionInterface("javax.resource.cci.Connection") .connectionImplClass("org.jboss.messaging.adapters.jcasample.SampleConnection") .transactionSupport("NoTransaction") .createConfigProperty() .configPropertyName("Input") .configPropertyType("java.lang.String") .configPropertyValue("test messages") .up() .createAuthenticationMechanism() .authenticationMechanismType("BasicPassword") .credentialInterface("javax.resource.security.PasswordCredential") .up() .reauthenticationSupport("false") .up(); String generatedRaXml = jca10Generated.exportAsString(); String originalRaXml = this.getResourceContents("src/test/resources/test-orig-connector10.xml"); // System.out.println(generatedRaXml); XmlAssert.assertIdentical(originalRaXml, generatedRaXml); }
@Test public void testHornetQExample() throws Exception { ConnectorDescriptor jca15Generated = create() .addDefaultNamespaces() .version("1.5") .description("HornetQ 2.0 Resource Adapter") .displayName("HornetQ 2.0 Resource Adapter") .vendorName("Red Hat Middleware LLC") .eisType("JMS 1.1 Server") .resourceadapterVersion("1.0") .getOrCreateLicense() .description( "Copyright 2009 Red Hat, Inc. " + "Red Hat licenses this file to you under the Apache License, version " + "2.0 (the \"License\"); you may not use this file except in compliance " + "with the License. You may obtain a copy of the License at " + " http://www.apache.org/licenses/LICENSE-2.0 " + "Unless required by applicable law or agreed to in writing, software " + "distributed under the License is distributed on an \"AS IS\" BASIS, " + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or " + "implied. See the License for the specific language governing " + "permissions and limitations under the License.") .licenseRequired(true) .up() .getOrCreateResourceadapter() .resourceadapterClass("org.hornetq.ra.HornetQResourceAdapter") .createConfigProperty() .description( "The transport type. Multiple connectors can be configured by using a comma separated list, " + "i.e. org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.") .configPropertyName("ConnectorClassName") .configPropertyType("java.lang.String") .configPropertyValue("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory") .up() .createConfigProperty() .description( "The transport configuration. These values must be in the form of key=val;key=val;, " + "if multiple connectors are used then each set must be separated by a comma i.e. host=host1;port=5445,host=host2;port=5446. " + "Each set of params maps to the connector classname specified.") .configPropertyName("ConnectionParameters") .configPropertyType("java.lang.String") .configPropertyValue("server-id=0") .up() .getOrCreateOutboundResourceadapter() .createConnectionDefinition() .managedconnectionfactoryClass("org.hornetq.ra.HornetQRAManagedConnectionFactory") .createConfigProperty() .description("The default session type") .configPropertyName("SessionDefaultType") .configPropertyType("java.lang.String") .configPropertyValue("javax.jms.Queue") .up() .createConfigProperty() .description( "Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality") .configPropertyName("UseTryLock") .configPropertyType("java.lang.Integer") .configPropertyValue("0") .up() .connectionfactoryInterface("org.hornetq.ra.HornetQRAConnectionFactory") .connectionfactoryImplClass("org.hornetq.ra.HornetQRAConnectionFactoryImpl") .connectionInterface("javax.jms.Session") .connectionImplClass("org.hornetq.ra.HornetQRASession") .up() .transactionSupport("XATransaction") .createAuthenticationMechanism() .authenticationMechanismType("BasicPassword") .credentialInterface("javax.resource.spi.security.PasswordCredential") .up() .reauthenticationSupport(false) .up() .getOrCreateInboundResourceadapter() .getOrCreateMessageadapter() .createMessagelistener() .messagelistenerType("javax.jms.MessageListener") .getOrCreateActivationspec() .activationspecClass("org.hornetq.ra.inflow.HornetQActivationSpec") .createRequiredConfigProperty() .configPropertyName("destination") .up() .up() .up() .up() .up() .up(); String generatedRaXml = jca15Generated.exportAsString(); String hornetQRaXml = this.getResourceContents("src/test/resources/test-orig-connector15.xml"); XmlAssert.assertIdentical(hornetQRaXml, generatedRaXml); }
@Test public void testImportGeneratedApplicationXml() throws Exception { ApplicationDescriptor app6Descr = create() .addDefaultNamespaces() .version("6") .applicationName("application-name0") .description("description0") .displayName("display-name0") .createIcon() .smallIcon("small-icon0") .largeIcon("large-icon0") .up() .initializeInOrder("true") .createModule() .ejb("ejb0") .altDd("alt-dd0") .up() .createSecurityRole() .description("description1") .roleName("role-name0") .up() .libraryDirectory("library-directory0") .createEnvEntry() .description("description2") .envEntryName("env-entry-name0") .envEntryType("env-entry-type0") .envEntryValue("env-entry-value0") .mappedName("mapped-name0") .createInjectionTarget() .injectionTargetClass("injection-target-class0") .injectionTargetName("$") .up() .lookupName("lookup-name0") .up() .createEjbRef() .description("description3") .ejbRefName("ejb-ref-name0") .ejbRefType("Entity") .home("home0") .remote("remote0") .ejbLink("ejb-link0") .mappedName("mapped-name1") .createInjectionTarget() .injectionTargetClass("injection-target-class1") .injectionTargetName("$") .up() .lookupName("lookup-name1") .up() .createEjbLocalRef() .description("description4") .ejbRefName("ejb-ref-name1") .ejbRefType("Entity") .localHome("local-home0") .local("local0") .ejbLink("ejb-link1") .mappedName("mapped-name2") .createInjectionTarget() .injectionTargetClass("injection-target-class2") .injectionTargetName("$") .up() .lookupName("lookup-name2") .up() .createServiceRef() .description("description5") .displayName("display-name1") .createIcon() .smallIcon("small-icon1") .largeIcon("large-icon1") .up() .serviceRefName("service-ref-name0") .serviceInterface("service-interface0") .serviceRefType("service-ref-type0") .wsdlFile("http://www.oxygenxml.com/") .jaxrpcMappingFile("jaxrpc-mapping-file0") .serviceQname("qName") .createPortComponentRef() .serviceEndpointInterface("service-endpoint-interface0") .enableMtom(false) .mtomThreshold(50) .getOrCreateAddressing() .enabled(false) .required(false) .responses("ANONYMOUS") .up() .getOrCreateRespectBinding() .enabled(false) .up() .portComponentLink("port-component-link0") .up() .createHandler() .description("description6") .displayName("display-name2") .createIcon() .smallIcon("small-icon2") .largeIcon("large-icon2") .up() .handlerName("handler-name0") .handlerClass("handler-class0") .createInitParam() .description("description7") .paramName("param-name0") .paramValue("param-value0") .up() .soapHeader("qName") .soapRole("soap-role0") .portName("port-name0") .up() .mappedName("mapped-name3") .createInjectionTarget() .injectionTargetClass("injection-target-class3") .injectionTargetName("$") .up() .lookupName("lookup-name3") .up() .createResourceRef() .description("description8") .resRefName("res-ref-name0") .resType("res-type0") .resAuth("Application") .resSharingScope("Shareable") .mappedName("mapped-name4") .createInjectionTarget() .injectionTargetClass("injection-target-class4") .injectionTargetName("$") .up() .lookupName("lookup-name4") .up() .createResourceEnvRef() .description("description9") .resourceEnvRefName("resource-env-ref-name0") .resourceEnvRefType("resource-env-ref-type0") .mappedName("mapped-name5") .createInjectionTarget() .injectionTargetClass("injection-target-class5") .injectionTargetName("$") .up() .lookupName("lookup-name5") .up() .createMessageDestinationRef() .description("description10") .messageDestinationRefName("message-destination-ref-name0") .messageDestinationType("message-destination-type0") .messageDestinationUsage("Consumes") .messageDestinationLink("message-destination-link0") .mappedName("mapped-name6") .createInjectionTarget() .injectionTargetClass("injection-target-class6") .injectionTargetName("$") .up() .lookupName("lookup-name6") .up() .createPersistenceContextRef() .description("description11") .persistenceContextRefName("persistence-context-ref-name0") .persistenceUnitName("persistence-unit-name0") .persistenceContextType("Transaction") .createPersistenceProperty() .name("name0") .value("value0") .up() .mappedName("mapped-name7") .createInjectionTarget() .injectionTargetClass("injection-target-class7") .injectionTargetName("$") .up() .up() .createPersistenceUnitRef() .description("description12") .persistenceUnitRefName("persistence-unit-ref-name0") .persistenceUnitName("persistence-unit-name1") .mappedName("mapped-name8") .createInjectionTarget() .injectionTargetClass("injection-target-class8") .injectionTargetName("$") .up() .up() .createMessageDestination() .description("description13") .displayName("display-name3") .createIcon() .smallIcon("small-icon3") .largeIcon("large-icon3") .up() .messageDestinationName("message-destination-name0") .mappedName("mapped-name9") .lookupName("lookup-name7") .up() .createDataSource() .description("description14") .name("name1") .className("class-name0") .serverName("server-name0") .portNumber(0) .databaseName("database-name0") .url("jdbc::") .user("user0") .password("password0") .createProperty() .name("name2") .value("value1") .up() .loginTimeout(0) .transactional(false) .isolationLevel("TRANSACTION_READ_UNCOMMITTED") .initialPoolSize(0) .maxPoolSize(0) .minPoolSize(0) .maxIdleTime(0) .maxStatements(0) .up(); String appXmlOriginal = getResourceContents("src/test/resources/test-gen-application6.xml"); String appXmlGenerated = app6Descr.exportAsString(); XmlAssert.assertIdentical(appXmlOriginal, appXmlGenerated); }