Mercurial > hg > blitz_stable
comparison test/org/dancres/blitz/BulkWriteTest.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; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import net.jini.core.entry.Entry; | |
7 import net.jini.core.lease.Lease; | |
8 | |
9 import org.dancres.blitz.mangler.*; | |
10 | |
11 public class BulkWriteTest { | |
12 public static void main(String args[]) { | |
13 | |
14 try { | |
15 System.out.println("Start space"); | |
16 | |
17 SpaceImpl mySpace = new SpaceImpl(null); | |
18 | |
19 System.out.println("Prepare entry"); | |
20 | |
21 EntryMangler myMangler = new EntryMangler(); | |
22 | |
23 ArrayList myMangled = new ArrayList(); | |
24 ArrayList myLeases = new ArrayList(); | |
25 | |
26 for (int i = 0; i < 100; i++) { | |
27 TestEntry myEntry = new TestEntry(Integer.toString(i)); | |
28 MangledEntry myPackedEntry = myMangler.mangle(myEntry); | |
29 myMangled.add(myPackedEntry); | |
30 myLeases.add(new Long(300000 + i)); | |
31 } | |
32 | |
33 List myLeaseResults = mySpace.write(myMangled, null, myLeases); | |
34 | |
35 for (int i = 0; i < myLeaseResults.size(); i++) { | |
36 System.out.println("Lease: " + i + " is " + ((WriteTicket) myLeaseResults.get(i)).getExpirationTime()); | |
37 } | |
38 | |
39 System.out.println("Do stop"); | |
40 | |
41 mySpace.stop(); | |
42 | |
43 } catch (Exception anE) { | |
44 System.err.println("Got exception :("); | |
45 anE.printStackTrace(System.err); | |
46 } | |
47 | |
48 } | |
49 | |
50 public static class TestEntry implements Entry { | |
51 public String rhubarb; | |
52 public Integer count; | |
53 | |
54 public TestEntry(String aThing) { | |
55 } | |
56 | |
57 public void init() { | |
58 rhubarb = "blah"; | |
59 count = new Integer(5); | |
60 } | |
61 | |
62 public String toString() { | |
63 return super.toString() + ", " + rhubarb + ", " + count; | |
64 } | |
65 } | |
66 } |