Mercurial > hg > blitz_stable
comparison test/org/dancres/blitz/mangler/EntryManglerTest.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.mangler; | |
2 | |
3 import net.jini.core.entry.Entry; | |
4 | |
5 public class EntryManglerTest { | |
6 private EntryManglerTest() { | |
7 } | |
8 | |
9 private void test(Entry anEntry) { | |
10 try { | |
11 EntryMangler myMangler = new EntryMangler(); | |
12 MangledEntry myEntry = myMangler.mangle(anEntry); | |
13 | |
14 myEntry.dump(System.out); | |
15 | |
16 Entry myNewEntry = myMangler.unMangle(myEntry); | |
17 | |
18 System.out.println("Unpacked result...."); | |
19 System.out.println(myNewEntry); | |
20 | |
21 long myStart = System.currentTimeMillis(); | |
22 | |
23 for (int i = 0; i < 10000; i++) { | |
24 if (myMangler.mangle(anEntry) == null) | |
25 throw new RuntimeException(); | |
26 } | |
27 | |
28 long myEnd = System.currentTimeMillis(); | |
29 | |
30 System.out.println("Time to mangle 10000: " + (myEnd - myStart)); | |
31 | |
32 myStart = System.currentTimeMillis(); | |
33 | |
34 for (int i = 0; i < 10000; i++) { | |
35 myMangler.unMangle(myEntry); | |
36 } | |
37 | |
38 myEnd = System.currentTimeMillis(); | |
39 | |
40 System.out.println("Time to unmangle 10000: " + (myEnd - myStart)); | |
41 | |
42 } catch (Exception anE) { | |
43 System.err.println("Failed"); | |
44 anE.printStackTrace(System.err); | |
45 } | |
46 } | |
47 | |
48 public static void main(String args[]) { | |
49 TestEntry myEntry = new TestEntry(); | |
50 myEntry.init(); | |
51 | |
52 new EntryManglerTest().test(myEntry); | |
53 } | |
54 | |
55 private static class TestEntry implements Entry { | |
56 public String rhubarb; | |
57 public Integer count; | |
58 | |
59 public TestEntry() { | |
60 } | |
61 | |
62 public void init() { | |
63 rhubarb = "blah"; | |
64 count = new Integer(5); | |
65 } | |
66 | |
67 public String toString() { | |
68 return super.toString() + ", " + rhubarb + ", " + count; | |
69 } | |
70 } | |
71 } |