You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vl...@apache.org on 2002/11/28 09:12:26 UTC
cvs commit: xml-xindice/java/tests/src/org/apache/xindice/integration/client/services XUpdateQueryTest.java
vladimir 2002/11/28 00:12:26
Modified: java/tests/src/org/apache/xindice IntegrationEmbedTests.java
IntegrationXmlRpcTests.java UnitTests.java
java/tests/src/org/apache/xindice/integration/client
XmlDbClientSetup.java
Added: java/tests/src/org/apache/xindice/integration
IntegrationTests.java
java/tests/src/org/apache/xindice/integration/client/services
XUpdateQueryTest.java
Log:
XUpdateTest added
Revision Changes Path
1.3 +27 -36 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IntegrationEmbedTests.java 28 Oct 2002 08:39:19 -0000 1.2
+++ IntegrationEmbedTests.java 28 Nov 2002 08:12:26 -0000 1.3
@@ -59,52 +59,43 @@
package org.apache.xindice;
+import org.apache.xindice.integration.IntegrationTests;
import org.apache.xindice.integration.client.XmlDbClient;
import org.apache.xindice.integration.client.XmlDbClientSetup;
-import org.apache.xindice.integration.client.basic.CollectionTest;
-import org.apache.xindice.integration.client.basic.DocumentTest;
-import org.apache.xindice.integration.client.basic.IndexTest;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import junitx.extensions.TestSetup;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Database;
+import junit.framework.Test;
+import junitx.extensions.TestSetup;
+
/**
* @version $Revision$, $Date$
* @author Vladimir R. Bossicard <vl...@apache.org>
*/
public class IntegrationEmbedTests {
- public static Test suite()
- throws Exception {
- TestSuite usecases = new TestSuite("Embed client integration tests");
- usecases.addTestSuite(CollectionTest.class);
- usecases.addTestSuite(IndexTest.class);
- usecases.addTestSuite(DocumentTest.class);
-
- return new TestSetup(new XmlDbClientSetup(usecases, new XmlDbClient("xmldb:xindice-embed://"))) {
-
- private Database database;
-
- public void setUp()
- throws Exception {
- String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
- Class cls = Class.forName(driver);
-
- database = (Database) cls.newInstance();
- DatabaseManager.registerDatabase(database);
- }
-
- public void tearDown()
- throws Exception {
- if (database != null) {
- DatabaseManager.deregisterDatabase(database);
+ public static Test suite() throws Exception {
+
+ return new TestSetup(new XmlDbClientSetup(IntegrationTests.testSuite("Embed client integration tests"),
+ new XmlDbClient("xmldb:xindice-embed://"))) {
+
+ private Database database;
+
+ public void setUp() throws Exception {
+ String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
+ Class cls = Class.forName(driver);
+
+ database = (Database) cls.newInstance();
+ DatabaseManager.registerDatabase(database);
+ }
+
+ public void tearDown() throws Exception {
+ if (database != null) {
+ DatabaseManager.deregisterDatabase(database);
+ }
}
- }
- };
- }
+ };
+ }
}
1.3 +30 -36 xml-xindice/java/tests/src/org/apache/xindice/IntegrationXmlRpcTests.java
Index: IntegrationXmlRpcTests.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/IntegrationXmlRpcTests.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IntegrationXmlRpcTests.java 28 Oct 2002 08:39:19 -0000 1.2
+++ IntegrationXmlRpcTests.java 28 Nov 2002 08:12:26 -0000 1.3
@@ -59,52 +59,46 @@
package org.apache.xindice;
+import org.apache.xindice.integration.IntegrationTests;
import org.apache.xindice.integration.client.XmlDbClient;
import org.apache.xindice.integration.client.XmlDbClientSetup;
-import org.apache.xindice.integration.client.basic.CollectionTest;
-import org.apache.xindice.integration.client.basic.DocumentTest;
-import org.apache.xindice.integration.client.basic.IndexTest;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import junitx.extensions.TestSetup;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Database;
+import junit.framework.Test;
+import junitx.extensions.TestSetup;
+
/**
* @version $Revision$, $Date$
* @author Vladimir R. Bossicard <vl...@apache.org>
*/
public class IntegrationXmlRpcTests {
- public static Test suite()
- throws Exception {
- TestSuite usecases = new TestSuite("XmlRpc client integration tests");
- usecases.addTestSuite(CollectionTest.class);
- usecases.addTestSuite(IndexTest.class);
- usecases.addTestSuite(DocumentTest.class);
-
- return new TestSetup(new XmlDbClientSetup(usecases, new XmlDbClient("xmldb:xindice://"))) {
-
- private Database database;
-
- public void setUp()
- throws Exception {
- String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
- Class cls = Class.forName(driver);
-
- database = (Database) cls.newInstance();
- DatabaseManager.registerDatabase(database);
- }
-
- public void tearDown()
- throws Exception {
- if (database != null) {
- DatabaseManager.deregisterDatabase(database);
+ public static Test suite()
+ throws Exception {
+
+ return new TestSetup(new XmlDbClientSetup(IntegrationTests.testSuite("XmlRpc client integration tests"),
+ new XmlDbClient("xmldb:xindice://"))) {
+
+ private Database database;
+
+ public void setUp()
+ throws Exception {
+ String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
+ Class cls = Class.forName(driver);
+
+ database = (Database) cls.newInstance();
+ DatabaseManager.registerDatabase(database);
+ }
+
+ public void tearDown()
+ throws Exception {
+ if (database != null) {
+ DatabaseManager.deregisterDatabase(database);
+ }
}
- }
- };
- }
+ };
+ }
}
1.6 +3 -8 xml-xindice/java/tests/src/org/apache/xindice/UnitTests.java
Index: UnitTests.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/UnitTests.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UnitTests.java 19 Nov 2002 09:17:57 -0000 1.5
+++ UnitTests.java 28 Nov 2002 08:12:26 -0000 1.6
@@ -63,17 +63,12 @@
import org.apache.xindice.client.xmldb.ResourceIteratorImplTest;
import org.apache.xindice.core.data.KeyTest;
import org.apache.xindice.core.data.ValueTest;
-import org.apache.xindice.core.filer.BTreeFiler;
-import org.apache.xindice.core.filer.FSFiler;
-import org.apache.xindice.core.filer.FilerTestCase;
-import org.apache.xindice.core.filer.FilerTestSetup;
-import org.apache.xindice.core.filer.MemFiler;
+import org.apache.xindice.core.filer.*;
import org.apache.xindice.tools.XMLToolsTest;
import org.apache.xindice.util.ConfigurationTest;
import junit.framework.Test;
import junit.framework.TestSuite;
-
import junitx.extensions.TestSetup;
import java.io.File;
1.1 xml-xindice/java/tests/src/org/apache/xindice/integration/IntegrationTests.java
Index: IntegrationTests.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 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 (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/>.
*
* $Id: IntegrationTests.java,v 1.1 2002/11/28 08:12:26 vladimir Exp $
*/
package org.apache.xindice.integration;
import org.apache.xindice.integration.client.basic.CollectionTest;
import org.apache.xindice.integration.client.basic.DocumentTest;
import org.apache.xindice.integration.client.basic.IndexTest;
import org.apache.xindice.integration.client.services.XUpdateQueryTest;
import junit.framework.TestSuite;
/**
* @version $Revision: 1.1 $, $Date: 2002/11/28 08:12:26 $
* @author Vladimir R. Bossicard <vl...@apache.org>
*/
public class IntegrationTests {
public static TestSuite testSuite(String name) {
TestSuite suite = new TestSuite(name);
suite.addTestSuite(CollectionTest.class);
suite.addTestSuite(IndexTest.class);
suite.addTestSuite(DocumentTest.class);
suite.addTestSuite(XUpdateQueryTest.class);
return suite;
}
}
1.3 +2 -3 xml-xindice/java/tests/src/org/apache/xindice/integration/client/XmlDbClientSetup.java
Index: XmlDbClientSetup.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/integration/client/XmlDbClientSetup.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XmlDbClientSetup.java 28 Oct 2002 08:39:20 -0000 1.2
+++ XmlDbClientSetup.java 28 Nov 2002 08:12:26 -0000 1.3
@@ -85,7 +85,6 @@
public void setUp()
throws Exception {
- // todo run the tearDown in a finally block
this.client.createCollection(INSTANCE_NAME, TEST_COLLECTION_NAME);
// now we set all tests with the client
1.1 xml-xindice/java/tests/src/org/apache/xindice/integration/client/services/XUpdateQueryTest.java
Index: XUpdateQueryTest.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 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 (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/>.
*
* $Id: XUpdateQueryTest.java,v 1.1 2002/11/28 08:12:26 vladimir Exp $
*/
package org.apache.xindice.integration.client.services;
import org.apache.xindice.integration.client.AbstractXmlDbClientTest;
import org.xmldb.api.modules.XUpdateQueryService;
import org.xmldb.api.base.Collection;
/**
* @version $Revision: 1.1 $, $Date: 2002/11/28 08:12:26 $
* @author Vladimir R. Bossicard <vl...@apache.org>
*/
public class XUpdateQueryTest
extends AbstractXmlDbClientTest {
public void testUpdateDocument()
throws Exception {
String document = "<?xml version=\"1.0\"?>" +
"<person>" +
"<fname>John</fname>" +
"<lname>Smith</lname>" +
"<phone type=\"work\">563-456-7890</phone>" +
"<phone type=\"home\">534-567-8901</phone>" +
"<email type=\"home\">jsmith@somemail.com</email>" +
"<email type=\"work\">john@lovesushi.com</email>" +
"<address type=\"home\">34 S. Colon St.</address>" +
"<address type=\"work\">9967 W. Shrimp Ave.</address>" +
"</person>";
this.client.insertDocument(TEST_COLLECTION_PATH, "xupdatedoc", document);
assertEquals(1, this.client.countDocument(TEST_COLLECTION_PATH));
String xupdate = "<xu:modifications version=\"1.0\"" +
" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
" <xu:remove select=\"/person/phone[@type = 'home']\"/>" +
" <xu:update select=\"/person/phone[@type = 'work']\">" +
" 480-300-3003" +
" </xu:update>" +
"</xu:modifications>";
String updatedDocument = "<?xml version=\"1.0\"?>" +
"<person>" +
"<fname>John</fname>" +
"<lname>Smith</lname>" +
"<phone type=\"work\">408-300-3003</phone>" +
"<email type=\"home\">jsmith@somemail.com</email>" +
"<email type=\"work\">john@lovesushi.com</email>" +
"<address type=\"home\">34 S. Colon St.</address>" +
"<address type=\"work\">9967 W. Shrimp Ave.</address>" +
"</person>";
Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
XUpdateQueryService service = (XUpdateQueryService) col.getService("XUpdateQueryService", "1.0");
long count = service.update(xupdate);
assertEquals(1, count);
String doc = this.client.getDocument(TEST_COLLECTION_PATH, "xupdatedoc");
assertNotNull(doc);
assertEquals(updatedDocument, doc);
this.client.removeDocument(TEST_COLLECTION_PATH, "xupdatedoc");
assertEquals(0, this.client.countDocument(TEST_COLLECTION_PATH));
}
}