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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/marshall/http/metadata/HTTPUnMarshallerMetadataTestCase_Retired.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
 
 
23
package org.jboss.test.remoting.marshall.http.metadata;
 
24
 
 
25
import junit.framework.TestCase;
 
26
import org.apache.log4j.Level;
 
27
import org.jboss.remoting.Client;
 
28
import org.jboss.remoting.InvokerLocator;
 
29
 
 
30
import java.util.HashMap;
 
31
import java.util.List;
 
32
import java.util.Map;
 
33
import java.util.Properties;
 
34
 
 
35
/**
 
36
 * Test case that uses the HTTPInvoker client to call on two different public SOAP services (one based
 
37
 * on Axis and the other based on .NET implementations).
 
38
 *
 
39
 * @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
 
40
 */
 
41
public class HTTPUnMarshallerMetadataTestCase_Retired extends TestCase
 
42
{
 
43
   private Client client;
 
44
 
 
45
   public void init(String httpTargetURL, HTTPUnMarshallerMock unmarshaller)
 
46
   {
 
47
      try
 
48
      {
 
49
         InvokerLocator locator = new InvokerLocator(httpTargetURL);
 
50
         client = new Client(locator);
 
51
         client.connect();
 
52
         client.setUnMarshaller(unmarshaller);
 
53
         client.connect();
 
54
      }
 
55
      catch(Exception e)
 
56
      {
 
57
         e.printStackTrace();
 
58
      }
 
59
   }
 
60
 
 
61
   public String makeInvocationCall(String httpTargetURL, String payload, Map metadata, HTTPUnMarshallerMock unmarshaller) throws Throwable
 
62
   {
 
63
      init(httpTargetURL, unmarshaller);
 
64
 
 
65
      Object obj = client.invoke(payload, metadata);
 
66
 
 
67
      System.out.println("invoke returned" + obj);
 
68
 
 
69
      return (String) obj;
 
70
   }
 
71
 
 
72
   public void testWeatherHTTPInvocation() throws Throwable
 
73
   {
 
74
 
 
75
      org.apache.log4j.BasicConfigurator.configure();
 
76
      org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
 
77
      org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
 
78
      org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
 
79
      org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
 
80
 
 
81
 
 
82
      String testURL = "http://services.xmethods.net:80/soap/servlet/rpcrouter";
 
83
 
 
84
      String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
 
85
                   "<soap:Envelope xmlns:mrns0=\"urn:xmethods-Temperature\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
 
86
                   "   <soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" +
 
87
                   "      <mrns0:getTemp>\n" +
 
88
                   "         <zipcode xsi:type=\"xs:string\">30106</zipcode>\n" +
 
89
                   "      </mrns0:getTemp>\n" +
 
90
                   "   </soap:Body>\n" +
 
91
                   "</soap:Envelope>";
 
92
 
 
93
      Map metadata = new HashMap();
 
94
      metadata.put(Client.RAW, Boolean.TRUE);
 
95
      metadata.put("TYPE", "POST");
 
96
 
 
97
      Properties headerProps = new Properties();
 
98
      headerProps.put("SOAPAction", "");
 
99
      headerProps.put("Content-type", "text/xml; charset=UTF-8");
 
100
 
 
101
      metadata.put("HEADER", headerProps);
 
102
 
 
103
 
 
104
      HTTPUnMarshallerMetadataTestCase_Retired client = new HTTPUnMarshallerMetadataTestCase_Retired();
 
105
 
 
106
      HTTPUnMarshallerMock unmarshaller = new HTTPUnMarshallerMock();
 
107
 
 
108
      String result = client.makeInvocationCall(testURL, xml, metadata, unmarshaller);
 
109
 
 
110
      // expect to get the following header
 
111
      assertNotNull(unmarshaller.getMetadata());
 
112
      List header = (List) unmarshaller.getMetadata().get("Status");
 
113
      assertEquals("200", header.get(0));
 
114
 
 
115
      // don't need to comapre full string. (as actual temp value will change each time run)
 
116
      assertEquals(getExpectedWeatherResult().substring(0, 380), result.substring(0, 380));
 
117
 
 
118
   }
 
119
 
 
120
   private String getExpectedWeatherResult()
 
121
   {
 
122
      return "<?xml version='1.0' encoding='UTF-8'?>" +
 
123
             "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
 
124
             "<SOAP-ENV:Body>" +
 
125
             "<ns1:getTempResponse xmlns:ns1=\"urn:xmethods-Temperature\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
 
126
             "<return xsi:type=\"xsd:float\">60.0</return>" +
 
127
             "</ns1:getTempResponse>" +
 
128
             "\n" +
 
129
             "</SOAP-ENV:Body>\n" +
 
130
             "</SOAP-ENV:Envelope>";
 
131
   }
 
132
 
 
133
 
 
134
}
 
 
b'\\ No newline at end of file'