Skip to Content.
Sympa Menu

notify-dpml - r1402 - trunk/main/planet/http/impl/src/test/net/dpml/http

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1402 - trunk/main/planet/http/impl/src/test/net/dpml/http
  • Date: Mon, 24 Apr 2006 18:44:15 +0200

Author: mcconnell
Date: 2006-04-24 18:44:12 +0200 (Mon, 24 Apr 2006)
New Revision: 1402

Added:

trunk/main/planet/http/impl/src/test/net/dpml/http/ServletEntryTestCase.java

trunk/main/planet/http/impl/src/test/net/dpml/http/ServletHolderTestCase.java

trunk/main/planet/http/impl/src/test/net/dpml/http/WebAppContextHandlerTestCase.java
Log:
add webapp context handler test case

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletEntryTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletEntryTestCase.java
2006-04-24 16:10:56 UTC (rev 1401)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletEntryTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.http;
+
+import junit.framework.TestCase;
+
+/**
+ * ServletEntryTestCase.
+ */
+public class ServletEntryTestCase extends TestCase
+{
+ private static final String NAME = "test";
+ private static final String PATH = "abc";
+
+ private ServletEntry m_entry;
+
+ /**
+ * Setup the servlet entry.
+ * @throws Exception if an error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_entry = new ServletEntry( NAME, PATH );
+ }
+
+
+ /**
+ * Test name.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testName() throws Exception
+ {
+ assertEquals( "name", NAME, m_entry.getName() );
+ }
+
+ /**
+ * Test path.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testPath() throws Exception
+ {
+ assertEquals( "path", PATH, m_entry.getPath() );
+ }
+
+}
+

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletHolderTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletHolderTestCase.java
2006-04-24 16:10:56 UTC (rev 1401)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/ServletHolderTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.http;
+
+import junit.framework.TestCase;
+
+/**
+ * ServletHolderTestCase.
+ */
+public class ServletHolderTestCase extends TestCase
+{
+ private static final String NAME = "test";
+ private static final String CLASSNAME =
ServletHolderTestCase.class.getName();
+
+ private ServletHolder m_holder;
+
+ /**
+ * Setup a servlet holder.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ m_holder = new ServletHolder( NAME, CLASSNAME );
+ }
+
+
+ /**
+ * Test name.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testName() throws Exception
+ {
+ assertEquals( "name", NAME, m_holder.getName() );
+ }
+
+ /**
+ * Test classname.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testClassname() throws Exception
+ {
+ assertEquals( "classname", CLASSNAME, m_holder.getClassName() );
+ }
+
+}
+

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/WebAppContextHandlerTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/WebAppContextHandlerTestCase.java
2006-04-24 16:10:56 UTC (rev 1401)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/WebAppContextHandlerTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.http;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.net.URI;
+import java.util.Map;
+import java.util.Hashtable;
+import java.security.Permission;
+import java.security.PermissionCollection;
+
+import net.dpml.http.WebAppContextHandler.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import net.dpml.logging.Logger;
+
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.security.SecurityHandler;
+import org.mortbay.jetty.servlet.SessionHandler;
+import org.mortbay.jetty.servlet.ServletHandler;
+
+/**
+ * WebAppContextHandler test case.
+ */
+public class WebAppContextHandlerTestCase extends
AbstractContextHandlerTestCase
+{
+ private static final URI WAR_URI = createWarURI();
+ private static final File TEMP_DIR = new File( "." );
+ private static final Map RESOURCE_ALIASES = new Hashtable();
+ private static final boolean EXTRACTION_POLICY = true;
+ private static final PermissionCollection PERMISSIONS =
createPermissionCollection();
+ private static final SecurityHandler SECURITY_HANDLER = new
SecurityHandler();
+ private static final SessionHandler SESSIONS_HANDLER = new
SessionHandler();
+ private static final ServletHandler SERVLET_HANDLER = new
ServletHandler();
+
+ private WebAppContextHandler m_handler;
+
+ /**
+ * Setup the WebAppContextHandler.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ Map map = createMap();
+
+ map.put( "war", WAR_URI );
+ map.put( "tempDirectory", TEMP_DIR );
+ map.put( "resourceAliases", RESOURCE_ALIASES );
+ map.put( "extractionPolicy", new Boolean( EXTRACTION_POLICY ) );
+ map.put( "permissions", PERMISSIONS );
+ map.put( "securityHandler", SECURITY_HANDLER );
+ map.put( "sessionHandler", SESSIONS_HANDLER );
+ map.put( "servletHandler", SERVLET_HANDLER );
+
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ Logger logger = new StandardLogger( "test" );
+ m_handler = new WebAppContextHandler( logger, context );
+ }
+
+ protected ContextHandler getContextHandler()
+ {
+ return m_handler;
+ }
+
+ /**
+ * Test war path assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testWar() throws Exception
+ {
+ assertEquals( "war", WAR_URI.toASCIIString(), m_handler.getWar() );
+ }
+
+ /**
+ * Test temp dir assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testTempDirectory() throws Exception
+ {
+ assertEquals( "tempDir", TEMP_DIR.getCanonicalFile(),
m_handler.getTempDirectory() );
+ }
+
+ /**
+ * Test resource aliases assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testResourceAliases() throws Exception
+ {
+ assertEquals( "resourceAliases", RESOURCE_ALIASES,
m_handler.getResourceAliases() );
+ }
+
+ /**
+ * Test permissions assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testPermissions() throws Exception
+ {
+ assertEquals( "permissions", PERMISSIONS, m_handler.getPermissions()
);
+ }
+
+ /**
+ * Test security handler assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testSecurityHandler() throws Exception
+ {
+ assertEquals( "securityHandler", SECURITY_HANDLER,
m_handler.getSecurityHandler() );
+ }
+
+ /**
+ * Test session handler assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testSessionHandler() throws Exception
+ {
+ assertEquals( "sessionHandler", SESSIONS_HANDLER,
m_handler.getSessionHandler() );
+ }
+
+ /**
+ * Test servlet handler assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testServletHandler() throws Exception
+ {
+ assertEquals( "servletHandler", SERVLET_HANDLER,
m_handler.getServletHandler() );
+ }
+
+ private static URI createWarURI()
+ {
+ try
+ {
+ return new URI( "artifact:war:acme/demo" );
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+
+ private static PermissionCollection createPermissionCollection()
+ {
+ Permission permission = new FilePermission( ".", "read" );
+ return permission.newPermissionCollection();
+ }
+}
+




  • r1402 - trunk/main/planet/http/impl/src/test/net/dpml/http, mcconnell at BerliOS, 04/24/2006

Archive powered by MHonArc 2.6.24.

Top of Page