public class JSONCodecTest extends TestCase {
public static String END_POINT = "http://localhost:8080/unitTest/json/parameter";
protected String postOnEndPoint(String postBody) throws MalformedURLException, IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(END_POINT).openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
connection.getOutputStream().write(postBody.getBytes());
BufferedReader bufReader = new BufferedReader(new InputStreamReader(connection.getResponseCode() < 300 ? connection.getInputStream() :
connection.getErrorStream()));
StringBuffer buf = new StringBuffer();
String str = bufReader.readLine();
while(str != null){
buf.append(str);
str = bufReader.readLine();
}
bufReader.close();
connection.disconnect();
return buf.toString();
}