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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/servlet/marshal/ContentTypeTestClient.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
* JBoss, Home of Professional Open Source
 
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
 
4
* by the @authors tag. See the copyright.txt in the distribution for a
 
5
* full listing of individual contributors.
 
6
*
 
7
* This is free software; you can redistribute it and/or modify it
 
8
* under the terms of the GNU Lesser General Public License as
 
9
* published by the Free Software Foundation; either version 2.1 of
 
10
* the License, or (at your option) any later version.
 
11
*
 
12
* This software is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
* Lesser General Public License for more details.
 
16
*
 
17
* You should have received a copy of the GNU Lesser General Public
 
18
* License along with this software; if not, write to the Free
 
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
21
*/
 
22
package org.jboss.test.remoting.transport.servlet.marshal;
 
23
 
 
24
import java.util.HashMap;
 
25
import java.util.Map;
 
26
 
 
27
import org.jboss.logging.Logger;
 
28
import org.jboss.remoting.Client;
 
29
import org.jboss.remoting.InvokerLocator;
 
30
import org.jboss.remoting.transport.http.HTTPMetadataConstants;
 
31
import org.jboss.test.remoting.transport.http.marshal.HttpContentTypeTestCase;
 
32
 
 
33
 
 
34
/**
 
35
 * Unit tests for JBREM-1145.
 
36
 * 
 
37
 * @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
 
38
 * @version $Revision: 1.1 $
 
39
 * <p>
 
40
 * Copyright August 17, 2009
 
41
 * </p>
 
42
 */
 
43
public class ContentTypeTestClient extends HttpContentTypeTestCase
 
44
{
 
45
   private static Logger log = Logger.getLogger(ContentTypeTestClient.class);
 
46
   
 
47
   
 
48
   protected void validateOrdinaryInvocation(Client client) throws Throwable
 
49
   {
 
50
      // Local tests
 
51
      log.info("TestMarshaller.marshallers.size(): " + TestMarshaller.marshallers.size());
 
52
      log.info("TestMarshaller.unmarshallers.size(): " + TestUnMarshaller.unmarshallers.size());
 
53
      assertEquals(2, TestMarshaller.marshallers.size());
 
54
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(1)).type);
 
55
      assertEquals(2, TestUnMarshaller.unmarshallers.size());
 
56
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
 
57
 
 
58
      // Remote tests
 
59
      int serverMarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_MARSHALLERS)).intValue();
 
60
      log.info("server side marshallers: " + serverMarshallerCount);
 
61
      int serverUnmarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_UNMARSHALLERS)).intValue();
 
62
      log.info("server side unmarshallers: " + serverUnmarshallerCount);
 
63
      Map metadata = new HashMap();
 
64
      metadata.put(TestInvocationHandler.N, Integer.toString(serverMarshallerCount - 1));
 
65
      String type = (String) client.invoke(TestInvocationHandler.GET_NTH_MARSHALLER_TYPE, metadata);
 
66
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, type);
 
67
      metadata.put(TestInvocationHandler.N, Integer.toString(serverUnmarshallerCount - 1));
 
68
      type = (String) client.invoke(TestInvocationHandler.GET_NTH_UNMARSHALLER_TYPE, metadata);
 
69
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, type);
 
70
      client.invoke(TestInvocationHandler.RESET);
 
71
   }
 
72
   
 
73
   
 
74
   protected void validateRawStringMessage(Client client) throws Throwable
 
75
   {
 
76
      // Local tests
 
77
      log.info("TestMarshaller.marshallers.size(): " + TestMarshaller.marshallers.size());
 
78
      log.info("TestMarshaller.unmarshallers.size(): " + TestUnMarshaller.unmarshallers.size());
 
79
      assertEquals(2, TestMarshaller.marshallers.size());
 
80
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(1)).type);
 
81
      assertEquals(2, TestUnMarshaller.unmarshallers.size());
 
82
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
 
83
 
 
84
      // Remote tests
 
85
      int serverMarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_MARSHALLERS)).intValue();
 
86
      log.info("server side marshallers: " + serverMarshallerCount);
 
87
      int serverUnmarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_UNMARSHALLERS)).intValue();
 
88
      log.info("server side unmarshallers: " + serverUnmarshallerCount);
 
89
      assertEquals(4, serverMarshallerCount);
 
90
      assertEquals(6, serverUnmarshallerCount);
 
91
      Map metadata = new HashMap();
 
92
      metadata.put(TestInvocationHandler.N, "3");
 
93
      String type = (String) client.invoke(TestInvocationHandler.GET_NTH_MARSHALLER_TYPE, metadata);
 
94
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, type);
 
95
      metadata.put(TestInvocationHandler.N, "1");
 
96
      type = (String) client.invoke(TestInvocationHandler.GET_NTH_UNMARSHALLER_TYPE, metadata);
 
97
      assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, type);
 
98
      client.invoke(TestInvocationHandler.RESET);
 
99
   }
 
100
   
 
101
   protected String getTransport()
 
102
   {
 
103
      return "servlet";
 
104
   }
 
105
   
 
106
   protected void setupServer(boolean addUseRemotingContentType, boolean useRemotingContentType) throws Exception
 
107
   {
 
108
      String path = null;
 
109
      String useRemotingContentTypeAttribute = null;
 
110
      if (addUseRemotingContentType)
 
111
      {
 
112
         if (useRemotingContentType)
 
113
         {
 
114
            path = "servlet-invoker/ServerInvokerServlet/true";
 
115
            useRemotingContentTypeAttribute = "&useRemotingContentType=true";         
 
116
         }
 
117
         else
 
118
         {
 
119
            path = "servlet-invoker/ServerInvokerServlet/false";
 
120
            useRemotingContentTypeAttribute = "&useRemotingContentType=false";
 
121
         }
 
122
      }
 
123
      else
 
124
      {
 
125
         path = "servlet-invoker/ServerInvokerServlet/default";
 
126
         useRemotingContentTypeAttribute = "";
 
127
      }
 
128
      
 
129
      String locatorURI = "servlet://localhost:8080/" + path + "/?datatype=test&marshaller=org.jboss.test.remoting.marshall.TestMarshaller&unmarshaller=org.jboss.test.remoting.marshall.TestUnmarshaller" + useRemotingContentTypeAttribute;
 
130
      serverLocator = new InvokerLocator(locatorURI);
 
131
   }
 
132
}
 
 
b'\\ No newline at end of file'