[logback-dev] svn commit: r610 - logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Sep 28 15:16:53 CEST 2006


Author: seb
Date: Thu Sep 28 15:16:53 2006
New Revision: 610

Modified:
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyTestSetup.java

Log:
- corrected basic test, it now creates the POST request correctly and retrieves the post content, too.

Modified: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
==============================================================================
--- logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	(original)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	Thu Sep 28 15:16:53 2006
@@ -54,41 +54,32 @@
   }
 
   public void testPostContentConverter() throws Exception {
-    System.out.println("into test");
+    //System.out.println("into test");
     URL url = new URL("http://localhost:8080/");
+    String msg = "test message";
+    
     HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+    //this line is necessary to make the stream aware of when the message is over.
+    connection.setFixedLengthStreamingMode(msg.getBytes().length);
     ((HttpURLConnection) connection).setRequestMethod("POST");
-
     connection.setDoOutput(true);
     connection.setDoInput(true);
     connection.setUseCaches(false);
     connection.setRequestProperty("Content-Type", "text/plain");
-    // connection.setRequestProperty("Content-Type",
-    // "application/x-www-form-urlencoded");
 
-    String msg = "test message";
+   
     PrintWriter output = new PrintWriter(new OutputStreamWriter(connection
         .getOutputStream()));
     output.print(msg);
     output.flush();
     output.close();
-    // System.out.println("length: " + connection.getContentLength());
-
-    // Reading the response
-    String result = Util.readToString(connection.getInputStream());
-    assertEquals("hello world", result);
 
     // StatusPrinter.print(requestLogImpl.getStatusManager());
 
     ListAppender listAppender = (ListAppender) requestLogImpl
         .getAppender("list");
+    Thread.sleep(100);
     AccessEvent event = (AccessEvent) listAppender.list.get(0);
     assertEquals(msg, event.getPostContent());
-    
-    Iterator it = listAppender.list.iterator();
-    while (it.hasNext()) {
-      AccessEvent event2 = (AccessEvent) it.next();
-      System.out.println("Event PostContent: " + event2.getPostContent());
-    }
   }
 }

Modified: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyTestSetup.java
==============================================================================
--- logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyTestSetup.java	(original)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyTestSetup.java	Thu Sep 28 15:16:53 2006
@@ -38,7 +38,7 @@
   String url = "http://localhost:8080/";
 
   public void setUp() throws Exception {
-    System.out.println("into setUp");
+    //System.out.println("into setUp");
     super.setUp();
 
     server = new Server();
@@ -64,7 +64,7 @@
   }
 
   public void tearDown() throws Exception {
-    System.out.println("into tearDown");
+    //System.out.println("into tearDown");
     super.tearDown();
     server.stop();
     Thread.sleep(1000);



More information about the logback-dev mailing list