notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1400 - in trunk/main/planet/http/impl/src: main/net/dpml/http test/net/dpml/http
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1400 - in trunk/main/planet/http/impl/src: main/net/dpml/http test/net/dpml/http
- Date: Mon, 24 Apr 2006 13:38:05 +0200
Author: mcconnell
Date: 2006-04-24 13:38:02 +0200 (Mon, 24 Apr 2006)
New Revision: 1400
Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/NCSARequestLogTestCase.java
Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
Log:
add NCSA request log testcase (and fix bug identified after testcase addition)
Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
2006-04-24 10:33:01 UTC (rev 1399)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
2006-04-24 11:38:02 UTC (rev 1400)
@@ -62,8 +62,9 @@
/**
* Return the log filename.
- * @param value the default filename value
- * @return the resolved filename value
+ * @param value the default filename value (may include symbolic
+ * references to system properties)
+ * @return the resolved filename
*/
String getFilename( String value );
@@ -97,12 +98,11 @@
boolean getLogLatency( boolean flag );
/**
- * Get the preference policy concerning address registration.
- * @param flag the proxy preferred policy - if tue the proxy
- * address will be used in preference to the request header address
- * @return the resulted proxy preferred policy
+ * Get the log cookies policy.
+ * @param flag the default policy
+ * @return the resolved policy
*/
- boolean getUseProxyPreference( boolean flag );
+ boolean getLogCookies( boolean flag );
}
/**
@@ -126,7 +126,10 @@
filename = PropertyResolver.resolve( System.getProperties(),
filename );
File file = new File( filename );
File parent = file.getParentFile();
- parent.mkdirs();
+ if( null != parent )
+ {
+ parent.mkdirs();
+ }
setFilename( filename );
}
@@ -157,7 +160,7 @@
boolean recordLatencyPolicy = context.getLogLatency( false );
setLogLatency( recordLatencyPolicy );
- boolean useProxyAddressPolicy = context.getUseProxyPreference( false
);
- setPreferProxiedForAddress( useProxyAddressPolicy );
+ boolean cookiesPolicy = context.getLogCookies( false );
+ setLogCookies( cookiesPolicy );
}
}
Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/NCSARequestLogTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/NCSARequestLogTestCase.java
2006-04-24 10:33:01 UTC (rev 1399)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/NCSARequestLogTestCase.java
2006-04-24 11:38:02 UTC (rev 1400)
@@ -0,0 +1,153 @@
+/*
+ * 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.NCSARequestLog.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import junit.framework.TestCase;
+
+/**
+ * NCSARequestLog test case.
+ */
+public class NCSARequestLogTestCase extends TestCase
+{
+ private static final String[] IGNORE_PATHS = new String[]{"abc","def"};
+ private static final boolean APPEND_POLICY = true;
+ private static final boolean EXTENDED_POLICY = true;
+ private static final boolean PROXY_PREFERRED_POLICY = true;
+ private static final String FILENAME = "foo.log";
+ private static final String LOG_DATE_FORMAT = "dd/mmm/yyyy:HH:mm:ss ZZZ";
+ private static final String LOG_TIME_ZONE = "PST";
+ private static final int RETAIN_DAYS = 70;
+ private static final boolean LATENCY_POLICY = true;
+ private static final boolean COOKIE_POLICY = true;
+
+ private NCSARequestLog m_logger;
+
+ /**
+ * Setup the NCSARequestLog.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ Map map = new Hashtable();
+ map.put( "ignorePaths", IGNORE_PATHS );
+ map.put( "append", new Boolean( APPEND_POLICY ) );
+ map.put( "extended", new Boolean( EXTENDED_POLICY ) );
+ map.put( "preferProxiedForAddress", new Boolean(
PROXY_PREFERRED_POLICY ) );
+ map.put( "filename", FILENAME );
+ map.put( "logDateFormat", LOG_DATE_FORMAT );
+ map.put( "logTimeZone", LOG_TIME_ZONE );
+ map.put( "retainDays", new Integer( 70 ) );
+ map.put( "logLatency", new Boolean( LATENCY_POLICY ) );
+ map.put( "logCookies", new Boolean( COOKIE_POLICY ) );
+
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ m_logger = new NCSARequestLog( context );
+ }
+
+
+ /**
+ * Test ignore-paths assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testIgnorePaths() throws Exception
+ {
+ assertEquals( "ignorePaths", IGNORE_PATHS, m_logger.getIgnorePaths()
);
+ }
+
+ /**
+ * Test append policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testAppendPolicy() throws Exception
+ {
+ assertEquals( "append", APPEND_POLICY, m_logger.isAppend() );
+ }
+
+ /**
+ * Test extended policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testExtendedPolicy() throws Exception
+ {
+ assertEquals( "extended", EXTENDED_POLICY, m_logger.isExtended() );
+ }
+
+ /**
+ * Test filename assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testFilename() throws Exception
+ {
+ assertEquals( "filename", FILENAME, m_logger.getFilename() );
+ }
+
+ /**
+ * Test the log date format assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testLogDateFormat() throws Exception
+ {
+ assertEquals( "logDateFormat", LOG_DATE_FORMAT,
m_logger.getLogDateFormat() );
+ }
+
+ /**
+ * Test the log time zone assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testLogTimeZone() throws Exception
+ {
+ assertEquals( "logTimeZone", LOG_TIME_ZONE,
m_logger.getLogTimeZone() );
+ }
+
+ /**
+ * Test the retain days assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testRetainDays() throws Exception
+ {
+ assertEquals( "retainDays", RETAIN_DAYS, m_logger.getRetainDays() );
+ }
+
+ /**
+ * Test the latency policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testLatencyPolicy() throws Exception
+ {
+ assertEquals( "latencyPolicy", LATENCY_POLICY,
m_logger.getLogLatency() );
+ }
+
+ /**
+ * Test the cookies policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testLogCookiesPolicy() throws Exception
+ {
+ assertEquals( "cookiesPolicy", COOKIE_POLICY,
m_logger.getLogCookies() );
+ }
+}
+
- r1400 - 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.