1
/***************************************
3
* JBoss: The OpenSource J2EE WebOS *
5
* Distributable under LGPL license. *
6
* See terms of license at gnu.org. *
8
***************************************/
9
package org.jboss.test.remoting.transport.http.proxy;
11
import junit.framework.TestCase;
12
import org.jboss.remoting.Client;
13
import org.jboss.remoting.InvokerLocator;
15
import java.util.HashMap;
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.
28
* @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
30
public class HTTPInvokerProxyTestCase_Retired extends TestCase
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";
41
public void init(String httpTargetURL)
45
InvokerLocator locator = new InvokerLocator(httpTargetURL);
46
Map config = new HashMap();
47
client = new Client(locator, config);
56
public String makeInvocationCall(String payload, Map metadata) throws Throwable
58
Object obj = client.invoke(payload, metadata);
60
System.out.println("invoke returned" + obj);
65
public void testHTTPProxyInvocationViaSystemConfig() throws Throwable
67
Map metadata = new HashMap();
68
metadata.put(Client.RAW, Boolean.TRUE);
69
metadata.put("TYPE", "GET");
73
System.setProperty("proxySet", "true");
74
System.setProperty("http.proxyHost", "84.19.177.62");
75
System.setProperty("http.proxyPort", "8080");
77
String result = makeInvocationCall(null, metadata);
79
System.out.println("invoke returned" + result);
81
assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50));
85
public void testHTTPProxyInvocationViaConfig() throws Throwable
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;
94
Class proxyClass = Class.forName("java.net.Proxy");
97
catch (ClassNotFoundException e)
99
System.out.println("Not running jdk 1.5 or higher, so will bypass testHTTPProxyInvocationViaConfig test.");
104
Map metadata = new HashMap();
105
metadata.put(Client.RAW, Boolean.TRUE);
106
metadata.put("TYPE", "GET");
110
metadata.put("http.proxyHost", "84.19.177.62");
111
metadata.put("http.proxyPort", "8080");
113
String result = makeInvocationCall(null, metadata);
115
System.out.println("invoke returned" + result);
117
assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50));
121
private String getExpectedGETResult()
123
return "Network Working Group H. AlvestrandRequest for Comments: 1766 ";
127
private String getExpectedGETResult()
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>";
b'\\ No newline at end of file'