From 3a4615ca48e4d61942fecc430e9aa3c83ed3c002 Mon Sep 17 00:00:00 2001 From: mss Date: Tue, 26 May 2015 14:08:16 +0200 Subject: [PATCH] Added template test This should be run first to ensure a H3 template is configured as default template. --- .../common/utils/SystemUtilsTester.java | 2 +- integration-test/system-test/pom.xml | 4 +- .../netarkivet/systemtest/SeleniumTest.java | 5 +- .../functional/TemplatePageTest.java | 78 +++++++++++++++++++ .../src/test/resources/full-test.xml | 15 +--- 5 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 integration-test/system-test/src/test/java/dk/netarkivet/systemtest/functional/TemplatePageTest.java diff --git a/common/common-test/src/test/java/dk/netarkivet/common/utils/SystemUtilsTester.java b/common/common-test/src/test/java/dk/netarkivet/common/utils/SystemUtilsTester.java index 4af447941b..095866c117 100644 --- a/common/common-test/src/test/java/dk/netarkivet/common/utils/SystemUtilsTester.java +++ b/common/common-test/src/test/java/dk/netarkivet/common/utils/SystemUtilsTester.java @@ -71,7 +71,7 @@ public void testGetCurrentClasspath() throws Exception { // Test that some version of the standard libraries are in there JARS: for (String jar : new String[] {"commons-fileupload.*\\.jar$", "commons-httpclient.*\\.jar$", - "commons-logging.*\\.jar$", "dom4j-.*\\.jar$", "jaxen-.*\\.jar$", "jetty-.*\\.jar$", "junit-.*\\.jar$", + "dom4j-.*\\.jar$", "jaxen-.*\\.jar$", "jetty-.*\\.jar$", "junit-.*\\.jar$", // Removed as not used in common. // "libidn-.*\\.jar$", // "lucene-core-.*\\.jar$" diff --git a/integration-test/system-test/pom.xml b/integration-test/system-test/pom.xml index 149bfbbebe..b35bfd6fc6 100644 --- a/integration-test/system-test/pom.xml +++ b/integration-test/system-test/pom.xml @@ -64,14 +64,14 @@ org.seleniumhq.selenium selenium-java - 2.43.1 + 2.45.0 test org.seleniumhq.selenium selenium-api - 2.43.1 + 2.45.0 diff --git a/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/SeleniumTest.java b/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/SeleniumTest.java index c1eb7699de..162f50f51b 100644 --- a/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/SeleniumTest.java +++ b/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/SeleniumTest.java @@ -27,8 +27,10 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; +import org.jaccept.TestEventManager; import org.jaccept.structure.ExtendedTestCase; import org.jaccept.testreport.ReportGenerator; +import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; @@ -100,7 +102,8 @@ private void initialiseSelenium() { baseUrl = testController.ENV.getGuiHost() + ":" + testController.ENV.getGuiPort(); PageHelper.initialize(driver, baseUrl); TestGUIController.waitForGUIToStart(60); - + TestEventManager.getInstance().addFixture("Selecting English as language"); + driver.findElement(By.linkText("English")).click(); } private void setupFixture() { diff --git a/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/functional/TemplatePageTest.java b/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/functional/TemplatePageTest.java new file mode 100644 index 0000000000..988c66fa6d --- /dev/null +++ b/integration-test/system-test/src/test/java/dk/netarkivet/systemtest/functional/TemplatePageTest.java @@ -0,0 +1,78 @@ +/* + * #%L + * NetarchiveSuite System test + * %% + * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, + * the National Library of France and the Austrian National Library. + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * . + * #L% + */ +package dk.netarkivet.systemtest.functional; + +import static dk.netarkivet.systemtest.page.DomainWebTestHelper.HIDE_UNUSED_CONFIGURATIONS_LINK; +import static dk.netarkivet.systemtest.page.DomainWebTestHelper.HIDE_UNUSED_SEED_LISTS_LINK; +import static dk.netarkivet.systemtest.page.DomainWebTestHelper.SHOW_UNUSED_CONFIGURATIONS_LINK; +import static dk.netarkivet.systemtest.page.DomainWebTestHelper.SHOW_UNUSED_SEED_LISTS_LINK; + +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import dk.netarkivet.systemtest.AbstractSystemTest; +import dk.netarkivet.systemtest.NASAssert; +import dk.netarkivet.systemtest.page.DomainConfigurationPageHelper; +import dk.netarkivet.systemtest.page.DomainWebTestHelper; +import dk.netarkivet.systemtest.page.PageHelper; + +public class TemplatePageTest extends AbstractSystemTest { + + @BeforeMethod(alwaysRun = true) + public void setup(Method method) { + } + + @Test(priority=-1, groups = {"guitest", "functest"}) + public void updateTemplateTest() throws Exception { + addDescription("Tests that harvest tempplates can be updated."); + addStep("Goto the template page", "The template page should load"); + PageHelper.gotoPage(PageHelper.MenuPages.EditHarvestTemplates); + NASAssert.assertTrue(driver.getPageSource().contains("Edit Harvest Templates"), + "Template page not loaded correctly"); + + addStep("Select the 'default_orderxml' in the Replace... drop down", ""); + new Select(driver.findElement(By.name("order_xml_to_replace"))).selectByVisibleText("default_orderxml"); + + addStep("Select the 'default_orderxml' in the Replace... drop down", ""); + Path currentRelativePath = Paths.get(""); + String s = currentRelativePath.toAbsolutePath().toString(); + driver.findElement(By.name("upload_file")).sendKeys(s + "/../../deploy/distribution/src/main/resources/order_templates_dist/default_orderxml.xml"); + + addStep("Click the upload button.", "The text 'The harvest template 'default_orderxml' has been updated' should be displayed"); + driver.findElement(By.name("upload")).click(); + NASAssert.assertTrue(driver.getPageSource().contains("The harvest template 'default_orderxml' has been updated"), + "Template not updated correctly"); + } +} diff --git a/integration-test/system-test/src/test/resources/full-test.xml b/integration-test/system-test/src/test/resources/full-test.xml index 96ccd29346..60314afdec 100644 --- a/integration-test/system-test/src/test/resources/full-test.xml +++ b/integration-test/system-test/src/test/resources/full-test.xml @@ -1,18 +1,9 @@ - - - - - - - - + + - + - - - \ No newline at end of file