You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2003/05/12 15:26:18 UTC
cvs commit: cocoon-2.1/src/test/org/apache/cocoon/environment/commandline/test CommandLineContextTestCase.java
stephan 2003/05/12 06:26:18
Modified: src/java/org/apache/cocoon/bean CocoonBean.java
src/java/org/apache/cocoon/environment
AbstractEnvironment.java
src/java/org/apache/cocoon/environment/commandline
FileSavingEnvironment.java
LinkSamplingEnvironment.java
src/scratchpad/src/org/apache/cocoon/ant
CocoonProcessorDelegate.java CocoonTask.java
src/test/org/apache/cocoon/components/resolver/test
ResolverImplTestCase.java
src/test/org/apache/cocoon/environment/commandline/test
CommandLineContextTestCase.java
Added: src/java/org/apache/cocoon/environment/commandline
CommandLineContext.java
Removed: src/java/org/apache/cocoon/environment/commandline
CommandlineContext.java
Log:
Update for IteratorEnumeration, since the commons team decided to remove
the deprecated class.
Rename CommandlineContext to CommandLineContext, following the name
convention.
Revision Changes Path
1.4 +4 -4 cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java
Index: CocoonBean.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CocoonBean.java 28 Mar 2003 12:55:42 -0000 1.3
+++ CocoonBean.java 12 May 2003 13:26:17 -0000 1.4
@@ -64,7 +64,7 @@
import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
import org.apache.cocoon.components.notification.Notifying;
import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.commandline.CommandlineContext;
+import org.apache.cocoon.environment.commandline.CommandLineContext;
import org.apache.cocoon.environment.commandline.LinkSamplingEnvironment;
import org.apache.cocoon.environment.commandline.FileSavingEnvironment;
import org.apache.cocoon.bean.destination.Destination;
@@ -132,7 +132,7 @@
private PrintWriter brokenLinkWriter;
// Internal Objects
- private CommandlineContext cliContext;
+ private CommandLineContext cliContext;
private Cocoon cocoon;
private Destination dest;
private static Logger log;
@@ -174,7 +174,7 @@
try {
DefaultContext appContext = new DefaultContext();
appContext.put(Constants.CONTEXT_CLASS_LOADER, Main.class.getClassLoader());
- cliContext = new CommandlineContext(contextDir);
+ cliContext = new CommandLineContext(contextDir);
cliContext.enableLogging(new LogKitLogger(log));
appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, cliContext);
DefaultLogKitManager logKitManager = null;
1.11 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
Index: AbstractEnvironment.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AbstractEnvironment.java 2 May 2003 06:53:10 -0000 1.10
+++ AbstractEnvironment.java 12 May 2003 13:26:17 -0000 1.11
@@ -69,7 +69,7 @@
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.util.BufferedOutputStream;
import org.apache.cocoon.util.ClassUtils;
-import org.apache.commons.collections.IteratorEnumeration;
+import org.apache.commons.collections.iterators.IteratorEnumeration;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.xml.sax.XMLizable;
import org.apache.excalibur.xmlizer.XMLizer;
1.3 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
Index: FileSavingEnvironment.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileSavingEnvironment.java 18 Mar 2003 15:23:49 -0000 1.2
+++ FileSavingEnvironment.java 12 May 2003 13:26:17 -0000 1.3
@@ -76,7 +76,7 @@
Map parameters,
Map links,
List gatheredLinks,
- CommandlineContext cliContext,
+ CommandLineContext cliContext,
OutputStream stream,
Logger log)
throws MalformedURLException {
1.2 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
Index: LinkSamplingEnvironment.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LinkSamplingEnvironment.java 9 Mar 2003 00:09:29 -0000 1.1
+++ LinkSamplingEnvironment.java 12 May 2003 13:26:17 -0000 1.2
@@ -76,7 +76,7 @@
File contextFile,
Map attributes,
Map parameters,
- CommandlineContext cliContext,
+ CommandLineContext cliContext,
Logger log)
throws MalformedURLException, IOException {
super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), log);
1.1 cocoon-2.1/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java
Index: CommandLineContext.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.environment.commandline;
import org.apache.commons.collections.iterators.IteratorEnumeration;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.cocoon.environment.Context;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.HashMap;
import java.io.InputStream;
/**
*
* Implements the {@link org.apache.cocoon.environment.Context} interface
* @author ?
* @version CVS $Id: CommandLineContext.java,v 1.1 2003/05/12 13:26:17 stephan Exp $
*/
public class CommandLineContext extends AbstractLogEnabled implements Context {
/** The context directory path*/
private String contextDir;
/** The context attributes */
private Map attributes;
/**
* Constructs a CommandlineContext object from a ServletContext object
*/
public CommandLineContext (String contextDir) {
String contextDirPath = new File(contextDir).getAbsolutePath();
// store contextDirPath as is don't remove trailing /.
this.contextDir = contextDirPath;
this.attributes = new HashMap();
}
public Object getAttribute(String name) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: getAttribute=" + name);
}
return this.attributes.get(name);
}
public void setAttribute(String name, Object value) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: setAttribute=" + name);
}
this.attributes.put(name, value);
}
public void removeAttribute(String name) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: removeAttribute=" + name);
}
this.attributes.remove(name);
}
public Enumeration getAttributeNames() {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: getAttributeNames");
}
return new IteratorEnumeration(this.attributes.keySet().iterator());
}
public URL getResource(String path) throws MalformedURLException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: getResource=" + path);
}
// rely on File to build correct File and URL
File f = new File( contextDir, path );
return f.toURL();
}
public String getRealPath(String path) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: getRealPath=" + path);
}
// rely on File to build correct File and URL
File f = new File( this.contextDir, path );
return f.getAbsolutePath();
}
public String getMimeType(String file) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("CommandlineContext: getMimeType=" + file);
}
//return servletContext.getMimeType(file);
return null;
}
public String getInitParameter(String name) {
getLogger().debug("CommandlineContext: getInitParameter=" + name);
return null;
}
public InputStream getResourceAsStream(String path){
getLogger().debug("CommandlineContext: getResourceAsStream "+path);
return null;
}
}
1.4 +4 -4 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/ant/CocoonProcessorDelegate.java
Index: CocoonProcessorDelegate.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/ant/CocoonProcessorDelegate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CocoonProcessorDelegate.java 24 Mar 2003 14:33:57 -0000 1.3
+++ CocoonProcessorDelegate.java 12 May 2003 13:26:17 -0000 1.4
@@ -70,7 +70,7 @@
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.environment.commandline.CommandlineContext;
+import org.apache.cocoon.environment.commandline.CommandLineContext;
import org.apache.cocoon.environment.commandline.LinkSamplingEnvironment;
/**
@@ -86,7 +86,7 @@
private org.apache.avalon.framework.context.Context context;
- private CommandlineContext clContext;
+ private CommandLineContext clContext;
private File contextDir;
private File destDir;
@@ -142,7 +142,7 @@
* @exception Exception Description of Exception
*/
public void initialize() throws Exception {
- clContext = (CommandlineContext) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+ clContext = (CommandLineContext) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
contextDir = new File(clContext.getRealPath("/"));
destDir = (File) this.context.get("dest-dir");
1.3 +3 -3 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/ant/CocoonTask.java
Index: CocoonTask.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/ant/CocoonTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CocoonTask.java 16 Mar 2003 18:03:54 -0000 1.2
+++ CocoonTask.java 12 May 2003 13:26:17 -0000 1.3
@@ -75,7 +75,7 @@
import org.apache.cocoon.Cocoon;
import org.apache.cocoon.Constants;
-import org.apache.cocoon.environment.commandline.CommandlineContext;
+import org.apache.cocoon.environment.commandline.CommandLineContext;
import org.apache.cocoon.util.IOUtils;
import org.apache.tools.ant.AntClassLoader;
@@ -606,7 +606,7 @@
File contextDir = (File) this.ctx.get("context-root");
File workDir = (File) this.ctx.get(Constants.CONTEXT_WORK_DIR);
- CommandlineContext clContext = new CommandlineContext(contextDir.toString());
+ CommandLineContext clContext = new CommandLineContext(contextDir.toString());
clContext.enableLogging(getLogger());
this.ctx.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, clContext);
this.ctx.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir));
1.4 +3 -3 cocoon-2.1/src/test/org/apache/cocoon/components/resolver/test/ResolverImplTestCase.java
Index: ResolverImplTestCase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/test/org/apache/cocoon/components/resolver/test/ResolverImplTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResolverImplTestCase.java 18 Mar 2003 01:01:26 -0000 1.3
+++ ResolverImplTestCase.java 12 May 2003 13:26:17 -0000 1.4
@@ -62,7 +62,7 @@
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.cocoon.Constants;
import org.apache.cocoon.components.resolver.ResolverImpl;
-import org.apache.cocoon.environment.commandline.CommandlineContext;
+import org.apache.cocoon.environment.commandline.CommandLineContext;
import org.apache.cocoon.util.IOUtils;
import org.apache.excalibur.xml.EntityResolver;
import org.xml.sax.InputSource;
@@ -438,7 +438,7 @@
context.put(Constants.CONTEXT_WORK_DIR, workDir);
- CommandlineContext commandline_context = new CommandlineContext(commandlineContextDir.toString());
+ CommandLineContext commandline_context = new CommandLineContext(commandlineContextDir.toString());
commandline_context.enableLogging(getLogEnabledLogger());
context.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, commandline_context);
}
1.4 +18 -18 cocoon-2.1/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
Index: CommandLineContextTestCase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CommandLineContextTestCase.java 16 Mar 2003 18:03:56 -0000 1.3
+++ CommandLineContextTestCase.java 12 May 2003 13:26:18 -0000 1.4
@@ -56,7 +56,7 @@
import junit.swingui.TestRunner;
import org.apache.avalon.framework.logger.ConsoleLogger;
-import org.apache.cocoon.environment.commandline.CommandlineContext;
+import org.apache.cocoon.environment.commandline.CommandLineContext;
import org.apache.log.Priority;
/**
@@ -83,8 +83,8 @@
*/
protected Priority m_logPriority = Priority.INFO;
- private String commandlineContextDir;
- private CommandlineContext commandlineContext;
+ private String commandLineContextDir;
+ private CommandLineContext commandLineContext;
/**
@@ -129,9 +129,9 @@
* @since
*/
public void setUp() throws Exception {
- commandlineContextDir = System.getProperty("java.io.tmpdir", "/tmp");
- commandlineContext = new CommandlineContext(commandlineContextDir);
- commandlineContext.enableLogging( new ConsoleLogger() );
+ commandLineContextDir = System.getProperty("java.io.tmpdir", "/tmp");
+ commandLineContext = new CommandLineContext(commandLineContextDir);
+ commandLineContext.enableLogging( new ConsoleLogger() );
}
@@ -153,10 +153,10 @@
public void testGetResource() throws Exception {
Object[] test_values = {
- new String[]{"", commandlineContextDir},
- new String[]{"/", commandlineContextDir},
- new String[]{"foo", commandlineContextDir + File.separator + "foo"},
- new String[]{"foo/bar", commandlineContextDir + File.separator + "foo/bar"}
+ new String[]{"", commandLineContextDir},
+ new String[]{"/", commandLineContextDir},
+ new String[]{"foo", commandLineContextDir + File.separator + "foo"},
+ new String[]{"foo/bar", commandLineContextDir + File.separator + "foo/bar"}
};
for (int i = 0; i < test_values.length; i++) {
String tests[] = (String[]) test_values[i];
@@ -164,7 +164,7 @@
File expected_file = new File(tests[1]);
URL expected = expected_file.toURL();
- URL result = commandlineContext.getResource(test);
+ URL result = commandLineContext.getResource(test);
String message = "Test " +
"'" + test + "'";
assertEquals(message, expected, result);
@@ -189,10 +189,10 @@
for (int i = 0; i < test_values.length; i++) {
String tests[] = (String[]) test_values[i];
String test = tests[0];
- File expected_file = new File(commandlineContextDir, tests[1]);
+ File expected_file = new File(commandLineContextDir, tests[1]);
String expected = expected_file.getAbsolutePath();
- String result = commandlineContext.getRealPath(test);
+ String result = commandLineContext.getRealPath(test);
String message = "Test " +
"'" + test + "'";
assertEquals(message, expected, result);
@@ -223,13 +223,13 @@
"'" + name + "'" + ", " + "'" + expected + "'";
*/
- commandlineContext.setAttribute(name, expected);
+ commandLineContext.setAttribute(name, expected);
- String result = (String) commandlineContext.getAttribute(name);
+ String result = (String) commandLineContext.getAttribute(name);
assertEquals("Test " + "'" + "n" + "'", expected, result);
- commandlineContext.removeAttribute(name);
- result = (String) commandlineContext.getAttribute(name);
+ commandLineContext.removeAttribute(name);
+ result = (String) commandLineContext.getAttribute(name);
assertEquals("Test " + "'" + "<null>" + "'", null, result);
}
}