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.
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.
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.
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.
22
package org.jboss.test.remoting.transport.servlet.marshal;
24
import java.util.HashMap;
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;
35
* Unit tests for JBREM-1145.
37
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
38
* @version $Revision: 1.1 $
40
* Copyright August 17, 2009
43
public class ContentTypeTestClient extends HttpContentTypeTestCase
45
private static Logger log = Logger.getLogger(ContentTypeTestClient.class);
48
protected void validateOrdinaryInvocation(Client client) throws Throwable
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);
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);
74
protected void validateRawStringMessage(Client client) throws Throwable
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);
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);
101
protected String getTransport()
106
protected void setupServer(boolean addUseRemotingContentType, boolean useRemotingContentType) throws Exception
109
String useRemotingContentTypeAttribute = null;
110
if (addUseRemotingContentType)
112
if (useRemotingContentType)
114
path = "servlet-invoker/ServerInvokerServlet/true";
115
useRemotingContentTypeAttribute = "&useRemotingContentType=true";
119
path = "servlet-invoker/ServerInvokerServlet/false";
120
useRemotingContentTypeAttribute = "&useRemotingContentType=false";
125
path = "servlet-invoker/ServerInvokerServlet/default";
126
useRemotingContentTypeAttribute = "";
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);
b'\\ No newline at end of file'