vgritsenko 2003/12/23 04:13:41
Modified: java/tests/src/org/apache/xindice IntegrationEmbedTests.java
java/tests/src/org/apache/xindice/integration
IntegrationTests.java
Added: java/tests/src/org/apache/xindice/integration/client/resources
BinaryResourceTest.java
Log:
Adding BinaryResource integration test (fails, inline meta data is disabled
ATM)
Revision Changes Path
1.6 +2 -3
xml-xindice/java/tests/src/org/apache/xindice/IntegrationEmbedTests.java
Index: IntegrationEmbedTests.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/IntegrationEmbedTests.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- IntegrationEmbedTests.java 7 Aug 2003 20:13:26 -0000 1.5
+++ IntegrationEmbedTests.java 23 Dec 2003 12:13:40 -0000 1.6
@@ -99,5 +99,4 @@
}
};
}
-
}
1.7 +5 -4
xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java
Index: IntegrationTests.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IntegrationTests.java 22 Dec 2003 13:58:17 -0000 1.6
+++ IntegrationTests.java 23 Dec 2003 12:13:40 -0000 1.7
@@ -66,6 +66,7 @@
import org.apache.xindice.integration.client.services.XPathQueryTest;
import org.apache.xindice.integration.client.services.XUpdateQueryTest;
import org.apache.xindice.integration.client.services.MetaTest;
+import org.apache.xindice.integration.client.resources.BinaryResourceTest;
import junit.framework.TestSuite;
@@ -83,8 +84,8 @@
suite.addTestSuite(XUpdateQueryTest.class);
suite.addTestSuite(XPathQueryTest.class);
suite.addTestSuite(MetaTest.class);
- suite.addTestSuite(IndexedSearchTest.class);
- // TODO: Binary resource test
+ suite.addTestSuite(IndexedSearchTest.class);
+ suite.addTestSuite(BinaryResourceTest.class);
return suite;
}
}
1.1
xml-xindice/java/tests/src/org/apache/xindice/integration/client/resources/BinaryResourceTest.java
Index: BinaryResourceTest.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 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 "Xindice" 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 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 and was
* originally based on software copyright (c) 1999-2001, The dbXML
* Group, L.L.C., http://www.dbxmlgroup.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* CVS $Id: BinaryResourceTest.java,v 1.1 2003/12/23 12:13:41 vgritsenko Exp $
*/
package org.apache.xindice.integration.client.resources;
import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Resource;
import org.xmldb.api.modules.BinaryResource;
/**
*/
public class BinaryResourceTest extends AbstractXmlDbClientTest {
public void testRoundTrip() throws Exception {
Collection collection =
client.getCollection(TEST_COLLECTION_PATH);
if (collection == null) {
throw new Exception("getCollection(" +
TEST_COLLECTION_PATH + ") returned null");
}
/*
* Create a binary resource, save it in the 'current'
collection,
* then retrieve it and verify that the data comes back right.
*/
Resource newResource = collection.createResource(null,
"BinaryResource");
newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
collection.storeResource(newResource);
String id = newResource.getId();
Resource foundResource = collection.getResource(id);
assertNotNull("We know you're in there...", foundResource);
assertEquals("The resource type is supposed be
'BinaryResource'", "BinaryResource", foundResource.getResourceType());
assertTrue("The resource is an instance of BinaryResource",
foundResource instanceof BinaryResource);
byte[] newBytes = (byte[]) newResource.getContent();
byte[] foundBytes = (byte[]) foundResource.getContent();
assertEquals("The size of the found and saved resource should
be the same...", newBytes.length, foundBytes.length);
for (int i = 0; i < newBytes.length; ++i) {
assertEquals("The resources differ in byte " + i,
newBytes[i], foundBytes[i]);
}
}
public void testList() throws Exception {
Collection collection = client.getCollection(TEST_COLLECTION_PATH);
if (collection == null) {
throw new Exception("getCollection(" + TEST_COLLECTION_PATH + ")
returned null");
}
//
// Create a binary resource, save it in the 'current' collection,
// then list resources.
//
Resource newResource = collection.createResource(null,
"BinaryResource");
newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
collection.storeResource(newResource);
String id = newResource.getId();
String[] resources = collection.listResources();
assertNotNull("Can not be null", resources);
assertEquals("Should have one resource", 1, resources.length);
assertEquals("Resource ID should match", id, resources[0]);
collection.removeResource(newResource);
}
public void testRemove() throws Exception {
Collection collection =
client.getCollection(TEST_COLLECTION_PATH);
if (collection == null) {
throw new Exception("getCollection(" +
TEST_COLLECTION_PATH + ") returned null");
}
/*
* Create a binary resource, save it in the 'current'
collection,
* then remove it and verify that it was indeed removed.
*/
Resource newResource = collection.createResource(null,
"BinaryResource");
newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
collection.storeResource(newResource);
String id = newResource.getId();
Resource foundResource = collection.getResource(id);
assertNotNull("It should be in there", foundResource);
collection.removeResource(foundResource);
foundResource = collection.getResource(id);
assertNull("It should not be in there anymore", foundResource);
}
}