Changeset 6 for trunk/testsrc/ws


Ignore:
Timestamp:
09/21/2005 10:00:46 PM (21 years ago)
Author:
dsowen
Message:

Split out the access stuff into accesslib.
New Creator interface off-loads object creation to user.

Location:
trunk/testsrc/ws/fugue88
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/testsrc/ws/fugue88/ContextTest.java

    r5 r6  
    33 *
    44 * $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 *
    59 * Revision 1.1  2005/08/19 17:51:17  dsowen
    610 * Fixed: NPEs when using accessors from paths, &c.  Included tests.
     
    1923
    2024import junit.framework.TestCase;
    21 import ws.fugue88.jpath.Accessor;
     25import ws.fugue88.access.Accessor;
    2226import ws.fugue88.jpath.Context;
    2327import ws.fugue88.jpath.ContextFactory;
    24 import ws.fugue88.jpath.Path;
     28import ws.fugue88.jpath.GraphCreator;
     29import ws.fugue88.jpath.SimplePathParser;
    2530
    2631/**
     
    3843
    3944                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"));
    4449                assertSame(a.b, accessor.getValue());
    4550                accessor.setValue("done");
     
    6065
    6166                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")));
    6470                try {
    65                         context.getTargetAccessor(new Path("/b")).setValue("done");
     71                        context.getTargetAccessor(new SimplePathParser().parse("/b")).setValue(
     72                                        "done");
    6673                        assertTrue(false);
    6774                } catch(UnsupportedOperationException e) {}
     
    8794
    8895                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");
    92101                assertEquals("done", a.getB());
    93102        }
     
    107116
    108117                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");
    112123                assertEquals("done", a.b.get("c"));
    113124        }
     
    126137
    127138                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")));
    130141                assertNull(b.a);
    131142        }
     
    145156
    146157                ContextFactory factory = new ContextFactory();
    147                 Context context = factory.createModifyingContext(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")));
    149160                assertNotNull(b.a);
    150161                assertNull(b.a.s);
     
    160171
    161172                ContextFactory factory = new ContextFactory();
    162                 Context context = factory.createModifyingContext(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"));
    164175                assertNotNull(b.a);
    165176                assertNull(b.a.s);
     
    184195
    185196                ContextFactory factory = new ContextFactory();
    186                 Context context = factory.createModifyingContext(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")));
    188199                assertNotNull(b.x);
    189200                assertNull(b.x.s);
  • trunk/testsrc/ws/fugue88/jpath/PathTest.java

    r2 r6  
    33 *
    44 * $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 *
    59 * Revision 1.1  2005/08/03 00:35:29  dsowen
    610 * Initial commit.
     
    2024        public void testQuote()
    2125        {
    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"));
    2428        }
    2529
    2630        public void testIdentifier() throws Exception
    2731        {
    28                 Path path = new Path("/test");
     32                Path path = new SimplePathParser().parse("/test");
    2933                Iterator i = path.iterator();
    3034                PathPart part = (PathPart)i.next();
     
    3640        public void testNumberSelector() throws Exception
    3741        {
    38                 Path path = new Path("[0]");
     42                Path path = new SimplePathParser().parse("[0]");
    3943                Iterator i = path.iterator();
    4044                PathPart part = (PathPart)i.next();
     
    4650        public void testStringSelectorSimple() throws Exception
    4751        {
    48                 Path path = new Path("['test']");
     52                Path path = new SimplePathParser().parse("['test']");
    4953                Iterator i = path.iterator();
    5054                PathPart part = (PathPart)i.next();
     
    5660        public void testStringSelectorQuoted() throws Exception
    5761        {
    58                 Path path = new Path("['te\\'st']");
     62                Path path = new SimplePathParser().parse("['te\\'st']");
    5963                Iterator i = path.iterator();
    6064                PathPart part = (PathPart)i.next();
     
    6367                assertFalse(i.hasNext());
    6468        }
     69
    6570        public void testCompound1() throws Exception
    6671        {
    67                 Path path = new Path("/a/b");
     72                Path path = new SimplePathParser().parse("/a/b");
    6873                Iterator i = path.iterator();
    6974                PathPart part = (PathPart)i.next();
Note: See TracChangeset for help on using the changeset viewer.