geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1030837 - in /geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src: main/java/org/apache/geronimo/testsuite/servlet3/app/ test/java/org/apache/geronimo/testsuite/servlet3/
Date Thu, 04 Nov 2010 05:33:33 GMT
Author: xuhaihong
Date: Thu Nov  4 05:33:33 2010
New Revision: 1030837

URL: http://svn.apache.org/viewvc?rev=1030837&view=rev
Log:
make the assert in the cases more tolerant

Modified:
    geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/AsyncServlet.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/TaskExecutor.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/test/java/org/apache/geronimo/testsuite/servlet3/TestAsync.java

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/AsyncServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/AsyncServlet.java?rev=1030837&r1=1030836&r2=1030837&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/AsyncServlet.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/AsyncServlet.java
Thu Nov  4 05:33:33 2010
@@ -44,7 +44,7 @@ public class AsyncServlet extends HttpSe
         out.println("</head>");
         out.println("<body>");
         out.println("<p id='a'>");
-        out.println("Servlet starts at: " + "<font color='red'><b id='sst'>"
+ new Date() + "</b></font>" + ".");
+        out.println("Servlet starts at: " + "<font color='red'> " + new Date() + "
-> <b id='sst'>" + System.currentTimeMillis() + "</b></font>" + ".");
         out.println("</p>");
         out.println("<br><br>");
 
@@ -54,7 +54,7 @@ public class AsyncServlet extends HttpSe
         new Thread(new TaskExecutor(ctx)).start();
 
         out.println("<p id='b'>");
-        out.println("Task assigned to executor.Servlet finishes at: " + "<font color='red'><b
id='sft'>" + new Date() + "</b></font>" + ".");
+        out.println("Task assigned to executor.Servlet finishes at: " + "<font color='red'>"
+ new Date() + " -> <b id='sft'>" + System.currentTimeMillis() + "</b></font>"
+ ".");
         out.println("</p>");
         out.println("<br><br>");
         out.flush();

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/TaskExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/TaskExecutor.java?rev=1030837&r1=1030836&r2=1030837&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/TaskExecutor.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/main/java/org/apache/geronimo/testsuite/servlet3/app/TaskExecutor.java
Thu Nov  4 05:33:33 2010
@@ -27,37 +27,37 @@ import javax.servlet.AsyncContext;
 
 public class TaskExecutor implements Runnable {
     private AsyncContext ctx = null;
-    
+
     public TaskExecutor(AsyncContext ctx) {
         this.ctx = ctx;
     }
-    
+
 
     public void run(){
         PrintWriter out = null;
         try {
             out = ctx.getResponse().getWriter();
-            
+
         } catch (IOException e) {
-            
+
             e.printStackTrace();
         }
         out.println("<p id='c'>");
-        out.println("TaskExecutor starts at: " + "<font color='red'><b id='tst'>"
+ new Date() + "</b></font>" + "." + "Task starts executing" + ".");
+        out.println("TaskExecutor starts at: " + "<font color='red'>" + new Date()
+ " -> <b id='tst'>" + System.currentTimeMillis() + "</b></font>" + "."
+ "Task starts executing" + ".");
         out.println("</p>");
         out.println("<br><br>");
         out.flush();
         try {
             Thread.sleep(10000);
         } catch (InterruptedException e) {
-            
+
             e.printStackTrace();
         }
         out.println("<p id='d'>");
         out.println("Task finishes.");
         out.println("</p>");
         out.println("<p>");
-        out.println("TaskExecutor finishes at: " + "<font color='red'><b id='tft'>"
+ new Date() + "</b></font>" + ".");
+        out.println("TaskExecutor finishes at: " + "<font color='red'>" + new Date()
+ " -> <b id='tft'>" + System.currentTimeMillis() + "</b></font>" + ".");
         out.println("</p>");
         out.println("<br><br>");
         out.println("</body>");

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/test/java/org/apache/geronimo/testsuite/servlet3/TestAsync.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/test/java/org/apache/geronimo/testsuite/servlet3/TestAsync.java?rev=1030837&r1=1030836&r2=1030837&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/test/java/org/apache/geronimo/testsuite/servlet3/TestAsync.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-test/servlet3.0-test-war/src/test/java/org/apache/geronimo/testsuite/servlet3/TestAsync.java
Thu Nov  4 05:33:33 2010
@@ -39,20 +39,10 @@ public class TestAsync extends SeleniumT
         assertTrue(selenium.isTextPresent("Task finishes."));
         assertTrue(selenium.isTextPresent("TaskExecutor finishes at:"));
 
-        String[] sftSplit = selenium.getText("xpath=//b[@id='sft']").split(":");
-        int sfti = getTime(sftSplit);
-        String[] tstSplit = selenium.getText("xpath=//b[@id='tst']").split(":");
-        int tsti = getTime(tstSplit);
-        String[] tftSplit = selenium.getText("xpath=//b[@id='tft']").split(":");
-        int tfti = getTime(tftSplit);
+        long sfti = Long.parseLong(selenium.getText("xpath=//b[@id='sft']"))/1000;
+        long tsti = Long.parseLong(selenium.getText("xpath=//b[@id='tst']"))/1000;
+        long tfti = Long.parseLong(selenium.getText("xpath=//b[@id='tft']"))/1000;
         assertTrue(sfti == tsti);
-        assertTrue(Math.abs(tfti - sfti) == 10);
-    }
-
-    private int getTime(String[] timeSplit) {
-        String time = timeSplit[timeSplit.length - 1].substring(0, 2);
-        int timei = Integer.parseInt(time);
-        return timei;
-    }
-
-}
+        long intervalTimeMills = tfti - sfti;
+        assertTrue(intervalTimeMills > 9L && intervalTimeMills < 12L);
+    }}



Mime
View raw message