/** @throws ClassNotFoundException */ @Test public void testResolveServiceC() throws ClassNotFoundException { final BaseSummoner summoner = new BaseSummoner(); summoner.setSummonResolver( new CompositeSummonResolver( new Vector<IServiceSummoner>() { { add(summoner); } })); ServiceA a = new ServiceA(); ServiceB b = new ServiceB(); ServiceC c = new ServiceC(); summoner.registerServiceFor(a.getClass().getCanonicalName(), a); summoner.registerServiceFor(b.getClass().getCanonicalName(), b); summoner.registerServiceFor(c.getClass().getCanonicalName(), c); SummonableService resolved = summoner.get(c.getClass().getCanonicalName(), c); summoner.resolveSummons(); assertEquals(c.getClass(), resolved.getClass()); assertTrue(b.equals(c.b)); assertTrue(a.equals(c.a)); }
public void doSomethingElseUsingServiceB(int noOfCallsToServiceB) { ServiceB serviceB = new ServiceB("config"); for (int i = 0; i < noOfCallsToServiceB; i++) { serviceB.computeX(i, 1); } config = serviceB.getConfig(); }
public String performComplexOperation(List<?> items) { ServiceB serviceB = new ServiceB(config); int i = 1; for (Object item : items) { serviceB.computeX(i, item.hashCode()); } return serviceB.findItem("ABC", "xyz", "01"); }
@Test public void afterAdvice() { OnExitTracingAspect aspect = new OnExitTracingAspect(); ServiceB b = new ServiceB("test"); assertEquals(3, b.computeX(1, 2)); assertEquals(5, b.computeX(2, 3)); assertEquals(-10, b.computeX(0, -10)); assertEquals(asList(3, 5, -10), aspect.values); }
@Test public void aroundAdvice() { TracingAspect aspect = new TracingAspect(); ServiceB b = new ServiceB("test"); assertEquals(3, b.computeX(1, 2)); assertEquals(5, b.computeX(2, 3)); assertEquals(-10, b.computeX(0, -10)); assertEquals(asList(1, 2, 2, 3, 0, -10), aspect.inputValues); assertEquals(asList(3, 5, -10), aspect.outputValues); }
public void methodB() { sb.methodB(); sc.methodC(); }
public void methodA() { sa.methodA(); sb.methodB(); }