### Question:
DefaultControllerFactory { public <T> T createController(Class<T> controllerClass) { try { return instanciateAndInjectDependencies(controllerClass); } finally { nestingLevel = 0; } }  T createController(Class<T> controllerClass); void setDependency(Class<?> type, Object dependency); void clearDependencies(); Function<Class<?>, Object> getInstanceProvider(); void setInstanceProvider(Function<Class<?>, Object> instanceProvider); Function<String, Object> getPropertiesProvider(); void setPropertiesProvider(Function<String, Object> propertiesProvider); void setLogger(Consumer<String> logger);  }### Answer:
@Test public void testPrototypeController() { assertTrue(factory.createController(TestController.class) != factory.createController(TestController.class)); }
@Test public void testSingletonDependencies() { TestController controller1 = factory.createController(TestController.class); TestController controller2 = factory.createController(TestController.class); assertTrue(controller1.model == controller2.model); assertTrue(controller1.service == controller2.service); }
@Test public void testSystemPropertyInjection() { System.setProperty("fieldInitializedFromSystemProperties", "sysProperty"); TestController controller = factory.createController(TestController.class); assertEquals("sysProperty", controller.fieldInitializedFromSystemProperties); assertNotNull(controller.userHomeDirectory); System.getProperties().remove("fieldInitializedFromSystemProperties"); }