Package org.mojavemvc.core

Examples of org.mojavemvc.core.MappedControllerDatabase


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

        FastClass fc = db.getFastClass(TestController.class);
        assertNotNull(fc);
        assertEquals(TestController.class, fc.getJavaClass());
        fc = db.getFastClass(TestStartupController.class);
        assertNotNull(fc);
        assertEquals(TestStartupController.class, fc.getJavaClass());

        assertEquals(TestController.class, db.getControllerClass("test"));
        assertEquals(TestStartupController.class, db.getControllerClass("startup"));
        assertEquals(TestController.class, db.getDefaultControllerClass());

        ActionSignature sig = db.getActionMethodSignature(TestController.class, "test1");
        assertEquals("testAction", sig.methodName());
        sig = db.getActionMethodSignature(TestController.class, "with-param");
        assertEquals("withParamAction", sig.methodName());
        sig = db.getActionMethodSignature(TestController.class, "another-param");
        assertEquals("anotherParamAction", sig.methodName());
        sig = db.getActionMethodSignature(TestController.class, "some-service");
        assertEquals("someServiceAction", sig.methodName());
        sig = db.getActionMethodSignature(TestController.class, "test-annotation");
        assertEquals("doAnnotationTest", sig.methodName());

        ActionSignature beforeActionMethod = db.getBeforeActionMethodFor(TestController.class);
        assertNotNull(beforeActionMethod);
        assertEquals("doSomethingBefore", beforeActionMethod.methodName());

        ActionSignature afterActionMethod = db.getAfterActionMethodFor(TestController.class);
        assertNotNull(afterActionMethod);
        assertEquals("doSomethingAfter", afterActionMethod.methodName());

        ActionSignature defaultActionSignature = db.getDefaultActionMethodFor(TestController.class);
        assertNotNull(defaultActionSignature);
        assertTrue(defaultActionSignature instanceof DefaultActionSignature);
        assertEquals("defaultAction", defaultActionSignature.methodName());

        ActionSignature afterConstructMethod = db.getAfterConstructMethodFor(TestController.class);
        assertNotNull(afterConstructMethod);
        assertEquals("init", afterConstructMethod.methodName());

        afterConstructMethod = db.getAfterConstructMethodFor(TestStartupController.class);
        assertNotNull(afterConstructMethod);
        assertEquals("init2", afterConstructMethod.methodName());

        Set<Class<?>> initControllers = db.getInitControllers();
        assertNotNull(initControllers);
        assertEquals(1, initControllers.size());
        assertEquals(TestStartupController.class, initControllers.iterator().next());
       
        assertEquals(12, rm.size());
View Full Code Here


    @Test
    public void testConstructWithInheritance() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>( );
        controllerClasses.add( TestChildClass.class );
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, new FakeRouteMap(),
                new HashMap<String, EntityMarshaller>());
       
        assertEquals( TestChildClass.class, db.getControllerClass("child"));
        assertEquals( TestChildClass.class, db.getDefaultControllerClass( ));
       
        ActionSignature sig = db.getActionMethodSignature(TestChildClass.class, "test");
        assertEquals( "testAction", sig.methodName() );
       
        ActionSignature defaultActionMethod = db.getDefaultActionMethodFor(TestChildClass.class);
        assertNotNull( defaultActionMethod );
        assertEquals( "defaultAction", defaultActionMethod.methodName( ) );
       
        ActionSignature beforeActionMethod = db.getBeforeActionMethodFor(TestChildClass.class);
        assertNotNull( beforeActionMethod );
        assertEquals( "doSomethingBefore", beforeActionMethod.methodName( ) );
    }
View Full Code Here

    public void testInterceptorInheritance() {
   
        Set<Class<?>> controllerClasses = new HashSet<Class<?>>( );
        controllerClasses.add( TestInterceptorController4.class );
        FakeRouteMap rm = new FakeRouteMap();
        ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
                new HashMap<String, EntityMarshaller>());
       
        List<Class<?>> interceptors = db.getInterceptorsFor(TestInterceptorController4.class);

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

        ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(ConcreteInterceptor.class);
        assertNotNull(beforeActionMethod);
        assertEquals("before", beforeActionMethod.methodName());
       
        assertEquals(1, rm.size());
        assertTrue(rm.contains(new MojaveRoute("interceptor4", "someAction", null)));
View Full Code Here

    public void testInvalidInterceptors1() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidInterceptorController1.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 testInvalidInterceptors2() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidInterceptorController2.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 testInvalidInterceptors3() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidInterceptorController3.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 testInvalidInterceptors4() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidInterceptorController4.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 testInvalidInterceptors5() {

        try {
            Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
            controllerClasses.add(TestInvalidInterceptorController5.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 testInterceptor1() {

        Set<Class<?>> controllerClasses = new HashSet<Class<?>>();
        controllerClasses.add(TestInterceptorController1.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(Interceptor1.class);
        assertNotNull(fc);
        assertEquals(Interceptor1.class, fc.getJavaClass());

        List<Class<?>> interceptors = db.getInterceptorsFor(TestInterceptorController1.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(1, rm.size());
        assertTrue(rm.contains(new MojaveRoute("interceptor1", "someAction", null)));
View Full Code Here

    public void testInterceptor2() {

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

        FastClass 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(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(1, rm.size());
        assertTrue(rm.contains(new MojaveRoute("interceptor2", "someAction", null)));
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.