You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2002/05/23 17:54:52 UTC
cvs commit: jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor GetXMLAssert.java XMLStreamResponseBodyAssert.java StreamResponseBodyAssert.java TProcessors.java
juergen 02/05/23 08:54:52
Modified: testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor
StreamResponseBodyAssert.java TProcessors.java
Added: testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor
GetXMLAssert.java XMLStreamResponseBodyAssert.java
Log:
XML files (with the XML extension) are not binary compared but rather normalised as utf-8.
Revision Changes Path
1.6 +5 -5 jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/StreamResponseBodyAssert.java
Index: StreamResponseBodyAssert.java
===================================================================
RCS file: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/StreamResponseBodyAssert.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamResponseBodyAssert.java 25 Apr 2002 21:15:13 -0000 1.5
+++ StreamResponseBodyAssert.java 23 May 2002 15:54:52 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/StreamResponseBodyAssert.java,v 1.5 2002/04/25 21:15:13 jericho Exp $
- * $Revision: 1.5 $
- * $Date: 2002/04/25 21:15:13 $
+ * $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/StreamResponseBodyAssert.java,v 1.6 2002/05/23 15:54:52 juergen Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/05/23 15:54:52 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* Abstract root class to perform the necessary checks for the received and expected stream body
*
* @author Software AG
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public abstract class StreamResponseBodyAssert extends ResponseBodyAssert{
@@ -135,7 +135,7 @@
/**
* checks if Expected and the received Response bodies are identical
*/
- private boolean compareStreams(InputStream receivedBody, InputStream expectedBody){
+ protected boolean compareStreams(InputStream receivedBody, InputStream expectedBody){
String contentValueProblem = null;
byte[] receivedBuffer = new byte[1];
byte[] expectedBuffer = new byte[1];
1.22 +9 -5 jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java
Index: TProcessors.java
===================================================================
RCS file: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TProcessors.java 21 May 2002 09:01:30 -0000 1.21
+++ TProcessors.java 23 May 2002 15:54:52 -0000 1.22
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java,v 1.21 2002/05/21 09:01:30 juergen Exp $
- * $Revision: 1.21 $
- * $Date: 2002/05/21 09:01:30 $
+ * $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java,v 1.22 2002/05/23 15:54:52 juergen Exp $
+ * $Revision: 1.22 $
+ * $Date: 2002/05/23 15:54:52 $
*
* ====================================================================
*
@@ -84,7 +84,7 @@
* Main class to performe a test case and check and report the results
*
* @author Software AG
- * @version $Revision: 1.21 $
+ * @version $Revision: 1.22 $
*/
public class TProcessors {
@@ -1299,7 +1299,11 @@
} else if (m instanceof VersionControlMethod){
result = new VersionControlAssert ((XMLResponseMethodBase) m, expectedResponseAsDOM(expectedResponse), xdavConfiguration, xmlresult);
} else if (m instanceof GetMethod){
- result = new GetAssert ( m, expectedResponseAsStream(expectedResponse), xdavConfiguration, xmlresult);
+ if (!m.getHeader("Content-Type").getValue().equals("text/xml")) {
+ result = new GetAssert ( m, expectedResponseAsStream(expectedResponse), xdavConfiguration, xmlresult);
+ } else {
+ result = new GetXMLAssert ( m, expectedResponseAsStream(expectedResponse), xdavConfiguration, xmlresult);
+ }
}
return result;
}
1.1 jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/GetXMLAssert.java
Index: GetXMLAssert.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/GetXMLAssert.java,v 1.1 2002/05/23 15:54:52 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/23 15:54:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 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", "Slide", 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 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.slide.testsuite.testtools.tprocessor;
// Slide
import org.apache.commons.httpclient.HttpMethod;
// java
import java.io.*;
import java.util.*;
//test package
import org.apache.slide.testsuite.testtools.tutil.*;
/**
* Perform the necessary checks for the received and expected Get body
*
* @author Software AG
* @version $Revision: 1.1 $
*/
public class GetXMLAssert extends XMLStreamResponseBodyAssert {
/** constructer
* @param WebdavMethodBase Element
*/
public GetXMLAssert(HttpMethod method, InputStream expectedBody, XConf xconf, XMLOutput xmlresult){
super(method, expectedBody, xconf, xmlresult);
}
/**
* checks if Expected Response and Response are same
*/
public boolean assert(){
if (method.getStatusCode() == 204 ||
method.getStatusCode() == 403 ||
method.getStatusCode() == 409 ||
method.getStatusCode() == 423 ||
method.getStatusCode() == 201 ||
method.getStatusCode() == 412 ){
return true;
}
return super.assert();
}
}
1.1 jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/XMLStreamResponseBodyAssert.java
Index: XMLStreamResponseBodyAssert.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/XMLStreamResponseBodyAssert.java,v 1.1 2002/05/23 15:54:52 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/05/23 15:54:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 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", "Slide", 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 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.slide.testsuite.testtools.tprocessor;
//java
import java.io.*;
import java.util.*;
// Slide
import org.apache.webdav.lib.methods.*;
import org.apache.commons.httpclient.*;
// JDOM
import org.jdom.input.*;
import org.jdom.output.*;
//test package
import org.apache.slide.testsuite.testtools.tutil.*;
/**
* Abstract root class to perform the necessary checks for the received and expected stream body
*
* @author Software AG
* @version $Revision: 1.1 $
*/
public abstract class XMLStreamResponseBodyAssert extends StreamResponseBodyAssert {
private final static boolean extendedPrintlnsrequested = false;
/** constructer
* @param WebdavMethodBase Element
*/
public XMLStreamResponseBodyAssert(HttpMethod method, InputStream expectedBody, XConf xconf, XMLOutput xmlresult){
super(method, expectedBody, xconf, xmlresult);
}
/**
* checks if Expected and the received Response bodies are identical
*/
protected boolean compareStreams(InputStream receivedBody, InputStream expectedBody){
String received = null;
String expected = null;
try
{
received = new XMLOutputter("", false, "UTF-8").outputString(new SAXBuilder().build(receivedBody));
expected = new XMLOutputter("", false, "UTF-8").outputString(new SAXBuilder().build(expectedBody));
System.out.println("#########################");
System.out.println("#########################");
System.out.println(received);
System.out.println("#########################");
System.out.println(expected);
System.out.println("#########################");
System.out.println("#########################");
}
catch (Exception e) {
e.printStackTrace();
xmlresult.writeException(e);
}
return super.compareStreams(new StringBufferInputStream(received),
new StringBufferInputStream(expected));
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>