Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse McConnell2011-05-13 20:22:12 +0000
committerJesse McConnell2011-05-13 20:22:12 +0000
commit5f01e2428b929e840fabe6c9383661f419492fff (patch)
tree29eb80f48d9205d3e3a947a868adce79534ae481 /jetty-deploy/src/test
parentdbcdcc6ce676b3e7b1e9b0b3a3150fbc1401100a (diff)
downloadorg.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.tar.gz
org.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.tar.xz
org.eclipse.jetty.project-5f01e2428b929e840fabe6c9383661f419492fff.zip
Bug 345729 add binding that can allow for global management of server and system classes for webapp contexts, added 2 gettings on webappcontext for getting default server and system class settings.
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3143 7e9141cc-0065-0410-87d8-b60c137991c4
Diffstat (limited to 'jetty-deploy/src/test')
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBindingTest.java145
-rw-r--r--jetty-deploy/src/test/resources/binding-test-contexts-1.xml78
-rw-r--r--jetty-deploy/src/test/resources/binding-test-contexts-2.xml63
3 files changed, 286 insertions, 0 deletions
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBindingTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBindingTest.java
new file mode 100644
index 0000000000..4583a3576f
--- /dev/null
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/WebappClasspathPatternBindingTest.java
@@ -0,0 +1,145 @@
+// ========================================================================
+// Copyright (c) Webtide LLC
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.apache.org/licenses/LICENSE-2.0.txt
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+package org.eclipse.jetty.deploy.bindings;
+
+import junit.framework.Assert;
+
+import org.eclipse.jetty.deploy.providers.ScanningAppProvider;
+import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
+import org.eclipse.jetty.toolchain.test.TestingDir;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Tests {@link ScanningAppProvider} as it starts up for the first time.
+ */
+public class WebappClasspathPatternBindingTest
+{
+ @Rule
+ public TestingDir testdir = new TestingDir();
+ private static XmlConfiguredJetty jetty;
+
+ @Before
+ public void setupEnvironment() throws Exception
+ {
+ jetty = new XmlConfiguredJetty(testdir);
+ jetty.addConfiguration("jetty.xml");
+// jetty.addConfiguration("jetty-deploymgr-contexts.xml");
+
+ // Setup initial context
+ jetty.copyContext("foo.xml","foo.xml");
+ jetty.copyWebapp("foo-webapp-1.war","foo.war");
+
+ // Should not throw an Exception
+ // jetty.load();
+
+ // Start it
+ // jetty.start();
+ }
+
+ @After
+ public void teardownEnvironment() throws Exception
+ {
+ // Stop jetty.
+ jetty.stop();
+ }
+
+ @Test
+ public void testServerAndSystemClassesOverride() throws Exception
+ {
+ jetty.addConfiguration("binding-test-contexts-1.xml");
+ jetty.load();
+ jetty.start();
+
+ WebAppContext context = jetty.getWebAppContexts().get(0);
+
+ Assert.assertNotNull(context);
+ Assert.assertEquals(context.getDefaultServerClasses().length, context.getServerClasses().length - 1); // added a pattern
+ Assert.assertEquals(context.getDefaultSystemClasses().length,context.getSystemClasses().length + 1); // removed a patter
+
+ boolean fooPackage = false;
+
+ // we are inserting the foo package into the server classes
+ for (String entry : context.getServerClasses())
+ {
+ if ("org.eclipse.foo.".equals(entry))
+ {
+ fooPackage = true;
+ }
+ }
+
+ Assert.assertTrue(fooPackage);
+
+ boolean jndiPackage = false;
+
+ // this test overrides and we removed the jndi from the list so it
+ // should test false
+ for (String entry : context.getSystemClasses())
+ {
+ if ("org.eclipse.jetty.jndi.".equals(entry))
+ {
+ jndiPackage = true;
+ }
+ }
+
+ Assert.assertFalse(jndiPackage);
+ }
+
+ @Test
+ public void testServerAndSystemClassesModification() throws Exception
+ {
+ jetty.addConfiguration("binding-test-contexts-2.xml");
+ jetty.load();
+ jetty.start();
+
+ WebAppContext context = jetty.getWebAppContexts().get(0);
+
+ Assert.assertNotNull(context);
+ Assert.assertEquals(context.getDefaultServerClasses().length,context.getServerClasses().length - 1); // added a pattern
+ Assert.assertEquals(context.getDefaultSystemClasses().length,context.getSystemClasses().length - 1); // added a pattern
+
+ boolean testPackageServer = false;
+
+
+ for (String entry : context.getSystemClasses())
+ {
+ if ("com.foo.test.".equals(entry))
+ {
+ testPackageServer = true;
+ }
+ }
+
+ Assert.assertTrue(testPackageServer);
+
+ boolean testPackageSystem = false;
+
+
+ for (String entry : context.getSystemClasses())
+ {
+ if ("com.foo.test.".equals(entry))
+ {
+ testPackageSystem = true;
+ }
+ }
+
+ Assert.assertTrue(testPackageSystem);
+ }
+
+}
+
diff --git a/jetty-deploy/src/test/resources/binding-test-contexts-1.xml b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml
new file mode 100644
index 0000000000..940b880f94
--- /dev/null
+++ b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <Array id="serverClasses" type="java.lang.String">
+ <Item>-org.eclipse.jetty.continuation.</Item>
+ <Item>-org.eclipse.jetty.jndi.</Item>
+ <Item>-org.eclipse.jetty.plus.jaas.</Item>
+ <Item>-org.eclipse.jetty.websocket.</Item>
+ <Item>-org.eclipse.jetty.servlet.DefaultServlet</Item>
+ <Item>org.eclipse.jetty.</Item>
+ <Item>org.eclipse.foo.</Item>
+ </Array>
+
+ <Array id="systemClasses" type="java.lang.String">
+ <Item>java.</Item>
+ <Item>javax.</Item>
+ <Item>org.xml.</Item>
+ <Item>org.w3c.</Item>
+ <Item>org.apache.commons.logging</Item>
+ <Item>org.eclipse.jetty.continuation</Item>
+ <Item>org.eclipse.jetty.plus.jaas.</Item>
+ <Item>org.eclipse.jetty.websocket</Item>
+ <Item>org.eclipse.jetty.servlet.DefaultServlet</Item>
+ </Array>
+
+ <Call name="addLifeCycle">
+ <Arg>
+ <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
+ <Set name="contexts">
+ <Ref id="Contexts" />
+ </Set>
+
+
+
+ <Ref id="DeploymentManager">
+ <Call name="addLifeCycleBinding">
+ <Arg>
+ <New class="org.eclipse.jetty.deploy.bindings.WebappClasspathPatternBinding">
+ <Set name="override">true</Set>
+ <Set name="serverClasses"><Ref id="serverClasses"/></Set>
+ <Set name="systemClasses"><Ref id="systemClasses"/></Set>
+ </New>
+ </Arg>
+ </Call>
+ </Ref>
+
+ <!-- Providers of Apps -->
+ <Set name="appProviders">
+ <Array type="org.eclipse.jetty.deploy.AppProvider">
+ <Item>
+ <New class="org.eclipse.jetty.deploy.providers.ContextProvider">
+ <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/contexts</Set>
+ <Set name="scanInterval">1</Set>
+ <Set name="configurationManager">
+ <New class="org.eclipse.jetty.deploy.FileConfigurationManager">
+ <Set name="file">
+ <Property name="test.targetdir" default="target" />/xml-configured-jetty.properties
+ </Set>
+ </New>
+ </Set>
+ </New>
+ </Item>
+ <Item>
+ <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
+ <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set>
+ <Set name="scanInterval">1</Set>
+ <Set name="contextXmlDir"><SystemProperty name="jetty.home" />/contexts</Set>
+ </New>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Arg>
+ </Call>
+
+</Configure>
diff --git a/jetty-deploy/src/test/resources/binding-test-contexts-2.xml b/jetty-deploy/src/test/resources/binding-test-contexts-2.xml
new file mode 100644
index 0000000000..665fd4ab31
--- /dev/null
+++ b/jetty-deploy/src/test/resources/binding-test-contexts-2.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <Array id="serverClasses" type="java.lang.String">
+ <Item>org.foo.test.</Item>
+ </Array>
+
+ <Array id="systemClasses" type="java.lang.String">
+ <Item>com.foo.test.</Item>
+ </Array>
+
+ <Call name="addLifeCycle">
+ <Arg>
+ <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
+ <Set name="contexts">
+ <Ref id="Contexts" />
+ </Set>
+
+
+
+ <Ref id="DeploymentManager">
+ <Call name="addLifeCycleBinding">
+ <Arg>
+ <New class="org.eclipse.jetty.deploy.bindings.WebappClasspathPatternBinding">
+ <Set name="serverClasses"><Ref id="serverClasses"/></Set>
+ <Set name="systemClasses"><Ref id="systemClasses"/></Set>
+ </New>
+ </Arg>
+ </Call>
+ </Ref>
+
+ <!-- Providers of Apps -->
+ <Set name="appProviders">
+ <Array type="org.eclipse.jetty.deploy.AppProvider">
+ <Item>
+ <New class="org.eclipse.jetty.deploy.providers.ContextProvider">
+ <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/contexts</Set>
+ <Set name="scanInterval">1</Set>
+ <Set name="configurationManager">
+ <New class="org.eclipse.jetty.deploy.FileConfigurationManager">
+ <Set name="file">
+ <Property name="test.targetdir" default="target" />/xml-configured-jetty.properties
+ </Set>
+ </New>
+ </Set>
+ </New>
+ </Item>
+ <Item>
+ <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
+ <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set>
+ <Set name="scanInterval">1</Set>
+ <Set name="contextXmlDir"><SystemProperty name="jetty.home" />/contexts</Set>
+ </New>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Arg>
+ </Call>
+
+</Configure>

Back to the top