本文整理汇总了Java中org.apache.catalina.deploy.ContextEnvironment.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ContextEnvironment.setName方法的具体用法?Java ContextEnvironment.setName怎么用?Java ContextEnvironment.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.deploy.ContextEnvironment
的用法示例。
在下文中一共展示了ContextEnvironment.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug49132
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test JNDI is available to ServletContextListeners.
*/
@Test
public void testBug49132() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
org.apache.catalina.Context ctx = tomcat.addContext("", null);
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType(BUG49132_VALUE.getClass().getName());
environment.setName(BUG49132_NAME);
environment.setValue(BUG49132_VALUE);
ctx.getNamingResources().addEnvironment(environment);
ctx.addApplicationListener(Bug49132Listener.class.getName());
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例2: testBug49132
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test JNDI is available to ServletContextListeners.
*/
@Test
public void testBug49132() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType(BUG49132_VALUE.getClass().getName());
environment.setName(BUG49132_NAME);
environment.setValue(BUG49132_VALUE);
ctx.getNamingResources().addEnvironment(environment);
ctx.addApplicationListener(new ApplicationListener(
Bug49132Listener.class.getName(), false));
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例3: testBug49132
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test JNDI is available to ServletContextListeners.
*/
@Test
public void testBug49132() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType(BUG49132_VALUE.getClass().getName());
environment.setName(BUG49132_NAME);
environment.setValue(BUG49132_VALUE);
ctx.getNamingResources().addEnvironment(environment);
ctx.addApplicationListener(Bug49132Listener.class.getName());
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例4: testBug49132
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test JNDI is available to ServletContextListeners.
*/
@Test
public void testBug49132() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType(JNDI_VALUE.getClass().getName());
environment.setName(JNDI_NAME);
environment.setValue(JNDI_VALUE);
ctx.getNamingResources().addEnvironment(environment);
ctx.addApplicationListener(Bug49132Listener.class.getName());
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例5: testEnableNaming
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI.
*/
@Test
public void testEnableNaming() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName(HelloWorldJndi.JNDI_ENV_NAME);
environment.setValue("Tomcat User");
ctx.getNamingResources().addEnvironment(environment);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
示例6: testEnableNamingGlobal
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI and using global resources.
*/
@Test
public void testEnableNamingGlobal() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName("globalTest");
environment.setValue("Tomcat User");
tomcat.getServer().getGlobalNamingResources().addEnvironment(environment);
ContextResourceLink link = new ContextResourceLink();
link.setGlobal("globalTest");
link.setName(HelloWorldJndi.JNDI_ENV_NAME);
link.setType("java.lang.String");
ctx.getNamingResources().addResourceLink(link);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
示例7: testBug54096
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
@Test
public void testBug54096() throws Exception {
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
org.apache.catalina.Context ctx = tomcat.addContext("", null);
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environmentA = new ContextEnvironment();
environmentA.setType(Bug54096EnvA.class.getName());
environmentA.setName(BUG54096_NameA);
environmentA.setValue(BUG54096_ValueA);
ctx.getNamingResources().addEnvironment(environmentA);
ContextEnvironment environmentB = new ContextEnvironment();
environmentB.setType(Bug54096EnvB.class.getName());
environmentB.setName(BUG54096_NameB);
environmentB.setValue(BUG54096_ValueB);
ctx.getNamingResources().addEnvironment(environmentB);
ctx.addApplicationListener(Bug54096Listener.class.getName());
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例8: testBug52830
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
@Test
public void testBug52830() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
// Create the resource
ContextEnvironment env = new ContextEnvironment();
env.setName("boolean");
env.setType(Boolean.class.getName());
env.setValue("true");
ctx.getNamingResources().addEnvironment(env);
// Map the test Servlet
Bug52830Servlet bug52830Servlet = new Bug52830Servlet();
Tomcat.addServlet(ctx, "bug52830Servlet", bug52830Servlet);
ctx.addServletMapping("/", "bug52830Servlet");
tomcat.start();
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
assertEquals(200, rc);
assertTrue(bc.toString().contains("truetrue"));
}
示例9: testEnableNaming
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI.
*/
@Test
public void testEnableNaming() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName(HelloWorldJndi.JNDI_ENV_NAME);
environment.setValue("Tomcat User");
ctx.getNamingResources().addEnvironment(environment);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
示例10: testEnableNamingGlobal
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI and using global resources.
*/
@Test
public void testEnableNamingGlobal() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName("globalTest");
environment.setValue("Tomcat User");
tomcat.getServer().getGlobalNamingResources().addEnvironment(environment);
ContextResourceLink link = new ContextResourceLink();
link.setGlobal("globalTest");
link.setName(HelloWorldJndi.JNDI_ENV_NAME);
ctx.getNamingResources().addResourceLink(link);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
示例11: testBug54096
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
@Test
public void testBug54096() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environmentA = new ContextEnvironment();
environmentA.setType(Bug54096EnvA.class.getName());
environmentA.setName(BUG54096_NameA);
environmentA.setValue(BUG54096_ValueA);
ctx.getNamingResources().addEnvironment(environmentA);
ContextEnvironment environmentB = new ContextEnvironment();
environmentB.setType(Bug54096EnvB.class.getName());
environmentB.setName(BUG54096_NameB);
environmentB.setValue(BUG54096_ValueB);
ctx.getNamingResources().addEnvironment(environmentB);
ctx.addApplicationListener(new ApplicationListener(
Bug54096Listener.class.getName(), false));
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例12: testBug52830
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
@Test
public void testBug52830() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// Must have a real docBase - just use temp
StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Create the resource
ContextEnvironment env = new ContextEnvironment();
env.setName("boolean");
env.setType(Boolean.class.getName());
env.setValue("true");
ctx.getNamingResources().addEnvironment(env);
// Map the test Servlet
Bug52830Servlet bug52830Servlet = new Bug52830Servlet();
Tomcat.addServlet(ctx, "bug52830Servlet", bug52830Servlet);
ctx.addServletMapping("/", "bug52830Servlet");
tomcat.start();
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/", bc, null);
assertEquals(200, rc);
assertTrue(bc.toString().contains("truetrue"));
}
示例13: testBug54096
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
@Test
public void testBug54096() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environmentA = new ContextEnvironment();
environmentA.setType(Bug54096EnvA.class.getName());
environmentA.setName(BUG54096_NameA);
environmentA.setValue(BUG54096_ValueA);
ctx.getNamingResources().addEnvironment(environmentA);
ContextEnvironment environmentB = new ContextEnvironment();
environmentB.setType(Bug54096EnvB.class.getName());
environmentB.setName(BUG54096_NameB);
environmentB.setValue(BUG54096_ValueB);
ctx.getNamingResources().addEnvironment(environmentB);
ctx.addApplicationListener(Bug54096Listener.class.getName());
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
}
示例14: testEnableNaming
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI.
*/
@Test
public void testEnableNaming() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName(HelloWorldJndi.JNDI_ENV_NAME);
environment.setValue("Tomcat User");
ctx.getNamingResources().addEnvironment(environment);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
示例15: testEnableNamingGlobal
import org.apache.catalina.deploy.ContextEnvironment; //导入方法依赖的package包/类
/**
* Test for enabling JNDI and using global resources.
*/
@Test
public void testEnableNamingGlobal() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// You can customise the context by calling its API
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
ContextEnvironment environment = new ContextEnvironment();
environment.setType("java.lang.String");
environment.setName("globalTest");
environment.setValue("Tomcat User");
tomcat.getServer().getGlobalNamingResources().addEnvironment(environment);
ContextResourceLink link = new ContextResourceLink();
link.setGlobal("globalTest");
link.setName(HelloWorldJndi.JNDI_ENV_NAME);
ctx.getNamingResources().addResourceLink(link);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}