ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Ws Wiki] Update of "XmlRpcExampleStringArray" by KenTanaka
Date Thu, 09 Jul 2009 23:00:56 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by KenTanaka:
http://wiki.apache.org/ws/XmlRpcExampleStringArray

The comment on the change is:
Added DirListTest.java listing

------------------------------------------------------------------------------
      </servlet-mapping>
  </web-app>
  }}}
- You can choose a `<servlet-name>` that you like, using the same value in the `<servlet>`
and `<servlet-mapping>` sections. Leave the `<servlet-class>` element as-is though.
The `<servlet-name>` and `<url-pattern>` will affect the URL you put into the
client application (App.java below).
+ You can choose a `<servlet-name>` that you like, using the same value in the `<servlet>`
and `<servlet-mapping>` sections. Leave the `<servlet-class>` element as-is though.
The `<servlet-name>` and `<url-pattern>` will affect the URL you put into the
client application (App.java below) so choose URL friendly names, with no spaces or unusual
punctuation.
  
+ == DirListTest.java Listing ==
+ Contents of '''{{{src/test/java/gov/noaa/eds/myXmlRpcServer/DirListTest.java}}}'''. This
is an optional JUnit test file.
+ 
+ {{{
+ /*
+  * FILE: DirListTest.java
+  */
+ 
+ package gov.noaa.eds.myXmlRpc;
+ 
+ import java.util.ArrayList;
+ import junit.framework.TestCase;
+ 
+ /**
+  * JUnit Test file
+  */
+ public class DirListTest extends TestCase {
+     
+     public DirListTest(String testName) {
+         super(testName);
+     }
+ 
+     @Override
+     protected void setUp() throws Exception {
+         super.setUp();
+     }
+ 
+     @Override
+     protected void tearDown() throws Exception {
+         super.tearDown();
+     }
+ 
+ 
+     /**
+      * Test of fileCount method, of class DirList.
+      */
+     public void testFileCount() {
+         System.out.println("fileCount");
+         String s1 = "always100000";
+         DirList instance = new DirList();
+         int expResult = 100000; // needs to match listLength in DirList.java
+         int result = instance.fileCount(s1);
+         assertEquals(expResult, result);
+     }
+ 
+ 
+     /**
+      * Test of ls method, of class DirList.
+      * Results are random, so don't look at specifics.
+      * 100000 filenames starting with "sample_" will be generated.
+      */
+     public void testLs() {
+         System.out.println("ls");
+         String dirName = "100000files";
+         DirList instance = new DirList();
+         ArrayList<String> result = instance.ls(dirName);
+         int errorCount = 0;
+         int totalLength = 0;
+         int fileCount = 0;
+         for (String fn : result) {
+             fileCount++;
+             totalLength += fn.length();
+             if (! fn.startsWith("sample_")) {
+                 errorCount++;
+             }
+         }
+         int avgLength = totalLength / fileCount;
+         System.out.println("  " + fileCount + " files, average name length="
+                 + avgLength);
+         System.out.println("  First 10:");
+         for (int i = 0; i < 10; i++) {
+             System.out.println("    " + result.get(i));
+         }
+         assertEquals(errorCount, 0);
+     }
+ 
+ }
+ }}}
  ----
  
  = myXmlRpcClient Code =

Mime
View raw message