Author: ggrekhov
Date: Thu Aug  2 14:47:14 2012
New Revision: 1368494

URL: http://svn.apache.org/viewvc?rev=1368494&view=rev
Log:
NetworkTesting: data caching is fixed

Removed:
    
incubator/openmeetings/trunk/singlewebapp/WebContent/openmeetings/testingTools/
Modified:
    
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/BaseURLLoadTest.lzx
    
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/DownloadSpeedTest.lzx
    
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/JitterTest.lzx
    
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/PingTest.lzx
    incubator/openmeetings/trunk/singlewebapp/build.xml
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/NetworkTestingController.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/BaseURLLoadTest.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/BaseURLLoadTest.lzx?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/BaseURLLoadTest.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/BaseURLLoadTest.lzx
 Thu Aug  2 14:47:14 2012
@@ -33,7 +33,7 @@
     </switch>
 
     <attribute name="testsCount" type="number" value="0" />
-    <attribute name="loadFileName" type="string" value="null" />
+    <attribute name="testTypeParameter" type="string" value="null" />
     <attribute name="verbose" type="boolean" value="true" />
 
     <attribute name="startTime" type="number" value="0" />
@@ -49,7 +49,7 @@
     <attribute name="loader" value="null" />
 
     <method name="initLoader">
-        hostUrl = "http://"; + host + ":" + port + canvas.uriContext + 
"/testingTools/" + loadFileName;
+        hostUrl = "http://"; + host + ":" + port + canvas.uriContext + 
"/networktest.upload?testType=" + testTypeParameter;
         request = new URLRequest(hostUrl);
 
         loader = new URLLoader();

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/DownloadSpeedTest.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/DownloadSpeedTest.lzx?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/DownloadSpeedTest.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/DownloadSpeedTest.lzx
 Thu Aug  2 14:47:14 2012
@@ -25,7 +25,7 @@
     <handler name="oninit">
         this.setAttribute("testsCount", 1);
         this.setAttribute("testName", "Download speed");
-        this.setAttribute("loadFileName", "downloadTest");
+        this.setAttribute("testTypeParameter", "download");
         this.setAttribute("verbose", false);
         this.setAttribute("resultText", true);
     </handler>

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/JitterTest.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/JitterTest.lzx?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/JitterTest.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/JitterTest.lzx
 Thu Aug  2 14:47:14 2012
@@ -25,7 +25,7 @@
     <handler name="oninit">
         this.setAttribute("testsCount", 100);
         this.setAttribute("testName", "Jitter");
-        this.setAttribute("loadFileName", "jitterTest");
+        this.setAttribute("testTypeParameter", "jitter");
         this.setAttribute("verbose", false);
         this.setAttribute("resultText", true);
     </handler>

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/PingTest.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/PingTest.lzx?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/PingTest.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/swf10/networkTesting/tests/PingTest.lzx
 Thu Aug  2 14:47:14 2012
@@ -25,7 +25,7 @@
     <handler name="oninit">
         this.setAttribute("testsCount", 10);
         this.setAttribute("testName", "Ping");
-        this.setAttribute("loadFileName", "pingTest");
+        this.setAttribute("testTypeParameter", "ping");
     </handler>
 
     <method name="generateReport">

Modified: incubator/openmeetings/trunk/singlewebapp/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/build.xml?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/build.xml (original)
+++ incubator/openmeetings/trunk/singlewebapp/build.xml Thu Aug  2 14:47:14 2012
@@ -420,9 +420,6 @@
                <copy todir="${dist.webapps.dir}">
                        <fileset dir="${webcontent.src.dir}/openmeetings" 
includes="*" />
                </copy>
-               <copy todir="${dist.webapps.dir}/testingTools">
-                       <fileset 
dir="${webcontent.src.dir}/openmeetings/testingTools" includes="*" />
-               </copy>
                <antcall target="-compile.flash" inheritAll="true" 
inheritRefs="true">
                        <param name="flash.src.dir" 
value="${laszlo.as3.src.dir}/networkTesting" />
                        <param name="flash.runtime" value="swf10" />

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/NetworkTestingController.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/NetworkTestingController.java?rev=1368494&r1=1368493&r2=1368494&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/NetworkTestingController.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/NetworkTestingController.java
 Thu Aug  2 14:47:14 2012
@@ -19,8 +19,10 @@
 package org.openmeetings.servlet.outputhandler;
 
 import java.io.IOException;
+import java.util.Arrays;
 
 import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -32,10 +34,82 @@ import org.springframework.web.bind.anno
 @Controller
 public class NetworkTestingController {
 
+    enum TestType {
+        UNKNOWN,
+        PING,
+        JITTER,
+        DOWNLOAD_SPEED,
+        UPLOAD_SPEED
+    }
+
+    private static final int PING_PACKET_SIZE = 64;
+    private static final int JITTER_PACKET_SIZE = 1024;
+    private static final int DOWNLOAD_PACKET_SIZE = 1024*1024;
+
+    private final byte[] pingData;
+    private final byte[] jitterData;
+    private final byte[] downloadData;
+
+    public NetworkTestingController() {
+        pingData = new byte[PING_PACKET_SIZE];
+        jitterData = new byte[JITTER_PACKET_SIZE];
+        downloadData = new byte[DOWNLOAD_PACKET_SIZE];
+
+        Arrays.fill(pingData, (byte) '0');
+        Arrays.fill(jitterData, (byte) '0');
+        Arrays.fill(downloadData, (byte) '0');
+    }
+
+    @RequestMapping(value = "/networktest.upload", method = RequestMethod.GET)
+       public void serviceGet(HttpServletRequest request, HttpServletResponse 
response, HttpSession session)
+                       throws ServletException, IOException {
+        String typeStr = request.getParameter("testType");
+        TestType testType = this.getTypeByString(typeStr);
+
+        // choose data to send
+        byte[] data = null;
+        switch (testType) {
+            case UNKNOWN:
+                return;
+            case PING:
+                data = pingData;
+                break;
+            case JITTER:
+                data = jitterData;
+                break;
+            case DOWNLOAD_SPEED:
+                data = downloadData;
+                break;
+        }
+
+        // set needed headers
+        response.setHeader("Cache-Control", "no-cache");
+        response.setHeader("Content-Length", String.valueOf(data.length));
+
+        // send data
+        ServletOutputStream outStream = response.getOutputStream();
+        outStream.write(data);
+        outStream.flush();
+    }
+
     @RequestMapping(value = "/networktest.upload", method = RequestMethod.POST)
-       public void service(HttpServletRequest request, HttpServletResponse 
httpServletResponse, HttpSession session)
+       public void servicePost(HttpServletRequest request, HttpServletResponse 
response, HttpSession session)
                        throws ServletException, IOException {
+    }
+
+
+    private TestType getTypeByString(String typeString) {
+        if ("ping".equals(typeString)) {
+            return TestType.PING;
+        } else if ("jitter".equals(typeString)) {
+            return TestType.JITTER;
+        } else if ("download".equals(typeString)) {
+            return TestType.DOWNLOAD_SPEED;
+        } else if ("upload".equals(typeString)) {
+            return TestType.UPLOAD_SPEED;
+        }
 
+        return TestType.UNKNOWN;
     }
 
 }


Reply via email to