You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/02/05 00:18:13 UTC
svn commit: r906723 -
/tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
Author: markt
Date: Thu Feb 4 23:18:12 2010
New Revision: 906723
URL: http://svn.apache.org/viewvc?rev=906723&view=rev
Log:
Add a test case for global naming resources with embedded
Modified:
tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java?rev=906723&r1=906722&r2=906723&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java Thu Feb 4 23:18:12 2010
@@ -36,6 +36,7 @@
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.deploy.ContextEnvironment;
+import org.apache.catalina.deploy.ContextResourceLink;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.realm.RealmBase;
import org.apache.tomcat.util.buf.ByteChunk;
@@ -252,6 +253,41 @@
assertEquals("Hello, Tomcat User", res.toString());
}
+ /**
+ * Test for enabling JNDI and using global resources.
+ */
+ public void testEnableNamingGlobal() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ // Must have a real docBase - just use temp
+ StandardContext 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());
+ }
+
/**
* Test for https://issues.apache.org/bugzilla/show_bug.cgi?id=47866
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org