1 20 package org.apache.cactus.framework.internal.orchestrator; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.net.HttpURLConnection ; 25 import java.net.MalformedURLException ; 26 import java.net.URL ; 27 28 import org.apache.cactus.framework.internal.orchestrator.handlers.GetTestHandler; 29 import org.apache.cactus.framework.internal.orchestrator.handlers.SetTestHandler; 30 31 public class OrchestratorClient 32 { 33 public void setTest(String name) 34 throws MalformedURLException , IOException 35 { 36 URL url = new URL ( 38 "http://localhost:7777" + SetTestHandler.PATH_IN_CONTEXT 39 + "?name=" + name); 40 41 System.err.println("URL = [" + url + "]"); 43 HttpURLConnection connection = 44 (HttpURLConnection ) url.openConnection(); 45 connection.setRequestMethod("GET"); 46 connection.getInputStream(); 47 } 48 49 public String getTest() 50 throws MalformedURLException , IOException 51 { 52 URL url = new URL ( 54 "http://localhost:7777" + GetTestHandler.PATH_IN_CONTEXT); 55 56 System.err.println("URL = [" + url + "]"); 58 HttpURLConnection connection = 59 (HttpURLConnection ) url.openConnection(); 60 connection.setRequestMethod("GET"); 61 62 InputStream in = connection.getInputStream(); 63 byte[] b = new byte[in.available()]; 64 in.read(b); 65 66 return new String (b); 67 } 68 69 } 70 | Popular Tags |