Revision: 4319 http://vexi.svn.sourceforge.net/vexi/?rev=4319&view=rev Author: mkpg2 Date: 2012-01-09 16:59:42 +0000 (Mon, 09 Jan 2012) Log Message: ----------- New tool. Httptester. For testing http connections w/ proxy.
Added Paths: ----------- trunk/org.vexi-tools.httptester/build.xml trunk/org.vexi-tools.httptester/meta/ trunk/org.vexi-tools.httptester/meta/module-build.xml trunk/org.vexi-tools.httptester/meta/module.xml trunk/org.vexi-tools.httptester/meta/product-assembly.xml trunk/org.vexi-tools.httptester/meta/product.xml trunk/org.vexi-tools.httptester/request.properties trunk/org.vexi-tools.httptester/src/ trunk/org.vexi-tools.httptester/src/main/ trunk/org.vexi-tools.httptester/src/main/java/ trunk/org.vexi-tools.httptester/src/main/java/httptester/ trunk/org.vexi-tools.httptester/src/main/java/httptester/HttpTester.java Property Changed: ---------------- trunk/org.vexi-tools.httptester/ Property changes on: trunk/org.vexi-tools.httptester ___________________________________________________________________ Added: svn:ignore + build release .settings .project .classpath Added: trunk/org.vexi-tools.httptester/build.xml =================================================================== --- trunk/org.vexi-tools.httptester/build.xml (rev 0) +++ trunk/org.vexi-tools.httptester/build.xml 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,6 @@ +<project default="eclipse_setup"> + + <property name="ebuild.home" location="../_ebuild"/> + <import file="${ebuild.home}/interface/workspace.ent"/> + +</project> \ No newline at end of file Property changes on: trunk/org.vexi-tools.httptester/build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/meta/module-build.xml =================================================================== --- trunk/org.vexi-tools.httptester/meta/module-build.xml (rev 0) +++ trunk/org.vexi-tools.httptester/meta/module-build.xml 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,9 @@ +<ebuild-module-build ebuild-version="0.8"> + <using source="local" name="library.util" context="build"/> + + <builders> + <builder refid="javac" /> + <builder refid="javaexport" /> + </builders> +</ebuild-module-build> + Property changes on: trunk/org.vexi-tools.httptester/meta/module-build.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/meta/module.xml =================================================================== --- trunk/org.vexi-tools.httptester/meta/module.xml (rev 0) +++ trunk/org.vexi-tools.httptester/meta/module.xml 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,13 @@ +<ebuild-module ebuild-version="0.8"> + <artifact name="java_classes.jar" /> + <artifact name="java.zip" /> + + <configurations> + <configuration name="debug" /> + </configurations> + + <dependencies> + <dependency source="maven-public" org="org.apache.httpcomponents" name="httpclient" tag="4.1.2"/> + <dependency source="local" name="library.util" /> + </dependencies> +</ebuild-module> Property changes on: trunk/org.vexi-tools.httptester/meta/module.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/meta/product-assembly.xml =================================================================== --- trunk/org.vexi-tools.httptester/meta/product-assembly.xml (rev 0) +++ trunk/org.vexi-tools.httptester/meta/product-assembly.xml 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,34 @@ +<ebuild-product-assembly ebuild-version="0.8"> + <using source="local" name="build.shared"/> + + <target name="jar"> + <assembler source="ebuild" name="build.java.jarmanifest" tag="0.7"> + <input> + <assembler source="ebuild" name="build.java.jarmerge" > + <input> + <module-selection artifact="java_classes.jar"> + <include source="local" name="tools.httptester"/> + </module-selection> + </input> + </assembler> + </input> + <property key="Main-Class" value="httptester.HttpTester"/> + </assembler> + </target> + <target name="directory"> + <assembler source="ebuild" name="build.file.layout"> + <input name="jar" ref="jar"/> + <input name="props" ref="jar"/> + <property key="layout"> + jar-> httptester.jar | + props-> request.properties | + </property> + </assembler> + </target> + <target name="archive"> + <assembler source="ebuild" name="build.file.archive"> + <input name="files" ref="directory"/> + </assembler> + </target> + +</ebuild-product-assembly> Property changes on: trunk/org.vexi-tools.httptester/meta/product-assembly.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/meta/product.xml =================================================================== --- trunk/org.vexi-tools.httptester/meta/product.xml (rev 0) +++ trunk/org.vexi-tools.httptester/meta/product.xml 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,5 @@ +<ebuild-product ebuild-version="0.8"> + <artifact name="jar" prefix="httptester" suffix=".jar"/> + + <configurations/> +</ebuild-product> Property changes on: trunk/org.vexi-tools.httptester/meta/product.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/request.properties =================================================================== --- trunk/org.vexi-tools.httptester/request.properties (rev 0) +++ trunk/org.vexi-tools.httptester/request.properties 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,13 @@ +message=<?xml version="1.0" encoding="UTF-8"?>\ + <methodCall>\ + <methodName>emanate5.Init.isInitialized</methodName>\ + <params/>\ + </methodCall> +target.host=sandbox.emanate5.com +target.port=8084 +target.path=/installation/xmlrpc + +proxy.host=82.198.228.92 +proxy.port=80 +#proxy.username= +#proxy.password= \ No newline at end of file Property changes on: trunk/org.vexi-tools.httptester/request.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/org.vexi-tools.httptester/src/main/java/httptester/HttpTester.java =================================================================== --- trunk/org.vexi-tools.httptester/src/main/java/httptester/HttpTester.java (rev 0) +++ trunk/org.vexi-tools.httptester/src/main/java/httptester/HttpTester.java 2012-01-09 16:59:42 UTC (rev 4319) @@ -0,0 +1,105 @@ +package httptester; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.HttpVersion; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.conn.params.ConnRoutePNames; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicHttpEntityEnclosingRequest; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; +import org.ibex.util.IOUtil; + + + +public class HttpTester { + + static public Properties load(File propsFile) throws IOException { + Properties props = new Properties(); + FileInputStream fis = new FileInputStream(propsFile); + props.load(fis); + fis.close(); + return props; + } + + static public int parsePort(String p){ + try{ + return Integer.parseInt(p); + }catch(NumberFormatException e){ + System.err.println("[ERROR] Not a valid port: "+p); + System.exit(1); + return -1; + } + } + + static public void main(String[] args) throws IOException { + Properties props = load(new File("request.properties")); + + String MESSAGE = props.getProperty("message"); + + DefaultHttpClient httpclient = new DefaultHttpClient(); + String PROXY_HOST = props.getProperty("proxy.host"); + if(PROXY_HOST!=null){ + int PROXY_PORT = parsePort(props.getProperty("proxy.port")); + + String PROXY_USERNAME = props.getProperty("proxy.username"); + if(PROXY_USERNAME!=null){ + String PROXY_PASSWORD = props.getProperty("proxy.password"); + httpclient.getCredentialsProvider().setCredentials( + new AuthScope(PROXY_HOST, PROXY_PORT), + new UsernamePasswordCredentials(PROXY_USERNAME, PROXY_PASSWORD)); + + } + + HttpHost proxy = new HttpHost(PROXY_HOST, PROXY_PORT); + httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + } + + + + String TARGET_HOST = props.getProperty("target.host"); + int TARGET_PORT = parsePort(props.getProperty("target.port")); + String TARGET_PATH = props.getProperty("target.path"); + + String targetUrl = "http://"+TARGET_HOST+":"+TARGET_PORT+TARGET_PATH; + + + HttpParams params = new BasicHttpParams(); + HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); + HttpProtocolParams.setContentCharset(params, "UTF-8"); + HttpProtocolParams.setUserAgent(params, "Vexi"); + HttpProtocolParams.setUseExpectContinue(params, true); + + + BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest( + "POST", targetUrl); + + + ByteArrayEntity entity = new ByteArrayEntity(MESSAGE.getBytes()); + entity.setContentType("text/xml"); + request.setEntity(entity); + + + + + + + HttpHost host = new HttpHost(TARGET_HOST, TARGET_PORT); + + request.setParams(params); + HttpResponse response = httpclient.execute(host, request); + byte[] bytes = IOUtil.toByteArray(response.getEntity().getContent()); + int statusCode = response.getStatusLine().getStatusCode(); + System.err.println("Status Code: "+statusCode); + System.err.println(new String(bytes)); + } +} Property changes on: trunk/org.vexi-tools.httptester/src/main/java/httptester/HttpTester.java ___________________________________________________________________ Added: svn:mime-type + text/plain This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn