Return-Path:
Mailing-List: contact turbine-torque-dev-help@jakarta.apache.org; run by ezmlm
Delivered-To: mailing list turbine-torque-dev@jakarta.apache.org
Received: (qmail 12227 invoked by uid 97); 14 Dec 2002 15:35:09 -0000
Received: (qmail 12222 invoked by uid 98); 14 Dec 2002 15:35:09 -0000
X-Antivirus: nagoya (v4218 created Aug 14 2002)
Received: (qmail 12203 invoked from network); 14 Dec 2002 15:35:07 -0000
Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142)
by nagoya.betaversion.org with SMTP; 14 Dec 2002 15:35:07 -0000
Received: (qmail 59595 invoked by uid 500); 14 Dec 2002 15:33:56 -0000
Received: (qmail 59584 invoked from network); 14 Dec 2002 15:33:55 -0000
Received: from icarus.apache.org (63.251.56.143)
by daedalus.apache.org with SMTP; 14 Dec 2002 15:33:55 -0000
Received: (qmail 35096 invoked by uid 1280); 14 Dec 2002 15:33:55 -0000
Date: 14 Dec 2002 15:33:55 -0000
Message-ID: <20021214153355.35095.qmail@icarus.apache.org>
From: mpoeschl@apache.org
To: jakarta-turbine-torque-cvs@apache.org
Subject: cvs commit: jakarta-turbine-torque/xdocs changes.xml
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
mpoeschl 2002/12/14 07:33:55
Modified: . build-test.xml
xdocs changes.xml
Added: src/rttest/org/apache/torque/engine/database/transform
SQLToAppDataTest.java
src/rttest schema.sql.ref.xml schema.sql
Log:
o TRQS95: Junit tests for sql2xml task (SQLToAppDataTest)
o create junit report for runtime tests in target/test-reports
if you update the site you should run the runtimetests first
(i will change the setup to run the truntimetests by default using axion sometimes ;-)
Revision Changes Path
1.40 +14 -2 jakarta-turbine-torque/build-test.xml
Index: build-test.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/build-test.xml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- build-test.xml 28 Nov 2002 21:25:06 -0000 1.39
+++ build-test.xml 14 Dec 2002 15:33:54 -0000 1.40
@@ -44,6 +44,17 @@
+
+
+
+
+
+
+
+
@@ -308,15 +319,16 @@
/>
-
+
+
-
+
1.1 jakarta-turbine-torque/src/rttest/org/apache/torque/engine/database/transform/SQLToAppDataTest.java
Index: SQLToAppDataTest.java
===================================================================
package org.apache.torque.engine.database.transform;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 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" and "Apache Software Foundation" and
* "Apache Turbine" 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",
* "Apache Turbine", 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 (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
* .
*/
import java.io.*;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.torque.BaseTestCase;
import org.apache.torque.engine.database.model.AppData;
import org.apache.torque.engine.sql.ParseException;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* @author Andreas Andreou
* @version $Id: SQLToAppDataTest.java,v 1.1 2002/12/14 15:33:54 mpoeschl Exp $
*/
public class SQLToAppDataTest extends BaseTestCase
{
/** The path to the configuration file. */
private static final String SQL_FOLDER = "target/test/rttest/sql";
private Vector files;
/**
* Creates a new instance.
*/
public SQLToAppDataTest(String name)
{
super(name);
}
public void setUp()
{
// this may not be needed
//super.setUp();
// init the vector
files = new Vector();
// find all sql files to test
File sqlFolder = new File(SQL_FOLDER);
if (sqlFolder != null && sqlFolder.isDirectory())
{
File allFiles[] = sqlFolder.listFiles();
for (int i = 0; i < allFiles.length; i++)
{
File thisFile = allFiles[i];
if (!thisFile.isDirectory() &&
thisFile.getName().toUpperCase().endsWith("SQL"))
{
System.out.println("Adding file:" + thisFile.getName());
files.add(thisFile);
}
}
}
if (files.size() == 0)
{
System.out.println("No files where found to test the sql2xml task");
}
}
public void testConvertToXml()
{
try
{
for (int i = 0; i < files.size(); i++)
{
File file = (File) files.elementAt(i);
String filename = file.getAbsolutePath();
// load the sql file
SQLToAppData s2a = new SQLToAppData(filename);
AppData ad = s2a.execute();
// write the output to a new xml file
String xmlFilename = filename + ".xml";
PrintWriter out = new PrintWriter(
new FileOutputStream(xmlFilename, false),true);
out.println(ad);
out.close();
// compare result
compareXmlFiles(filename + ".ref.xml", xmlFilename);
}
}
catch (IOException expIo)
{
expIo.printStackTrace(System.out);
}
catch (ParseException expParse)
{
expParse.printStackTrace(System.out);
}
}
private void renameDTD(String sFile)
{
try
{
BufferedReader reader = new BufferedReader(new FileReader(sFile));
String line;
StringBuffer sb = new StringBuffer(5000);
while ((line=reader.readLine())!=null)
{
sb.append(line).append("\n");
}
reader.close();
String data=sb.toString();
if (data == null || data.length() == 0)
return;
int index=data.indexOf("", index);
if (index2 != -1)
{
data = data.substring(0, index - 1)
+ data.substring(index2 + 1);
}
}
//data.replaceFirst("/database.dtd","/database.xxx");
BufferedWriter writer = new BufferedWriter(
new FileWriter(sFile, false));
writer.write(data);
writer.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
private void compareXmlFiles(String refFile, String newFile)
{
System.out.println("Comparing " + newFile + " against " + refFile);
//System.out.println("Rename DTD to disable checking for default values...");
// The dom parser uses the DTD to add default values to the xml nodes.
// This makes difficult comparing the xml files.
// Since I couldn't find any way to disable this behavior,
// I chose to delete the DTD declaration from the xml files.
renameDTD(refFile);
renameDTD(newFile);
try
{
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setExpandEntityReferences(false);
docFactory.setValidating(false);
DocumentBuilder doc = docFactory.newDocumentBuilder();
Document refDoc = doc.parse(new File(refFile));
Document newDoc = doc.parse(new File(newFile));
NodeList refList = refDoc.getElementsByTagName("database");
NodeList newList = newDoc.getElementsByTagName("database");
assertNotNull(refList);
assertNotNull(newList);
for (int i = 0; i < refList.getLength(); i++)
{
Node refNode = refList.item(i);
Node newNode = newList.item(i);
checkNodes(refNode, newNode);
refNode = refNode.getFirstChild();
newNode = newNode.getFirstChild();
}
}
catch (ParserConfigurationException e)
{
e.printStackTrace(System.out);
}
catch (FactoryConfigurationError factoryConfigurationError)
{
factoryConfigurationError.printStackTrace(System.out);
}
catch (SAXException e)
{
e.printStackTrace(System.out);
}
catch (IOException e)
{
e.printStackTrace(System.out);
}
}
private void checkNodes(Node refNodeStart, Node newNodeStart)
{
Node refNode = refNodeStart;
Node newNode = newNodeStart;
while (refNode != null)
{
assertNotNull(newNode);
if (refNode.getNodeType() != Node.TEXT_NODE)
{
// check matching names
System.out.println(refNode.getNodeName() + " : "
+ newNode.getNodeName());
assertEquals(refNode.getNodeName(), newNode.getNodeName());
// check matching attributes
NamedNodeMap refNnm = refNode.getAttributes();
NamedNodeMap newNnm = newNode.getAttributes();
for (int j = 0; j < refNnm.getLength(); j++)
{
Node refItem = refNnm.item(j);
String refName = refItem.getNodeName();
Node newItem = newNnm.getNamedItem(refName);
// check existance
assertNotNull(newItem);
// check matching value
System.out.println(" " + refName + " : "
+ refItem.getNodeValue()+" -> "
+ newItem.getNodeValue());
assertEquals(refItem.getNodeValue(), newItem.getNodeValue());
}
}
Node refChild = refNode.getFirstChild();
Node newChild = newNode.getFirstChild();
if (refChild != null)
{
assertNotNull(newChild);
checkNodes(refChild, newChild);
}
// check matching siblings
refNode = refNode.getNextSibling();
newNode = newNode.getNextSibling();
}
}
// just for internal test
public static void main(String args[])
{
SQLToAppDataTest test = new SQLToAppDataTest("inner test");
//test.compareXmlFiles("c:/schema.sql.xml", "c:/schema.sql.xml.new");
test.compareXmlFiles(
"C:/java/projects/jakarta-turbine-torque/jakarta-turbine-torque/target/test/rttest/sql/schema.sql.ref.xml",
"C:/java/projects/jakarta-turbine-torque/jakarta-turbine-torque/target/test/rttest/sql/schema.sql.xml");
}
}
1.1 jakarta-turbine-torque/src/rttest/schema.sql.ref.xml
Index: schema.sql.ref.xml
===================================================================
1.1 jakarta-turbine-torque/src/rttest/schema.sql
Index: schema.sql
===================================================================
CREATE TABLE jiveForum (
forumID INT NOT NULL,
name VARCHAR(255),
description TEXT,
modifiedDate VARCHAR(15),
creationDate VARCHAR(15),
moderated INT default 2 NOT NULL,
PRIMARY KEY (forumID)
);
1.57 +3 -0 jakarta-turbine-torque/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/xdocs/changes.xml,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- changes.xml 10 Dec 2002 20:49:00 -0000 1.56
+++ changes.xml 14 Dec 2002 15:33:55 -0000 1.57
@@ -19,6 +19,8 @@
-
+ Removed all deprecated stuff from the java code. Make sure to not get
+ any deprecation warnings before you switch to 3.1!
@@ -28,6 +30,7 @@
-
+ TRQS95: Junit tests for sql2xml task (SQLToAppDataTest)