Project

General

Profile

Download (3.98 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2009 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.dataportal.selenium.tests.reference;
10

    
11
import java.net.MalformedURLException;
12
import java.util.UUID;
13

    
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
import org.junit.Before;
17
import org.junit.Test;
18

    
19
import com.thoughtworks.selenium.webdriven.commands.WaitForPageToLoad;
20

    
21
import eu.etaxonomy.dataportal.DataPortalSite;
22
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
23
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
24
import eu.etaxonomy.dataportal.pages.GenericPortalPage;
25

    
26
/**
27
 * Issues to be covered by this TestClass:
28
 *
29
 * #3616
30
 *
31
 * @author a.kohlbecker
32
 */
33
@DataPortalContexts( { DataPortalSite.reference })
34
public class NamePageRedirectTest extends CdmDataPortalTestBase{
35

    
36
    private static final Logger logger = LogManager.getLogger();
37

    
38
    static final UUID taxon_achilllea_santolina_uuid = UUID.fromString("c246856f-c03e-4cb7-ac92-d9b2864084cd");
39
    static final UUID name_achilllea_santolina_uuid = UUID.fromString("2ff1fb18-7055-420f-8c10-5105b66974de");
40

    
41

    
42
    @Before
43
    public void setUp() throws Exception {
44
        driver.get(getContext().getSiteUri().toString());
45
    }
46

    
47
    /**
48
     * related to https://dev.e-taxonomy.eu/redmine/issues/8304
49
     */
50
    @Test
51
    public void testNoRedirect() throws MalformedURLException {
52

    
53
        GenericPortalPage p = new GenericPortalPage(driver, getContext(), "name/" + name_achilllea_santolina_uuid.toString() + "/null/null");
54
        assertTrue(
55
                "The target page should be a name page, no redirect must have happened.",
56
                p.getDrupalPagePath().startsWith("cdm_dataportal/name/" + name_achilllea_santolina_uuid.toString()));
57

    
58
        p = new GenericPortalPage(driver, getContext(), "name/" + name_achilllea_santolina_uuid.toString() + "/null/null/null");
59
        assertTrue(
60
                "The target page should be a name page, no redirect must have happened.",
61
                p.getDrupalPagePath().startsWith("cdm_dataportal/name/" + name_achilllea_santolina_uuid.toString()));
62

    
63
        p = new GenericPortalPage(driver, getContext(), "name/" + name_achilllea_santolina_uuid.toString() + "///");
64
        assertTrue(
65
                "The target page should be a name page, no redirect must have happened.",
66
                p.getDrupalPagePath().startsWith("cdm_dataportal/name/" + name_achilllea_santolina_uuid.toString()));
67

    
68
    }
69

    
70

    
71
    /**
72
     * related to https://dev.e-taxonomy.eu/redmine/issues/8304
73
     */
74
    @Test
75
    public void testRedirectToTaxon() throws MalformedURLException {
76

    
77

    
78
        WaitForPageToLoad wait = new WaitForPageToLoad();
79
        String timeout = "5";
80
        GenericPortalPage p = new GenericPortalPage(driver, getContext(), "name/" + name_achilllea_santolina_uuid.toString() + "/null/null/redirect_to_taxon");
81
        wait.apply(driver, new String[] {timeout});
82
        wait.apply(driver, new String[] {timeout});
83
        logger.debug("DrupalPagePath: " + p.getDrupalPagePath());
84
        assertTrue(
85
                "The target page should be a taxon page, the name page must have been redirected to the according taxon page.",
86
                p.getDrupalPagePath().startsWith("cdm_dataportal/taxon/" + taxon_achilllea_santolina_uuid.toString()));
87

    
88
        p = new GenericPortalPage(driver, getContext(), "name/" + name_achilllea_santolina_uuid.toString() + "///redirect_to_taxon");
89
        wait.apply(driver, new String[] {timeout});
90
        logger.debug("DrupalPagePath: " + p.getDrupalPagePath());
91
        assertTrue(
92
                "The target page should be a taxon page, the name page must have been redirected to the according taxon page.",
93
                p.getDrupalPagePath().startsWith("cdm_dataportal/taxon/" + taxon_achilllea_santolina_uuid.toString()));
94

    
95
    }
96

    
97
}
(7-7/16)