[jboss-svn-commits] JBL Code SVN: r17261 - in labs/jbossesb/trunk/product: samples/quickstarts/transform_XML2XML_stream and 13 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Dec 15 15:04:05 EST 2007
Author: beve
Date: 2007-12-15 15:04:05 -0500 (Sat, 15 Dec 2007)
New Revision: 17261
Added:
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/SampleOrder.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/deployment.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbm-queue-service.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbmq-queue-service.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbossesb-properties.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jndi.properties
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/juddi.properties
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/log4j.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/readme.txt
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/smooks-res.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/test/
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/test/SendJMSMessage.java
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitor.java
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/ServiceDelegator.java
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitorUnitTest.java
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/SampleOrder.xml
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/ServiceDelegatorUnitTest.java
Log:
Work for Jira JBESB-1411, "Smooks DOMVisitor that sends the Element object to an ESB Service"
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/SampleOrder.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/SampleOrder.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/SampleOrder.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,19 @@
+<Order orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0" netAmount="59.97" totalAmount="64.92" tax="4.95">
+ <Customer userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
+ <OrderLines>
+ <OrderLine position="1" quantity="1">
+ <Product productId="364" title="The 40-Year-Old Virgin " price="29.98"/>
+ </OrderLine>
+ <OrderLine position="2" quantity="1">
+ <Product productId="299" title="Pulp Fiction" price="29.99"/>
+ </OrderLine>
+ </OrderLines>
+ <OrderLines>
+ <OrderLine position="6" quantity="1">
+ <Product productId="324" title="Fletch" price="99.99"/>
+ </OrderLine>
+ <OrderLine position="8" quantity="1">
+ <Product productId="400" title="Fletch Lives" price="99.99"/>
+ </OrderLine>
+ </OrderLines>
+</Order>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/build.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/build.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,20 @@
+<project name="transformation-stream-quickstart" default="deploy" basedir=".">
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <property name="additional.deploys" value="smooks-cdr.lst,smooks-res.xml" />
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
+ <target name="runtest" depends="compile" description="runs Test JMS Sender">
+ <echo>Runs Test JMS Sender</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.transformxml2xmlstream.test.SendJMSMessage" failonerror="true">
+ <arg value="SampleOrder.xml" />
+ <classpath refid="exec-classpath" />
+ </java>
+ </target>
+
+</project>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/deployment.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/deployment.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,6 @@
+<jbossesb-deployment>
+ <depends>jboss.esb:deployment=smooks.esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_gw</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_response</depends>
+</jbossesb-deployment>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbm-queue-service.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbm-queue-service.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_gw"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_esb"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_esb2"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_response"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbmq-queue-service.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbmq-queue-service.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_gw">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_esb">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_esb2">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_transform_stream_response">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+ </mbean>
+</server>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jboss-esb.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jboss-esb.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,61 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
+ xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMQ"
+ connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost">
+
+ <jms-bus busid="quickstartGwChannel">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_transform_stream_gw" />
+ </jms-bus>
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_transform_stream_esb" />
+ </jms-bus>
+
+ <jms-bus busid="quickstartEsbChannel2">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_transform_stream_esb2" />
+ </jms-bus>
+
+ </jms-provider>
+ </providers>
+
+ <services>
+
+ <service category="FirstServiceESB" name="SimpleListener"
+ description="Hello World">
+ <listeners>
+ <jms-listener name="JMS-Gateway" busidref="quickstartGwChannel" maxThreads="1" is-gateway="true"/>
+ <jms-listener name="quickstart" busidref="quickstartEsbChannel" maxThreads="1" />
+ </listeners>
+ <actions mep="OneWay">
+ <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="[transform_XML2XML_simple] Message before transformation" />
+ </action>
+ <action name="simple-transform" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <property name="resource-config" value="/smooks-res.xml" />
+ </action>
+ <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="[transform_XML2XML_simple] Message after transformation" />
+ </action>
+ </actions>
+ </service>
+
+ <service category="FirstServiceESB" name="SendToJMSQueue" description="Routes the ESB Message to a JMS Queue">
+ <listeners>
+ <jms-listener name="jmsRouterListener" busidref="quickstartEsbChannel2" maxThreads="1" />
+ </listeners>
+ <actions mep="OneWay">
+ <action name="Router" class="org.jboss.soa.esb.actions.routing.JMSRouter">
+ <property name="jndiName" value="/queue/quickstart_transform_stream_response"/>
+ <property name="unwrap" value="true"/>
+ <property name="persistent" value="true"/>
+ </action>
+ </actions>
+ </service>
+
+ </services>
+
+</jbossesb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jbossesb-properties.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and others contributors as indicated
+ by the @authors tag. All rights reserved.
+ See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU Lesser General Public License, v. 2.1.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI"
+ value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"
+ value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+ <property name="org.jboss.soa.esb.registry.implementationClass"
+ value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass"
+ value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user"
+ value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password"
+ value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass"
+ value="org.apache.ws.scout.transport.RMITransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <!-- # of milliseconds to timeout waiting for a connection from pool -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+ <properties name="transformation">
+ <property name="java.naming.provider.url" value="localhost"/>
+ </properties>
+</esb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jndi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jndi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/jndi.properties 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/juddi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/juddi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/juddi.properties 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/log4j.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/log4j.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="WARN"/>
+ </category>
+ <category name="org.jboss.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.milyn">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.jboss.internal.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.apache">
+ <priority value="ERROR"/>
+ </category>
+ <category name="quickstart">
+ <priority value="INFO"/>
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/readme.txt (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/readme.txt 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,64 @@
+Overview:
+=========
+ This is a very basic example of how to "stream" a fragment of a transformation
+ to an ESB Service. The trick behind this is using a Smooks DOMVisitor (a SAXVisitor
+ will soon appear) that send the element it is passed in its visitBefore and/or
+ visitAfter. For more information about Smooks visitor see Smooks User Guide:
+ http://milyn.codehaus.org/Smooks+User+Guide
+
+ Check out the Administration Console Flash demos at:
+ http://labs.jboss.com/portal/jbossesb/resources/tutorials/xformation-demos/console-demos.html
+
+Running this quickstart:
+========================
+ Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+ and a more detailed descripton of the different ways to run the quickstarts.
+
+ A comprehensive description of message transformation can be found in
+ MessageTransformation.pdf, located in the docs/services folder.
+
+To Run standalone mode:
+=======================
+ 1. In a command terminal window in the quickstart folder type
+ 'ant deploy-jms-dests'.
+ 2. In a command terminal window in this folder ("Window1"), type 'ant run'.
+ 3. Open another command terminal window in this folder ("Window2"), type
+ 'ant runtest'.
+ 4. Switch back to "Window1" to see the output from the ESB
+ 5. When finished, interrupt the ESB using Ctrl-C and, in this folder
+ ("Window1"), type 'ant undeploy-jms-dests'.
+
+To Run '.esb' archive mode:
+===========================
+ 1. In a command terminal window in this folder ("Window1"), type 'ant deploy'.
+ 2. Open another command terminal window in this folder ("Window2"), type
+ 'ant runtest'.
+ 3. Switch back to Application Server console to see the output from the ESB
+ 4. In this folder ("Window1"), type 'ant undeploy'.
+
+What to look at in this Quickstart:
+===================================
+ As stated above, reading MessageTransformation.pdf would be of great benefit
+ in understanding JBoss ESB Transformations.
+
+ jboss-esb.xml:
+ The ESB configuration file in this Quickstart simply defines a JMS Listener
+ for receiving the contents of the SampleOrder.xml file located in this
+ folder. This XML message will be transformed by this service.
+
+ smooks-res.xml:
+ This file defines the Transformations for the Quickstart. This is where
+ we configure the DOMVisitor:
+ <resource-config selector="OrderLines">
+ <resource>org.jboss.soa.esb.visitors.DOMServiceDelegateVisitor</resource>
+ <param name="service-category-name">FirstServiceESB</param>
+ <param name="service-name">sendToJMSQueue</param>
+ <param name="send-in-visit-after">true</param>
+ </resource-config>
+ When Smooks finds a match for the selector OrderLines (the transformed OrderLines fragment)
+ it will invoke the DOMServiceDelegateVisitor's visitAfter() method. visitAfter contains the
+ logic to wrap the Element pass to it in an ESB Message object and send that object to the
+ configured service.
+ Any number of Visitors can be added and you can do all sorts of things in them.
+
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/smooks-res.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/smooks-res.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/smooks-res.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,24 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+
+ <resource-config selector="OrderLines">
+ <resource>org.jboss.soa.esb.visitors.DOMServiceDelegateVisitor</resource>
+ <param name="service-category-name">FirstServiceESB</param>
+ <param name="service-name">sendToJMSQueue</param>
+ <param name="send-in-visit-after">true</param>
+ </resource-config>
+
+ <resource-config selector="OrderLines OrderLine">
+ <resource type="xsl">
+ <![CDATA[<line-item>
+ <product><xsl:value-of select="./Product/@productId" /></product>
+ <price><xsl:value-of select="./Product/@price" /></price>
+ <quantity><xsl:value-of select="@quantity" /></quantity>
+ </line-item>]]>
+ </resource>
+ <param name="is-xslt-templatelet">true</param>
+ </resource-config>
+
+
+
+</smooks-resource-list>
Added: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_stream/src/org/jboss/soa/esb/samples/quickstart/transformxml2xmlstream/test/SendJMSMessage.java 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.transformxml2xmlstream.test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Scanner;
+import java.io.OutputStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.ErrorListener;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.soa.esb.util.FileUtil;
+import org.jboss.soa.esb.util.Util;
+
+public class SendJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+ Queue response;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/quickstart_transform_stream_gw");
+ response = (Queue) iniCtx.lookup("queue/quickstart_transform_stream_response");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public void sendAMessage(String fileName) throws JMSException, FileNotFoundException, IOException {
+
+ QueueSender send = session.createSender(que);
+ ObjectMessage tm;
+ File file = new File(fileName);
+
+ if(!file.exists()) {
+ throw new IllegalArgumentException("Input message file [" + file.getAbsolutePath() + "] not found.");
+ }
+
+ String message = FileUtil.readTextFile(file);
+
+ tm = session.createObjectMessage(message);
+ tm.setStringProperty("jbesbfilename", "transformedmessageXML2Simple.log");
+ send.send(tm);
+ send.close();
+
+ System.out.println("*** Switch back to the ESB Java console now to see '" + fileName + "' before and after the transformation...");
+ }
+
+ public void receiveFromResponseQueue() throws JMSException, IOException
+ {
+ MessageConsumer consumer = session.createConsumer( response );
+ consumer.setMessageListener( new MessageListener() {
+ public void onMessage( Message msg )
+ {
+ try
+ {
+ ObjectMessage objectMessage = (ObjectMessage) msg;
+ System.out.println( "Received msg : " );
+ printPretty( (Element)objectMessage.getObject(), System.out );
+ System.out.println( "" );
+ }
+ catch( JMSException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ System.out.println( "Waiting for messages from response queue (Press q to exit)" );
+ while ( true )
+ {
+ Scanner sc = new Scanner(System.in);
+ if ( sc.hasNext( "q" ) )
+ break;
+ }
+ consumer.close();
+ }
+
+
+ public static void main(String args[]) throws Exception
+ {
+ SendJMSMessage sm = new SendJMSMessage();
+ sm.setupConnection();
+ sm.sendAMessage(args[0]);
+ sm.receiveFromResponseQueue();
+ sm.stop();
+ }
+
+ public static void printPretty( final Element element, final OutputStream out )
+ {
+ TransformerFactory tfactory = TransformerFactory.newInstance();
+ try
+ {
+ tfactory.setAttribute("indent-number", new Integer(4));
+ }
+ catch (Exception e) {/*ignore*/ }
+
+ Transformer serializer;
+ try {
+ serializer = tfactory.newTransformer();
+ serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ serializer.transform(new DOMSource(element), new StreamResult(out));
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitor.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitor.java (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitor.java 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.visitors;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.milyn.SmooksException;
+import org.milyn.cdr.SmooksConfigurationException;
+import org.milyn.cdr.SmooksResourceConfiguration;
+import org.milyn.container.ExecutionContext;
+import org.milyn.delivery.dom.DOMElementVisitor;
+import org.w3c.dom.Element;
+
+/**
+ * DomServiceDelegatorVisitor is a Smooks vistor which wraps
+ * the element object in an ESB Message object and then sends
+ * the message to the configured ESB Service.
+ * <p>
+ * Sample config (smooks-res.xml) :
+ * <pre>
+ * <resource-config selector="OrderLines">
+ * <resource>org.jboss.soa.esb.visitors.DOMServiceDelegateVisitor</resource>
+ * <param name="service-category-name">FirstServiceESB</param>
+ * <param name="service-name">sendToJMSQueue</param>
+ * <param name="send-in-visit-after">true</param>
+ * </pre>
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class DOMServiceDelegateVisitor implements DOMElementVisitor
+{
+ private Logger log = Logger.getLogger( DOMServiceDelegateVisitor.class );
+
+ public static final String SEND_IN_VISIT_BEFORE = "send-in-visit-before";
+ public static final String SEND_IN_VISIT_AFTER = "send-in-visit-after";
+
+ private ServiceDelegator serviceDelegator;
+
+ private boolean sendInVisitAfter;
+ private boolean sendInVisitBefore;
+
+ public DOMServiceDelegateVisitor()
+ {
+ serviceDelegator = new ServiceDelegator();
+ }
+
+ public void visitAfter( Element element, ExecutionContext executionContext ) throws SmooksException
+ {
+ if ( sendInVisitAfter )
+ sendToService( element );
+ }
+
+ public void visitBefore( Element element, ExecutionContext executionContext ) throws SmooksException
+ {
+ if ( sendInVisitBefore )
+ sendToService( element );
+ }
+
+ protected void sendToService( final Element element ) throws SmooksException
+ {
+ try
+ {
+ serviceDelegator.delegateToESBService( createMessage( element ) );
+ }
+ catch (MessageDeliverException e)
+ {
+ String errorMsg = "MessageDeliveryException in visitAfter: ";
+ log.error( errorMsg , e );
+ throw new SmooksException( errorMsg, e );
+ }
+ }
+
+ public void setConfiguration( SmooksResourceConfiguration config ) throws SmooksConfigurationException
+ {
+ serviceDelegator.setConfiguration( config );
+
+ sendInVisitAfter = Boolean.parseBoolean( config.getStringParameter( SEND_IN_VISIT_AFTER , "false" ) );
+ sendInVisitBefore = Boolean.parseBoolean( config.getStringParameter( SEND_IN_VISIT_BEFORE , "false" ) );
+
+ if ( sendInVisitBefore == false && sendInVisitAfter == false )
+ throw new SmooksConfigurationException ("Atleast one of [" + SEND_IN_VISIT_BEFORE + "] and [" + SEND_IN_VISIT_AFTER + "] must be true" );
+ }
+
+ protected Message createMessage( final Element element )
+ {
+ Message message = MessageFactory.getInstance().getMessage();
+ message.getBody().add( element );
+ return message;
+ }
+
+ public ServiceDelegator getServiceDelegator()
+ {
+ return serviceDelegator;
+ }
+
+ public void setServiceDelegator( ServiceDelegator serviceDelegator )
+ {
+ this.serviceDelegator = serviceDelegator;
+ }
+
+}
Added: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/ServiceDelegator.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/ServiceDelegator.java (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/visitors/ServiceDelegator.java 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.visitors;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.milyn.cdr.SmooksConfigurationException;
+import org.milyn.cdr.SmooksResourceConfiguration;
+
+/**
+ * ServiceDelegateVisitor is a Smooks visitor that delegates to
+ * a JBoss ESB service.
+ * <p>
+ * Sample config (smooks-res.xml) :
+ * <pre>
+ * <param name="service-category-name">FirstServiceESB</param>
+ * <param name="service-name">sendToJMSQueue</param>
+ * </pre>
+ *
+ * This class is intended to be used as a delegator for Smooks Visitors,
+ * like a DOMVisitor or a SAXVisitor.
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class ServiceDelegator
+{
+ private Logger log = Logger.getLogger( ServiceDelegator.class );
+
+ public static final String SERVICE_NAME_ATTR = "service-name";
+ public static final String SERVICE_CATEGORY_NAME_ATTR = "service-category-name";
+
+ private String serviceCategoryName;
+ private String serviceName;
+
+ private SmooksResourceConfiguration resourceConfig;
+ private ServiceInvoker serviceInvoker;
+
+ public void setConfiguration( SmooksResourceConfiguration config ) throws SmooksConfigurationException
+ {
+ if ( config == null )
+ throw new SmooksConfigurationException( " SmooksResourceConfig was null." );
+
+ resourceConfig = config;
+
+ serviceCategoryName = resourceConfig.getStringParameter( SERVICE_CATEGORY_NAME_ATTR );
+ if ( serviceCategoryName == null )
+ throw new SmooksConfigurationException( "[" + SERVICE_CATEGORY_NAME_ATTR + "] must be set.");
+
+ serviceName = resourceConfig.getStringParameter( SERVICE_NAME_ATTR );
+ if ( serviceName == null )
+ throw new SmooksConfigurationException( "[" + SERVICE_NAME_ATTR + "] must be set.");
+ try
+ {
+ serviceInvoker = createServiceInvoker( serviceCategoryName, serviceName );
+ }
+ catch (MessageDeliverException e)
+ {
+ log.error( "Could not create a ServiceInvoker", e );
+ throw new SmooksConfigurationException ( e );
+ }
+ }
+
+ public Message delegateToESBServiceSync( final Message message, final long timeout ) throws FaultMessageException, MessageDeliverException, RegistryException
+ {
+ Message returnedMessage = null;
+ if ( message != null )
+ returnedMessage = serviceInvoker.deliverSync( message, timeout );
+
+ return returnedMessage;
+ }
+
+ public void delegateToESBService( final Message message ) throws MessageDeliverException
+ {
+ if ( message != null )
+ serviceInvoker.deliverAsync( message );
+ }
+
+ public String getServiceCategoryName()
+ {
+ return serviceCategoryName;
+ }
+
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
+ protected ServiceInvoker createServiceInvoker( final String serviceCategoryName, final String serviceName ) throws MessageDeliverException
+ {
+ return new ServiceInvoker( serviceCategoryName, serviceName );
+ }
+
+}
Added: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitorUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/DOMServiceDelegateVisitorUnitTest.java 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.visitors;
+
+import static org.jboss.soa.esb.visitors.ServiceDelegator.SERVICE_CATEGORY_NAME_ATTR;
+import static org.jboss.soa.esb.visitors.ServiceDelegator.SERVICE_NAME_ATTR;
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.junit.Before;
+import org.junit.Test;
+import org.milyn.cdr.SmooksConfigurationException;
+import org.milyn.cdr.SmooksResourceConfiguration;
+
+/**
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class DOMServiceDelegateVisitorUnitTest
+{
+ private DOMServiceDelegateVisitor visitor;
+ private SmooksResourceConfiguration resourceConfig;
+
+ private String serviceCategoryName = "testCategoryName";
+ private String serviceName = "testServiceName";
+
+ @Test ( expected = SmooksConfigurationException.class )
+ public void setConfigurationNegative()
+ {
+ resourceConfig.setParameter( SERVICE_CATEGORY_NAME_ATTR, serviceCategoryName );
+ resourceConfig.setParameter( SERVICE_NAME_ATTR, serviceName );
+ visitor.setConfiguration( resourceConfig );
+ }
+
+ @Test
+ public void setConfiguration()
+ {
+ resourceConfig.setParameter( SERVICE_CATEGORY_NAME_ATTR, serviceCategoryName );
+ resourceConfig.setParameter( SERVICE_NAME_ATTR, serviceName );
+ resourceConfig.setParameter( DOMServiceDelegateVisitor.SEND_IN_VISIT_AFTER, "true" );
+ visitor.setConfiguration( resourceConfig );
+ }
+
+ @Before
+ public void createServiceDelegatVistorInstance() throws MessageDeliverException
+ {
+ visitor = new DOMServiceDelegateVisitor();
+ ServiceDelegator invoker = new ServiceDelegator() {
+ protected ServiceInvoker createServiceInvoker( String serviceCategoryName, String serviceName ) throws MessageDeliverException
+ {
+ return null;
+ }
+ };
+ visitor.setServiceDelegator( invoker );
+ }
+
+ @Before
+ public void createSmooksResourceConfiguration()
+ {
+ final String resource = ServiceDelegator.class.getName();
+ resourceConfig = new SmooksResourceConfiguration( "Order", resource );
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( DOMServiceDelegateVisitorUnitTest.class );
+ }
+}
Added: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/SampleOrder.xml
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/SampleOrder.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/SampleOrder.xml 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,11 @@
+<Order orderId="1" orderDate="Wed Nov 15 13:45:28 EST 2006" statusCode="0" netAmount="59.97" totalAmount="64.92" tax="4.95">
+ <Customer userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
+ <OrderLines>
+ <OrderLine position="1" quantity="1">
+ <Product productId="364" title="The 40-Year-Old Virgin " price="29.98"/>
+ </OrderLine>
+ <OrderLine position="2" quantity="1">
+ <Product productId="299" title="Pulp Fiction" price="29.99"/>
+ </OrderLine>
+ </OrderLines>
+</Order>
Added: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/ServiceDelegatorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/ServiceDelegatorUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/visitors/ServiceDelegatorUnitTest.java 2007-12-15 20:04:05 UTC (rev 17261)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.visitors;
+
+import static org.jboss.soa.esb.visitors.ServiceDelegator.SERVICE_CATEGORY_NAME_ATTR;
+import static org.jboss.soa.esb.visitors.ServiceDelegator.SERVICE_NAME_ATTR;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.junit.Before;
+import org.junit.Test;
+import org.milyn.cdr.SmooksConfigurationException;
+import org.milyn.cdr.SmooksResourceConfiguration;
+import org.xml.sax.SAXException;
+
+/**
+ * Test Smooks JBoss ESB ServiceDelegatorVisitor
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class ServiceDelegatorUnitTest
+{
+ private static final String SELECTOR = "Order";
+
+ private ServiceDelegator visitor;
+ private SmooksResourceConfiguration resourceConfig;
+
+ private String serviceCategoryName = "testCategoryName";
+ private String serviceName = "testServiceName";
+
+ @Test ( expected = SmooksConfigurationException.class )
+ public void setServiceNameNegative() throws SAXException, IOException
+ {
+ resourceConfig.setParameter( SERVICE_CATEGORY_NAME_ATTR, serviceCategoryName );
+ visitor.setConfiguration( resourceConfig );
+ fail( SERVICE_NAME_ATTR + " should be allowed to be null. Excepteded SmooksConfigurationException" );
+ }
+
+ @Test ( expected = SmooksConfigurationException.class )
+ public void setServiceCategoryNameNegative() throws SAXException, IOException
+ {
+ resourceConfig.setParameter( SERVICE_NAME_ATTR, serviceName );
+ visitor.setConfiguration( resourceConfig );
+ fail( SERVICE_CATEGORY_NAME_ATTR + " should be allowed to be null. Excepteded SmooksConfigurationException" );
+ }
+
+ @Test
+ public void setServiceCategoryNameAndServiceName() throws SAXException, IOException
+ {
+ resourceConfig.setParameter( SERVICE_CATEGORY_NAME_ATTR, serviceCategoryName );
+ resourceConfig.setParameter( SERVICE_NAME_ATTR, serviceName );
+ resourceConfig.setParameter( DOMServiceDelegateVisitor.SEND_IN_VISIT_AFTER, "true" );
+ visitor.setConfiguration( resourceConfig );
+
+ assertEquals( serviceCategoryName, visitor.getServiceCategoryName() );
+ assertEquals( serviceName, visitor.getServiceName() );
+ }
+
+ @Before
+ public void createServiceDelegatVistorInstance() throws MessageDeliverException
+ {
+ visitor = new ServiceDelegator() {
+ @Override
+ protected ServiceInvoker createServiceInvoker( String serviceCategoryName, String serviceName ) throws MessageDeliverException
+ {
+ return null;
+ }
+ };
+ }
+
+ @Before
+ public void createSmooksResourceConfiguration()
+ {
+ final String resource = ServiceDelegator.class.getName();
+ resourceConfig = new SmooksResourceConfiguration( SELECTOR, resource );
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( ServiceDelegatorUnitTest.class );
+ }
+}
More information about the jboss-svn-commits
mailing list