Changeset 6 for trunk/testsrc
- Timestamp:
- 09/21/2005 10:00:46 PM (21 years ago)
- Location:
- trunk/testsrc/ws/fugue88
- Files:
-
- 2 edited
-
ContextTest.java (modified) (10 diffs)
-
jpath/PathTest.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/testsrc/ws/fugue88/ContextTest.java
r5 r6 3 3 * 4 4 * $Log$ 5 * Revision 1.2 2005/09/21 22:00:46 dsowen 6 * Split out the access stuff into accesslib. 7 * New Creator interface off-loads object creation to user. 8 * 5 9 * Revision 1.1 2005/08/19 17:51:17 dsowen 6 10 * Fixed: NPEs when using accessors from paths, &c. Included tests. … … 19 23 20 24 import junit.framework.TestCase; 21 import ws.fugue88. jpath.Accessor;25 import ws.fugue88.access.Accessor; 22 26 import ws.fugue88.jpath.Context; 23 27 import ws.fugue88.jpath.ContextFactory; 24 import ws.fugue88.jpath.Path; 28 import ws.fugue88.jpath.GraphCreator; 29 import ws.fugue88.jpath.SimplePathParser; 25 30 26 31 /** … … 38 43 39 44 ContextFactory factory = new ContextFactory(); 40 Context context = factory.createContext(a );41 assertSame(a.b, context.getTarget(new Path("/b")));42 43 Accessor accessor = context.getTargetAccessor(new Path("/b"));45 Context context = factory.createContext(a, GraphCreator.NULL); 46 assertSame(a.b, context.getTarget(new SimplePathParser().parse("/b"))); 47 48 Accessor accessor = context.getTargetAccessor(new SimplePathParser().parse("/b")); 44 49 assertSame(a.b, accessor.getValue()); 45 50 accessor.setValue("done"); … … 60 65 61 66 ContextFactory factory = new ContextFactory(); 62 Context context = factory.createContext(a); 63 assertEquals("test", context.getTarget(new Path("/b"))); 67 Context context = factory.createContext(a, GraphCreator.NULL); 68 assertEquals("test", 69 context.getTarget(new SimplePathParser().parse("/b"))); 64 70 try { 65 context.getTargetAccessor(new Path("/b")).setValue("done"); 71 context.getTargetAccessor(new SimplePathParser().parse("/b")).setValue( 72 "done"); 66 73 assertTrue(false); 67 74 } catch(UnsupportedOperationException e) {} … … 87 94 88 95 ContextFactory factory = new ContextFactory(); 89 Context context = factory.createContext(a); 90 assertEquals("test", context.getTarget(new Path("/b"))); 91 context.getTargetAccessor(new Path("/b")).setValue("done"); 96 Context context = factory.createContext(a, GraphCreator.NULL); 97 assertEquals("test", 98 context.getTarget(new SimplePathParser().parse("/b"))); 99 context.getTargetAccessor(new SimplePathParser().parse("/b")).setValue( 100 "done"); 92 101 assertEquals("done", a.getB()); 93 102 } … … 107 116 108 117 ContextFactory factory = new ContextFactory(); 109 Context context = factory.createContext(a); 110 assertEquals("test", context.getTarget(new Path("/b['c']"))); 111 context.getTargetAccessor(new Path("/b['c']")).setValue("done"); 118 Context context = factory.createContext(a, GraphCreator.NULL); 119 assertEquals("test", 120 context.getTarget(new SimplePathParser().parse("/b['c']"))); 121 context.getTargetAccessor(new SimplePathParser().parse("/b['c']")).setValue( 122 "done"); 112 123 assertEquals("done", a.b.get("c")); 113 124 } … … 126 137 127 138 ContextFactory factory = new ContextFactory(); 128 Context context = factory.createContext(b );129 assertNull(context.getTarget(new Path("/a/s")));139 Context context = factory.createContext(b, GraphCreator.NULL); 140 assertNull(context.getTarget(new SimplePathParser().parse("/a/s"))); 130 141 assertNull(b.a); 131 142 } … … 145 156 146 157 ContextFactory factory = new ContextFactory(); 147 Context context = factory.create ModifyingContext(b);148 assertNull(context.getTarget(new Path("/a/s")));158 Context context = factory.createContext(b, GraphCreator.DEFAULT); 159 assertNull(context.getTarget(new SimplePathParser().parse("/a/s"))); 149 160 assertNotNull(b.a); 150 161 assertNull(b.a.s); … … 160 171 161 172 ContextFactory factory = new ContextFactory(); 162 Context context = factory.create ModifyingContext(b);163 Accessor accessor = context.getTargetAccessor(new Path("/a/s"));173 Context context = factory.createContext(b, GraphCreator.DEFAULT); 174 Accessor accessor = context.getTargetAccessor(new SimplePathParser().parse("/a/s")); 164 175 assertNotNull(b.a); 165 176 assertNull(b.a.s); … … 184 195 185 196 ContextFactory factory = new ContextFactory(); 186 Context context = factory.create ModifyingContext(b);187 assertNull(context.getTarget(new Path("/x/s")));197 Context context = factory.createContext(b, GraphCreator.DEFAULT); 198 assertNull(context.getTarget(new SimplePathParser().parse("/x/s"))); 188 199 assertNotNull(b.x); 189 200 assertNull(b.x.s); -
trunk/testsrc/ws/fugue88/jpath/PathTest.java
r2 r6 3 3 * 4 4 * $Log$ 5 * Revision 1.2 2005/09/21 22:00:46 dsowen 6 * Split out the access stuff into accesslib. 7 * New Creator interface off-loads object creation to user. 8 * 5 9 * Revision 1.1 2005/08/03 00:35:29 dsowen 6 10 * Initial commit. … … 20 24 public void testQuote() 21 25 { 22 assertEquals("test", Path .quote("test"));23 assertEquals("te\\'st", Path .quote("te'st"));26 assertEquals("test", PathParser.quote("test")); 27 assertEquals("te\\'st", PathParser.quote("te'st")); 24 28 } 25 29 26 30 public void testIdentifier() throws Exception 27 31 { 28 Path path = new Path("/test");32 Path path = new SimplePathParser().parse("/test"); 29 33 Iterator i = path.iterator(); 30 34 PathPart part = (PathPart)i.next(); … … 36 40 public void testNumberSelector() throws Exception 37 41 { 38 Path path = new Path("[0]");42 Path path = new SimplePathParser().parse("[0]"); 39 43 Iterator i = path.iterator(); 40 44 PathPart part = (PathPart)i.next(); … … 46 50 public void testStringSelectorSimple() throws Exception 47 51 { 48 Path path = new Path("['test']");52 Path path = new SimplePathParser().parse("['test']"); 49 53 Iterator i = path.iterator(); 50 54 PathPart part = (PathPart)i.next(); … … 56 60 public void testStringSelectorQuoted() throws Exception 57 61 { 58 Path path = new Path("['te\\'st']");62 Path path = new SimplePathParser().parse("['te\\'st']"); 59 63 Iterator i = path.iterator(); 60 64 PathPart part = (PathPart)i.next(); … … 63 67 assertFalse(i.hasNext()); 64 68 } 69 65 70 public void testCompound1() throws Exception 66 71 { 67 Path path = new Path("/a/b");72 Path path = new SimplePathParser().parse("/a/b"); 68 73 Iterator i = path.iterator(); 69 74 PathPart part = (PathPart)i.next();
Note: See TracChangeset
for help on using the changeset viewer.
