下面列出了怎么用org.springframework.context.support.AbstractRefreshableApplicationContext的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
public void testParentApplicationEvent() {
AbstractRefreshableApplicationContext parent = new ClassPathXmlApplicationContext();
parent.refresh();
SpringBusFactory factory = new SpringBusFactory(parent);
Bus bus = factory.createBus();
CXFBusLifeCycleManager manager = bus.getExtension(CXFBusLifeCycleManager.class);
BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
manager.registerLifeCycleListener(listener);
EasyMock.reset(listener);
listener.preShutdown();
EasyMock.expectLastCall().times(1);
listener.postShutdown();
EasyMock.expectLastCall().times(1);
EasyMock.replay(listener);
parent.close();
EasyMock.verify(listener);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
AbstractRefreshableApplicationContext ctx = (AbstractRefreshableApplicationContext)getServer().getApplicationContext();
this.retryingTransactionHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper");
this.authenticationService = (MutableAuthenticationService)ctx.getBean("AuthenticationService");
this.personService = (PersonService)ctx.getBean("PersonService");
this.siteService = (SiteService)ctx.getBean("SiteService");
this.nodeService = (NodeService)ctx.getBean("NodeService");
this.nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService");
this.checkOutCheckInService = (CheckOutCheckInService)ctx.getBean("checkOutCheckInService");
this.permissionService = (PermissionService)ctx.getBean("permissionService");
// Do the setup as admin
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
// Create a site
TEST_SITE = createSite(TEST_SITE_NAME);
// Create two users, one who's a site member
createUser(USER_ONE, true);
createUser(USER_TWO, false);
// Do our tests by default as the first user who is a contributor
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
}
@Before
public void setup() {
//System.err.printf("ApplicationContext Type [%s]%n", ObjectUtils.nullSafeClassName(this.applicationContext));
assertThat(this.applicationContext).isInstanceOf(AbstractRefreshableApplicationContext.class);
}