View Javadoc

1   /*
2    * $Id: SpringRemotingTestCase.java 22469 2011-07-20 09:26:08Z justin.calleja $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.spring.remoting;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.Test;
20  import org.junit.runners.Parameterized.Parameters;
21  import org.mule.tck.AbstractServiceAndFlowTestCase;
22  import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
23  
24  public class SpringRemotingTestCase extends AbstractServiceAndFlowTestCase
25  {
26      private static final String SPRING_HTTP_ENDPOINT = "http://localhost:8003/springService";
27  
28      public SpringRemotingTestCase(ConfigVariant variant, String configResources)
29      {
30          super(variant, configResources);
31      }
32      
33      @Parameters
34      public static Collection<Object[]> parameters()
35      {
36          return Arrays.asList(new Object[][]{
37              {ConfigVariant.SERVICE, "spring-remoting-mule-config-service.xml"},
38              {ConfigVariant.FLOW, "spring-remoting-mule-config-flow.xml"}
39          });
40      }
41  
42      @Test
43      public void testHttpInvokeSpringService() throws Exception
44      {
45          ComplexData cd = new ComplexData("Foo", new Integer(13));
46          HttpInvokerProxyFactoryBean invoker = new HttpInvokerProxyFactoryBean();
47          invoker.setServiceInterface(WorkInterface.class);
48          invoker.setServiceUrl(SPRING_HTTP_ENDPOINT);
49          invoker.afterPropertiesSet();
50          WorkInterface worker = (WorkInterface)invoker.getObject();
51          ComplexData data = worker.executeComplexity(cd);
52          assertNotNull(data);
53          assertEquals(data.getSomeString(), "Foo Received");
54          assertEquals(data.getSomeInteger(), new Integer(14));
55      }
56  }