@Before public void setup() { when(iocManager.lookupBean(UnanchoredWorkbenchPartPresenter.class).getInstance()).thenReturn(unanchoredWorkbenchPartPresenter); when(iocManager.lookupBean(WorkbenchPartPresenterDefault.class).getInstance()).thenReturn(workbenchPartPresenterDefault); }
@Test public void testNewWorkbenchPartPresenterDefault() { beanFactory.newWorkbenchPart(null, null, null, null, WorkbenchPartPresenterDefault.class); verify(iocManager.lookupBean(WorkbenchPartPresenterDefault.class)).getInstance(); verify(iocManager.lookupBean(UnanchoredWorkbenchPartPresenter.class), never()).getInstance(); } }
public void testProxyingWithOnlyInjectableConstructor() throws Exception { try { IOC.getBeanManager().lookupBean(ProxiableInjectableConstr.class).getInstance(); } catch (final Throwable t) { throw new AssertionError("Could not construct instance of proxiable type with injectable constructor.", t); } }
public void testDependentScopeWithPackageConstr() throws Exception { try { IOC.getBeanManager().lookupBean(DependentWithPackageConstr.class).getInstance(); } catch (final Throwable t) { throw new AssertionError("Could not create instance of bean with package constructor.", t); } }
public void testTextBoxInjection() throws Exception { try { IOC.getBeanManager().lookupBean(ClassWithInjectedTextBox.class).getInstance(); } catch (Throwable t) { throw new AssertionError("Could not create instance of type with injected TextBox.", t); } }
public void testErrorMessageWhenProxyingFailsWithOnlyInjectableConstructor() throws Exception { try { IOC.getBeanManager().lookupBean(ProxiableInjectableConstrThrowsNPE.class).getInstance(); fail("Looking up an instance should have failed when creating proxy."); } catch (final Throwable t) { assertTrue("The error message did not explain that the problem was with proxying.", t.getMessage().contains("proxy")); } }
public void testNotWhitelistedPackage() throws Exception { try { IOC.getBeanManager().lookupBean(NotWhitelistedBean.class).getInstance(); fail("Should not be able to resolve a not whitelisted bean!"); } catch (final IOCResolutionException e) { // expected } }
public void testWhitelistedAndBlacklistedBean() throws Exception { try { IOC.getBeanManager().lookupBean(WhitelistedAndBlacklistedBean.class).getInstance(); fail("Should not be able to resolve a whitelisted bean if it is blacklisted!"); } catch (final IOCResolutionException e) { // expected } }
@Override protected void gwtSetUp() throws Exception { super.gwtSetUp(); module = IOC.getBeanManager().lookupBean(BeanWithManagedInstance.class).getInstance(); }
public void testLocalBeanSatisfiesJsTypeInterfaceForDefaultInjectionSite() throws Exception { final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance(); assertNotNull(module.defaultSatisfiedIface); assertTrue(module.defaultSatisfiedIface instanceof InternallySatisfiedImpl); assertSame(module.defaultSatisfiedIface, IOC.getBeanManager().lookupBean(InternallySatisfiedJsTypeIface.class).getInstance()); }
public void testLocalBeanSatisfiesJsTypeInterfaceForExternalInjectionSite() throws Exception { final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance(); assertNotNull(module.externalSatisfiedIface); assertTrue(module.externalSatisfiedIface instanceof InternallySatisfiedImpl); assertSame(module.externalSatisfiedIface, IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance().externalSatisfiedIface); }
/** * Regression test for ERRAI-340 */ public void testInjectWithUnqualifiedImpl() throws Exception { InjectionPoint injectionPoint = IOC.getBeanManager().lookupBean(InjectionPoint.class).getInstance(); assertTrue("Injected value should be instance of AImpl", injectionPoint.getInjected() instanceof AImpl); }
public void testExtensionProvidedGetsCorrectNonBindingQualifierValues() throws Exception { final ClassWithNonBindingQualifiedFields instance = IOC.getBeanManager().lookupBean(ClassWithNonBindingQualifiedFields.class).getInstance(); assertEquals("foo", instance.foo); assertEquals("bar", instance.bar); }
public void testWindowContextBeanSatisfiesJsTypeInterfaceForExternalInjectionSite() throws Exception { final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance(); assertNotNull(module.defaultUnsatisfiedIface); assertEquals("external", module.defaultUnsatisfiedIface.message()); }
public void testProducerMethodNativeOfJsType() throws Exception { injectScriptThenRun(() -> { try { final NativeTypeTestModule module = IOC.getBeanManager().lookupBean(NativeTypeTestModule.class).getInstance(); assertNotNull(module.producedNativeIface); assertEquals("Not the expected implementation (in native.js).", "please", module.producedNativeIface.getMagicWord()); } catch (final IOCResolutionException ex) { fail("Precondition failed: Problem looking up test module."); } }); }
public void testBeanDecoratedWithProxy() { final MyDecoratedBean instance = IOC.getBeanManager().lookupBean(MyDecoratedBean.class).getInstance(); instance.someMethod("a", 1); instance.someMethod("b", 2); instance.someMethod("c", 3); assertEquals(instance.getTestMap(), TestDataCollector.getBeforeInvoke()); assertEquals(instance.getTestMap(), TestDataCollector.getAfterInvoke()); final Map<String, Object> expectedProperties = new HashMap<>(); expectedProperties.put("foobar", "foobie!"); assertEquals(expectedProperties, TestDataCollector.getProperties()); }
public void testDestroyingProducedBeanOfApplicationScopedProducerUsingParamInjectedManagedInstance() throws Exception { final OtherDestructableClass producedBean = getBeanManager().lookupBean(OtherDestructableClass.class, a).getInstance(); assertFalse(producedBean.isDestroyed()); getBeanManager().destroyBean(producedBean); assertTrue(producedBean.isDestroyed()); }
public void testDestroyingProducedBeanOfDepdendentScopedProducerUsingParamInjectedManagedInstance() throws Exception { final OtherDestructableClass producedBean = getBeanManager().lookupBean(OtherDestructableClass.class, b).getInstance(); assertFalse(producedBean.isDestroyed()); getBeanManager().destroyBean(producedBean); assertTrue(producedBean.isDestroyed()); }
public void testInstantiableNativeJsTypeWithFieldDependencyIsInjectable() throws Exception { injectScriptThenRun(() -> { try { final NativeTypeTestModule module = IOC.getBeanManager().lookupBean(NativeTypeTestModule.class).getInstance(); final NativeConcreteJsTypeWithFieldDependency instance = module.nativeWithFieldDep; assertNotNull(instance.get()); assertEquals("Not the expected implementation (in native.js).", "I am a native type!", instance.get().message()); } catch (final IOCResolutionException ex) { fail("Precondition failed: Problem looking up test module."); } }); }
public void testInterfaceResolution() { final HappyInspector happyInspector = IOC.getBeanManager().lookupBean(HappyInspector.class).getInstance(); assertTrue(happyInspector.confirmHappiness()); assertNotNull(happyInspector.getStringService()); assertEquals("Hello", happyInspector.getStringService().get()); assertNotNull(happyInspector.getIntegerService()); assertEquals(new Integer(111), happyInspector.getIntegerService().get()); assertNotNull(happyInspector.getLongService()); assertEquals(new Long(1l), happyInspector.getLongService().get()); }