Mercurial > hg > blitz_condensed
comparison test/org/dancres/blitz/NullTakeTest.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 net.jini.core.entry.Entry; | |
4 import net.jini.core.lease.Lease; | |
5 | |
6 import org.dancres.blitz.mangler.*; | |
7 | |
8 import org.dancres.blitz.disk.Disk; | |
9 import org.dancres.blitz.disk.DiskTxn; | |
10 | |
11 public class NullTakeTest { | |
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 System.out.println("init'd entry"); | |
24 MangledEntry myPackedEntry = | |
25 myMangler.mangle(new TestEntry().init()); | |
26 | |
27 System.out.println("Do null take:"); | |
28 System.out.println(mySpace.take(MangledEntry.NULL_TEMPLATE, null, | |
29 1000)); | |
30 | |
31 System.out.println("Do write: " + | |
32 mySpace.write(myPackedEntry, null, | |
33 Lease.FOREVER)); | |
34 | |
35 MangledEntry myWild = myMangler.mangle(new TestEntry()); | |
36 System.out.println("Do null read: "); | |
37 System.out.println(mySpace.read(MangledEntry.NULL_TEMPLATE, | |
38 null, Lease.FOREVER)); | |
39 | |
40 System.out.println("Do null take:"); | |
41 System.out.println(mySpace.take(MangledEntry.NULL_TEMPLATE, null, | |
42 Lease.FOREVER)); | |
43 | |
44 System.out.println("Do stop"); | |
45 | |
46 mySpace.stop(); | |
47 | |
48 } catch (Exception anE) { | |
49 System.err.println("Got exception :("); | |
50 anE.printStackTrace(System.err); | |
51 } | |
52 | |
53 } | |
54 | |
55 public static class TestEntry implements Entry { | |
56 public String rhubarb; | |
57 public Integer count; | |
58 | |
59 public TestEntry() { | |
60 } | |
61 | |
62 public TestEntry init() { | |
63 rhubarb = "blah"; | |
64 count = new Integer(5); | |
65 | |
66 return this; | |
67 } | |
68 | |
69 public TestEntry init2() { | |
70 rhubarb = "blahblah"; | |
71 count = new Integer(5); | |
72 | |
73 return this; | |
74 } | |
75 | |
76 public TestEntry init3() { | |
77 rhubarb = "blahh"; | |
78 count = new Integer(5); | |
79 | |
80 return this; | |
81 } | |
82 | |
83 public String toString() { | |
84 return super.toString() + ", " + rhubarb + ", " + count; | |
85 } | |
86 } | |
87 } |