1 16 17 package org.apache.axis2.rest; 18 19 21 import junit.framework.TestCase; 22 import org.apache.axis2.description.ServiceDescription; 23 import org.apache.axis2.engine.Echo; 24 import org.apache.axis2.integration.UtilServer; 25 import org.apache.axis2.util.Utils; 26 27 import javax.xml.namespace.QName ; 28 import java.io.BufferedReader ; 29 import java.io.InputStreamReader ; 30 import java.net.HttpURLConnection ; 31 import java.net.URL ; 32 33 public class HttpGetRESTBasedTest extends TestCase { 34 private QName serviceName = new QName ("EchoXMLService"); 35 private QName operationName = new QName ("echoOMElement"); 36 37 38 public HttpGetRESTBasedTest() { 39 super(HttpGetRESTBasedTest.class.getName()); 40 } 41 42 public HttpGetRESTBasedTest(String testName) { 43 super(testName); 44 } 45 46 protected void setUp() throws Exception { 47 UtilServer.start(); 48 49 ServiceDescription service = 50 Utils.createSimpleService(serviceName,Echo.class.getName(),operationName); 51 UtilServer.deployService(service); 52 53 } 54 55 protected void tearDown() throws Exception { 56 UtilServer.unDeployService(serviceName); 57 UtilServer.stop(); 58 } 59 60 public void testEchoXMLSync() throws Exception { 61 URL wsdlrequestUrl = 63 new URL ("http://127.0.0.1:5555/axis2/services/EchoXMLService/echoOMElement?value1=value1,value2=value2"); 64 65 HttpURLConnection connection = (HttpURLConnection ) wsdlrequestUrl.openConnection(); 66 BufferedReader reader = 67 new BufferedReader (new InputStreamReader (connection.getInputStream())); 68 connection.getResponseCode(); 69 String line = reader.readLine(); 70 while (line != null) { 71 System.out.println(line); 72 line = reader.readLine(); 73 } 74 } 75 76 } 77 | Popular Tags |