Skip to Content.
Sympa Menu

notify-dpml - r1403 - in trunk/main/planet/http/impl/src: main/net/dpml/http 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: r1403 - in trunk/main/planet/http/impl/src: main/net/dpml/http test/net/dpml/http
  • Date: Mon, 24 Apr 2006 20:09:21 +0200

Author: mcconnell
Date: 2006-04-24 20:09:17 +0200 (Mon, 24 Apr 2006)
New Revision: 1403

Added:

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

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

trunk/main/planet/http/impl/src/test/net/dpml/http/SslSocketConnectorTestCase.java
Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/ConnectorContext.java
Log:
add ssl connector testcase

Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/ConnectorContext.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/ConnectorContext.java
2006-04-24 16:44:12 UTC (rev 1402)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/ConnectorContext.java
2006-04-24 18:09:17 UTC (rev 1403)
@@ -71,7 +71,7 @@
int getAcceptQueueSize( int size );

/**
- * Return the number of inital acceptors.
+ * Return the number of initial acceptors.
* @param size implementation defined default value
* @return the supplied value unless overriden in the deployment
configuration
*/

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/AbstractConnectorContextTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/AbstractConnectorContextTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/AbstractConnectorContextTestCase.java
2006-04-24 18:09:17 UTC (rev 1403)
@@ -0,0 +1,195 @@
+/*
+ * 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.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.http.ResourceContextHandler.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import net.dpml.logging.Logger;
+
+import org.mortbay.jetty.AbstractConnector;
+
+import junit.framework.TestCase;
+
+/**
+ * NCSARequestLog test case.
+ */
+public abstract class AbstractConnectorContextTestCase extends TestCase
+{
+ private static final String HOST = "localhost";
+ private static final int PORT = 1234;
+ private static final int HEADER_BUFFER_SIZE = 64;
+ private static final int MAX_IDLE_TIME = 32;
+ private static final int REQUEST_BUFFER_SIZE = 32;
+ private static final int RESPONSE_BUFFER_SIZE = 33;
+ private static final int ACCEPT_QUEUE_SIZE = 18;
+ private static final int INITIAL_ACCEPTORS_SIZE = 18;
+ private static final int SO_LINGER_TIME = 130;
+ private static final int CONFIDENTIAL_PORT = 1234;
+ private static final String CONFIDENTIAL_SCHEME = "http"; // normally
https
+ private static final int INTEGRAL_PORT = 1289;
+ private static final String INTEGRAL_SCHEME = "http"; // normally https
+
+ /**
+ * Setup the context map.
+ * @throws Exception if an error occurs
+ */
+ protected Map createMap() throws Exception
+ {
+ Map map = new Hashtable();
+ map.put( "host", HOST );
+ map.put( "port", new Integer( PORT ) );
+ map.put( "maxIdleTime", new Integer( MAX_IDLE_TIME ) );
+ map.put( "headerBufferSize", new Integer( HEADER_BUFFER_SIZE ) );
+ map.put( "requestBufferSize", new Integer( REQUEST_BUFFER_SIZE ) );
+ map.put( "responseBufferSize", new Integer( RESPONSE_BUFFER_SIZE ) );
+ map.put( "acceptQueueSize", new Integer( ACCEPT_QUEUE_SIZE ) );
+ map.put( "acceptors", new Integer( INITIAL_ACCEPTORS_SIZE ) );
+ map.put( "soLingerTime", new Integer( SO_LINGER_TIME ) );
+ map.put( "confidentialPort", new Integer( CONFIDENTIAL_PORT ) );
+ map.put( "confidentialScheme", CONFIDENTIAL_SCHEME );
+ map.put( "integralPort", new Integer( INTEGRAL_PORT ) );
+ map.put( "integralScheme", INTEGRAL_SCHEME );
+ return map;
+ }
+
+ protected abstract AbstractConnector getConnector();
+
+ /**
+ * Test hosts assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testHost() throws Exception
+ {
+ assertEquals( "host", HOST, getConnector().getHost() );
+ }
+
+ /**
+ * Test port assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testPort() throws Exception
+ {
+ assertEquals( "port", PORT, getConnector().getPort() );
+ }
+
+ /**
+ * Test hewder buffer size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testMaxIdleTime() throws Exception
+ {
+ assertEquals( "maxIdleTime", MAX_IDLE_TIME,
getConnector().getMaxIdleTime() );
+ }
+
+ /**
+ * Test header buffer size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testHeaderBufferSize() throws Exception
+ {
+ assertEquals( "headerBufferSize", HEADER_BUFFER_SIZE,
getConnector().getHeaderBufferSize() );
+ }
+
+ /**
+ * Test request buffer size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testRequestBufferSize() throws Exception
+ {
+ assertEquals( "requestBufferSize", REQUEST_BUFFER_SIZE,
getConnector().getRequestBufferSize() );
+ }
+
+ /**
+ * Test responce buffer size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testResponseBufferSize() throws Exception
+ {
+ assertEquals( "responseBufferSize", RESPONSE_BUFFER_SIZE,
getConnector().getResponseBufferSize() );
+ }
+
+ /**
+ * Test accept queue size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testAcceptQueueSize() throws Exception
+ {
+ assertEquals( "acceptQueueSize", ACCEPT_QUEUE_SIZE,
getConnector().getAcceptQueueSize() );
+ }
+
+ /**
+ * Test initial accept size assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testAcceptors() throws Exception
+ {
+ assertEquals( "acceptors", INITIAL_ACCEPTORS_SIZE,
getConnector().getAcceptors() );
+ }
+
+ /**
+ * Test so-lingert-time assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testSoLingerTime() throws Exception
+ {
+ assertEquals( "soLingerTime", SO_LINGER_TIME,
getConnector().getSoLingerTime() );
+ }
+
+ /**
+ * Test confidential port assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testConfidentialPort() throws Exception
+ {
+ assertEquals( "confidentialPort", CONFIDENTIAL_PORT,
getConnector().getConfidentialPort() );
+ }
+
+ /**
+ * Test confidential scheme assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testConfidentialScheme() throws Exception
+ {
+ assertEquals( "confidentialScheme", CONFIDENTIAL_SCHEME,
getConnector().getConfidentialScheme() );
+ }
+
+ /**
+ * Test integral port assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testIntegralPort() throws Exception
+ {
+ assertEquals( "integralPort", INTEGRAL_PORT,
getConnector().getIntegralPort() );
+ }
+
+ /**
+ * Test integal scheme assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testIntegralScheme() throws Exception
+ {
+ assertEquals( "integralScheme", INTEGRAL_SCHEME,
getConnector().getIntegralScheme() );
+ }
+}
+

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/SelectChannelConnectorTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/SelectChannelConnectorTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/SelectChannelConnectorTestCase.java
2006-04-24 18:09:17 UTC (rev 1403)
@@ -0,0 +1,69 @@
+/*
+ * 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.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.http.SelectChannelConnector.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import org.mortbay.jetty.AbstractConnector;
+
+/**
+ * SelectChannelConnectorTestCase.
+ */
+public class SelectChannelConnectorTestCase extends
AbstractConnectorContextTestCase
+{
+ private static final boolean ASSUME_SHORT_DISPATH_POLICY = true;
+
+ private SelectChannelConnector m_connector;
+
+ /**
+ * Test context value handling integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ Map map = createMap();
+
+ map.put( "assumeShortDispatch", new Boolean(
ASSUME_SHORT_DISPATH_POLICY ) );
+
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ m_connector = new SelectChannelConnector( context );
+ }
+
+ protected AbstractConnector getConnector()
+ {
+ return m_connector;
+ }
+
+ /**
+ * Test min-thread assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testAssumeShortDispatch() throws Exception
+ {
+ assertEquals( "assumeShortDispatch", ASSUME_SHORT_DISPATH_POLICY,
m_connector.getAssumeShortDispatch() );
+ }
+
+}
+

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/SslSocketConnectorTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/SslSocketConnectorTestCase.java
2006-04-24 16:44:12 UTC (rev 1402)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/SslSocketConnectorTestCase.java
2006-04-24 18:09:17 UTC (rev 1403)
@@ -0,0 +1,161 @@
+/*
+ * 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.net.URI;
+import java.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.http.SslSocketConnector.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import org.mortbay.jetty.AbstractConnector;
+
+/**
+ * SslSocketConnectorTestCase.
+ */
+public class SslSocketConnectorTestCase extends
AbstractConnectorContextTestCase
+{
+ private static final String[] CIPHER_SUITES = new String[0];
+ private static final String ALGORITHM = "QWERTY";
+ private static final String PROTOCOL = "XYZ";
+ private static final URI KEYSTORE_URI = createKeystoreURI();
+ private static final String KEYSTORE_TYPE = "ABC";
+ private static final boolean WANT_CLIENT_AUTH = true;
+ private static final boolean NEED_CLIENT_AUTH = true;
+ private static final String PROVIDER = "ACME";
+ private static final String TRUST_ALGORITHM = "QWERTY";
+
+ private SslSocketConnector m_connector;
+
+ /**
+ * Setup the SslSocketConnector instance.
+ * @throws Exception if an error occurs
+ */
+ public void setUp() throws Exception
+ {
+ Map map = createMap();
+
+ map.put( "cipherSuites", CIPHER_SUITES );
+ map.put( "algorithm", ALGORITHM );
+ map.put( "protocol", PROTOCOL );
+ map.put( "keyStore", KEYSTORE_URI );
+ map.put( "keyStoreType", KEYSTORE_TYPE );
+ map.put( "wantClientAuth", new Boolean( WANT_CLIENT_AUTH ) );
+ map.put( "needClientAuth", new Boolean( NEED_CLIENT_AUTH ) );
+ map.put( "provider", PROVIDER );
+ map.put( "trustAlgorithm", TRUST_ALGORITHM );
+
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ m_connector = new SslSocketConnector( context );
+ }
+
+ protected AbstractConnector getConnector()
+ {
+ return m_connector;
+ }
+
+ /**
+ * Test min-thread assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testCipherSuites() throws Exception
+ {
+ assertEquals( "cipherSuites", CIPHER_SUITES,
m_connector.getCipherSuites() );
+ }
+
+ /**
+ * Test algorithm assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testAlgorith() throws Exception
+ {
+ assertEquals( "algorith", ALGORITHM, m_connector.getAlgorithm() );
+ }
+
+ /**
+ * Test protocol assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testProtocol() throws Exception
+ {
+ assertEquals( "protocol", PROTOCOL, m_connector.getProtocol() );
+ }
+
+ /**
+ * Test keystore path assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testKeystorePath() throws Exception
+ {
+ assertEquals( "keystore", KEYSTORE_URI.toASCIIString(),
m_connector.getKeystore() );
+ }
+
+ /**
+ * Test keystore type assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testKeystoreType() throws Exception
+ {
+ assertEquals( "keystoreType", KEYSTORE_TYPE,
m_connector.getKeystoreType() );
+ }
+
+ /**
+ * Test want-client-auth policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testWantClientAuthentication() throws Exception
+ {
+ assertEquals( "wantClientAuth", WANT_CLIENT_AUTH,
m_connector.getWantClientAuth() );
+ }
+
+ /**
+ * Test need-client-auth policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testNeedClientAuthentication() throws Exception
+ {
+ assertEquals( "needClientAuth", NEED_CLIENT_AUTH,
m_connector.getNeedClientAuth() );
+ }
+
+ /**
+ * Test provider assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testProvider() throws Exception
+ {
+ assertEquals( "provider", PROVIDER, m_connector.getProvider() );
+ }
+
+ private static URI createKeystoreURI()
+ {
+ try
+ {
+ return new File( ".keystore" ).toURI();
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+}
+




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

Archive powered by MHonArc 2.6.24.

Top of Page