ScopeContainer extends AbstractContainer { public <T extends Scope> Supplier<T> registerAlias(String scopeName, String aliasName) { if (this.scopeMapping.containsKey(aliasName)) { throw new IllegalStateException("the scope " + aliasName + " already exists."); } Supplier<Scope> oldScope = this.scopeMapping.get(scopeName); if (oldScope == null) { throw new IllegalStateException("reference Scope does not exist."); } return (Supplier<T>) this.registerScopeProvider(aliasName, oldScope); } ScopeContainer(SpiCallerContainer spiContainer); Supplier<T> registerAlias(String scopeName, String aliasName); Supplier<T> registerScope(String scopeName, Scope scopeInstance); Supplier<T> registerScopeProvider(String scopeName, Supplier<T> scopeProvider); Supplier<Scope> findScope(String scopeName); Supplier<Scope>[] collectScope(BindInfo<?> bindInfo); Supplier<Scope>[] collectScope(Class<?> targetType); boolean isSingleton(BindInfo<?> bindInfo); boolean isSingleton(Class<?> targetType);  }
@Test public void scopTest5() { SpiCallerContainer spiCallerContainer = new SpiCallerContainer(); ScopeContainer scopeContainer = new ScopeContainer(spiCallerContainer); spiCallerContainer.init(); scopeContainer.init(); scopeContainer.registerAlias(javax.inject.Singleton.class.getName(), My.class.getName()); try { scopeContainer.registerAlias(javax.inject.Singleton.class.getName(), My.class.getName()); assert true; } catch (IllegalStateException e) { assert e.getMessage().equals("the scope " + My.class.getName() + " already exists."); } }
@Test public void scopTest6() { SpiCallerContainer spiCallerContainer = new SpiCallerContainer(); ScopeContainer scopeContainer = new ScopeContainer(spiCallerContainer); spiCallerContainer.init(); try { scopeContainer.registerAlias(My.class.getName(), javax.inject.Singleton.class.getName()); assert true; } catch (IllegalStateException e) { assert e.getMessage().equals("reference Scope does not exist."); } }