Package org.apache.wink.server.internal.registry

Examples of org.apache.wink.server.internal.registry.ResourceRecordFactory$InstanceObjectFactory


    public static class Dummy {

    }

    public void testStaticResource() {
        ResourceRecordFactory factory = new ResourceRecordFactory(new LifecycleManagersRegistry());

        ResourceRecord record = factory.getResourceRecord(Resource1.class);
        assertEquals("/path1", record.getMetadata().getPath());
        record = factory.getResourceRecord(Resource2.class);
        assertEquals("/path2", record.getMetadata().getPath());

        Resource1 r1 = new Resource1();
        ResourceRecord record1 = factory.getResourceRecord(r1);
        assertEquals("/path1", record1.getMetadata().getPath());
        Object o = record1.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource1);
        record = factory.getResourceRecord(Resource1.class);
        assertTrue(record == record1);
        o = record.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource1);

        Resource2 r2 = new Resource2();
        ResourceRecord record2 = factory.getResourceRecord(r2);
        assertEquals("/path2", record2.getMetadata().getPath());
        o = record2.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource2);
        record = factory.getResourceRecord(Resource2.class);
        assertTrue(record == record2);
        o = record.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource2);
    }
View Full Code Here


        o = record.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource2);
    }

    public void testDynamicResource() {
        ResourceRecordFactory factory = new ResourceRecordFactory(new LifecycleManagersRegistry());
        Dynamic dynamic = new Dynamic();
        dynamic.setPath("/pathDyna");

        ResourceRecord dynamicRecord = factory.getResourceRecord(dynamic);
        assertEquals("/pathDyna", dynamicRecord.getMetadata().getPath());
        Object o = dynamicRecord.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Dynamic);
        assertTrue(o == dynamic);

        Dynamic dynamic2 = new Dynamic();
        dynamic2.setPath("/pathDyna2");
        ResourceRecord dynamicRecord2 = factory.getResourceRecord(dynamic2);
        assertEquals("/pathDyna2", dynamicRecord2.getMetadata().getPath());
        Object o2 = dynamicRecord2.getObjectFactory().getInstance(null);
        assertTrue(o2 instanceof Dynamic);
        assertTrue(dynamicRecord2 != dynamicRecord);

        try {
            factory.getResourceRecord(Dynamic.class);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

        } catch (IllegalArgumentException e) {
        }
    }

    public void testSubResource() {
        ResourceRecordFactory factory = new ResourceRecordFactory(new LifecycleManagersRegistry());

        // test for sub-resource
        Dummy dummy = new Dummy();
        ResourceRecord dummyRecord = factory.getResourceRecord(dummy, false);
        Object o = dummyRecord.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Dummy);
        assertTrue(o == dummy);

        Dummy dummy2 = new Dummy();
        ResourceRecord dummyRecord2 = factory.getResourceRecord(dummy2, false);
        Object o2 = dummyRecord2.getObjectFactory().getInstance(null);
        assertTrue(o2 instanceof Dummy);
        assertTrue(dummyRecord2 != dummyRecord);

        try {
            factory.getResourceRecord(new Dummy());
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

        try {
            factory.getResourceRecord(Dummy.class);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.wink.server.internal.registry.ResourceRecordFactory$InstanceObjectFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.