@Test public void shouldBeAbleToDetermineType() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("instance")); Assert.assertEquals(InjectionPointImplTestCase.class, point.getType()); }
@Test public void shouldBeAbleToDetermineScope() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("suiteInstance")); Assert.assertEquals(ApplicationScoped.class, point.getScope()); }
@Test public void shouldBeAbleToReadAndInvokeInjectionPoints() throws Exception { ExtensionWithInjection target = new ExtensionWithInjection(); Extension extension = ExtensionImpl.of(target); Assert.assertEquals( "Verify correct injection fields were found", 1, extension.getInjectionPoints().size()); Instance<Object> instance = new DummyInstanceImpl(); for (InjectionPoint point : extension.getInjectionPoints()) { point.set(instance); } extension.getObservers().get(0).invoke(null, new Object()); Assert.assertTrue(target.methodOneWasCalled); Assert.assertNotNull(instance.get()); }
@Test public void shouldBeAbleToFindRawTypeForGenericWildCard() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("genericWildCardInstance")); try { Assert.assertEquals(GenericWildCard.class, point.getType()); } catch (Exception e) { //e.printStackTrace(); throw e; } }
@Test public void shouldBeAbleToDetermineScope() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("suiteInstance")); Assert.assertEquals(ApplicationScoped.class, point.getScope()); }
@Test public void shouldBeAbleToReadAndInvokeInjectionPoints() throws Exception { ExtensionWithInjection target = new ExtensionWithInjection(); Extension extension = ExtensionImpl.of(target); Assert.assertEquals( "Verify correct injection fields were found", 1, extension.getInjectionPoints().size()); Instance<Object> instance = new DummyInstanceImpl(); for (InjectionPoint point : extension.getInjectionPoints()) { point.set(instance); } extension.getObservers().get(0).invoke(null, new Object()); Assert.assertTrue(target.methodOneWasCalled); Assert.assertNotNull(instance.get()); }
@Test public void shouldBeAbleToDetermineType() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("instance")); Assert.assertEquals(InjectionPointImplTestCase.class, point.getType()); }
@Test public void shouldBeAbleToFindRawTypeForGenericWildCard() throws Exception { InjectionPoint point = InjectionPointImpl.of(this, this.getClass().getDeclaredField("genericWildCardInstance")); try { Assert.assertEquals(GenericWildCard.class, point.getType()); } catch (Exception e) { //e.printStackTrace(); throw e; } }