1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.filter.test.ui

File FilterTest.java

 

Code metrics

0
16
2
1
96
47
2
0.12
8
2
1

Classes

Class Line # Actions
FilterTest 45 16 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.filter.test.ui;
21   
22    import java.io.File;
23    import java.io.IOException;
24    import java.net.URL;
25   
26    import org.apache.commons.io.FileUtils;
27    import org.apache.commons.io.IOUtils;
28    import org.junit.Assert;
29    import org.junit.Before;
30    import org.junit.Rule;
31    import org.junit.Test;
32    import org.openqa.selenium.By;
33    import org.openqa.selenium.WebElement;
34    import org.xwiki.panels.test.po.ApplicationsPanel;
35    import org.xwiki.test.ui.AbstractTest;
36    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
37    import org.xwiki.test.ui.po.ViewPage;
38   
39    /**
40    * UI tests for the Filter application.
41    *
42    * @version $Id: b77509638e363f05ebfcb6ba4ad0d6a24f4a5f36 $
43    */
44    // TODO: provide PO APIs when Filter application is in a more final state
 
45    public class FilterTest extends AbstractTest
46    {
47    // Login as superadmin to have delete rights.
48    @Rule
49    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
50   
51    private ViewPage vp;
52   
 
53  1 toggle @Before
54    public void setUp()
55    {
56    // Navigate to the Filter app by clicking in the Application Panel.
57    // This verifies that the Filter application is registered in the Applications Panel.
58    // It also verifies that the Translation is registered properly.
59  1 ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
60  1 this.vp = applicationPanel.clickApplication("Filter Streams Converter");
61   
62    // Verify we're on the right page!
63  1 Assert.assertEquals("Filter", this.vp.getMetaDataValue("space"));
64  1 Assert.assertEquals("WebHome", this.vp.getMetaDataValue("page"));
65    }
66   
 
67  1 toggle @Test
68    public void testConvertXMLURL() throws IOException, InterruptedException
69    {
70  1 URL url = getClass().getResource("/xml/document1.xml");
71   
72    // Set input
73  1 WebElement inputType = getDriver().findElement(By.id("filter_input_type"));
74    // TODO: make sure the right type is selected
75  1 WebElement inputElement = getDriver().findElement(By.id("filter_input_properties_descriptor_source"));
76  1 inputElement.sendKeys("url:" + url.toString());
77   
78    // Set output
79  1 WebElement outputType = getDriver().findElement(By.id("filter_output_type"));
80    // TODO: make sure the right type is selected
81  1 File tmp = File.createTempFile("result", ".xml");
82  1 WebElement outputElement = getDriver().findElement(By.id("filter_output_properties_descriptor_target"));
83  1 outputElement.sendKeys("file:" + tmp.getAbsolutePath());
84   
85    // Start conversion
86  1 WebElement submit = getDriver().findElement(By.name("convert"));
87  1 submit.click();
88   
89    // Give some time to finish the conversion
90    // TODO: use a cleaner way to find if the conversion is done
91  1 Thread.sleep(30000);
92   
93  1 Assert.assertEquals(IOUtils.toString(getClass().getResource("/xml/document1.xml")),
94    FileUtils.readFileToString(tmp));
95    }
96    }