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());