/** * Builds injection point. */ protected InjectionPoint buildInjectionPoint( final String annotationValue, final String propertyName, final Class propertyType, final Class<? extends MadvocScope> scope) { final String value = annotationValue.trim(); final String name, targetName; if (StringUtil.isNotBlank(value)) { name = value; targetName = propertyName; } else { name = propertyName; targetName = null; } return new InjectionPoint(propertyType, name, targetName, scopeResolver.defaultOrScopeType(scope)); }
@Test void testScopeRegistration() { final ScopeResolver scopeResolver = new ScopeResolver(); scopeResolver.madpc = new PetiteContainer(); scopeResolver.madpc.addBean("madvocEncoding", new MadvocEncoding()); final MadvocScope requestScope = scopeResolver.defaultOrScopeType(RequestScope.class); final MadvocScope requestScope2 = scopeResolver.defaultOrScopeType(RequestScope.class); assertEquals(requestScope2, requestScope); final MyScope myScope = scopeResolver.defaultOrScopeType(MyScope.class); assertEquals(2, scopeResolver.allScopes.size()); }
@Test void testScopeClassLookup() { final ScopeResolver scopeResolver = new ScopeResolver(); scopeResolver.madpc = new PetiteContainer(); scopeResolver.madpc.addBean("madvocEncoding", new MadvocEncoding()); final MadvocScope madvocScope = scopeResolver.defaultOrScopeType(MyScope.class); assertNotNull(madvocScope); assertTrue(madvocScope instanceof MyScope); final MadvocScope madvocScope2 = scopeResolver.defaultOrScopeType(MyScope.class); assertEquals(madvocScope2, madvocScope); } }