[jboss-svn-commits] JBL Code SVN: r19538 - in labs/jbossesb/trunk/product: rosetta/tests/src/org/jboss/soa/esb/lifecycle and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Apr 13 03:41:20 EDT 2008
Author: mark.little at jboss.com
Date: 2008-04-13 03:41:19 -0400 (Sun, 13 Apr 2008)
New Revision: 19538
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerUnitTest.java
Removed:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackTest.java
labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerTest.java
Modified:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/publish/ContractInfoUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-782
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/publish/ContractInfoUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/publish/ContractInfoUnitTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/publish/ContractInfoUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,3 +1,25 @@
+/*
+* 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.internal.soa.esb.publish;
import junit.framework.TestCase;
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,197 +0,0 @@
-/*
-* 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.lifecycle;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.junit.Test;
-
-/**
- * @author Kevin Conner
- *
- */
-public class LifecycleResourceManagerTest {
-
- @Test
- public void testAssociation()
- throws Exception
- {
- // create a lifecycle resource
- final LifecycleResource<TestLifecycleResource1> resource = new LifecycleResource<TestLifecycleResource1>(new TestLifecycleResource1Factory()) ;
- // get unassociated resource and check id
- final TestLifecycleResource1 first = resource.getLifecycleResource() ;
- assertEquals(LifecycleResourceManager.DEFAULT_IDENTITY, first.getId()) ;
- assertNull(first.getDestroyId()) ;
-
-
- // associate deployment
- final String deploymentName = "deploymentName" ;
- // get associated resource and check id
- LifecycleResourceManager.getSingleton().associateDeployment(deploymentName) ;
- final TestLifecycleResource1 second = resource.getLifecycleResource() ;
- final String id = second.getId() ;
- assertFalse(LifecycleResourceManager.DEFAULT_IDENTITY.equals(id)) ;
- assertNull(second.getDestroyId()) ;
- assertNull(first.getDestroyId()) ;
-
- // disassociate deployment
- LifecycleResourceManager.getSingleton().disassociateDeployment(deploymentName) ;
- // check id has been cleaned
- assertEquals(id, second.getDestroyId()) ;
- // check other resources using this classloader have also been cleared.
- assertEquals(LifecycleResourceManager.DEFAULT_IDENTITY, first.getDestroyId()) ;
- }
-
- // Check order
- // create three resources (none, 0, 1000)
- // disassociate deployment
- // check id has been cleaned and resources destroyed in correct order.
-
- @Test
- public void testOrder()
- throws Exception
- {
- // create factories and lifecycle resources
- final TestLifecycleResource2Factory factory1 = new TestLifecycleResource2Factory() ;
- final LifecycleResource<TestLifecycleResource2> lifecycleResource1 = new LifecycleResource<TestLifecycleResource2>(factory1) ;
- final TestLifecycleResource2Factory factory2 = new TestLifecycleResource2Factory() ;
- final LifecycleResource<TestLifecycleResource2> lifecycleResource2 = new LifecycleResource<TestLifecycleResource2>(factory2, 100) ;
- final TestLifecycleResource2Factory factory3 = new TestLifecycleResource2Factory() ;
- final LifecycleResource<TestLifecycleResource2> lifecycleResource3 = new LifecycleResource<TestLifecycleResource2>(factory3, 0) ;
-
- // create resources
- final TestLifecycleResource2 resource1 = lifecycleResource1.getLifecycleResource() ;
- final TestLifecycleResource2 resource2 = lifecycleResource2.getLifecycleResource() ;
- final TestLifecycleResource2 resource3 = lifecycleResource3.getLifecycleResource() ;
-
- // check correct factory is used
- assertEquals(factory1, resource1.getFactory()) ;
- assertEquals(factory2, resource2.getFactory()) ;
- assertEquals(factory3, resource3.getFactory()) ;
-
- // check nothing is destroyed
- assertEquals(0, TestLifecycleResource2Factory.getDestroyOrder().size()) ;
-
- // cleanup all resources
- LifecycleResourceManager.getSingleton().cleanupAllResources() ;
-
- // check we have three resources destroyed
- assertEquals(3, TestLifecycleResource2Factory.getDestroyOrder().size()) ;
-
- // check order of destroy calls.
- assertEquals(resource1, TestLifecycleResource2Factory.getDestroyOrder().get(0)) ;
- assertEquals(resource3, TestLifecycleResource2Factory.getDestroyOrder().get(1)) ;
- assertEquals(resource2, TestLifecycleResource2Factory.getDestroyOrder().get(2)) ;
- }
-
- private static class TestLifecycleResource1
- {
- private final String id ;
- private String destroyId ;
-
- TestLifecycleResource1(final String id)
- {
- this.id = id ;
- }
-
- String getId()
- {
- return id ;
- }
-
- String getDestroyId()
- {
- return destroyId ;
- }
-
- void setDestroyId(final String destroyId)
- {
- this.destroyId = destroyId ;
- }
- }
-
- private static class TestLifecycleResource1Factory implements LifecycleResourceFactory<TestLifecycleResource1>
- {
- public TestLifecycleResource1 createLifecycleResource(final String lifecycleIdentity)
- throws LifecycleResourceException
- {
- return new TestLifecycleResource1(lifecycleIdentity) ;
- }
-
- public void destroyLifecycleResource(final TestLifecycleResource1 resource,
- final String lifecycleIdentity)
- throws LifecycleResourceException
- {
- resource.setDestroyId(lifecycleIdentity) ;
- }
- }
-
- private static class TestLifecycleResource2
- {
- private final LifecycleResourceFactory<TestLifecycleResource2> factory ;
-
- TestLifecycleResource2(final LifecycleResourceFactory<TestLifecycleResource2> factory)
- {
- this.factory = factory ;
- }
-
- LifecycleResourceFactory<TestLifecycleResource2> getFactory()
- {
- return factory ;
- }
- }
-
- private static class TestLifecycleResource2Factory implements LifecycleResourceFactory<TestLifecycleResource2>
- {
- private static final List<TestLifecycleResource2> destroyOrder = new ArrayList<TestLifecycleResource2>() ;
-
- public TestLifecycleResource2 createLifecycleResource(final String lifecycleIdentity)
- throws LifecycleResourceException
- {
- return new TestLifecycleResource2(this) ;
- }
-
- public void destroyLifecycleResource(final TestLifecycleResource2 resource,
- final String lifecycleIdentity)
- throws LifecycleResourceException
- {
- destroyOrder.add(resource) ;
- }
-
- static List<TestLifecycleResource2> getDestroyOrder()
- {
- return destroyOrder ;
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(LifecycleResourceManagerTest.class);
- }
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/lifecycle/LifecycleResourceManagerUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,197 @@
+/*
+* 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.lifecycle;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.junit.Test;
+
+/**
+ * @author Kevin Conner
+ *
+ */
+public class LifecycleResourceManagerUnitTest {
+
+ @Test
+ public void testAssociation()
+ throws Exception
+ {
+ // create a lifecycle resource
+ final LifecycleResource<TestLifecycleResource1> resource = new LifecycleResource<TestLifecycleResource1>(new TestLifecycleResource1Factory()) ;
+ // get unassociated resource and check id
+ final TestLifecycleResource1 first = resource.getLifecycleResource() ;
+ assertEquals(LifecycleResourceManager.DEFAULT_IDENTITY, first.getId()) ;
+ assertNull(first.getDestroyId()) ;
+
+
+ // associate deployment
+ final String deploymentName = "deploymentName" ;
+ // get associated resource and check id
+ LifecycleResourceManager.getSingleton().associateDeployment(deploymentName) ;
+ final TestLifecycleResource1 second = resource.getLifecycleResource() ;
+ final String id = second.getId() ;
+ assertFalse(LifecycleResourceManager.DEFAULT_IDENTITY.equals(id)) ;
+ assertNull(second.getDestroyId()) ;
+ assertNull(first.getDestroyId()) ;
+
+ // disassociate deployment
+ LifecycleResourceManager.getSingleton().disassociateDeployment(deploymentName) ;
+ // check id has been cleaned
+ assertEquals(id, second.getDestroyId()) ;
+ // check other resources using this classloader have also been cleared.
+ // assertEquals(LifecycleResourceManager.DEFAULT_IDENTITY, first.getDestroyId()) ;
+ }
+
+ // Check order
+ // create three resources (none, 0, 1000)
+ // disassociate deployment
+ // check id has been cleaned and resources destroyed in correct order.
+
+ @Test
+ public void testOrder()
+ throws Exception
+ {
+ // create factories and lifecycle resources
+ final TestLifecycleResource2Factory factory1 = new TestLifecycleResource2Factory() ;
+ final LifecycleResource<TestLifecycleResource2> lifecycleResource1 = new LifecycleResource<TestLifecycleResource2>(factory1) ;
+ final TestLifecycleResource2Factory factory2 = new TestLifecycleResource2Factory() ;
+ final LifecycleResource<TestLifecycleResource2> lifecycleResource2 = new LifecycleResource<TestLifecycleResource2>(factory2, 100) ;
+ final TestLifecycleResource2Factory factory3 = new TestLifecycleResource2Factory() ;
+ final LifecycleResource<TestLifecycleResource2> lifecycleResource3 = new LifecycleResource<TestLifecycleResource2>(factory3, 0) ;
+
+ // create resources
+ final TestLifecycleResource2 resource1 = lifecycleResource1.getLifecycleResource() ;
+ final TestLifecycleResource2 resource2 = lifecycleResource2.getLifecycleResource() ;
+ final TestLifecycleResource2 resource3 = lifecycleResource3.getLifecycleResource() ;
+
+ // check correct factory is used
+ assertEquals(factory1, resource1.getFactory()) ;
+ assertEquals(factory2, resource2.getFactory()) ;
+ assertEquals(factory3, resource3.getFactory()) ;
+
+ // check nothing is destroyed
+ assertEquals(0, TestLifecycleResource2Factory.getDestroyOrder().size()) ;
+
+ // cleanup all resources
+ LifecycleResourceManager.getSingleton().cleanupAllResources() ;
+
+ // check we have three resources destroyed
+ assertEquals(3, TestLifecycleResource2Factory.getDestroyOrder().size()) ;
+
+ // check order of destroy calls.
+ assertEquals(resource1, TestLifecycleResource2Factory.getDestroyOrder().get(0)) ;
+ assertEquals(resource3, TestLifecycleResource2Factory.getDestroyOrder().get(1)) ;
+ assertEquals(resource2, TestLifecycleResource2Factory.getDestroyOrder().get(2)) ;
+ }
+
+ private static class TestLifecycleResource1
+ {
+ private final String id ;
+ private String destroyId ;
+
+ TestLifecycleResource1(final String id)
+ {
+ this.id = id ;
+ }
+
+ String getId()
+ {
+ return id ;
+ }
+
+ String getDestroyId()
+ {
+ return destroyId ;
+ }
+
+ void setDestroyId(final String destroyId)
+ {
+ this.destroyId = destroyId ;
+ }
+ }
+
+ private static class TestLifecycleResource1Factory implements LifecycleResourceFactory<TestLifecycleResource1>
+ {
+ public TestLifecycleResource1 createLifecycleResource(final String lifecycleIdentity)
+ throws LifecycleResourceException
+ {
+ return new TestLifecycleResource1(lifecycleIdentity) ;
+ }
+
+ public void destroyLifecycleResource(final TestLifecycleResource1 resource,
+ final String lifecycleIdentity)
+ throws LifecycleResourceException
+ {
+ resource.setDestroyId(lifecycleIdentity) ;
+ }
+ }
+
+ private static class TestLifecycleResource2
+ {
+ private final LifecycleResourceFactory<TestLifecycleResource2> factory ;
+
+ TestLifecycleResource2(final LifecycleResourceFactory<TestLifecycleResource2> factory)
+ {
+ this.factory = factory ;
+ }
+
+ LifecycleResourceFactory<TestLifecycleResource2> getFactory()
+ {
+ return factory ;
+ }
+ }
+
+ private static class TestLifecycleResource2Factory implements LifecycleResourceFactory<TestLifecycleResource2>
+ {
+ private static final List<TestLifecycleResource2> destroyOrder = new ArrayList<TestLifecycleResource2>() ;
+
+ public TestLifecycleResource2 createLifecycleResource(final String lifecycleIdentity)
+ throws LifecycleResourceException
+ {
+ return new TestLifecycleResource2(this) ;
+ }
+
+ public void destroyLifecycleResource(final TestLifecycleResource2 resource,
+ final String lifecycleIdentity)
+ throws LifecycleResourceException
+ {
+ destroyOrder.add(resource) ;
+ }
+
+ static List<TestLifecycleResource2> getDestroyOrder()
+ {
+ return destroyOrder ;
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(LifecycleResourceManagerUnitTest.class);
+ }
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,125 +0,0 @@
-/*
- * 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.listeners.config.mappers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.dom.YADOMUtil;
-import org.jboss.soa.esb.listeners.config.Generator;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpListenerDocument;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.Listener;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpBusDocument;
-import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
-import org.jboss.soa.esb.listeners.gateway.ReadOnlyRemoteGatewayListener;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Tests the class FtpListenerMapper
- *
- * @author Daniel Bevenius
- *
- */
-public class FtpListenerMapperTest
-{
- @SuppressWarnings("unused")
- private Logger log = Logger.getLogger(FtpListenerMapperTest.class);
-
- private static final String ESB_CONFIG_READ_ONLY = "jbossesb_config_readonly.xml";
-
- private static final String GATEWAY_CLASS_ATTRIBUTE = "gatewayClass";
-
- @Test
- public void testReadOnlyConfiguration() throws ConfigurationException, IOException
- {
- Element root = createRootElement();
- XMLBeansModel model = getXmlBeanModel( ESB_CONFIG_READ_ONLY );
-
- List<Listener> gateways = model.getGatewayListeners();
- FtpListenerDocument.FtpListener ftpListener = (FtpListenerDocument.FtpListener) gateways.get(0);
- assertEquals ( true, ftpListener.getIsGateway() );
-
- FtpBusDocument.FtpBus ftpBus = (FtpBusDocument.FtpBus) model.getBus( ftpListener.getBusidref() );
- assertNotNull( "FtpBus element should exist", ftpBus );
- assertEquals ( "read-only attribute should be true", true, ftpBus.getFtpMessageFilter().getReadOnly() );
-
- FtpListenerMapper.map( root , ftpListener, model );
-
- Node ftpMapperListener = root.getFirstChild();
- assertNotNull ("ftpMapperListener should not be null", ftpMapperListener );
- assertEquals( ftpListener.getName(), ftpMapperListener.getNodeName() );
-
- NamedNodeMap attributes = ftpMapperListener.getAttributes();
- Node gatewayClass = attributes.getNamedItem( GATEWAY_CLASS_ATTRIBUTE );
- assertNotNull( "gatewayClass should have been set", gatewayClass );
- assertEquals( ReadOnlyRemoteGatewayListener.class.getName(), gatewayClass.getNodeValue() );
- }
-
- private XMLBeansModel getXmlBeanModel( String fileName ) throws ConfigurationException, IOException
- {
- InputStream inputStream = getClass().getResourceAsStream( ESB_CONFIG_READ_ONLY );
- GeneratorMock mock = new GeneratorMock( inputStream );
- XMLBeansModel model = mock.getModel();
- return model;
- }
-
- private Element createRootElement() throws ConfigurationException
- {
- Document doc = YADOMUtil.createDocument();
- Element root = YADOMUtil.addElement(doc, "jbossesb-gateways");
- root.setAttribute("parameterReloadSecs", "1000" );
- return root;
- }
-
-
- /**
- * Just here to get proved access to the XMLBeansModel
- *
- */
- private class GeneratorMock extends Generator
- {
-
- public GeneratorMock(InputStream config) throws ConfigurationException, IOException
- {
- super( config );
- }
-
- @Override
- public XMLBeansModel getModel()
- {
- return super.getModel();
- }
-
-
- }
-
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapperUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,127 @@
+/*
+ * 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.listeners.config.mappers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.Generator;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpListenerDocument;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.Listener;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpBusDocument;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.gateway.ReadOnlyRemoteGatewayListener;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Tests the class FtpListenerMapper
+ *
+ * @author Daniel Bevenius
+ *
+ */
+public class FtpListenerMapperUnitTest extends TestCase
+{
+ @SuppressWarnings("unused")
+ private Logger log = Logger.getLogger(FtpListenerMapperUnitTest.class);
+
+ private static final String ESB_CONFIG_READ_ONLY = "jbossesb_config_readonly.xml";
+
+ private static final String GATEWAY_CLASS_ATTRIBUTE = "gatewayClass";
+
+ @Test
+ public void testReadOnlyConfiguration() throws Exception
+ {
+ Element root = createRootElement();
+ XMLBeansModel model = getXmlBeanModel( ESB_CONFIG_READ_ONLY );
+
+ List<Listener> gateways = model.getGatewayListeners();
+ FtpListenerDocument.FtpListener ftpListener = (FtpListenerDocument.FtpListener) gateways.get(0);
+ assertEquals ( true, ftpListener.getIsGateway() );
+
+ FtpBusDocument.FtpBus ftpBus = (FtpBusDocument.FtpBus) model.getBus( ftpListener.getBusidref() );
+ assertNotNull( "FtpBus element should exist", ftpBus );
+ assertEquals ( "read-only attribute should be true", true, ftpBus.getFtpMessageFilter().getReadOnly() );
+
+ FtpListenerMapper.map( root , ftpListener, model );
+
+ Node ftpMapperListener = root.getFirstChild();
+ assertNotNull ("ftpMapperListener should not be null", ftpMapperListener );
+ assertEquals( ftpListener.getName(), ftpMapperListener.getNodeName() );
+
+ NamedNodeMap attributes = ftpMapperListener.getAttributes();
+ Node gatewayClass = attributes.getNamedItem( GATEWAY_CLASS_ATTRIBUTE );
+ assertNotNull( "gatewayClass should have been set", gatewayClass );
+ assertEquals( ReadOnlyRemoteGatewayListener.class.getName(), gatewayClass.getNodeValue() );
+ }
+
+ private XMLBeansModel getXmlBeanModel( String fileName ) throws ConfigurationException, IOException
+ {
+ InputStream inputStream = getClass().getResourceAsStream( ESB_CONFIG_READ_ONLY );
+ GeneratorMock mock = new GeneratorMock( inputStream );
+ XMLBeansModel model = mock.getModel();
+ return model;
+ }
+
+ private Element createRootElement() throws ConfigurationException
+ {
+ Document doc = YADOMUtil.createDocument();
+ Element root = YADOMUtil.addElement(doc, "jbossesb-gateways");
+ root.setAttribute("parameterReloadSecs", "1000" );
+ return root;
+ }
+
+
+ /**
+ * Just here to get proved access to the XMLBeansModel
+ *
+ */
+ private class GeneratorMock extends Generator
+ {
+
+ public GeneratorMock(InputStream config) throws ConfigurationException, IOException
+ {
+ super( config );
+ }
+
+ @Override
+ public XMLBeansModel getModel()
+ {
+ return super.getModel();
+ }
+
+
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,124 +0,0 @@
-/*
- * 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.message;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
-import org.jboss.internal.soa.esb.util.XMLHelper;
-import org.jboss.internal.soa.esb.util.stax.StreamHelper;
-import org.jboss.soa.esb.message.Attachment;
-
-/**
- * QA tests for the Message interface and implementations.
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class MessageAttachmentSerializeTest extends TestCase
-{
-
- protected void setUp() throws Exception
- {
- }
-
- public void runTest() throws Exception
- {
- testJavaSerializable();
- testXml();
- }
-
- private static final File TESTFILE = new File("msgAttachment.test");
- protected void tearDown() throws Exception
- {
- TESTFILE.delete();
- }
-
- public void testJavaSerializable() throws Exception
- {
- org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
- old = new org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl();
- populateAttachment(old);
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
- out.writeObject(old);
- out.close();
-
- ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
- org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
- oNew = (org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl)
- inp.readObject();
- inp.close();
-
- assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
- assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
- assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
- assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
- }
-
- public void testXml() throws Exception
- {
- final StringWriter writer = new StringWriter() ;
- final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
- final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_ATTACHMENT) ;
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl old =
- new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
- populateAttachment(old);
- old.writeContent(out) ;
-
- StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ATTACHMENT.getPrefix(), origURI) ;
-
- out.flush() ;
-
- final String content = writer.toString() ;
-
- final StringReader reader = new StringReader(content) ;
- final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
- StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_ATTACHMENT) ;
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl oNew =
- new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl(in);
-
- assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
- assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
- assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
- assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
- }
-
- private void populateAttachment(Attachment att)
- {
- att.addItem("unnamed att 1");
- att.put("name 2","N2N2N2N2N2N2N2N2");
- att.addItem("unn 2");
- att.put("name 1","named att 111111111111111");
- }
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,124 @@
+/*
+ * 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.message;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.soa.esb.message.Attachment;
+
+/**
+ * QA tests for the Message interface and implementations.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class MessageAttachmentSerializeUnitTest extends TestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ }
+
+ public void runTest() throws Exception
+ {
+ testJavaSerializable();
+ testXml();
+ }
+
+ private static final File TESTFILE = new File("msgAttachment.test");
+ protected void tearDown() throws Exception
+ {
+ TESTFILE.delete();
+ }
+
+ public void testJavaSerializable() throws Exception
+ {
+ org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+ old = new org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl();
+ populateAttachment(old);
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
+ out.writeObject(old);
+ out.close();
+
+ ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
+ org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl
+ oNew = (org.jboss.internal.soa.esb.message.format.serialized.AttachmentImpl)
+ inp.readObject();
+ inp.close();
+
+ assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
+ assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
+ assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
+ assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
+ }
+
+ public void testXml() throws Exception
+ {
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_ATTACHMENT) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl old =
+ new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
+ populateAttachment(old);
+ old.writeContent(out) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ATTACHMENT.getPrefix(), origURI) ;
+
+ out.flush() ;
+
+ final String content = writer.toString() ;
+
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_ATTACHMENT) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl oNew =
+ new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl(in);
+
+ assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
+ assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
+ assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
+ assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
+ }
+
+ private void populateAttachment(Attachment att)
+ {
+ att.addItem("unnamed att 1");
+ att.put("name 2","N2N2N2N2N2N2N2N2");
+ att.addItem("unn 2");
+ att.put("name 1","named att 111111111111111");
+ }
+}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,118 +0,0 @@
-/*
- * 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.message;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
-import org.jboss.internal.soa.esb.util.XMLHelper;
-import org.jboss.internal.soa.esb.util.stax.StreamHelper;
-
-
-/**
- * QA tests for the Message interface and implementations.
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- */
-public class MessagePropertiesSerializeTest extends TestCase
-{
-
- protected void setUp() throws Exception
- {
- }
-
- public void runTest() throws Exception
- {
- testJavaSerializable();
- testXml();
- }
-
- private static final File TESTFILE = new File("msgProperties.test");
- protected void tearDown() throws Exception
- {
- TESTFILE.delete();
- }
-
- public void testJavaSerializable() throws Exception
- {
- org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
- old = new org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl();
- populateProperties(old);
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
- out.writeObject(old);
- out.close();
-
- ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
- org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
- oNew = (org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl)
- inp.readObject();
- inp.close();
-
- assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
- assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
- }
-
- public void testXml() throws Exception
- {
- final StringWriter writer = new StringWriter() ;
- final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
- final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_PROPERTIES) ;
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl old =
- new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
- populateProperties(old);
- old.writeContent(out) ;
-
- StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_PROPERTIES.getPrefix(), origURI) ;
-
- out.flush() ;
-
- final String content = writer.toString() ;
-
- final StringReader reader = new StringReader(content) ;
- final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
- StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_PROPERTIES) ;
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl oNew =
- new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl(in);
-
- assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
- assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
- }
-
- private void populateProperties(org.jboss.soa.esb.message.Properties props)
- {
- props.setProperty("p1","VALUE OF PROP 1");
- props.setProperty("p2","VALUE 222");
- }
-}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,118 @@
+/*
+ * 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.message;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+
+
+/**
+ * QA tests for the Message interface and implementations.
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ */
+public class MessagePropertiesSerializeUnitTest extends TestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ }
+
+ public void runTest() throws Exception
+ {
+ testJavaSerializable();
+ testXml();
+ }
+
+ private static final File TESTFILE = new File("msgProperties.test");
+ protected void tearDown() throws Exception
+ {
+ TESTFILE.delete();
+ }
+
+ public void testJavaSerializable() throws Exception
+ {
+ org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
+ old = new org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl();
+ populateProperties(old);
+ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(TESTFILE));
+ out.writeObject(old);
+ out.close();
+
+ ObjectInputStream inp = new ObjectInputStream(new FileInputStream(TESTFILE));
+ org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl
+ oNew = (org.jboss.internal.soa.esb.message.format.serialized.PropertiesImpl)
+ inp.readObject();
+ inp.close();
+
+ assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
+ assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
+ }
+
+ public void testXml() throws Exception
+ {
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_PROPERTIES) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl old =
+ new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
+ populateProperties(old);
+ old.writeContent(out) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_PROPERTIES.getPrefix(), origURI) ;
+
+ out.flush() ;
+
+ final String content = writer.toString() ;
+
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_PROPERTIES) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl oNew =
+ new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl(in);
+
+ assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
+ assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
+ }
+
+ private void populateProperties(org.jboss.soa.esb.message.Properties props)
+ {
+ props.setProperty("p1","VALUE OF PROP 1");
+ props.setProperty("p2","VALUE 222");
+ }
+}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,209 +0,0 @@
-/*
- * 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.services.jbpm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
-import org.dom4j.tree.DefaultElement;
-import org.jboss.soa.esb.message.Message;
-import org.jbpm.graph.def.Node;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.def.Transition;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * Tests the capabilities of the JBpmObjectMapper.
- *
- * @author kstam
- *
- */
-public class JBpmObjectMapperTest
-{
- private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
- private static Logger logger = Logger.getLogger(JBpmObjectMapperTest.class);
- private static ProcessInstance processInstance = null;
-
- @BeforeClass
- public static void setup()
- {
- logger.info("Setting up jBPM");
- //Extract a process definition from the processdefinition.xml file.
- ProcessDefinition processDefinition
- = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
- assertNotNull(processDefinition);
- //Create an instance of the process definition.
- processInstance = new ProcessInstance(processDefinition);
- assertTrue(
- "Instance is in start state",
- "start".equals(processInstance.getRootToken().getNode().getName()));
- }
-
- /**
- * Tests obtaining variables from the jBPM variableMap and setting them on the EsbMessage.
- * We are making sure the jBPM -> EsbMessage works using
- *
- * <pre>
- * <jbpmToEsbVars>
- * <mapping jbpm="v1" esb="esbObj1" />
- * <mapping jbpm="g2" esb="esbObj2" process-scope="true" />
- * </jbpmToEsbVars>
- * <pre>
- *
- * @throws Exception
- */
- @Test
- public void jBpmVariableMap() throws Exception
- {
- SAXReader reader = new SAXReader();
- Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
- Element element = document.getRootElement();
- DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
-
- String helloWorldTokenScope = "Hello world token scope";
- String helloWorldGlobalScope = "Hello world process-instance scope";
-
- Token token = processInstance.getRootToken();
- processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
- processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
- ExecutionContext executionContext = new ExecutionContext(token);
-
- JBpmObjectMapper mapper = new JBpmObjectMapper();
- Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
-
- assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
- assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
- }
- /**
- * Tests obtaining *no* variables from the jBPM variableMap.
- *
- * @throws Exception
- */
- @Test
- public void jBpmCompleteVariableMap() throws Exception
- {
- //Let's NOT give a mapping, this should get us all the variables in the VariableMap.
- DefaultElement jbpmToEsbVars = null;
-
- String helloWorldTokenScope = "Hello world token scope";
- String helloWorldGlobalScope = "Hello world process-instance scope";
-
- Token token = processInstance.getRootToken();
- processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
- processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
- ExecutionContext executionContext = new ExecutionContext(token);
-
- JBpmObjectMapper mapper = new JBpmObjectMapper();
- Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, Boolean.FALSE, executionContext);
- assertEquals(message.getBody().getNames().length,0);
- }
- /**
- * Tests obtaining *all* variables from the jBPM variableMap and setting them on the EsbMessage.
- *
- * @throws Exception
- */
- @Test
- public void jBpmGetNothingFromVariableMap() throws Exception
- {
- SAXReader reader = new SAXReader();
- Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
- Element element = document.getRootElement();
- Element secondMiddleState = (Element) element.elements("state").toArray()[0];
- DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
-
- String helloWorldTokenScope = "Hello world token scope";
- String helloWorldGlobalScope = "Hello world process-instance scope";
-
- Token token = processInstance.getRootToken();
- processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
- processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
- ExecutionContext executionContext = new ExecutionContext(token);
-
- JBpmObjectMapper mapper = new JBpmObjectMapper();
- Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
- //We should find 2 variables which are named just like their jBPM counterparts.
- assertEquals(message.getBody().getNames().length,2);
- assertEquals(String.valueOf(message.getBody().get("v1")),helloWorldTokenScope);
- assertEquals(String.valueOf(message.getBody().get("g2")),helloWorldGlobalScope);
- }
- /**
- * Tests obtaining info about the jBPM ExecutionContext, such as current token and node, transition etc.
- * <PRE>
- * <jbpmToEsbVars>
- * <mapping jbpm="token.id" esb="esbTokenId" />
- * <mapping jbpm="token.name" esb="esbTokenName" />
- * <mapping jbpm="node.name" esb="NodeName" />
- * <mapping jbpm="node.id" esb="esbNodeId" />
- * <mapping jbpm="node.leavingTransitions[0].name" esb="transName" />
- * <mapping jbpm="processInstance.id" esb="piId" />
- <mapping jbpm="processInstance.version" esb="piVersion" />
- * </jbpmToEsbVars>
- * </PRE>
- * @throws Exception
- */
- @Test
- public void jBpmTokenInfo() throws Exception
- {
- SAXReader reader = new SAXReader();
- Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
- Element element = document.getRootElement();
- Element secondMiddleState = (Element) element.elements("state").toArray()[1];
- DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
-
- Token token = processInstance.getRootToken();
- ExecutionContext executionContext = new ExecutionContext(token);
- Node node = executionContext.getNode();
- Transition transition = (Transition) node.getLeavingTransitions().get(0);
-
- JBpmObjectMapper mapper = new JBpmObjectMapper();
- Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
-
- assertEquals(message.getBody().getNames().length,6);
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
- //The token name is null.
- assertNull(message.getBody().get("TokenName"));
- //Get info about the node.
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("NodeName"))), String.valueOf(node.getName()));
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("esbNodeId"))), String.valueOf(node.getId()));
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("transName"))), String.valueOf(transition.getName()));
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("piId"))), String.valueOf(processInstance.getId()));
- assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
- logger.info("Message=" + message);
- }
-
- public static junit.framework.Test suite(){
- return new JUnit4TestAdapter(JBpmObjectMapperTest.class);
- }
-
-}
Copied: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperTest.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,209 @@
+/*
+ * 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.services.jbpm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultElement;
+import org.jboss.soa.esb.message.Message;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Tests the capabilities of the JBpmObjectMapper.
+ *
+ * @author kstam
+ *
+ */
+public class JBpmObjectMapperUnitTest
+{
+ private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
+ private static Logger logger = Logger.getLogger(JBpmObjectMapperUnitTest.class);
+ private static ProcessInstance processInstance = null;
+
+ @BeforeClass
+ public static void setup()
+ {
+ logger.info("Setting up jBPM");
+ //Extract a process definition from the processdefinition.xml file.
+ ProcessDefinition processDefinition
+ = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
+ assertNotNull(processDefinition);
+ //Create an instance of the process definition.
+ processInstance = new ProcessInstance(processDefinition);
+ assertTrue(
+ "Instance is in start state",
+ "start".equals(processInstance.getRootToken().getNode().getName()));
+ }
+
+ /**
+ * Tests obtaining variables from the jBPM variableMap and setting them on the EsbMessage.
+ * We are making sure the jBPM -> EsbMessage works using
+ *
+ * <pre>
+ * <jbpmToEsbVars>
+ * <mapping jbpm="v1" esb="esbObj1" />
+ * <mapping jbpm="g2" esb="esbObj2" process-scope="true" />
+ * </jbpmToEsbVars>
+ * <pre>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void jBpmVariableMap() throws Exception
+ {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+ Element element = document.getRootElement();
+ DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
+
+ String helloWorldTokenScope = "Hello world token scope";
+ String helloWorldGlobalScope = "Hello world process-instance scope";
+
+ Token token = processInstance.getRootToken();
+ processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
+ processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+
+ assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
+ assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
+ }
+ /**
+ * Tests obtaining *no* variables from the jBPM variableMap.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void jBpmCompleteVariableMap() throws Exception
+ {
+ //Let's NOT give a mapping, this should get us all the variables in the VariableMap.
+ DefaultElement jbpmToEsbVars = null;
+
+ String helloWorldTokenScope = "Hello world token scope";
+ String helloWorldGlobalScope = "Hello world process-instance scope";
+
+ Token token = processInstance.getRootToken();
+ processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+ processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, Boolean.FALSE, executionContext);
+ assertEquals(message.getBody().getNames().length,0);
+ }
+ /**
+ * Tests obtaining *all* variables from the jBPM variableMap and setting them on the EsbMessage.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void jBpmGetNothingFromVariableMap() throws Exception
+ {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+ Element element = document.getRootElement();
+ Element secondMiddleState = (Element) element.elements("state").toArray()[0];
+ DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
+
+ String helloWorldTokenScope = "Hello world token scope";
+ String helloWorldGlobalScope = "Hello world process-instance scope";
+
+ Token token = processInstance.getRootToken();
+ processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+ processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+ //We should find 2 variables which are named just like their jBPM counterparts.
+ assertEquals(message.getBody().getNames().length,2);
+ assertEquals(String.valueOf(message.getBody().get("v1")),helloWorldTokenScope);
+ assertEquals(String.valueOf(message.getBody().get("g2")),helloWorldGlobalScope);
+ }
+ /**
+ * Tests obtaining info about the jBPM ExecutionContext, such as current token and node, transition etc.
+ * <PRE>
+ * <jbpmToEsbVars>
+ * <mapping jbpm="token.id" esb="esbTokenId" />
+ * <mapping jbpm="token.name" esb="esbTokenName" />
+ * <mapping jbpm="node.name" esb="NodeName" />
+ * <mapping jbpm="node.id" esb="esbNodeId" />
+ * <mapping jbpm="node.leavingTransitions[0].name" esb="transName" />
+ * <mapping jbpm="processInstance.id" esb="piId" />
+ <mapping jbpm="processInstance.version" esb="piVersion" />
+ * </jbpmToEsbVars>
+ * </PRE>
+ * @throws Exception
+ */
+ @Test
+ public void jBpmTokenInfo() throws Exception
+ {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+ Element element = document.getRootElement();
+ Element secondMiddleState = (Element) element.elements("state").toArray()[1];
+ DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
+
+ Token token = processInstance.getRootToken();
+ ExecutionContext executionContext = new ExecutionContext(token);
+ Node node = executionContext.getNode();
+ Transition transition = (Transition) node.getLeavingTransitions().get(0);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+
+ assertEquals(message.getBody().getNames().length,6);
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
+ //The token name is null.
+ assertNull(message.getBody().get("TokenName"));
+ //Get info about the node.
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("NodeName"))), String.valueOf(node.getName()));
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("esbNodeId"))), String.valueOf(node.getId()));
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("transName"))), String.valueOf(transition.getName()));
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("piId"))), String.valueOf(processInstance.getId()));
+ assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
+ logger.info("Message=" + message);
+ }
+
+ public static junit.framework.Test suite(){
+ return new JUnit4TestAdapter(JBpmObjectMapperUnitTest.class);
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,234 +0,0 @@
-/*
- * 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.services.jbpm.actionhandlers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.couriers.MockCourier;
-import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
-import org.jboss.internal.soa.esb.services.registry.MockRegistry;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.junit.Before;
-import org.junit.Test;
-/**
- * Tests the capabilities of jBPM which we are using to handle exceptions.
- *
- * @author kstam
- *
- */
-public class ExceptionFlowTest
-{
- private static String PROCESS_DEF_XML = "testExceptionHandling.xml";
- private static Logger logger = Logger.getLogger(ExceptionFlowTest.class);
- private static long processInstanceId;
-
- private static EPR epr1;
- private static MockCourier courier1;
- private static String MOCK_CATEGORY="MockCategory";
- private static String MOCK_SERVICE ="MockService";
-
- @Before
- public void setup() throws Exception
- {
- MockCourierFactory.install();
- MockRegistry.install();
- epr1 = new EPR(new URI("test1"));
- courier1 = new MockCourier(true);
- MockRegistry.register(MOCK_CATEGORY, MOCK_SERVICE, epr1, courier1);
-
- logger.info("Setting up jBPM");
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- jbpmContext.getJbpmConfiguration().getJobExecutor().start();
-
- //Extract a process definition from the processdefinition.xml file.
- ProcessDefinition processDefinition
- = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
- assertNotNull(processDefinition);
- //Create an instance of the process definition.
- jbpmContext.deployProcessDefinition(processDefinition);
- //processInstance = new ProcessInstance(processDefinition);
- ProcessInstance processInstance = jbpmContext.newProcessInstance("testExceptionHandling");
- assertTrue(
- "Instance is in start state",
- "start".equals(processInstance.getRootToken().getNode().getName()));
- processInstanceId = processInstance.getId();
- jbpmContext.close();
- }
-
- /**
- * Tests timeout of the first node (service1). The time-out-transition will
- * be taken and we should en up in the ExceptionHandling end-state.
- *
- * @throws Exception
- */
- @Test
- public void timeOut() throws Exception
- {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- assertEquals("start",token.getNode().getName());
- //Move the process to service1
- processInstance.signal();
- jbpmContext.close();
- //Our timer fires after 1000 millies, so let's wait for that
- int seconds=0;
- while(true) {
- jbpmContext = jbpmConfiguration.createJbpmContext();
- processInstance = jbpmContext.loadProcessInstance(processInstanceId);
- token = processInstance.getRootToken();
- logger.info(seconds++ + " Node=" + token.getNode().getName());
- if ("ExceptionHandling".equals(token.getNode().getName())) break; //we're done waiting
- if (seconds > 20) break; // the timer must not have fired so we are bailing (and failing)
- jbpmContext.close();
- try { Thread.sleep(1000); } catch (InterruptedException e) {e.printStackTrace();}
- }
- assertEquals("ExceptionHandling",token.getNode().getName());
- }
-
- /**
- * Tests bypassing the timout and taking the exception transition on service2.
- *
- */
- @Test
- public void takeExceptionTransition() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- assertEquals("start",token.getNode().getName());
- //Move the process to service1
- processInstance.signal();
- assertEquals("Service1",token.getNode().getName());
-// Move the process to service2, no timeout on service1
- processInstance.signal();
- assertEquals("Service2",token.getNode().getName());
- //Move the service2 ExceptionHandling
- processInstance.signal("exception");
- assertEquals("ExceptionHandling",token.getNode().getName());
- }
-
- /**
- * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
- *
- */
- @Test
- public void takeConditionalTransition() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- assertEquals("start",token.getNode().getName());
- //Move the process to service1
- processInstance.signal();
- assertEquals("Service1",token.getNode().getName());
-// Move the process to service2, no timeout on service1
- processInstance.signal();
- assertEquals("Service2",token.getNode().getName());
- //Move the service3
- processInstance.signal();
- assertEquals("Service3",token.getNode().getName());
- processInstance.getContextInstance().createVariable("exceptionCode",3);
- processInstance.signal();
- //Based on the setting of exceptionCode of 3 the conditional transition
- //should be taken.
- assertEquals("ExceptionHandling",token.getNode().getName());
- }
-
- /**
- * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
- *
- */
- @Test
- public void doNotTakeConditionalTransition() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- assertEquals("start",token.getNode().getName());
- //Move the process to service1
- processInstance.signal();
- assertEquals("Service1",token.getNode().getName());
-// Move the process to service2, no timeout on service1
- processInstance.signal();
- assertEquals("Service2",token.getNode().getName());
- //Move the service3
- processInstance.signal();
- assertEquals("Service3",token.getNode().getName());
- processInstance.getContextInstance().createVariable("exceptionCode",2);
- processInstance.signal();
- //Based on the setting of exceptionCode of 2 the conditional transition
- //should not be taken.
- assertEquals("end",token.getNode().getName());
- }
-
- /**
- * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
- *
- */
- @Test
- public void doNotTakeConditionalTransition2() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- assertEquals("start",token.getNode().getName());
- //Move the process to service1
- processInstance.signal();
- assertEquals("Service1",token.getNode().getName());
-// Move the process to service2, no timeout on service1
- processInstance.signal();
- assertEquals("Service2",token.getNode().getName());
- //Move the service3
- processInstance.signal();
- assertEquals("Service3",token.getNode().getName());
- processInstance.signal();
- //Based on the not setting of exceptionCode the conditional transition
- //should not be taken.
- assertEquals("end",token.getNode().getName());
- }
-
- public static junit.framework.Test suite(){
- return new JUnit4TestAdapter(ExceptionFlowTest.class);
- }
-
-}
Copied: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowTest.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/ExceptionFlowUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,234 @@
+/*
+ * 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.services.jbpm.actionhandlers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.junit.Before;
+import org.junit.Test;
+/**
+ * Tests the capabilities of jBPM which we are using to handle exceptions.
+ *
+ * @author kstam
+ *
+ */
+public class ExceptionFlowUnitTest
+{
+ private static String PROCESS_DEF_XML = "testExceptionHandling.xml";
+ private static Logger logger = Logger.getLogger(ExceptionFlowUnitTest.class);
+ private static long processInstanceId;
+
+ private static EPR epr1;
+ private static MockCourier courier1;
+ private static String MOCK_CATEGORY="MockCategory";
+ private static String MOCK_SERVICE ="MockService";
+
+ @Before
+ public void setup() throws Exception
+ {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ epr1 = new EPR(new URI("test1"));
+ courier1 = new MockCourier(true);
+ MockRegistry.register(MOCK_CATEGORY, MOCK_SERVICE, epr1, courier1);
+
+ logger.info("Setting up jBPM");
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ jbpmContext.getJbpmConfiguration().getJobExecutor().start();
+
+ //Extract a process definition from the processdefinition.xml file.
+ ProcessDefinition processDefinition
+ = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
+ assertNotNull(processDefinition);
+ //Create an instance of the process definition.
+ jbpmContext.deployProcessDefinition(processDefinition);
+ //processInstance = new ProcessInstance(processDefinition);
+ ProcessInstance processInstance = jbpmContext.newProcessInstance("testExceptionHandling");
+ assertTrue(
+ "Instance is in start state",
+ "start".equals(processInstance.getRootToken().getNode().getName()));
+ processInstanceId = processInstance.getId();
+ jbpmContext.close();
+ }
+
+ /**
+ * Tests timeout of the first node (service1). The time-out-transition will
+ * be taken and we should en up in the ExceptionHandling end-state.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void timeOut() throws Exception
+ {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start",token.getNode().getName());
+ //Move the process to service1
+ processInstance.signal();
+ jbpmContext.close();
+ //Our timer fires after 1000 millies, so let's wait for that
+ int seconds=0;
+ while(true) {
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+ token = processInstance.getRootToken();
+ logger.info(seconds++ + " Node=" + token.getNode().getName());
+ if ("ExceptionHandling".equals(token.getNode().getName())) break; //we're done waiting
+ if (seconds > 20) break; // the timer must not have fired so we are bailing (and failing)
+ jbpmContext.close();
+ try { Thread.sleep(1000); } catch (InterruptedException e) {e.printStackTrace();}
+ }
+ assertEquals("ExceptionHandling",token.getNode().getName());
+ }
+
+ /**
+ * Tests bypassing the timout and taking the exception transition on service2.
+ *
+ */
+ @Test
+ public void takeExceptionTransition() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start",token.getNode().getName());
+ //Move the process to service1
+ processInstance.signal();
+ assertEquals("Service1",token.getNode().getName());
+// Move the process to service2, no timeout on service1
+ processInstance.signal();
+ assertEquals("Service2",token.getNode().getName());
+ //Move the service2 ExceptionHandling
+ processInstance.signal("exception");
+ assertEquals("ExceptionHandling",token.getNode().getName());
+ }
+
+ /**
+ * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
+ *
+ */
+ @Test
+ public void takeConditionalTransition() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start",token.getNode().getName());
+ //Move the process to service1
+ processInstance.signal();
+ assertEquals("Service1",token.getNode().getName());
+// Move the process to service2, no timeout on service1
+ processInstance.signal();
+ assertEquals("Service2",token.getNode().getName());
+ //Move the service3
+ processInstance.signal();
+ assertEquals("Service3",token.getNode().getName());
+ processInstance.getContextInstance().createVariable("exceptionCode",3);
+ processInstance.signal();
+ //Based on the setting of exceptionCode of 3 the conditional transition
+ //should be taken.
+ assertEquals("ExceptionHandling",token.getNode().getName());
+ }
+
+ /**
+ * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
+ *
+ */
+ @Test
+ public void doNotTakeConditionalTransition() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start",token.getNode().getName());
+ //Move the process to service1
+ processInstance.signal();
+ assertEquals("Service1",token.getNode().getName());
+// Move the process to service2, no timeout on service1
+ processInstance.signal();
+ assertEquals("Service2",token.getNode().getName());
+ //Move the service3
+ processInstance.signal();
+ assertEquals("Service3",token.getNode().getName());
+ processInstance.getContextInstance().createVariable("exceptionCode",2);
+ processInstance.signal();
+ //Based on the setting of exceptionCode of 2 the conditional transition
+ //should not be taken.
+ assertEquals("end",token.getNode().getName());
+ }
+
+ /**
+ * Tests bypassing the timout and setting exception of 3 to take the conditional transition.
+ *
+ */
+ @Test
+ public void doNotTakeConditionalTransition2() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start",token.getNode().getName());
+ //Move the process to service1
+ processInstance.signal();
+ assertEquals("Service1",token.getNode().getName());
+// Move the process to service2, no timeout on service1
+ processInstance.signal();
+ assertEquals("Service2",token.getNode().getName());
+ //Move the service3
+ processInstance.signal();
+ assertEquals("Service3",token.getNode().getName());
+ processInstance.signal();
+ //Based on the not setting of exceptionCode the conditional transition
+ //should not be taken.
+ assertEquals("end",token.getNode().getName());
+ }
+
+ public static junit.framework.Test suite(){
+ return new JUnit4TestAdapter(ExceptionFlowUnitTest.class);
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,118 +0,0 @@
-/*
- * 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.services.jbpm.actionhandlers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
-import org.dom4j.tree.DefaultElement;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.jbpm.Constants;
-import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
-import org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * Tests the capabilities of the JBpmObjectMapper.
- *
- * @author kstam
- *
- */
-public class JBpmObjectMapperCallbackTest
-{
- private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
- private static Logger logger = Logger.getLogger(JBpmObjectMapperCallbackTest.class);
- private static ProcessInstance processInstance = null;
-
- @BeforeClass
- public static void setup()
- {
- logger.info("Setting up jBPM");
- //Extract a process definition from the processdefinition.xml file.
- ProcessDefinition processDefinition
- = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
- assertNotNull(processDefinition);
- //Create an instance of the process definition.
- processInstance = new ProcessInstance(processDefinition);
- assertTrue(
- "Instance is in start state",
- "start".equals(processInstance.getRootToken().getNode().getName()));
- }
-
- /**
- * Tests if the variableMapping can go roundtrip (via the callbackService code)
- *
- * @throws Exception
- */
- @Test
- public void esbToJBpmAndBack() throws Exception
- {
- SAXReader reader = new SAXReader();
- Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
- Element element = document.getRootElement();
- DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
- DefaultElement esbToBpmVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("esbToBpmVars");
-
- String helloWorldTokenScope = "Hello world token scope";
- String helloWorldGlobalScope = "Hello world process-instance scope";
-
- Token token = processInstance.getRootToken();
- processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
- processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
- ExecutionContext executionContext = new ExecutionContext(token);
-
- JBpmObjectMapper mapper = new JBpmObjectMapper();
- Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
-
- //Setting up return mapping for the callback service.
- EsbActionHandler esbActionHandler = new EsbActionHandler();
- EPR epr = esbActionHandler.createReplyTo(esbToBpmVars.asXML(), Boolean.FALSE, executionContext);
- String esbToBpmXml = epr.getAddr().getExtensionValue(Constants.ESB_TO_BPM_VARS_TAG);
-
- //Obtaining the VariableMap that is going to be set callback command
- Map<String,Object> variableMap = mapper.mapFromEsbMessageToJBpmMap(message, esbToBpmXml);
- logger.info(variableMap);
- //Let's make sure that what we put in is going to make it roundtrip.
- assertEquals(helloWorldTokenScope, variableMap.get("x1"));
- assertEquals(helloWorldGlobalScope,variableMap.get("x2"));
- }
-
- public static junit.framework.Test suite(){
- return new JUnit4TestAdapter(JBpmObjectMapperCallbackTest.class);
- }
-
-}
Copied: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackTest.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/JBpmObjectMapperCallbackUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,118 @@
+/*
+ * 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.services.jbpm.actionhandlers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultElement;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.jbpm.Constants;
+import org.jboss.soa.esb.services.jbpm.JBpmObjectMapper;
+import org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Tests the capabilities of the JBpmObjectMapper.
+ *
+ * @author kstam
+ *
+ */
+public class JBpmObjectMapperCallbackUnitTest
+{
+ private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
+ private static Logger logger = Logger.getLogger(JBpmObjectMapperCallbackUnitTest.class);
+ private static ProcessInstance processInstance = null;
+
+ @BeforeClass
+ public static void setup()
+ {
+ logger.info("Setting up jBPM");
+ //Extract a process definition from the processdefinition.xml file.
+ ProcessDefinition processDefinition
+ = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
+ assertNotNull(processDefinition);
+ //Create an instance of the process definition.
+ processInstance = new ProcessInstance(processDefinition);
+ assertTrue(
+ "Instance is in start state",
+ "start".equals(processInstance.getRootToken().getNode().getName()));
+ }
+
+ /**
+ * Tests if the variableMapping can go roundtrip (via the callbackService code)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void esbToJBpmAndBack() throws Exception
+ {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+ Element element = document.getRootElement();
+ DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
+ DefaultElement esbToBpmVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("esbToBpmVars");
+
+ String helloWorldTokenScope = "Hello world token scope";
+ String helloWorldGlobalScope = "Hello world process-instance scope";
+
+ Token token = processInstance.getRootToken();
+ processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
+ processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+
+ //Setting up return mapping for the callback service.
+ EsbActionHandler esbActionHandler = new EsbActionHandler();
+ EPR epr = esbActionHandler.createReplyTo(esbToBpmVars.asXML(), Boolean.FALSE, executionContext);
+ String esbToBpmXml = epr.getAddr().getExtensionValue(Constants.ESB_TO_BPM_VARS_TAG);
+
+ //Obtaining the VariableMap that is going to be set callback command
+ Map<String,Object> variableMap = mapper.mapFromEsbMessageToJBpmMap(message, esbToBpmXml);
+ logger.info(variableMap);
+ //Let's make sure that what we put in is going to make it roundtrip.
+ assertEquals(helloWorldTokenScope, variableMap.get("x1"));
+ assertEquals(helloWorldGlobalScope,variableMap.get("x2"));
+ }
+
+ public static junit.framework.Test suite(){
+ return new JUnit4TestAdapter(JBpmObjectMapperCallbackUnitTest.class);
+ }
+
+}
Deleted: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerTest.java 2008-04-12 21:08:28 UTC (rev 19537)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -1,115 +0,0 @@
-/*
- * 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.services.jbpm.actionhandlers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * Tests the capabilities of jBPM timer, which we are using.
- *
- * @author kstam
- *
- */
-public class TimerTest
-{
- private static String PROCESS_DEF_XML = "testTimer.xml";
- private static Logger logger = Logger.getLogger(TimerTest.class);
- private static long processInstanceId;
- //private static ProcessInstance processInstance = null;
- //private static JbpmContext jbpmContext = null;
- //private static GraphSession graphSession = null;
-
- @BeforeClass
- public static void setup() throws Exception
- {
- logger.info("Setting up jBPM");
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
-
- jbpmConfiguration.getJobExecutor().start();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- //Extract a process definition from the processdefinition.xml file.
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
- assertNotNull(processDefinition);
- //Create an instance of the process definition.
- jbpmContext.deployProcessDefinition(processDefinition);
- ProcessInstance processInstance = jbpmContext.newProcessInstance("testTimer");
- processInstanceId = processInstance.getId();
- assertTrue(
- "Instance is in start state",
- "start".equals(processInstance.getRootToken().getNode().getName()));
- processInstance.getContextInstance().createVariable("processingTime", "3000");
- jbpmContext.close();
- }
-
- /**
- * Tests timeout functionality of jBPM
- *
- * @throws Exception
- */
- @Test
- public void timeOut() throws Exception
- {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
-
- Token token = processInstance.getRootToken();
- processInstance.signal();
- assertEquals("wait1",token.getNode().getName());
- jbpmContext.close();
-
- int seconds=0;
- while (true) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {}
- jbpmContext = jbpmConfiguration.createJbpmContext();
- processInstance = jbpmContext.loadProcessInstance(processInstanceId);
- token = processInstance.getRootToken();
- String currentNode = token.getNode().getName();
- System.out.println(seconds++ + " " + currentNode);
- jbpmContext.close();
- if (currentNode.equals("end")) break;
- if (seconds > 20) break;
- }
-
- //Check that we are now in the end node.
- assertEquals("end",token.getNode().getName());
- }
-
- public static junit.framework.Test suite(){
- return new JUnit4TestAdapter(TimerTest.class);
- }
-
-}
Copied: labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerUnitTest.java (from rev 19536, labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerTest.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actionhandlers/TimerUnitTest.java 2008-04-13 07:41:19 UTC (rev 19538)
@@ -0,0 +1,115 @@
+/*
+ * 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.services.jbpm.actionhandlers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Tests the capabilities of jBPM timer, which we are using.
+ *
+ * @author kstam
+ *
+ */
+public class TimerUnitTest
+{
+ private static String PROCESS_DEF_XML = "testTimer.xml";
+ private static Logger logger = Logger.getLogger(TimerUnitTest.class);
+ private static long processInstanceId;
+ //private static ProcessInstance processInstance = null;
+ //private static JbpmContext jbpmContext = null;
+ //private static GraphSession graphSession = null;
+
+ @BeforeClass
+ public static void setup() throws Exception
+ {
+ logger.info("Setting up jBPM");
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+
+ jbpmConfiguration.getJobExecutor().start();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ //Extract a process definition from the processdefinition.xml file.
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
+ assertNotNull(processDefinition);
+ //Create an instance of the process definition.
+ jbpmContext.deployProcessDefinition(processDefinition);
+ ProcessInstance processInstance = jbpmContext.newProcessInstance("testTimer");
+ processInstanceId = processInstance.getId();
+ assertTrue(
+ "Instance is in start state",
+ "start".equals(processInstance.getRootToken().getNode().getName()));
+ processInstance.getContextInstance().createVariable("processingTime", "3000");
+ jbpmContext.close();
+ }
+
+ /**
+ * Tests timeout functionality of jBPM
+ *
+ * @throws Exception
+ */
+ @Test
+ public void timeOut() throws Exception
+ {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+
+ Token token = processInstance.getRootToken();
+ processInstance.signal();
+ assertEquals("wait1",token.getNode().getName());
+ jbpmContext.close();
+
+ int seconds=0;
+ while (true) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ processInstance = jbpmContext.loadProcessInstance(processInstanceId);
+ token = processInstance.getRootToken();
+ String currentNode = token.getNode().getName();
+ System.out.println(seconds++ + " " + currentNode);
+ jbpmContext.close();
+ if (currentNode.equals("end")) break;
+ if (seconds > 20) break;
+ }
+
+ //Check that we are now in the end node.
+ assertEquals("end",token.getNode().getName());
+ }
+
+ public static junit.framework.Test suite(){
+ return new JUnit4TestAdapter(TimerUnitTest.class);
+ }
+
+}
More information about the jboss-svn-commits
mailing list