Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 84936 invoked from network); 2 Jan 2008 20:35:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2008 20:35:47 -0000 Received: (qmail 54134 invoked by uid 500); 2 Jan 2008 20:35:36 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 54121 invoked by uid 500); 2 Jan 2008 20:35:36 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 54112 invoked by uid 99); 2 Jan 2008 20:35:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jan 2008 12:35:36 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jan 2008 20:35:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DC2371A9842; Wed, 2 Jan 2008 12:35:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r608212 [2/2] - in /incubator/tuscany/java/sca/modules/binding-jms/src: main/java/org/apache/tuscany/sca/binding/jms/ main/java/org/apache/tuscany/sca/binding/jms/impl/ main/java/org/apache/tuscany/sca/binding/jms/provider/ test/java/org/ap... Date: Wed, 02 Jan 2008 20:35:17 -0000 To: tuscany-commits@ws.apache.org From: antelder@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080102203525.DC2371A9842@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java Wed Jan 2 12:35:15 2008 @@ -41,38 +41,35 @@ */ public class JMSBindingServiceBindingProvider implements ServiceBindingProvider { - private RuntimeComponentService service; - private JMSBinding jmsBinding; - private JMSResourceFactory jmsResourceFactory; - private MessageConsumer consumer; + private JMSBinding jmsBinding; + private JMSResourceFactory jmsResourceFactory; + private MessageConsumer consumer; public JMSBindingServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, JMSBinding binding) { - this.service = service; - this.jmsBinding = binding; - - jmsResourceFactory = jmsBinding.getJmsResourceFactory(); - + this.service = service; + this.jmsBinding = binding; + + jmsResourceFactory = jmsBinding.getJmsResourceFactory(); + // if the default destination queue names is set // set the destinate queue name to the reference name // so that any wires can be assured a unique endpoint. - if (jmsBinding.getDestinationName().equals(JMSBindingConstants.DEFAULT_DESTINATION_NAME)){ - //jmsBinding.setDestinationName(service.getName()); - throw new JMSBindingException("No destination specified for service " + - service.getName()); + if (jmsBinding.getDestinationName().equals(JMSBindingConstants.DEFAULT_DESTINATION_NAME)) { + // jmsBinding.setDestinationName(service.getName()); + throw new JMSBindingException("No destination specified for service " + service.getName()); } if (jmsBinding.getXMLFormat()) { setXMLDataBinding(service); } - } protected void setXMLDataBinding(RuntimeComponentService service) { - if (service.getInterfaceContract()!= null) { + if (service.getInterfaceContract() != null) { try { InterfaceContract ic = (InterfaceContract)service.getInterfaceContract().clone(); @@ -101,7 +98,7 @@ registerListerner(); } catch (Exception e) { throw new JMSBindingException("Error starting JMSServiceBinding", e); - } + } } public void stop() { @@ -110,26 +107,26 @@ jmsResourceFactory.closeConnection(); } catch (Exception e) { throw new JMSBindingException("Error stopping JMSServiceBinding", e); - } + } } - + private void registerListerner() throws NamingException, JMSException { - Session session = jmsResourceFactory.createSession(); - Destination destination = lookupDestinationQueue(); - + Session session = jmsResourceFactory.createSession(); + Destination destination = lookupDestinationQueue(); + consumer = session.createConsumer(destination); - + // TODO - We assume the target is a Java class here!!! - //Class aClass = getTargetJavaClass(getBindingInterfaceContract().getInterface()); - // Object instance = component.createSelfReference(aClass).getService(); + // Class aClass = getTargetJavaClass(getBindingInterfaceContract().getInterface()); + // Object instance = component.createSelfReference(aClass).getService(); consumer.setMessageListener(new JMSBindingListener(jmsBinding, jmsResourceFactory, service)); jmsResourceFactory.startConnection(); } - + /** * Looks up the Destination Queue for the JMS Binding. *

@@ -138,31 +135,33 @@ *

  • always - the JMS queue is always created. It is an error if the queue already exists *
  • ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists *
  • never - the JMS queue is never created. It is an error if the queue does not exist - * + * * See the SCA JMS Binding specification for more information. *

    + * * @return The Destination queue. * @throws NamingException Failed to lookup JMS queue - * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that the JMS queue's current - * existance/non-existance is not compatible with the create mode specified on the binding + * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that the JMS queue's current + * existance/non-existance is not compatible with the create mode specified on the binding */ private Destination lookupDestinationQueue() throws NamingException, JMSBindingException { Destination destination = jmsResourceFactory.lookupDestination(jmsBinding.getDestinationName()); - + String qCreateMode = jmsBinding.getDestinationCreate(); if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) { // In this mode, the queue must not already exist as we are creating it if (destination != null) { - throw new JMSBindingException("JMS Destination " + - jmsBinding.getDestinationName() + - " already exists but has create mode of \"" + qCreateMode + "\" while registering service " + - service.getName() + - " listener"); + throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName() + + " already exists but has create mode of \"" + + qCreateMode + + "\" while registering service " + + service.getName() + + " listener"); } - + // Create the queue destination = jmsResourceFactory.createDestination(jmsBinding.getDestinationName()); - + } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { // In this mode, the queue may nor may not exist. It will be created if it does not exist if (destination == null) { @@ -172,21 +171,23 @@ } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) { // In this mode, the queue must have already been created. if (destination == null) { - throw new JMSBindingException("JMS Destination " + - jmsBinding.getDestinationName() + - " not found but create mode of \"" + qCreateMode + "\" while registering service " + - service.getName() + - " listener"); + throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName() + + " not found but create mode of \"" + + qCreateMode + + "\" while registering service " + + service.getName() + + " listener"); } } // Make sure we ended up with a queue if (destination == null) { - throw new JMSBindingException("JMS Destination " + - jmsBinding.getDestinationName() + - " not found with create mode of \"" + qCreateMode + "\" while registering service " + - service.getName() + - " listener"); + throw new JMSBindingException("JMS Destination " + jmsBinding.getDestinationName() + + " not found with create mode of \"" + + qCreateMode + + "\" while registering service " + + service.getName() + + " listener"); } return destination; Modified: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java Wed Jan 2 12:35:15 2008 @@ -22,8 +22,7 @@ import javax.jms.Session; /** - * Interface for a component that does operation selection and message payload - * processing + * Interface for a component that does operation selection and message payload processing */ public interface JMSMessageProcessor { Modified: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorImpl.java Wed Jan 2 12:35:15 2008 @@ -37,12 +37,12 @@ public class JMSMessageProcessorImpl implements JMSMessageProcessor { - protected String operationPropertyName; + protected String operationPropertyName; protected boolean xmlFormat; public JMSMessageProcessorImpl(JMSBinding jmsBinding) { this.operationPropertyName = jmsBinding.getOperationSelectorPropertyName(); - this.xmlFormat = jmsBinding.getXMLFormat(); + this.xmlFormat = jmsBinding.getXMLFormat(); } /* @@ -63,8 +63,7 @@ /* * (non-Javadoc) * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#setOperationName(javax.jms.Message, - * java.lang.String) + * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#setOperationName(javax.jms.Message, java.lang.String) */ public void setOperationName(String operationName, Message message) { try { @@ -79,8 +78,7 @@ /* * (non-Javadoc) * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Session, - * java.lang.Object) + * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Session, java.lang.Object) */ public Message insertPayloadIntoJMSMessage(Session session, Object o) { if (xmlFormat) { @@ -120,7 +118,7 @@ throw new JMSBindingException(e); } } - + protected Object extractObjectPayload(Message msg) { try { @@ -129,7 +127,7 @@ } catch (JMSException e) { throw new JMSBindingException(e); } - } + } protected Message createXMLJMSMessage(Session session, Object o) { try { Modified: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java Wed Jan 2 12:35:15 2008 @@ -25,8 +25,7 @@ import javax.naming.NamingException; /* - * Brings together the JMS binding description and the - * API used for generating and manageing JMS resources + * Brings together the JMS binding description and the API used for generating and manageing JMS resources */ public interface JMSResourceFactory { @@ -40,6 +39,6 @@ public abstract void closeConnection() throws JMSException, NamingException; public abstract Destination lookupDestination(String jndiName) throws NamingException; - + public abstract Destination createDestination(String jndiName) throws NamingException; } Modified: incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryActiveMQImpl.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryActiveMQImpl.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryActiveMQImpl.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryActiveMQImpl.java Wed Jan 2 12:35:15 2008 @@ -33,26 +33,24 @@ /** * Abstracts away any JMS provide specific feature from the JMS binding - * + * * @version $Rev$ $Date$ */ public class JMSResourceFactoryActiveMQImpl implements JMSResourceFactory { private JMSBinding jmsBinding; private Connection connection; - private Context context; - private boolean isConnectionStarted; + private Context context; + private boolean isConnectionStarted; public JMSResourceFactoryActiveMQImpl(JMSBinding jmsBinding) { this.jmsBinding = jmsBinding; } /* - * This is a simple implementation where a connection is created per binding - * Ideally the resource factory should be able to leverage the host - * environment to provide connection pooling if it can. E.g. if Tuscany is - * running inside an AppServer Then we could leverage the JMS resources it - * provides + * This is a simple implementation where a connection is created per binding Ideally the resource factory should be + * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside + * an AppServer Then we could leverage the JMS resources it provides * * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection() */ @@ -105,10 +103,8 @@ private void createInitialContext() throws NamingException { Properties props = new Properties(); - props.setProperty(Context.INITIAL_CONTEXT_FACTORY, - jmsBinding.getInitialContextFactoryName().trim()); - props.setProperty(Context.PROVIDER_URL, - jmsBinding.getJndiURL().trim()); + props.setProperty(Context.INITIAL_CONTEXT_FACTORY, jmsBinding.getInitialContextFactoryName().trim()); + props.setProperty(Context.PROVIDER_URL, jmsBinding.getJndiURL().trim()); context = new InitialContext(props); } @@ -117,23 +113,22 @@ if (context == null) { createInitialContext(); } - + Destination dest = null; - + try { dest = (Destination)context.lookup(jndiName); - } catch(NamingException ex){ - - } + } catch (NamingException ex) { + + } return dest; } /** - * You can create a destination in ActiveMQ (and have it appear in JNDI) - * by putting "dynamicQueues/" in front of the queue name being looked up - * + * You can create a destination in ActiveMQ (and have it appear in JNDI) by putting "dynamicQueues/" in front of the + * queue name being looked up */ public Destination createDestination(String jndiName) throws NamingException { - return lookupDestination("dynamicQueues/" + jndiName); + return lookupDestination("dynamicQueues/" + jndiName); } } Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java Wed Jan 2 12:35:15 2008 @@ -33,11 +33,9 @@ public void setServiceA(HelloWorldService service) { this.serviceA = service; } - + public String sayHello(String name) { return serviceA.sayHello(name); } - - - + } Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSTestCaseFIXME.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSTestCaseFIXME.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSTestCaseFIXME.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSTestCaseFIXME.java Wed Jan 2 12:35:15 2008 @@ -26,34 +26,29 @@ import org.junit.BeforeClass; import org.junit.Test; - /** * This shows how to test the JMS binding using a simple HelloWorld application. */ public class JMSTestCaseFIXME { - private static BrokerService broker; - private static HelloWorldService helloWorldService; - private static SCADomain scaDomain; + private static BrokerService broker; + private static HelloWorldService helloWorldService; + private static SCADomain scaDomain; /* - * This test is a bit strange for two reasons - * 1/ starting and stopping the broker repeatedly for multiple tests - * sometimes leads to orphaned lock files being left on disc - * 2/ it doesn't seem possible to load a single composite file - * at the moment so I've put all the components for the test - * in one. This makes it very difficult to test for failure - * cases at this level. - * For these reasons setup happens at a class level at the moment + * This test is a bit strange for two reasons 1/ starting and stopping the broker repeatedly for multiple tests + * sometimes leads to orphaned lock files being left on disc 2/ it doesn't seem possible to load a single composite + * file at the moment so I've put all the components for the test in one. This makes it very difficult to test for + * failure cases at this level. For these reasons setup happens at a class level at the moment */ - + @BeforeClass public static void oneTimeSetUp() throws Exception { // start the activemq broker broker = new BrokerService(); broker.addConnector("tcp://localhost:61616"); broker.start(); - + // start the SCA runtime scaDomain = SCADomain.newInstance("JMSBindingTest.composite"); } @@ -61,26 +56,22 @@ @AfterClass public static void oneTimeTearDown() throws Exception { scaDomain.close(); - + broker.stop(); // only available in 4.2 snapshot - //broker.waitUntilStopped(); - } - -/* At the moment I can't get at the target list in order to auto generate queue names - * so binding.jms with no configuration doesn't work - @Test - public void testHelloWorldMinimal() throws Exception { - helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldMinimalClientComponent"); - assertEquals("Hello Fred", helloWorldService.sayHello("Fred")); + // broker.waitUntilStopped(); } -*/ + + /* + * At the moment I can't get at the target list in order to auto generate queue names so binding.jms with no + * configuration doesn't work @Test public void testHelloWorldMinimal() throws Exception { helloWorldService = + * scaDomain.getService(HelloWorldService.class, "HelloWorldMinimalClientComponent"); assertEquals("Hello Fred", + * helloWorldService.sayHello("Fred")); } + */ @Test public void testHelloWorldCreate() throws Exception { helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldCreateClientComponent"); assertEquals("ServiceA says Hello Fred-A ServiceB says Hello Fred-B", helloWorldService.sayHello("Fred")); } - - } Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCase.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCase.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCase.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCase.java Wed Jan 2 12:35:15 2008 @@ -36,92 +36,85 @@ import org.junit.Test; /** - * This unit test is used to ensure that a JMS Message delivered - * to a Component will select the correct operation based on - * the details in section 1.5 of the JMS Binding specification. + * This unit test is used to ensure that a JMS Message delivered to a Component will select the correct operation based + * on the details in section 1.5 of the JMS Binding specification. */ -public class OperationSelectionTestCase -{ +public class OperationSelectionTestCase { /** - * This test attempts to invoke a Service with a Single method where scaOperationName - * is not specified in the JMS Message + * This test attempts to invoke a Service with a Single method where scaOperationName is not specified in the JMS + * Message *

    - * Expected behaviour is that the single method will be invoked as scaOperationName - * is ignored + * Expected behaviour is that the single method will be invoked as scaOperationName is ignored * * @throws Exception Failed */ @Test public void testServiceWithOnlyOneOperationScaOperationNameNotSpecified() throws Exception { // Create the operation we should match - final Operation expectedOperation = new OperationImpl("myOperation"); - + final Operation expectedOperation = new OperationImpl("myOperation"); + // Create the list of operations for the Service final List operations = new ArrayList(); operations.add(expectedOperation); // The name of the Operation in the JMS Message - not specified final String scaOperationName = null; - + // Do the test doTestJMSBinding(expectedOperation, operations, scaOperationName); } /** - * This test attempts to invoke a Service with a Single method where scaOperationName - * in the JMS Message matches the method name on the Service + * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message matches the + * method name on the Service *

    - * Expected behaviour is that the single method will be invoked as scaOperationName - * is ignored + * Expected behaviour is that the single method will be invoked as scaOperationName is ignored * * @throws Exception Failed */ @Test public void testServiceWithOnlyOneOperationScaOperationNameMatches() throws Exception { // Create the operation we should match - final Operation expectedOperation = new OperationImpl("myOperation"); - + final Operation expectedOperation = new OperationImpl("myOperation"); + // Create the list of operations for the Service final List operations = new ArrayList(); operations.add(expectedOperation); // The name of the Operation in the JMS Message - matches operation name final String scaOperationName = expectedOperation.getName(); - + // Do the test doTestJMSBinding(expectedOperation, operations, scaOperationName); } - /** - * This test attempts to invoke a Service with a Single method where scaOperationName - * in the JMS Message is different the method name on the Service + * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message is + * different the method name on the Service *

    - * Expected behaviour is that the single method will be invoked as scaOperationName - * is ignored + * Expected behaviour is that the single method will be invoked as scaOperationName is ignored * * @throws Exception Failed */ @Test public void testServiceWithOnlyOneOperationScaOperationNameDifferent() throws Exception { // Create the operation we should match - final Operation expectedOperation = new OperationImpl("myOperation"); - + final Operation expectedOperation = new OperationImpl("myOperation"); + // Create the list of operations for the Service final List operations = new ArrayList(); operations.add(expectedOperation); // The name of the Operation in the JMS Message - different to operation name final String scaOperationName = "Does Not Match Opeation Name"; - + // Do the test doTestJMSBinding(expectedOperation, operations, scaOperationName); } - /** - * This test attempts to invoke a Service with a multiple operations where scaOperationName - * specified in the JMS Message matches an operation name + * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS + * Message matches an operation name *

    * Expected behaviour is that the named method will be invoked. * @@ -130,7 +123,7 @@ @Test public void testServiceWithMultipleOperationsScaOperationNameSpecified() throws Exception { // Create the list of operations for the Service - final List operations = new ArrayList(); + final List operations = new ArrayList(); for (int i = 0; i < 5; i++) { operations.add(new OperationImpl("operation" + i)); } @@ -139,15 +132,15 @@ for (Operation expectedOperation : operations) { // The name of the Operation in the JMS Message final String scaOperationName = expectedOperation.getName(); - + // Do the test doTestJMSBinding(expectedOperation, operations, scaOperationName); } } - + /** - * This test attempts to invoke a Service with a multiple operations where scaOperationName - * specified in the JMS Message is not set so we invoke the onMessage() method + * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS + * Message is not set so we invoke the onMessage() method *

    * Expected behaviour is that the onMessage() method should be used instead * @@ -156,37 +149,34 @@ @Test public void testServiceWithMultipleOperationsScaOperationNotSpecified() throws Exception { // Create the list of operations for the Service - final List operations = new ArrayList(); + final List operations = new ArrayList(); for (int i = 0; i < 5; i++) { operations.add(new OperationImpl("operation" + i)); } - + // Add the onMessage operation to the Service Contract final Operation onMessageOperation = new OperationImpl("onMessage"); operations.add(onMessageOperation); - // The name of the Operation in the JMS Message is not set so it will attempt - // to invoke the onMessage() method + // The name of the Operation in the JMS Message is not set so it will attempt + // to invoke the onMessage() method final String scaOperationName = null; - + // Do the test doTestJMSBinding(onMessageOperation, operations, scaOperationName); } /** - * This is the test method that will attempt to unit test invoking a Service with the - * specified operations using a JMS Message with the specified scaOperationName to ensure - * that it invokes the expectedOperation + * This is the test method that will attempt to unit test invoking a Service with the specified operations using a + * JMS Message with the specified scaOperationName to ensure that it invokes the expectedOperation * * @param expectedOperation The Operation we are expecting to be invoked over JMS * @param operations The list of Operations supported by the Service * @param scaOperationName The value to set scaOperationName in the JMS Message - * * @throws Exception Failed */ - private void doTestJMSBinding(Operation expectedOperation, List operations, String scaOperationName) - throws Exception - { + private void doTestJMSBinding(Operation expectedOperation, List operations, String scaOperationName) + throws Exception { // Create the test JMS Binding final JMSBinding jmsBinding = new JMSBinding(); JMSResourceFactory jmsResourceFactory = null; @@ -194,9 +184,9 @@ // Extra information for the method we are invoking final String operationParams = "Hello"; final Object operationReturnValue = "Operation Success"; - + // Mock up the Service. Basically, it is going to call: - // List opList = service.getInterfaceContract().getInterface().getOperations(); + // List opList = service.getInterfaceContract().getInterface().getOperations(); final InterfaceContract ifaceContract = EasyMock.createStrictMock(InterfaceContract.class); final RuntimeComponentService service = EasyMock.createStrictMock(RuntimeComponentService.class); final Interface iface = EasyMock.createStrictMock(Interface.class); @@ -205,36 +195,36 @@ EasyMock.expect(service.getInterfaceContract()).andReturn(ifaceContract); // Mock up getting and invoking the RuntimeWire. It is going to call: - // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload); + // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload); final RuntimeWire runtimeWire = EasyMock.createStrictMock(RuntimeWire.class); EasyMock.expect(service.getRuntimeWire(jmsBinding)).andReturn(runtimeWire); - EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[]{operationParams})).andReturn(operationReturnValue); - + EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[] {operationParams})) + .andReturn(operationReturnValue); + // Create the JMS Binding Listener final JMSBindingListener bindingListener = new JMSBindingListener(jmsBinding, jmsResourceFactory, service); - + // Simulate a message final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class); EasyMock.expect(requestJMSMsg.getStringProperty("scaOperationName")).andReturn(scaOperationName); EasyMock.expect(requestJMSMsg.getText()).andReturn(operationParams); EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(null); - - + // Lets put all the mocks into replay mode -// EasyMock.replay(iface); + // EasyMock.replay(iface); EasyMock.replay(ifaceContract); EasyMock.replay(service); EasyMock.replay(requestJMSMsg); EasyMock.replay(runtimeWire); - + // Do the test bindingListener.onMessage(requestJMSMsg); // Verify our Mock objects -// EasyMock.verify(iface); -// EasyMock.verify(ifaceContract); -// EasyMock.verify(service); -// EasyMock.verify(requestJMSMsg); -// EasyMock.verify(runtimeWire); + // EasyMock.verify(iface); + // EasyMock.verify(ifaceContract); + // EasyMock.verify(service); + // EasyMock.verify(requestJMSMsg); + // EasyMock.verify(runtimeWire); } } Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java Wed Jan 2 12:35:15 2008 @@ -34,8 +34,9 @@ @Before public void init() { - scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite", "simple/service.composite"); -// scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); + scaDomain = + SCADomain.newInstance("http://localhost", "/", "simple/client.composite", "simple/service.composite"); + // scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); } @Test Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactory.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactory.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactory.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactory.java Wed Jan 2 12:35:15 2008 @@ -62,8 +62,8 @@ final Session session = EasyMock.createMock(Session.class); final MessageConsumer consumer = EasyMock.createMock(MessageConsumer.class); final MessageListener listener = EasyMock.createMock(MessageListener.class); - EasyMock.expect(session.createConsumer((Destination) EasyMock.anyObject())).andReturn(consumer); - consumer.setMessageListener((MessageListener) EasyMock.anyObject()); + EasyMock.expect(session.createConsumer((Destination)EasyMock.anyObject())).andReturn(consumer); + consumer.setMessageListener((MessageListener)EasyMock.anyObject()); EasyMock.replay(session); EasyMock.replay(consumer); EasyMock.replay(listener); Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueExist.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueExist.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueExist.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueExist.java Wed Jan 2 12:35:15 2008 @@ -25,19 +25,17 @@ import org.easymock.EasyMock; /** - * This mock JMSResourceFactory will create a mock Destination when the - * lookupDestination() method is called + * This mock JMSResourceFactory will create a mock Destination when the lookupDestination() method is called */ -public class MockJMSResourceFactoryQueueExist extends MockJMSResourceFactory -{ +public class MockJMSResourceFactoryQueueExist extends MockJMSResourceFactory { /** * Constructor - * + * * @param jmsBinding Ignored */ public MockJMSResourceFactoryQueueExist(JMSBinding jmsBinding) { } - + /** * Return a mock Destination object */ Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueNotExist.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueNotExist.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueNotExist.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/mock/MockJMSResourceFactoryQueueNotExist.java Wed Jan 2 12:35:15 2008 @@ -24,19 +24,17 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; /** - * This mock JMSResourceFactory will always return null when the - * lookupDestination() method is called + * This mock JMSResourceFactory will always return null when the lookupDestination() method is called */ -public class MockJMSResourceFactoryQueueNotExist extends MockJMSResourceFactory -{ +public class MockJMSResourceFactoryQueueNotExist extends MockJMSResourceFactory { /** * Constructor - * + * * @param jmsBinding Ignored */ public MockJMSResourceFactoryQueueNotExist(JMSBinding jmsBinding) { } - + /** * Always returns null */ Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceQueueCreateModeTestCase.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceQueueCreateModeTestCase.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceQueueCreateModeTestCase.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceQueueCreateModeTestCase.java Wed Jan 2 12:35:15 2008 @@ -29,228 +29,250 @@ import org.junit.Test; /** - * This unit test tests various combinations of the JMS Binding create modes for both request and response - * queues. + * This unit test tests various combinations of the JMS Binding create modes for both request and response queues. *

    * The SCA JMS Binding specification lists 3 create modes: *

      *
    • always - the JMS queue is always created. It is an error if the queue already exists *
    • ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists *
    • never - the JMS queue is never created. It is an error if the queue does not exist - *
    + * * See the SCA JMS Binding specification for more information. */ public class JMSBindingReferenceQueueCreateModeTestCase { - + /** - * Test creating a request queue in "never" mode - * where the queue does not exist. - * We are expecting an exception + * Test creating a request queue in "never" mode where the queue does not exist. We are expecting an exception */ @Test public void testRequestCreateNeverQueueNotExist() { - String requestCreateMode = "never"; + String requestCreateMode = "never"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = false; boolean expectingRequestException = true; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a request queue in "never" mode - * where the queue exists. - * We are expecting this to work + * Test creating a request queue in "never" mode where the queue exists. We are expecting this to work */ @Test public void testRequestCreateNeverQueueExists() { - String requestCreateMode = "never"; + String requestCreateMode = "never"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = true; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } - /** - * Test creating a request queue in "ifnotexist" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a request queue in "ifnotexist" mode where the queue does not exist. We are expecting this to work */ @Test public void testRequestCreateIfNotExistQueueNotExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = false; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a request queue in "ifnotexist" mode - * where the queue exists. - * We are expecting this to work + * Test creating a request queue in "ifnotexist" mode where the queue exists. We are expecting this to work */ @Test public void testRequestCreateIfNotExistQueueExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = true; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } - /** - * Test creating a request queue in "always" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a request queue in "always" mode where the queue does not exist. We are expecting this to work */ @Test public void testRequestCreateAlwaysQueueNotExist() { - String requestCreateMode = "always"; + String requestCreateMode = "always"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = false; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a request queue in "always" mode - * where the queue exists. - * We are expecting an exception + * Test creating a request queue in "always" mode where the queue exists. We are expecting an exception */ @Test public void testRequestCreateAlwaysQueueExists() { - String requestCreateMode = "always"; + String requestCreateMode = "always"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = true; boolean expectingRequestException = true; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a response queue in "never" mode - * where the queue does not exist. - * We are expecting an exception + * Test creating a response queue in "never" mode where the queue does not exist. We are expecting an exception */ @Test public void testResponseCreateNeverQueueNotExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "never"; boolean preCreateQueue = false; boolean expectingRequestException = false; boolean expectingResponseException = true; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a response queue in "never" mode - * where the queue exists. - * We are expecting this to work + * Test creating a response queue in "never" mode where the queue exists. We are expecting this to work */ @Test public void testResponseCreateNeverQueueExists() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "never"; boolean preCreateQueue = true; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } - /** - * Test creating a response queue in "ifnotexist" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a response queue in "ifnotexist" mode where the queue does not exist. We are expecting this to work */ @Test public void testResponseCreateIfNotExistQueueNotExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = false; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a response queue in "ifnotexist" mode - * where the queue not exists. - * We are expecting this to work + * Test creating a response queue in "ifnotexist" mode where the queue not exists. We are expecting this to work */ @Test public void testResponseCreateIfNotExistQueueExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "ifnotexist"; boolean preCreateQueue = true; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } - /** - * Test creating a response queue in "always" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a response queue in "always" mode where the queue does not exist. We are expecting this to work */ @Test public void testResponseCreateAlwaysQueueNotExist() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "always"; boolean preCreateQueue = false; boolean expectingRequestException = false; boolean expectingResponseException = false; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } /** - * Test creating a response queue in "always" mode - * where the queue exists. - * We are expecting an exception + * Test creating a response queue in "always" mode where the queue exists. We are expecting an exception */ @Test public void testResponseCreateAlwaysQueueExists() { - String requestCreateMode = "ifnotexist"; + String requestCreateMode = "ifnotexist"; String responseCreateMode = "always"; boolean preCreateQueue = true; boolean expectingRequestException = false; boolean expectingResponseException = true; - - doTestCase(requestCreateMode, responseCreateMode, preCreateQueue, expectingRequestException, expectingResponseException); + + doTestCase(requestCreateMode, + responseCreateMode, + preCreateQueue, + expectingRequestException, + expectingResponseException); } - + /** * This is the main test method for the various test scenarios for the JMS Binding. * * @param requestCreateMode The required create mode for the request destination queue * @param responseCreateMode The required create mode for the response destination queue * @param preCreateQueue Whether the queue should be pre-created. - * @param expectingRequestException true if we are expecting an exception because the - * request queue configuration is invalid; false otherwise - * @param expectingResponseException true if we are expecting an exception because the - * request queue configuration is invalid; false otherwise - */ - private void doTestCase(String requestCreateMode, String responseCreateMode, boolean preCreateQueue, - boolean expectingRequestException, boolean expectingResponseException) { + * @param expectingRequestException true if we are expecting an exception because the request queue configuration is + * invalid; false otherwise + * @param expectingResponseException true if we are expecting an exception because the request queue configuration + * is invalid; false otherwise + */ + private void doTestCase(String requestCreateMode, + String responseCreateMode, + boolean preCreateQueue, + boolean expectingRequestException, + boolean expectingResponseException) { String requestDestinationName = "SomeRequestDestination"; String responseDestinationName = "SomeResponseDestination"; String jmsBindingName = "MyJMSBinding"; @@ -267,15 +289,15 @@ jmsBinding.setDestinationName(requestDestinationName); jmsBinding.setResponseDestinationName(responseDestinationName); jmsBinding.setName(jmsBindingName); - + // Create the operation Operation operation = new OperationImpl(); operation.setName("OperationName"); - + // Try and create the JMS Binding Invoker for the JMS Binding try { new JMSBindingInvoker(jmsBinding, operation); - + // Check whether we were expecting an exception if (expectingRequestException || expectingResponseException) { // We were expecting an exception Modified: incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCase.java URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCase.java?rev=608212&r1=608211&r2=608212&view=diff ============================================================================== --- incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCase.java (original) +++ incubator/tuscany/java/sca/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCase.java Wed Jan 2 12:35:15 2008 @@ -36,95 +36,82 @@ *
  • always - the JMS queue is always created. It is an error if the queue already exists *
  • ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists *
  • never - the JMS queue is never created. It is an error if the queue does not exist - * + * * See the SCA JMS Binding specification for more information. */ -public class JMSBindingServiceQueueCreateModeTestCase -{ +public class JMSBindingServiceQueueCreateModeTestCase { /** - * Test creating a queue in "never" mode - * where the queue does not exist. - * We are expecting an exception + * Test creating a queue in "never" mode where the queue does not exist. We are expecting an exception */ @Test public void testCreateNeverQueueNotExist() { - String createMode = "never"; + String createMode = "never"; boolean preCreateQueue = false; boolean expectingException = true; - + doTestCase(createMode, preCreateQueue, expectingException); } /** - * Test creating a queue in "never" mode - * where the queue exists. - * We are expecting this to work + * Test creating a queue in "never" mode where the queue exists. We are expecting this to work */ @Test public void testCreateNeverQueueExist() { - String createMode = "never"; + String createMode = "never"; boolean preCreateQueue = true; boolean expectingException = false; - + doTestCase(createMode, preCreateQueue, expectingException); } /** - * Test creating a queue in "ifnotexist" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a queue in "ifnotexist" mode where the queue does not exist. We are expecting this to work */ @Test public void testCreateIfNotExistQueueNotExist() { - String createMode = "ifnotexist"; + String createMode = "ifnotexist"; boolean preCreateQueue = false; boolean expectingException = false; - + doTestCase(createMode, preCreateQueue, expectingException); } - + /** - * Test creating a queue in "ifnotexist" mode - * where the queue exists. - * We are expecting this to work + * Test creating a queue in "ifnotexist" mode where the queue exists. We are expecting this to work */ @Test public void testCreateIfNotExistQueueExist() { - String createMode = "ifnotexist"; + String createMode = "ifnotexist"; boolean preCreateQueue = true; boolean expectingException = false; - + doTestCase(createMode, preCreateQueue, expectingException); } /** - * Test creating a queue in "always" mode - * where the queue does not exist. - * We are expecting this to work + * Test creating a queue in "always" mode where the queue does not exist. We are expecting this to work */ @Test public void testCreateAlwaysQueueNotExist() { - String createMode = "always"; + String createMode = "always"; boolean preCreateQueue = false; boolean expectingException = false; - + doTestCase(createMode, preCreateQueue, expectingException); } - + /** - * Test creating a queue in "always" mode - * where the queue exists. - * We are expecting an exception + * Test creating a queue in "always" mode where the queue exists. We are expecting an exception */ @Test public void testCreateAlwaysQueueExist() { - String createMode = "always"; + String createMode = "always"; boolean preCreateQueue = true; boolean expectingException = true; - + doTestCase(createMode, preCreateQueue, expectingException); } - + /** * This is the main test method for the various test scenarios for the JMS Binding. * @@ -132,8 +119,7 @@ * @param preCreateQueue Whether the queue should be pre-created. * @param expectingException true if test should throw an exception */ - private void doTestCase(String createMode, boolean preCreateQueue, - boolean expectingException) { + private void doTestCase(String createMode, boolean preCreateQueue, boolean expectingException) { String destinationName = "SomeDestination"; String jmsBindingName = "MyJMSBinding"; String serviceName = "MyServiceName"; @@ -151,10 +137,11 @@ RuntimeComponentService service = new RuntimeComponentServiceImpl(); service.setName(serviceName); - + // Try and create the JMS Binding Service for the JMS Binding try { - JMSBindingServiceBindingProvider jmsService = new JMSBindingServiceBindingProvider(null, service, jmsBinding); + JMSBindingServiceBindingProvider jmsService = + new JMSBindingServiceBindingProvider(null, service, jmsBinding); jmsService.start(); // Check whether we were expecting an exception @@ -172,13 +159,14 @@ // We should get a JMSBindingException Assert.assertTrue(ex.getMessage().indexOf("Error starting JMSServiceBinding") != -1); - + // Validate that the expected chained exception exception has the text we expect Assert.assertNotNull(ex.getCause()); Assert.assertTrue(ex.getCause().getMessage().indexOf("JMS Destination") != -1); Assert.assertTrue(ex.getCause().getMessage().indexOf(createMode) != -1); Assert.assertTrue(ex.getCause().getMessage().indexOf(destinationName) != -1); - Assert.assertTrue(ex.getCause().getMessage().indexOf("registering service " + serviceName + " listener") != -1); + Assert + .assertTrue(ex.getCause().getMessage().indexOf("registering service " + serviceName + " listener") != -1); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org For additional commands, e-mail: tuscany-commits-help@ws.apache.org