~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to .pc/0001-convert-to-official-Java-concurrent-packages.patch/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/SpringHessianPerformanceClient.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************
 
2
 *                                     *
 
3
 *  JBoss: The OpenSource J2EE WebOS   *
 
4
 *                                     *
 
5
 *  Distributable under LGPL license.  *
 
6
 *  See terms of license at gnu.org.   *
 
7
 *                                     *
 
8
 ***************************************/
 
9
package org.jboss.test.remoting.performance.spring.hessian.client;
 
10
 
 
11
import EDU.oswego.cs.dl.util.concurrent.Latch;
 
12
import junit.framework.Test;
 
13
import org.jboss.jrunit.decorators.ThreadLocalDecorator;
 
14
import org.jboss.logging.Logger;
 
15
import org.jboss.remoting.InvokerLocator;
 
16
import org.jboss.test.remoting.performance.spring.hessian.web.SpringHessianServer;
 
17
import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper;
 
18
import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest;
 
19
import org.springframework.context.ApplicationContext;
 
20
import org.springframework.context.support.FileSystemXmlApplicationContext;
 
21
import org.springframework.remoting.caucho.HessianProxyFactoryBean;
 
22
 
 
23
import java.net.MalformedURLException;
 
24
import java.rmi.server.UID;
 
25
import java.util.Map;
 
26
 
 
27
/**
 
28
 * @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
 
29
 */
 
30
public class SpringHessianPerformanceClient extends PerformanceClientTest
 
31
{
 
32
 
 
33
   private SpringHessianServer springHessianServerService;
 
34
   private String clientSessionId = new UID().toString();
 
35
 
 
36
   protected static final Logger log = Logger.getLogger(SpringHessianPerformanceClient.class);
 
37
 
 
38
   public static Test suite()
 
39
   {
 
40
      return new ThreadLocalDecorator(SpringHessianPerformanceClient.class, 1);
 
41
   }
 
42
 
 
43
   public SpringHessianServer getSpringHessianServerService()
 
44
   {
 
45
      return springHessianServerService;
 
46
   }
 
47
 
 
48
   public void setSpringHessianServerService(SpringHessianServer springHessianServerService)
 
49
   {
 
50
      this.springHessianServerService = springHessianServerService;
 
51
   }
 
52
 
 
53
   public void init()
 
54
   {
 
55
 
 
56
//      Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringHessianPerformanceClient.class);
 
57
//      BeanFactory factory = new XmlBeanFactory(res);
 
58
//      springHessianServerService = (SpringHessianServer)factory.getBean("springRMIServerService");
 
59
 
 
60
 
 
61
      try
 
62
      {
 
63
         HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
 
64
         factory.setServiceInterface(SpringHessianServer.class);
 
65
         factory.setServiceUrl("http://localhost:8080/remoting/springHessianServerService");
 
66
         factory.afterPropertiesSet();
 
67
         springHessianServerService = (SpringHessianServer) factory.getObject();
 
68
         if (false) throw new MalformedURLException("xxx");
 
69
      }
 
70
      catch (MalformedURLException e)
 
71
      {
 
72
         e.printStackTrace();
 
73
      }
 
74
 
 
75
   }
 
76
 
 
77
   /**
 
78
    * This will be used to create callback server
 
79
    *
 
80
    * @param port
 
81
    * @return
 
82
    * @throws Exception
 
83
    */
 
84
   protected InvokerLocator initServer(int port) throws Exception
 
85
   {
 
86
      return null;
 
87
   }
 
88
 
 
89
   protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock)
 
90
         throws Throwable
 
91
   {
 
92
      String springServiceXml = this.getClass().getResource("SpringHessianClientService.xml").getFile();
 
93
 
 
94
      ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml);
 
95
      SpringHessianCallbackServer callbackServer = (SpringHessianCallbackServer) context.getBean("springHessianCallbackServerService");
 
96
      callbackServer.setClientSessionId(clientSessionId);
 
97
      callbackServer.setServerDoneLock(serverDoneLock);
 
98
      return callbackServer;
 
99
 
 
100
//      RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock);
 
101
//      callbackServer.start();
 
102
//      return callbackServer;
 
103
   }
 
104
 
 
105
   protected void populateMetadata(Map metadata)
 
106
   {
 
107
      super.populateMetadata(metadata);
 
108
      metadata.put("transport", "spring_hessian");
 
109
      metadata.put("serialization", "java");
 
110
   }
 
111
 
 
112
   protected Object getBenchmarkAlias()
 
113
   {
 
114
      String config = System.getProperty("alias");
 
115
      if(config == null || config.length() == 0)
 
116
      {
 
117
         config = System.getProperty("jboss-junit-configuration");
 
118
         if(config == null || config.length() == 0)
 
119
         {
 
120
            config = "spring_hessian" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java";
 
121
         }
 
122
      }
 
123
      return config;
 
124
   }
 
125
 
 
126
 
 
127
   protected Object makeInvocation(String method, Object param) throws Throwable
 
128
   {
 
129
      if(method.equals(NUM_OF_CALLS))
 
130
      {
 
131
         return springHessianServerService.sendNumberOfCalls(clientSessionId, param);
 
132
      }
 
133
      else if(method.equals(TEST_INVOCATION))
 
134
      {
 
135
         return springHessianServerService.makeCall(clientSessionId, param);
 
136
      }
 
137
      else
 
138
      {
 
139
         throw new Exception("Was not able to find remote method call for " + method);
 
140
      }
 
141
   }
 
142
 
 
143
   public static void main(String[] args)
 
144
   {
 
145
      SpringHessianPerformanceClient test = new SpringHessianPerformanceClient();
 
146
      try
 
147
      {
 
148
         test.setUp();
 
149
         test.testClientCalls();
 
150
         test.tearDown();
 
151
      }
 
152
      catch(Throwable throwable)
 
153
      {
 
154
         throwable.printStackTrace();
 
155
      }
 
156
   }
 
157
 
 
158
}