From: Jean-Marc V. <jm...@us...> - 2004-08-21 15:34:12
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3152/src/org/exist/xquery/test Modified Files: XQueryTest.java Log Message: Index: XQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XQueryTest.java 21 Aug 2004 08:46:07 -0000 1.3 --- XQueryTest.java 21 Aug 2004 15:34:00 -0000 1.4 *************** *** 5,8 **** --- 5,9 ---- import junit.framework.TestCase; + import org.exist.xmldb.DatabaseInstanceManager; import org.w3c.dom.Element; import org.xmldb.api.DatabaseManager; *************** *** 33,36 **** --- 34,41 ---- private static String attributeXML; private static int stringSize; + private static int nbElem; + private String file_name = "detail_xml.xml"; + private String xml; + private Database database; public XQueryTest(String arg0) { *************** *** 42,46 **** // initialize driver Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); ! Database database = (Database) cl.newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); --- 47,51 ---- // initialize driver Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); ! database = (Database) cl.newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); *************** *** 66,69 **** --- 71,88 ---- } + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + // testCollection.removeResource( testCollection .getResource(file_name)); + + DatabaseManager.deregisterDatabase(database); + DatabaseInstanceManager dim = + (DatabaseInstanceManager) testCollection.getService( + "DatabaseInstanceManager", "1.0"); + dim.shutdown(); + System.out.println("tearDown PASSED"); + } + public void testFor() { ResourceSet result; *************** *** 121,144 **** try { System.out.println("testLargeAttributeSimple 1: ========" ); ! String large = makeString(stringSize); ! String head = "<details format='xml'>"; ! String elem = "<metadata docid='" + large + "'></metadata>"; ! String tail = "</details>"; ! String xml = head + elem + elem + tail; ! final String FILE_NAME = "detail_xml.xml"; ! XPathQueryService service = ! storeXMLStringAndGetQueryService(FILE_NAME, xml); ! query = "doc('"+ FILE_NAME+"') / details/metadata[@docid= '" + large + "' ]"; ! result = service.queryResource(FILE_NAME, query ); ! printResult(result); ! assertEquals( "XQuery: " + query, 2, result.getSize() ); ! } catch (XMLDBException e) { ! System.out.println("testLargeAttributeSimple(): XMLDBException: "+e); ! fail(e.getMessage()); } - } ! public void testLargeAttributeRealFile() { ResourceSet result; String query; --- 140,219 ---- try { System.out.println("testLargeAttributeSimple 1: ========" ); ! String large = createXMLContentWithLargeString(); ! XPathQueryService service = ! storeXMLStringAndGetQueryService(file_name, xml); ! ! query = "doc('"+ file_name+"') / details/metadata[@docid= '" + large + "' ]"; ! result = service.queryResource(file_name, query ); ! printResult(result); ! assertEquals( "XQuery: " + query, nbElem, result.getSize() ); ! } catch (XMLDBException e) { ! System.out.println("testLargeAttributeSimple(): XMLDBException: "+e); ! fail(e.getMessage()); ! } ! } ! public void testLargeAttributeContains() { ! ResourceSet result; ! String query; ! XMLResource resu; ! try { ! System.out.println("testLargeAttributeSimple 1: ========" ); ! String large = createXMLContentWithLargeString(); ! XPathQueryService service = ! storeXMLStringAndGetQueryService(file_name, xml); ! ! query = "doc('"+ file_name+"') / details/metadata[ contains(@docid, 'aa') ]"; ! result = service.queryResource(file_name, query ); ! assertEquals( "XQuery: " + query, nbElem, result.getSize() ); ! } catch (XMLDBException e) { ! System.out.println("testLargeAttributeSimple(): XMLDBException: "+e); ! fail(e.getMessage()); ! } } ! public void testLargeAttributeKeywordOperator() { ! ResourceSet result; ! String query; ! XMLResource resu; ! try { ! System.out.println("testLargeAttributeSimple 1: ========" ); ! String large = createXMLContentWithLargeString(); ! XPathQueryService service = ! storeXMLStringAndGetQueryService(file_name, xml); ! ! query = "doc('"+ file_name+"') / details/metadata[ @docid &= '" + large + "' ]"; ! result = service.queryResource(file_name, query ); ! assertEquals( "XQuery: " + query, nbElem, result.getSize() ); ! } catch (XMLDBException e) { ! System.out.println("testLargeAttributeSimple(): XMLDBException: "+e); ! fail(e.getMessage()); ! } ! } ! ! /** CAUTION side effect on field xml ! * @return the large string contained in the atrbute(s) ! */ ! private String createXMLContentWithLargeString() { ! String large = makeString(stringSize); ! String head = "<details format='xml'>"; ! String elem = "<metadata docid='" + large + "'></metadata>"; ! String tail = "</details>"; ! xml = head; ! for ( int i=0; i< nbElem; i++ ) ! xml += elem; ! xml += tail; ! return large; ! } ! ! public void testRetrieveLargeAttribute() throws XMLDBException{ ! System.out.println("testRetrieveLargeAttribute 1: ========" ); ! XMLResource res = (XMLResource) testCollection.getResource(file_name); ! System.out.println("res.getContent(): " + res.getContent() ); ! } ! ! /** This test is obsolete because testLargeAttributeSimple() reproduces the problem without a file, ! * but I keep it to show how one can test with an XML file. */ ! public void obsoleteTestLargeAttributeRealFile() { ResourceSet result; String query; *************** *** 148,152 **** String large; large = "challengesininformationretrievalandlanguagemodelingreportofaworkshopheldatthecenterforintelligentinformationretrievaluniversityofmassachusettsamherstseptember2002-extdocid-howardturtlemarksandersonnorbertfuhralansmeatonjayaslamdragomirradevwesselkraaijellenvoorheesamitsinghaldonnaharmanjaypontejamiecallannicholasbelkinjohnlaffertylizliddyronirosenfeldvictorlavrenkodavidjharperrichschwartzjohnpragerchengxiangzhaijinxixusalimroukosstephenrobertsonandrewmccallumbrucecroftrmanmathasuedumaisdjoerdhiemstraeduardhovyralphweischedelthomashofmannjamesallanchrisbuckleyphilipresnikdavidlewis2003"; - large = "challenges"; if (attributeXML != null) large = attributeXML; --- 223,226 ---- *************** *** 217,228 **** public static void main(String[] args) { ! if ( args.length > 0) { attributeXML = args[0]; } stringSize = 513; ! if ( args.length > 1) { stringSize = Integer.parseInt( args[1] ); } ! junit.textui.TestRunner.run(XQueryTest.class); } --- 291,306 ---- public static void main(String[] args) { ! if ( args.length > 0 ) { attributeXML = args[0]; } stringSize = 513; ! if ( args.length > 1 ) { stringSize = Integer.parseInt( args[1] ); } ! nbElem = 2; ! if ( args.length > 2 ) { ! nbElem = Integer.parseInt( args[2] ); ! } ! junit.textui.TestRunner.run(XQueryTest.class); } |