AstrixContextImpl implements Astrix, AstrixApplicationContext { @Override public <T> T getBean(Class<T> beanType) { return getBean(beanType, null); } AstrixContextImpl(Modules modules, AstrixApplicationDescriptor applicationDescriptor); @Override void destroy(); @Override void close(); BeanConfiguration getBeanConfiguration(AstrixBeanKey<?> beanKey); @Override T getBean(Class<T> beanType); @Override T getBean(Class<T> beanType, String qualifier); T getBean(AstrixBeanKey<T> beanKey); @Override T waitForBean(Class<T> beanType, long timeoutMillis); @Override T waitForBean(Class<T> beanType, String qualifier, long timeoutMillis); final T getInstance(final Class<T> classType); @Override void startServicePublisher();  }
@Test(expected = MissingBeanProviderException.class) public void detectsMissingBeans() throws Exception { TestAstrixConfigurer astrixConfigurer = new TestAstrixConfigurer(); AstrixContextImpl AstrixContext = (AstrixContextImpl) astrixConfigurer.configure(); AstrixContext.getBean(HelloBeanImpl.class); }
@Test(expected = MissingBeanDependencyException.class) public void detectsMissingBeanDependencies() throws Exception { TestAstrixConfigurer astrixConfigurer = new TestAstrixConfigurer(); astrixConfigurer.registerApiProvider(DependentApi.class); AstrixContextImpl AstrixContext = (AstrixContextImpl) astrixConfigurer.configure(); AstrixContext.getBean(DependentBean.class); }
@Test public void astrixBeansAreInitializedWhenFirstCreated() throws Exception { TestAstrixConfigurer astrixConfigurer = new TestAstrixConfigurer(); astrixConfigurer.registerApiProvider(HelloBeanLibrary.class); AstrixContextImpl astrixContext = (AstrixContextImpl) astrixConfigurer.configure(); HelloBeanImpl helloBean = astrixContext.getBean(HelloBeanImpl.class); assertTrue(helloBean.initialized); }
@Test public void createdAstrixBeansAreCached() throws Exception { TestAstrixConfigurer astrixConfigurer = new TestAstrixConfigurer(); astrixConfigurer.registerApiProvider(HelloBeanLibrary.class); AstrixContextImpl AstrixContext = (AstrixContextImpl) astrixConfigurer.configure(); HelloBeanImpl beanA = AstrixContext.getBean(HelloBeanImpl.class); HelloBeanImpl beanB = AstrixContext.getBean(HelloBeanImpl.class); assertSame(beanA, beanB); }