Package org.mojavemvc.core

Examples of org.mojavemvc.core.MappedControllerDatabase


        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestInterceptorController1.class);
        controllerClasses.add(TestInterceptorController2.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestInterceptorController1.class);
        assertNotNull(fc);
        assertEquals(TestInterceptorController1.class, fc.getJavaClass());
        fc = db.getFastClass(TestInterceptorController2.class);
        assertNotNull(fc);
        assertEquals(TestInterceptorController2.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsFor(TestInterceptorController1.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsFor(TestInterceptorController2.class);

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());
       
        assertEquals(2, rm.size());
        assertTrue(rm.contains(new MojaveRoute("interceptor1", "someAction", null)));
View Full Code Here


    public void testInterceptor3() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInterceptorController3.class);
            new MappedControllerDatabase(controllerClasses, new FakeRouteMap(),
                    new HashMap<String, EntityMarshaller>());
            fail("should have thrown exception");
        } catch (Exception e) {
            if (!(e instanceof ConfigurationException)) {
                fail("wrong exception type");
View Full Code Here

    public void testMethodInterceptorController1() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestMethodInterceptorController1.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestMethodInterceptorController1.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsForAction(TestMethodInterceptorController1.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController1.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());
       
        assertEquals(2, rm.size());
        assertTrue(rm.contains(new MojaveRoute("method-interceptor1", null, null)));
View Full Code Here

    public void testMethodInterceptorController2() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestMethodInterceptorController2.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestMethodInterceptorController2.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController2.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsForAction(TestMethodInterceptorController2.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());
       
        assertEquals(1, rm.size());
        assertTrue(rm.contains(new MojaveRoute("method-interceptor2", "someAction", null)));
View Full Code Here

    public void testMethodInterceptorController3() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestMethodInterceptorController3.class);
            new MappedControllerDatabase(controllerClasses, new FakeRouteMap(),
                    new HashMap<String, EntityMarshaller>());
            fail("should have thrown exception");
        } catch (Exception e) {
            if (!(e instanceof ConfigurationException)) {
                fail("wrong exception type");
View Full Code Here

    public void testMethodInterceptorController4() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestMethodInterceptorController4.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestMethodInterceptorController4.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController4.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsForAction(TestMethodInterceptorController4.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController4.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());
       
        assertEquals(2, rm.size());
        assertTrue(rm.contains(new MojaveRoute("method-interceptor4", null, null)));
View Full Code Here

    public void testMethodInterceptorController5() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestMethodInterceptorController5.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestMethodInterceptorController5.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController5.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsFor(TestMethodInterceptorController5.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController5.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController5.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());
       
        assertEquals(2, rm.size());
        assertTrue(rm.contains(new MojaveRoute("method-interceptor5", null, null)));
View Full Code Here

    public void testMethodInterceptorController6() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestMethodInterceptorController6.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestMethodInterceptorController6.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController6.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor3.class);
        assertNotNull(fc);
        assertEquals(Interceptor3.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsFor(TestMethodInterceptorController6.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor3.class, interceptors.get(0));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController6.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController6.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor3.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before3", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor3.class);
        assertNotNull(afterActionMethod);
        assertEquals("after3", afterActionMethod.methodName());
       
        assertEquals(2, rm.size());
        assertTrue(rm.contains(new MojaveRoute("method-interceptor6", null, null)));
View Full Code Here

        controllerClasses.add(TestMethodInterceptorController2.class);
        controllerClasses.add(TestMethodInterceptorController4.class);
        controllerClasses.add(TestMethodInterceptorController5.class);
        controllerClasses.add(TestMethodInterceptorController6.class);
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());

        FastClass fc = db.getFastClass(TestInterceptorController1.class);
        assertNotNull(fc);
        assertEquals(TestInterceptorController1.class, fc.getJavaClass());
        fc = db.getFastClass(TestInterceptorController2.class);
        assertNotNull(fc);
        assertEquals(TestInterceptorController2.class, fc.getJavaClass());
        fc = db.getFastClass(TestMethodInterceptorController1.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController1.class, fc.getJavaClass());
        fc = db.getFastClass(TestMethodInterceptorController2.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController2.class, fc.getJavaClass());
        fc = db.getFastClass(TestMethodInterceptorController4.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController4.class, fc.getJavaClass());
        fc = db.getFastClass(TestMethodInterceptorController5.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController5.class, fc.getJavaClass());
        fc = db.getFastClass(TestMethodInterceptorController6.class);
        assertNotNull(fc);
        assertEquals(TestMethodInterceptorController6.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor2.class);
        assertNotNull(fc);
        assertEquals(Interceptor2.class, fc.getJavaClass());
        fc = db.getFastClass(Interceptor3.class);
        assertNotNull(fc);
        assertEquals(Interceptor3.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsFor(TestInterceptorController1.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsFor(TestInterceptorController2.class);

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController1.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController1.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController2.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController4.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController4.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsFor(TestMethodInterceptorController5.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController5.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController5.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        interceptors = db.getInterceptorsFor(TestMethodInterceptorController6.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor3.class, interceptors.get(0));

        interceptors = db.getInterceptorsForAction(TestMethodInterceptorController6.class, "someAction");

        assertNotNull(interceptors);
        assertEquals(2, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));
        assertEquals(Interceptor2.class, interceptors.get(1));

        interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController6.class);

        assertNotNull(interceptors);
        assertEquals(1, interceptors.size());
        assertEquals(Interceptor1.class, interceptors.get(0));

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before2", beforeActionMethod.methodName());

        beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor3.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before3", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
        assertNotNull(afterActionMethod);
        assertEquals("after", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
        assertNotNull(afterActionMethod);
        assertEquals("after2", afterActionMethod.methodName());

        afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor3.class);
        assertNotNull(afterActionMethod);
        assertEquals("after3", afterActionMethod.methodName());
       
        assertEquals(11, rm.size());
        assertTrue(rm.contains(new MojaveRoute("interceptor1", "someAction", null)));
View Full Code Here

    public void testInvalidActionController1() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidActionController1.class);
            new MappedControllerDatabase(controllerClasses, new FakeRouteMap(),
                    new HashMap<String, EntityMarshaller>());
            fail("should have thrown exception");
        } catch (Exception e) {
            if (!(e instanceof ConfigurationException)) {
                fail("wrong exception type");
View Full Code Here

TOP

Related Classes of org.mojavemvc.core.MappedControllerDatabase

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.