morgand 01/08/24 11:55:23
Modified: latka/resource latka.properties.internal
latka/src/java/org/apache/commons/latka Latka.java
Added: latka/src/java/org/apache/commons/latka LatkaException.java
Log:
some cleanup and logging configuration
Revision Changes Path
1.9 +1 -0 jakarta-commons/latka/resource/latka.properties.internal
Index: latka.properties.internal
===================================================================
RCS file: /home/cvs/jakarta-commons/latka/resource/latka.properties.internal,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- latka.properties.internal 2001/08/23 20:26:59 1.8
+++ latka.properties.internal 2001/08/24 18:55:23 1.9
@@ -6,4 +6,5 @@
latka.validator.responseHeader=org.apache.commons.latka.validators.ResponseHeaderHandler
latka.validator.goldenFile=org.apache.commons.latka.validators.GoldenFileHandler
+latka.writeLog=true
1.10 +27 -13
jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java
Index: Latka.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Latka.java 2001/08/23 19:57:48 1.9
+++ Latka.java 2001/08/24 18:55:23 1.10
@@ -113,6 +113,8 @@
protected static Category log =
Category.getInstance(Latka.class.getName());
+ protected Properties _props = LatkaProperties.getProperties();
+
public static String LATKA_USAGE = null;
static {
StringBuffer buf = new StringBuffer();
@@ -125,7 +127,7 @@
LATKA_USAGE = buf.toString();
}
- public void runTests(Suite suite) {
+ public void runTests(Suite suite) throws LatkaException {
InputSource source = null;
@@ -186,7 +188,6 @@
String xmlDocument = writer.toString();
- //log the xml
try {
logXML(xmlDocument);
} catch (IOException e) {
@@ -209,12 +210,17 @@
}
if (failed == true) {
- System.exit(1);
+ throw new LatkaException("SUITE FAILED");
}
}
protected void logXML(String xml) throws IOException {
+ String logProp = _props.getProperty("latka.writeLog");
+ if ((logProp != null) && (logProp.equals("false"))) {
+ return;
+ }
+
File dir = new File("logs");
dir.mkdirs();
SimpleDateFormat formatter
@@ -240,29 +246,25 @@
transformer.transform(xmlSource,result);
}
- public static void main (String args[]) {
-
+ protected void runCommandLine(String args[]) throws LatkaException {
+
if (args.length < 1) {
System.out.println(LATKA_USAGE);
}
-
- Latka latka = new Latka();
-
+
String uri = args[0];
if (args.length > 1) {
- Properties props = LatkaProperties.getProperties();
-
for (int i = 1; i < args.length; ++i) {
String arg = args[i];
if (arg.startsWith("prop:")) {
String propName = arg.substring(5,arg.indexOf("="));
String propValue = arg.substring(arg.indexOf("=")+1);
- props.setProperty(propName,propValue);
+ _props.setProperty(propName,propValue);
} else if (arg.startsWith("propfile:")) {
try {
- props.load(new FileInputStream(arg.substring(9)));
+ _props.load(new FileInputStream(arg.substring(9)));
} catch (IOException e) {
System.out.println("Could not load user prop file, uri=" +
arg.substring(9));
}
@@ -274,7 +276,19 @@
}
Suite suite = new Suite(uri);
- latka.runTests(suite);
+ runTests(suite);
+ }
+
+ public static void main (String args[]) {
+
+ Latka latka = new Latka();
+ try {
+ latka.runCommandLine(args);
+ } catch (LatkaException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
}
1.1
jakarta-commons/latka/src/java/org/apache/commons/latka/LatkaException.java
Index: LatkaException.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", 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 [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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 (INCLUDING, 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. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.commons.latka;
public class LatkaException extends Exception {
public LatkaException(String message) {
super(message);
}
}