本文整理汇总了Java中org.apache.catalina.core.StandardContext.setDistributable方法的典型用法代码示例。如果您正苦于以下问题:Java StandardContext.setDistributable方法的具体用法?Java StandardContext.setDistributable怎么用?Java StandardContext.setDistributable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.core.StandardContext
的用法示例。
在下文中一共展示了StandardContext.setDistributable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateSessionAndPassivate
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
@Test
public void testCreateSessionAndPassivate() throws IOException, LifecycleException, ClassNotFoundException {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
ctx.setDistributable(true);
Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
ctx.addServletMapping("/dummy", "DummyServlet");
PersistentManager manager = new PersistentManager();
TesterStore store = new TesterStore();
manager.setStore(store);
manager.setMaxIdleBackup(0);
ctx.setManager(manager);
ctx.addValve(new PersistentValve());
tomcat.start();
Assert.assertEquals("No active sessions", manager.getActiveSessions(), 0);
Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
String sessionId = getUrl(
"http://localhost:" + getPort()
+ "/dummy?no_create_session=false").toString();
Assert.assertNotNull("Session is stored", store.load(sessionId));
Assert.assertEquals("All sessions are passivated", manager.getActiveSessions(), 0);
Assert.assertTrue("One session was created", !manager.getSessionIdsFull().isEmpty());
}
示例2: noSessionCreate_57637
import org.apache.catalina.core.StandardContext; //导入方法依赖的package包/类
@Test
public void noSessionCreate_57637() throws IOException, LifecycleException {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
ctx.setDistributable(true);
Tomcat.addServlet(ctx, "DummyServlet", new DummyServlet());
ctx.addServletMapping("/dummy", "DummyServlet");
PersistentManager manager = new PersistentManager();
TesterStore store = new TesterStore();
manager.setStore(store);
manager.setMaxIdleBackup(0);
ctx.setManager(manager);
ctx.addValve(new PersistentValve());
tomcat.start();
Assert.assertEquals(manager.getActiveSessions(), 0);
Assert.assertTrue("No sessions managed", manager.getSessionIdsFull().isEmpty());
Assert.assertEquals(
"NO_SESSION",
getUrl(
"http://localhost:" + getPort()
+ "/dummy?no_create_session=true").toString());
Assert.assertEquals(manager.getActiveSessions(), 0);
Assert.assertTrue("No sessions where created", manager.getSessionIdsFull().isEmpty());
}