Index: dspace/src/main/config/build.xml =================================================================== --- dspace/src/main/config/build.xml (revision 4671) +++ dspace/src/main/config/build.xml (working copy) @@ -140,6 +140,17 @@ + + + + + + + + + + + @@ -751,4 +762,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests defined for the JSPUI interface + + + + + + + + + + + + + + + No tests defined for the JSPUI interface + + + + + + + + + + + + + + + + No tests defined for the OAI interface + + + + + + + + + + + + + + + No tests defined for the OAI interface + + + + + + + + + + + + + + + + + + + Index: dspace/bin/stop-winstone =================================================================== --- dspace/bin/stop-winstone (revision 0) +++ dspace/bin/stop-winstone (revision 0) @@ -0,0 +1,96 @@ +#!/bin/sh + +########################################################################### +# +# stop-winstone +# +# Version: $Revision: 618 $ +# +# Date: $Date: 2003-04-07 09:41:43 -0500 (Mon, 07 Apr 2003) $ +# +# Copyright (c) 2002, Hewlett-Packard Company and Massachusetts +# Institute of Technology. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - 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. +# +# - Neither the name of the Hewlett-Packard Company nor the name of the +# Massachusetts Institute of Technology nor the names of their +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS 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 COPYRIGHT +# HOLDERS OR 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 is a simple shell script for stopping the winstone webserver. + +USAGE="stop-winstone" + +# Check we have at least one command-line argument +if [ "$#" != "0" ]; then + echo $USAGE + exit 1 +fi + +# Assume we're in the bin subdirectory of the DSpace installation directory +BINDIR=`dirname $0` +DSPACEDIR=`cd "$BINDIR/.." ; pwd` +LOGFILE="$DSPACEDIR/log/winstone" + + + +## Function to get the PID(s) of the running winstone. Note, this function may +## return multiple PIDs if several winstones are running out of the same webapps directory. +pid_of_winstone () { + ps auxwww | grep java | grep "winstone.*jar --webappsDir=" | grep -v grep | awk '{print $2}'; +} + +## First, ask nicely for winstone to exit. +if [ -n "`pid_of_winstone`" ]; then + kill -15 `pid_of_winstone` +else + echo "Winstone is not running." + exit 0 +fi + + +## Check that winstone exited, if it does not then kill it. +echo "Stopping Winstone...\c" + +sleep=0 +while true; do + sleep 1 + echo ".\c" + + if [ $sleep -gt 20 ]; then + kill -9 `pid_of_winstone` + echo " Killed." + break + fi + if [ ! -n "`pid_of_winstone`" ]; then + echo " Stopped." + break + else + let sleep++ + fi +done Property changes on: dspace/bin/stop-winstone ___________________________________________________________________ Added: svn:executable + * Index: dspace/bin/start-winstone =================================================================== --- dspace/bin/start-winstone (revision 0) +++ dspace/bin/start-winstone (revision 0) @@ -0,0 +1,147 @@ +#!/bin/sh + +########################################################################### +# +# start-winstone +# +# Version: $Revision: 618 $ +# +# Date: $Date: 2003-04-07 09:41:43 -0500 (Mon, 07 Apr 2003) $ +# +# Copyright (c) 2002, Hewlett-Packard Company and Massachusetts +# Institute of Technology. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - 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. +# +# - Neither the name of the Hewlett-Packard Company nor the name of the +# Massachusetts Institute of Technology nor the names of their +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS 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 COPYRIGHT +# HOLDERS OR 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 is a simple shell script for starting the winstone webserver. The +# webserver will be run in the background, then the shell script will check +# to make sure the server started successfully before return a status code. If +# the server faild to start then an error status code will be returned, +# otherwise a positive status code is returned. + +USAGE="start-winstone" + +# Check we have at least one command-line argument +if [ "$#" != "0" ]; then + echo $USAGE + exit 1 +fi + +# Assume we're in the bin subdirectory of the DSpace installation directory +BINDIR=`dirname $0` +DSPACEDIR=`cd "$BINDIR/.." ; pwd` +LOGFILE="$DSPACEDIR/log/winstone" + + +## Check if winstone is allready running +pid_of_winstone () { + ps auxwww | grep java | grep "winstone.*jar --webappsDir=" | grep -v grep | awk '{print $2}'; +} + +## If winstone is running, then stop it. +if [ -n "`pid_of_winstone`" ]; then + echo "Winstone (PID:`pid_of_winstone`) is all ready running, attempting to stop...\c" + kill -15 `pid_of_winstone` + + sleep=0 + while true; do + sleep 1 + echo ".\c" + + if [ $sleep -gt 20 ]; then + kill -9 `pid_of_winstone` + echo " Killed." + break + fi + if [ ! -n "`pid_of_winstone`" ]; then + echo " Stopped." + break + else + let sleep++ + fi + done +fi + + +## Rotate old logs +if [ -f "$LOGFILE.log" ]; then + #Find the oldest log + lastlogindex=1 + while true; do + if [ -f "${LOGFILE}${lastlogindex}.log" ] + then + let lastlogindex++ + else + break + fi + done + + #Move each log up one + i=$lastlogindex + while [ $i -gt 1 ]; do + mv ${LOGFILE}$[$i-1].log ${LOGFILE}${i}.log + let i-- + done + mv ${LOGFILE}.log ${LOGFILE}1.log +fi + +## Acutaly start winstone +java -Xmx256m -jar $DSPACEDIR/lib/winstone-*.jar --webappsDir=$DSPACEDIR/webapps/ > ${LOGFILE}.log 2>&1 & + + +## Check that winstone started successfully, otherwise exit with an error code. +echo "Starting Winstone...\c" + +sleep=0 +while true; do + sleep 1 + echo ".\c" + + if [ $sleep -gt 60 ]; then + echo " Failed, check the log for error." + cat ${LOGFILE}.log + exit 1 + fi + + if grep -q "java.net.BindException: Address already in use" ${LOGFILE}.log; then + echo " Failed, address already in use." + exit 1 + fi + + if grep -q "Winstone Servlet Engine .* running" ${LOGFILE}.log; then + echo " Started." + exit 0 + fi + + let sleep++ +done + Property changes on: dspace/bin/start-winstone ___________________________________________________________________ Added: svn:executable + * Index: dspace/pom.xml =================================================================== --- dspace/pom.xml (revision 4666) +++ dspace/pom.xml (working copy) @@ -526,6 +526,14 @@ org.dspace dspace-api-lang + + org.dspace + dspace-xmlui-test + + + net.sourceforge.winstone + winstone + \ No newline at end of file Index: dspace/etc/test/structure.xml =================================================================== --- dspace/etc/test/structure.xml (revision 0) +++ dspace/etc/test/structure.xml (revision 0) @@ -0,0 +1,23 @@ + + + Community A + + Collection A.1 + + + Collection A.2 + + + Community AB + + Collection AB.1 + + + + + Community B + + Collection B.1 + + + \ No newline at end of file Index: dspace/etc/test/import1/A/dublin_core.xml =================================================================== --- dspace/etc/test/import1/A/dublin_core.xml (revision 0) +++ dspace/etc/test/import1/A/dublin_core.xml (revision 0) @@ -0,0 +1,10 @@ + + + 2007-09-30T01:40:12Z + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sit amet neque dui. Etiam pellentesque gravida scelerisque. Phasellus quis mauris tortor. Morbi et laoreet tellus. Vivamus non massa turpis, imperdiet consequat dolor. Mauris lorem lectus, lacinia sit amet dictum sit amet, tincidunt ac metus. Aliquam vestibulum venenatis faucibus. In suscipit, orci a rhoncus suscipit, massa felis facilisis neque, vel tincidunt ante eros a nunc. Suspendisse laoreet quam ac massa posuere feugiat. Sed tincidunt vehicula tincidunt. Aliquam gravida, dolor non accumsan eleifend, massa arcu tincidunt ipsum, ac mattis justo leo a quam. Fusce erat elit, placerat sed egestas sit amet, lacinia sed leo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi ligula velit, adipiscing non tincidunt a, molestie eget elit. Sed quis velit a elit blandit commodo in sit amet sem. Pellentesque adipiscing velit ac massa laoreet aliquet. Aliquam ultrices imperdiet enim, ut sodales nisl feugiat et. Proin sit amet purus risus, id pharetra nisl. Praesent sit amet euismod augue. Etiam ac consequat tellus. + + en_US + testing + Test Document A + Otto Fox + Index: dspace/etc/test/import1/A/TestDocumentA.pdf =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: dspace/etc/test/import1/A/TestDocumentA.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: dspace/etc/test/import1/A/contents =================================================================== --- dspace/etc/test/import1/A/contents (revision 0) +++ dspace/etc/test/import1/A/contents (revision 0) @@ -0,0 +1 @@ +TestDocumentA.pdf Index: dspace/etc/test/import1/B/dublin_core.xml =================================================================== --- dspace/etc/test/import1/B/dublin_core.xml (revision 0) +++ dspace/etc/test/import1/B/dublin_core.xml (revision 0) @@ -0,0 +1,9 @@ + + + 2005-09-30T01:40:12Z + Nam interdum lorem sit amet nulla congue et adipiscing augue fringilla. Proin id orci sit amet libero consequat posuere bibendum in purus. Vivamus scelerisque gravida tellus vitae accumsan. Vestibulum varius, turpis id malesuada sollicitudin, massa tellus porta neque, fermentum vestibulum tellus odio vel sapien. Maecenas pharetra consequat sollicitudin. Morbi eros ante, tristique ac consequat sollicitudin, congue in magna. Ut scelerisque tempor interdum. Aliquam erat volutpat. Nullam pellentesque, elit vel laoreet sodales, magna libero venenatis mauris, nec consequat mauris mauris suscipit purus. Praesent ultrices neque eu mauris dapibus commodo feugiat nisi euismod. Pellentesque porttitor scelerisque sem, sed consectetur dolor semper sit amet. Proin ac congue lorem. Suspendisse gravida, nibh quis congue molestie, mauris orci volutpat ligula, ut commodo magna diam quis neque. Duis eget ipsum magna. Suspendisse rutrum suscipit sapien, vestibulum dignissim tellus vulputate quis. Cras at ante non ligula vestibulum porta. Nullam id turpis sem. + en_US + testing + Test Document B + Dan Zappone + Index: dspace/etc/test/import1/B/TestDocumentB.pdf =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: dspace/etc/test/import1/B/TestDocumentB.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: dspace/etc/test/import1/B/contents =================================================================== --- dspace/etc/test/import1/B/contents (revision 0) +++ dspace/etc/test/import1/B/contents (revision 0) @@ -0,0 +1 @@ +TestDocumentB.pdf Index: dspace/etc/test/import1/C/dublin_core.xml =================================================================== --- dspace/etc/test/import1/C/dublin_core.xml (revision 0) +++ dspace/etc/test/import1/C/dublin_core.xml (revision 0) @@ -0,0 +1,9 @@ + + + 2004-09-30T01:40:12Z + This is a simple test document that could represent any number of things such as a learning object. + en_US + testing + Test Document C + Scott Phillips + Index: dspace/etc/test/import1/C/TestDocumentC.pdf =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: dspace/etc/test/import1/C/TestDocumentC.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: dspace/etc/test/import1/C/contents =================================================================== --- dspace/etc/test/import1/C/contents (revision 0) +++ dspace/etc/test/import1/C/contents (revision 0) @@ -0,0 +1 @@ +TestDocumentC.pdf Index: dspace/etc/clean-database.sql =================================================================== --- dspace/etc/clean-database.sql (revision 4666) +++ dspace/etc/clean-database.sql (working copy) @@ -62,50 +62,50 @@ DROP VIEW DCValue; -- Then the tables -DROP TABLE collection_item_count; -DROP TABLE community_item_count; -DROP TABLE checksum_history; -DROP TABLE most_recent_checksum; -DROP TABLE checksum_results; -DROP TABLE ItemsBySubject; -DROP TABLE ItemsByDateAccessioned; -DROP TABLE ItemsByDate; -DROP TABLE ItemsByTitle; -DROP TABLE ItemsByAuthor; -DROP TABLE Communities2Item; -DROP TABLE EPersonGroup2WorkspaceItem; -DROP TABLE HistoryState; -DROP TABLE History; -DROP TABLE Subscription; -DROP TABLE RegistrationData; -DROP TABLE TasklistItem; -DROP TABLE WorkflowItem; -DROP TABLE WorkspaceItem; -DROP TABLE Handle; -DROP TABLE EPersonGroup2EPerson; -DROP TABLE ResourcePolicy; -DROP TABLE Collection2Item; -DROP TABLE Community2Collection; -DROP TABLE Community2Community; -DROP TABLE Collection; -DROP TABLE Community; -DROP TABLE MetadataValue; -DROP TABLE MetadataFieldRegistry; -DROP TABLE MetadataSchemaRegistry; -DROP TABLE Bundle2Bitstream; -DROP TABLE Item2Bundle; -DROP TABLE Bundle; -DROP TABLE most_recent_checksum; -DROP TABLE checksum_history; -DROP TABLE checksum_results; -DROP TABLE Item; -DROP TABLE Group2GroupCache; -DROP TABLE Group2Group; -DROP TABLE EPersonGroup; -DROP TABLE EPerson; -DROP TABLE Bitstream; -DROP TABLE FileExtension; -DROP TABLE BitstreamFormatRegistry; +DROP TABLE collection_item_count CASCADE; +DROP TABLE community_item_count CASCADE; +DROP TABLE checksum_history CASCADE; +DROP TABLE most_recent_checksum CASCADE; +DROP TABLE checksum_results CASCADE; +DROP TABLE ItemsBySubject CASCADE; +DROP TABLE ItemsByDateAccessioned CASCADE; +DROP TABLE ItemsByDate CASCADE; +DROP TABLE ItemsByTitle CASCADE; +DROP TABLE ItemsByAuthor CASCADE; +DROP TABLE Communities2Item CASCADE; +DROP TABLE EPersonGroup2WorkspaceItem CASCADE; +DROP TABLE HistoryState CASCADE; +DROP TABLE History CASCADE; +DROP TABLE Subscription CASCADE; +DROP TABLE RegistrationData CASCADE; +DROP TABLE TasklistItem CASCADE; +DROP TABLE WorkflowItem CASCADE; +DROP TABLE WorkspaceItem CASCADE; +DROP TABLE Handle CASCADE; +DROP TABLE EPersonGroup2EPerson CASCADE; +DROP TABLE ResourcePolicy CASCADE; +DROP TABLE Collection2Item CASCADE; +DROP TABLE Community2Collection CASCADE; +DROP TABLE Community2Community CASCADE; +DROP TABLE Collection CASCADE; +DROP TABLE Community CASCADE; +DROP TABLE MetadataValue CASCADE; +DROP TABLE MetadataFieldRegistry CASCADE; +DROP TABLE MetadataSchemaRegistry CASCADE; +DROP TABLE Bundle2Bitstream CASCADE; +DROP TABLE Item2Bundle CASCADE; +DROP TABLE Bundle CASCADE; +DROP TABLE most_recent_checksum CASCADE; +DROP TABLE checksum_history CASCADE; +DROP TABLE checksum_results CASCADE; +DROP TABLE Item CASCADE; +DROP TABLE Group2GroupCache CASCADE; +DROP TABLE Group2Group CASCADE; +DROP TABLE EPersonGroup CASCADE; +DROP TABLE EPerson CASCADE; +DROP TABLE Bitstream CASCADE; +DROP TABLE FileExtension CASCADE; +DROP TABLE BitstreamFormatRegistry CASCADE; -- Now drop the sequences for ID (primary key) creation DROP SEQUENCE bitstreamformatregistry_seq; Index: pom.xml =================================================================== --- pom.xml (revision 4666) +++ pom.xml (working copy) @@ -258,6 +258,11 @@ dspace-xmlui-wing ${project.version} + + org.dspace + dspace-xmlui-test + ${project.version} + org.dspace @@ -494,6 +499,31 @@ ojdbc14 10.2.0.2.0 + + net.sourceforge.winstone + winstone + 0.9.10 + + + junit + junit + 4.8.1 + + + org.hamcrest + hamcrest-all + 1.1 + + + net.sourceforge.htmlunit + htmlunit + 2.6 + + + commons-cli + commons-cli + 1.0 + Index: dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AdvancedSearchTester.java =================================================================== --- dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AdvancedSearchTester.java (revision 0) +++ dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AdvancedSearchTester.java (revision 0) @@ -0,0 +1,68 @@ +package org.dspace.app.xmlui.aspect.artifactbrowser; + +import java.io.IOException; +import java.net.MalformedURLException; + +import junit.framework.TestCase; + +import org.dspace.app.xmlui.XMLUITestRunner; + +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +public class AdvancedSearchTester extends TestCase { + + /** + * Test the advanced search page. Open the advanced search page verifying + * that the search form is correct, then submit a query and verify the + * results of the advanced query. + * + * @throws IOException + * @throws MalformedURLException + * @throws FailingHttpStatusCodeException + * @throws IOException + * @throws MalformedURLException + * @throws FailingHttpStatusCodeException + */ + public void testAdvancedSearchPage() throws FailingHttpStatusCodeException, + MalformedURLException, IOException { + WebClient webClient = new WebClient(); + HtmlPage page = webClient.getPage(XMLUITestRunner.getRepositoryURL() + + "advanced-search"); + assertEquals("Advanced Search", page.getTitleText()); + + HtmlForm form = (HtmlForm) page + .getHtmlElementById("aspect_artifactbrowser_AdvancedSearch_div_search-query"); + + // Check that these fields are here, if they are not htmlunit will throw + // an error. + form.getSelectByName("scope"); + form.getSelectByName("field1"); + form.getInputByName("query1"); + form.getSelectByName("conjunction2"); + form.getSelectByName("field2"); + form.getInputByName("query2"); + form.getSelectByName("conjunction3"); + form.getSelectByName("field3"); + form.getInputByName("query3"); + form.getInputByName("submit"); + + // Fill out the search form + (form.getInputByName("query1")).setValueAttribute("test"); + (form.getSelectByName("field1")).setSelectedAttribute("title", true); + (form.getInputByName("query2")).setValueAttribute("learning"); + (form.getSelectByName("field2")).setSelectedAttribute("abstract", true); + page = (form.getInputByName("submit")).click(); + + // Check that Document C is returned + assertTrue(page + .getBody() + .asText() + .indexOf( + "Your query \"((title:test) AND (abstract:learning))\" produced") > -1); + page.getAnchorByText("Test Document C"); + assertTrue(page.asText().indexOf("Scott Phillips") > -1); + } +} Index: dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/SimpleSearchTester.java =================================================================== --- dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/SimpleSearchTester.java (revision 0) +++ dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/SimpleSearchTester.java (revision 0) @@ -0,0 +1,91 @@ +package org.dspace.app.xmlui.aspect.artifactbrowser; + +import java.io.IOException; +import java.net.MalformedURLException; + +import junit.framework.TestCase; + +import org.dspace.app.xmlui.XMLUITestRunner; + +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlAnchor; +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlInput; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +public class SimpleSearchTester extends TestCase { + + /** + * This tests the quick simple search from almost everypage in the + * repository, we use the homepage in this case. A simple search is + * performed from the homepage and the results are examined. + * + * @throws IOException + * @throws MalformedURLException + * @throws FailingHttpStatusCodeException + */ + public void testSimpleSearchFromHomepage() + throws FailingHttpStatusCodeException, MalformedURLException, + IOException { + WebClient webClient = new WebClient(); + + // Get the home page + HtmlPage page = webClient.getPage(XMLUITestRunner.getRepositoryURL()); + assertEquals("DSpace Home", page.getTitleText()); + + HtmlForm form = (HtmlForm) page.getHtmlElementById("ds-search-form"); + assertTrue(form != null); + HtmlInput query = form.getInputByName("query"); + assertEquals("", query.getValueAttribute()); + query.setValueAttribute("learning object"); + + // Get the search page + page = (form.getInputByName("submit")).click(); + assertTrue(page.asText().indexOf( + "Your query \"learning object\" produced") != -1); + + HtmlAnchor anchor = page.getAnchorByText("Test Document C"); + assertTrue(anchor != null); + + assertTrue(page.asText().indexOf("Scott Phillips") != -1); + } + + /** + * This tests the simple search page directly, opens the page examining that + * the form returned is correct. Then it submits a search query and verifies + * the results. + * + * @throws IOException + * @throws MalformedURLException + * @throws FailingHttpStatusCodeException + */ + public void testSimpleSearchPage() throws FailingHttpStatusCodeException, + MalformedURLException, IOException { + WebClient webClient = new WebClient(); + + // Get the homepage + HtmlPage page = webClient.getPage(XMLUITestRunner.getRepositoryURL() + + "search"); + ; + assertEquals("Search", page.getTitleText()); + + HtmlForm form = (HtmlForm) page + .getHtmlElementById("aspect_artifactbrowser_SimpleSearch_div_general-query"); + assertTrue(form != null); + + // Perform the search + HtmlInput query = form.getInputByName("query"); + query.setValueAttribute("learning object"); + page = (form.getInputByName("submit")).click(); + + // Check the results + assertTrue(page.asText().indexOf( + "Your query \"learning object\" produced") != -1); + + // If the link dosn't exist an error will be thrown. + page.getAnchorByText("Test Document C"); + assertTrue(page.asText().indexOf("Scott Phillips") != -1); + } + +} Index: dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ItemViewerTester.java =================================================================== --- dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ItemViewerTester.java (revision 0) +++ dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/ItemViewerTester.java (revision 0) @@ -0,0 +1,45 @@ +package org.dspace.app.xmlui.aspect.artifactbrowser; + +import java.io.IOException; +import java.net.MalformedURLException; + +import junit.framework.TestCase; + +import org.dspace.app.xmlui.XMLUITestRunner; + +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +public class ItemViewerTester extends TestCase { + + /** + * Test that all the fields in the DSpace Metadata Application Profile are + * available from the detailed item view. + * + * @throws FailingHttpStatusCodeException + * @throws MalformedURLException + * @throws IOException + */ + public void testItemDisplayFullView() + throws FailingHttpStatusCodeException, MalformedURLException, + IOException { + + final String fullItemHandle = "123456789/8"; + + WebClient webClient = new WebClient(); + // Get the item page + HtmlPage page = webClient.getPage(XMLUITestRunner.getRepositoryURL() + + "handle/" + fullItemHandle + "?show=full"); + + String[] fields = { "dc.creator", "dc.date.accessioned", + "dc.date.available", "dc.date.issued", "dc.identifier.uri", + "dc.description.abstract", "dc.description.provenance", + "dc.language.iso", "dc.subject", "dc.title" }; + + for (String field : fields) { + assertTrue(page.asText().indexOf(field) != -1); + } + } + +} Index: dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/XMLUITestRunner.java =================================================================== --- dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/XMLUITestRunner.java (revision 0) +++ dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/XMLUITestRunner.java (revision 0) @@ -0,0 +1,184 @@ +package org.dspace.app.xmlui; + +/* XMLUITestRunner.java + * + * Date: Feb 25, 2010 + * + * Copyright (c) 2007-2010 Texas Digital Library. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - 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. + * + * - Neither the name of the + * Texas Digital Library nor the names of their + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS 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 COPYRIGHT + * HOLDERS OR 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. + */ + +import junit.runner.Version; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.PosixParser; +import org.apache.commons.lang.ArrayUtils; +import org.dspace.app.xmlui.aspect.artifactbrowser.AdvancedSearchTester; +import org.dspace.app.xmlui.aspect.artifactbrowser.ItemViewerTester; +import org.dspace.app.xmlui.aspect.artifactbrowser.SimpleSearchTester; +import org.dspace.core.ConfigurationManager; +import org.junit.internal.RealSystem; +import org.junit.internal.TextListener; +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; + +/** + * XMLUI test running is a simple class that starts the Junit tests. This + * provides the command line interface to start the tests and records important + * information about when the test instances of DSpace are. + * + * @author Scott Phillips + * + */ + +public class XMLUITestRunner { + + /** + * List of all the API-based tests to perform + */ + private static final Class[] API_TESTS = { + // There are none. + }; + + /** + * List of all the htmlunit-based tests + */ + private static final Class[] WEB_TESTS = { AdvancedSearchTester.class, + ItemViewerTester.class, SimpleSearchTester.class }; + + /** + * Combined list of all tests. + */ + private static final Class[] ALL_TESTS = (Class[]) ArrayUtils.addAll( + API_TESTS, WEB_TESTS); + + /** + * This initialization parameter is used by the various test cases so that + * they know what repository URL to test against. + */ + private static String repositoryURL = null; + + public static String getRepositoryURL() { + if (repositoryURL == null) + // This is used when run from within eclipse's junit. + return "http://localhost:8080/xmlui/"; + else + return repositoryURL; + } + + /** + * Absolute or relative path to the DSpace config file. + */ + private static String repositoryCONFIG = null; + + public static String getRepositoryCONFIG() { + if (repositoryCONFIG == null) + // When running from junit from eclipse this parameter should work. + return "dspace/target/dspace-1.5.2-build.dir/test/config/dspace.cfg"; + else + return repositoryCONFIG; + } + + /** + * Command line entry point. + */ + public static void main(String[] args) { + + boolean displayhelp = false; + // create an options object and populate it + CommandLineParser parser = new PosixParser(); + Options options = new Options(); + options.addOption("w", "repositoryURL", true, + "URL of the repository to perform tests against."); + options + .addOption("c", "repositoryCONFIG", true, + "Absolute or relative path to the dspace.cfg configuration file."); + options.addOption("h", "help", false, "Display command help"); + + try { + CommandLine line = parser.parse(options, args); + + if (line.hasOption('w')) { + repositoryURL = line.getOptionValue('w'); + } else { + displayhelp = true; + System.out.println("Error: No -w option."); + } + + if (line.hasOption('c')) { + repositoryCONFIG = line.getOptionValue('c'); + } else { + displayhelp = true; + System.out.println("Error: No -c option."); + } + + if (line.hasOption('h')) { + displayhelp = true; + } + } catch (ParseException pe) { + displayhelp = true; + } + + if (displayhelp) { + HelpFormatter myhelp = new HelpFormatter(); + myhelp.printHelp("XMLUITestRunner\n", options); + System.out + .println("XMLUITestRunner -w http://localhost:8080/xmlui/ -c test/config/dspace.cfg"); + System.exit(0); + } + + initDSpace(); + + System.out.println("JUnit version " + Version.id()); + JUnitCore jUnitCore = new JUnitCore(); + jUnitCore.addListener(new TextListener(new RealSystem())); + + Result result = jUnitCore.run(ALL_TESTS); + System.exit(result.wasSuccessful() ? 0 : 1); + } + + /** + * Initialize DSpace's configuration. + */ + public static void initDSpace() { + if (!ConfigurationManager.isConfigured()) { + String dspaceConfig = getRepositoryCONFIG(); + System.out.println("Initializing DSpace: " + dspaceConfig); + ConfigurationManager.loadConfig(dspaceConfig); + } + } + +} Property changes on: dspace-xmlui/dspace-xmlui-test/src/main/java/org/dspace/app/xmlui/XMLUITestRunner.java ___________________________________________________________________ Added: svn:mime-type + text/plain Index: dspace-xmlui/dspace-xmlui-test/pom.xml =================================================================== --- dspace-xmlui/dspace-xmlui-test/pom.xml (revision 0) +++ dspace-xmlui/dspace-xmlui-test/pom.xml (revision 0) @@ -0,0 +1,81 @@ + + 4.0.0 + org.dspace + dspace-xmlui-test + jar + DSpace XML-UI (Manakin) :: Functional Web-Based Tests + + Test suite for web-based functional testing of the XMLUI user interface. + + + + org.dspace + dspace-xmlui + 1.5.2 + + + + + maven.dspace.org-snapshot + DSpace Maven Snapshot Repository + http://maven.dspace.org/snapshot + + false + fail + + + true + never + fail + + + + + + + + scm:svn:http://dspace.svn.sourceforge.net/svnroot/dspace/tags/dspace-1.5.2/dspace-xmlui/dspace-xmlui-test/ + scm:svn:https://dspace.svn.sourceforge.net/svnroot/dspace/tags/dspace-1.5.2/dspace-xmlui/dspace-xmlui-test/ + http://dspace.svn.sourceforge.net/viewvc/dspace/tags/dspace-1.5.2/dspace-xmlui/dspace-xmlui-test/ + + + + + + + + net.sourceforge.htmlunit + htmlunit + + + + + junit + junit + 4.7 + + + + + commons-cli + commons-cli + + + + + org.hamcrest + hamcrest-all + + + + org.dspace + dspace-api + ${project.version} + + + + \ No newline at end of file Index: dspace-xmlui/pom.xml =================================================================== --- dspace-xmlui/pom.xml (revision 4666) +++ dspace-xmlui/pom.xml (working copy) @@ -46,6 +46,7 @@ dspace-xmlui-wing dspace-xmlui-api + dspace-xmlui-test dspace-xmlui-webapp