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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/http/proxy/HTTPInvokerProxyTestCase_Retired.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20110909140103-o8ucrolqt5g25k57
Tags: upstream-2.5.3.SP1
ImportĀ upstreamĀ versionĀ 2.5.3.SP1

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.transport.http.proxy;
 
10
 
 
11
import junit.framework.TestCase;
 
12
import org.jboss.remoting.Client;
 
13
import org.jboss.remoting.InvokerLocator;
 
14
 
 
15
import java.util.HashMap;
 
16
import java.util.Map;
 
17
 
 
18
/**
 
19
 * This class is for testing http client invocations through
 
20
 * public proxy server.  Is not a great tests as there is no way
 
21
 * to really prove went through the proxy.  Best test can do
 
22
 * is indicate problem with config.  Also, test may fail just due
 
23
 * to not being able to use proxy server (as is a public proxy server
 
24
 * in China and have no control over it.  for more public proxy server
 
25
 * listings, can see http://www.publicproxyservers.com/page1.html).
 
26
 * Also, no gurantee the content on testUrl will never be changed.
 
27
 *
 
28
 * @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
 
29
 */
 
30
public class HTTPInvokerProxyTestCase_Retired extends TestCase
 
31
{
 
32
   private Client client;
 
33
//   private String testUrl = "http://www.gnu.org/licenses/gpl.html";
 
34
   private String testUrl = "http://www.ietf.org/rfc/rfc1766.txt?number=1766";
 
35
 
 
36
   public void setUp()
 
37
   {
 
38
      init(testUrl);
 
39
   }
 
40
 
 
41
   public void init(String httpTargetURL)
 
42
   {
 
43
      try
 
44
      {
 
45
         InvokerLocator locator = new InvokerLocator(httpTargetURL);
 
46
         Map config = new HashMap();
 
47
         client = new Client(locator, config);
 
48
         client.connect();
 
49
      }
 
50
      catch (Exception e)
 
51
      {
 
52
         e.printStackTrace();
 
53
      }
 
54
   }
 
55
 
 
56
   public String makeInvocationCall(String payload, Map metadata) throws Throwable
 
57
   {
 
58
      Object obj = client.invoke(payload, metadata);
 
59
 
 
60
      System.out.println("invoke returned" + obj);
 
61
 
 
62
      return (String) obj;
 
63
   }
 
64
 
 
65
   public void testHTTPProxyInvocationViaSystemConfig() throws Throwable
 
66
   {
 
67
      Map metadata = new HashMap();
 
68
      metadata.put(Client.RAW, Boolean.TRUE);
 
69
      metadata.put("TYPE", "GET");
 
70
 
 
71
 
 
72
      // proxy info
 
73
      System.setProperty("proxySet", "true");
 
74
      System.setProperty("http.proxyHost", "84.19.177.62");
 
75
      System.setProperty("http.proxyPort", "8080");
 
76
 
 
77
      String result = makeInvocationCall(null, metadata);
 
78
 
 
79
      System.out.println("invoke returned" + result);
 
80
 
 
81
      assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50));
 
82
 
 
83
   }
 
84
 
 
85
   public void testHTTPProxyInvocationViaConfig() throws Throwable
 
86
   {
 
87
      // need to make sure is running jdk 1.5 or higher.
 
88
      // otherwise, no point in running this test method as will
 
89
      // not work with jdk 1.4.
 
90
      boolean isJDK15 = false;
 
91
 
 
92
      try
 
93
      {
 
94
         Class proxyClass = Class.forName("java.net.Proxy");
 
95
         isJDK15 = true;
 
96
      }
 
97
      catch (ClassNotFoundException e)
 
98
      {
 
99
         System.out.println("Not running jdk 1.5 or higher, so will bypass testHTTPProxyInvocationViaConfig test.");
 
100
      }
 
101
 
 
102
      if(isJDK15)
 
103
      {
 
104
         Map metadata = new HashMap();
 
105
         metadata.put(Client.RAW, Boolean.TRUE);
 
106
         metadata.put("TYPE", "GET");
 
107
 
 
108
 
 
109
         // proxy info
 
110
         metadata.put("http.proxyHost", "84.19.177.62");
 
111
         metadata.put("http.proxyPort", "8080");
 
112
 
 
113
         String result = makeInvocationCall(null, metadata);
 
114
 
 
115
         System.out.println("invoke returned" + result);
 
116
 
 
117
         assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50));
 
118
      }
 
119
   }
 
120
 
 
121
   private String getExpectedGETResult()
 
122
   {
 
123
      return "Network Working Group                                      H. AlvestrandRequest for Comments: 1766  ";
 
124
   }
 
125
 
 
126
/*
 
127
   private String getExpectedGETResult()
 
128
   {
 
129
      return "<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><HTML><HEAD><TITLE>GNU General Public License - " +
 
130
             "GNU Project - Free Software Foundation (FSF)</TITLE><LINK REV=\"made\" " +
 
131
             "HREF=\"mailto:webmasters@www.gnu.org\"><link rel=\"stylesheet\" type=\"text/css\" href=\"/gnu.css\" />" +
 
132
             "</HEAD><BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#1F00FF\" ALINK=\"#FF0000\" VLINK=\"#9900DD\">" +
 
133
             "<H1>GNU General Public License</H1><A HREF=\"/graphics/philosophicalgnu.html\"><IMG SRC=\"/graphics/philosophical-gnu-sm.jpg\"   " +
 
134
             "ALT=\" [image of a Philosophical GNU] \"   WIDTH=\"160\" HEIGHT=\"200\"></A><!-- Please keep this list alphabetical -->" +
 
135
             "<!-- tower, gpl.ja.html is Japanese translation of THIS PAGE, --><!-- NOT translation of GPL itself(gpl.ja.html contains the original --> " +
 
136
             "<!-- English version). So please do not remove the following. --><!-- Thanks -mhatta -->" +
 
137
             "<!-- The same for the Czech page. The entire text of GPL is not --><!-- translated on this page. Thanks Sisao -->[   " +
 
138
             "<A HREF=\"/licenses/gpl.cs.html\">Czech</A>| <A HREF=\"/licenses/gpl.html\">English</A>| <A HREF=\"/licenses/gpl.ja.html\">Japanese</A>]" +
 
139
             "<!-- It is best to not enumerate the translations here in a menu bar, --><!-- It is best to have the users follow this link, so they have the FSF' -->" +
 
140
             "<!-- explanation about translations being unofficial, etc. --><P><UL>  <LI>" +
 
141
             "<A HREF=\"/licenses/gpl-violation.html\"><EM>What to do if you see a       possible GPL violation</EM></A>  <LI>" +
 
142
             "<A HREF=\"/licenses/translations.html\"><EM>Translations       of the GPL</EM></A>  <LI><A HREF=\"/licenses/gpl-faq.html\"" +
 
143
             "><EM>GPL Frequently Asked Questions</EM></A>  <LI>The GNU General Public License (GPL)       " +
 
144
             "<A HREF=\"/licenses/gpl.txt\">in plain text format</A>  <LI>The GNU General Public License (GPL)       " +
 
145
             "<A HREF=\"/licenses/gpl.texi\">in Texinfo format</A>  <LI>The GNU General Public License (GPL)       " +
 
146
             "<A HREF=\"/licenses/gpl-2.0.tex\">in LaTeX format</A>  <li>The GNU General Public License (GPL)       " +
 
147
             "<a href=\"/licenses/gpl.dbk\">as an appendix in DocBook format</a></UL><P>       <HR><P><H2>Table of Contents</H2><UL>  " +
 
148
             "<LI><A NAME=\"TOC1\" HREF=\"gpl.html#SEC1\">GNU GENERAL PUBLIC LICENSE</A><UL><LI><A NAME=\"TOC2\" HREF=\"gpl.html#SEC2\">Preamble</A>";
 
149
   }
 
150
*/
 
151
 
 
152
}
 
 
b'\\ No newline at end of file'