changeset 434:7d527bff842a

Added test environment.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 06 Feb 2015 12:24:23 +0100
parents 8751d2135364
children 2b58a86ca06f
files src/test/java/de/intevation/lada/LadaTest.java src/test/java/de/intevation/lada/test/QueryServiceTest.java src/test/resources/META-INF/test-persistence.xml src/test/resources/arquillian.xml src/test/resources/queryconf.json
diffstat 5 files changed, 226 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/LadaTest.java	Fri Feb 06 12:24:23 2015 +0100
@@ -0,0 +1,45 @@
+package de.intevation.lada;
+
+import java.net.URL;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import de.intevation.lada.rest.QueryService;
+import de.intevation.lada.test.ProbeServiceTest;
+import de.intevation.lada.test.QueryServiceTest;
+
+@RunWith(Arquillian.class)
+public class LadaTest {
+
+    @Inject
+    private QueryService queryService;
+
+    @Deployment
+    public static WebArchive createDeployment() throws Exception {
+        return ShrinkWrap.create(WebArchive.class, "lada-basis-test.war")
+            .addPackages(true, Package.getPackage("de.intevation.lada"))
+            .addClass(QueryServiceTest.class)
+            .addAsResource("queryconf.json", "queryconf.json")
+            .addAsResource("META-INF/test-persistence.xml",
+                "META-INF/persistence.xml");
+    }
+
+    /**
+     * Testing the QueryService.
+     */
+    @Test
+    public final void testQueryService() throws Exception {
+        QueryServiceTest queryServiceTest = new QueryServiceTest();
+        queryServiceTest.test(queryService);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/de/intevation/lada/test/QueryServiceTest.java	Fri Feb 06 12:24:23 2015 +0100
@@ -0,0 +1,23 @@
+package de.intevation.lada.test;
+
+import org.junit.Assert;
+
+import de.intevation.lada.rest.QueryService;
+import de.intevation.lada.util.rest.Response;
+
+
+public class QueryServiceTest {
+
+    public final void test(QueryService queryService) throws Exception {
+        queryService(queryService);
+    }
+
+    private final void queryService(QueryService queryService)
+    throws Exception {
+        Response response = queryService.get();
+        Assert.assertEquals("200", response.getMessage());
+        Assert.assertTrue(response.getSuccess());
+        Assert.assertNotNull(response.getData());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/META-INF/test-persistence.xml	Fri Feb 06 12:24:23 2015 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.1"
+   xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+    <persistence-unit name="bund" transaction-type="JTA">
+        <!--provider>org.hibernate.jpa.HibernatePersistenceProvider</provider-->
+        <jta-data-source>java:/jboss/lada-bund</jta-data-source>
+        <exclude-unlisted-classes>false</exclude-unlisted-classes>
+        <properties>
+            <property name="jboss.entity.manager.jndi.name" value="java:app/entitymanager/bund"/>
+            <!-- Properties for Hibernate -->
+            <property name="hibernate.show_sql" value="true" />
+            <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="none"/>
+            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" /> 
+       </properties>
+   	</persistence-unit>
+   	<persistence-unit name="land">
+   	    <provider>org.hibernate.ejb.HibernatePersistence</provider>
+        <jta-data-source>java:/jboss/lada-land</jta-data-source>
+       	<exclude-unlisted-classes>false</exclude-unlisted-classes>
+    	<properties>
+            <property name="jboss.entity.manager.jndi.name" value="java:app/entitymanager/land"/>
+            <property name="hibernate.show_sql" value="true" />
+            <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="none"/>
+       </properties>
+    </persistence-unit>
+    <persistence-unit name="stamm">
+        <provider>org.hibernate.ejb.HibernatePersistence</provider>
+        <jta-data-source>java:/jboss/lada-stamm</jta-data-source>
+        <properties>
+            <property name="jboss.entity.manager.jndi.name" value="java:app/entitymanager/stamm"/>
+            <property name="hibernate.show_sql" value="true" />
+            <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="none"/>
+        </properties>
+    </persistence-unit>
+</persistence>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/arquillian.xml	Fri Feb 06 12:24:23 2015 +0100
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    JBoss, Home of Professional Open Source
+    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
+    contributors by the @authors tag. See the copyright.txt in the
+    distribution for a full listing of individual contributors.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<arquillian xmlns="http://jboss.org/schema/arquillian"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://jboss.org/schema/arquillian
+        http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+   <!-- Uncomment to have test archives exported to the file system for inspection -->
+<!--    <engine>  -->
+<!--       <property name="deploymentExportPath">target/</property>  -->
+<!--    </engine> -->
+
+   <!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->
+   <defaultProtocol type="Servlet 3.0" />
+
+     <!-- Example configuration for a remote JBoss Enterprise Application Platform 6 or AS 7 instance -->
+   <container qualifier="jboss" default="true">
+        <!-- By default, arquillian will use the JBOSS_HOME environment variable.  Alternatively, the configuration below can be uncommented. -->
+        <!--<configuration> -->
+        <!--<property name="jbossHome">/path/to/jboss/as</property> -->
+        <!--</configuration> -->
+   </container>
+
+</arquillian>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/resources/queryconf.json	Fri Feb 06 12:24:23 2015 +0100
@@ -0,0 +1,80 @@
+[
+{   "id": 1,
+    "name": "Kein Filter",
+    "description": "Abfrage der Proben ohne Filter",
+    "sql": "select probe_id, mst_id, umw_id from l_probe",
+    "result": [
+        {"dataIndex": "probeId", "header": "ProbeId", "width": 100},
+        {"dataIndex": "mstId", "header": "MST", "width": 100},
+        {"dataIndex": "umwId", "header": "Umweltbereich", "width": 100}
+    ],
+    "filters": [
+    ]
+},
+{   "id": 2,
+    "name": "MST und UMW",
+    "description": "Abfrage der Proben gefiltert nach Messtellen ID und ID des Umweltbereichs",
+    "sql": "select probe_id, mst_id, umw_id from l_probe where (mst_id = :mst_id OR '' = :mst_id) and (umw_id = :umw_id OR '' = :umw_id)",
+    "result": [
+        {"dataIndex": "probeId", "header": "ProbeId", "width": 100},
+        {"dataIndex": "mstId", "header": "MST", "width": 100},
+        {"dataIndex": "umwId", "header": "Umweltbereich", "width": 100}
+    ],
+    "filters": [
+        {"dataIndex": "mst_id", "type": "listmst", "label": "Messstelle"},
+        {"dataIndex": "umw_id", "type": "listumw", "label": "Umweltbereich"}
+    ]
+},
+{   "id": 3,
+    "name": "Proben pro Land",
+    "description": "Detailiertere Beschreibung der Abfrage",
+    "sql": "select probe_id, netzbetreiber_id, mst_id, umw_id, hauptproben_nr from l_probe where (netzbetreiber_id = :netz OR '' = :netz)",
+    "result": [
+        {"dataIndex": "probeId", "header": "ProbeId", "width": 100},
+        {"dataIndex": "netzbetreiberId", "header": "Land", "width": 100},
+        {"dataIndex": "mstId", "header": "MST", "width": 100},
+        {"dataIndex": "umwId", "header": "Umweltbereich", "width": 100},
+        {"dataIndex": "hauptprobenNr", "header": "Proben-Nr", "width": 100}
+    ],
+    "filters": [
+        {"dataIndex": "netz", "type": "listnetz", "label": "Land"}
+    ]
+},
+{   "id": 4,
+    "name": "alle Proben mit Ort",
+    "description": "alle Proben mit Entnahmeort",
+    "sql": "select lp.probe_id, lp.netzbetreiber_id, lp.mst_id, lp.umw_id, lp.hauptproben_nr, ort.gem_id, s_verwaltungseinheit.bezeichnung from l_probe left outer join l_ort on (lp.probe_id = l_ort.probe_id) left outer join ort on (l_ort.ort_id = ort.ort_id) left outer join s_verwaltungseinheit on (ort.gem_id = s_verwaltungseinheit.gem_id) where l_ort.orts_typ = 'E' or l_ort.orts_typ is null",
+    "result": [
+        {"dataIndex": "probeId", "header": "ProbeId", "width": 100},
+        {"dataIndex": "netzbetreiberId", "header": "Land", "width": 50},
+        {"dataIndex": "mstId", "header": "MST", "width": 60},
+        {"dataIndex": "umwId", "header": "Umweltbereich", "width": 100},
+        {"dataIndex": "hauptprobenNr", "header": "Proben-Nr", "width": 100},
+        {"dataIndex": "gemId", "header": "Gem-ID", "width": 100},
+        {"dataIndex": "bezeichnung", "header": "Gemeinde", "flex": 1}
+    ],
+    "filters": [
+    ]
+},
+{   "id": 5,
+    "name": "Proben pro Land und UMW (Multiselect)",
+    "description": "Abfrage aller Proben gefiltert pro Land und Umweltbereich (mit Mehrfachauswahl)",
+    "sql": "select lp.probe_id, lp.netzbetreiber_id, lp.mst_id, to_char(lp.probeentnahme_beginn,'YYYY-mm-dd HH24:MI') entnahme_von, to_char(lp.probeentnahme_ende,'YYYY-mm-dd HH24:MI') entnahme_bis, lp.umw_id, lp.hauptproben_nr, l_ort.orts_typ, ort.gem_id, s_verwaltungseinheit.bezeichnung from l_probe left outer join l_ort on (lp.probe_id = l_ort.probe_id) left outer join ort on (l_ort.ort_id = ort.ort_id) left outer join s_verwaltungseinheit on (ort.gem_id = s_verwaltungseinheit.gem_id) where (l_ort.orts_typ = 'E' or l_ort.orts_typ is null) and lp.netzbetreiber_id = :netz and (umw_id similar to (:umw_id) OR '' = :umw_id)",
+    "result": [
+        {"dataIndex": "probeId", "header": "ProbeId", "width": 100},
+        {"dataIndex": "netzbetreiberId", "header": "Land", "width": 50},
+        {"dataIndex": "mstId", "header": "MST", "width": 50},
+        {"dataIndex": "entnahmeVon", "header": "Entnahme von", "width": 120},
+        {"dataIndex": "entnahmeBis", "header": "Entnahme bis", "width": 120},
+        {"dataIndex": "umwId", "header": "Umweltbereich", "width": 100},
+        {"dataIndex": "hauptprobenNr", "header": "Proben-Nr", "width": 100},
+        {"dataIndex": "ortsTyp", "header": "Ortstyp", "width": 50},
+        {"dataIndex": "genId", "header": "Gemeinde-ID", "width": 100},
+        {"dataIndex": "bezeichnung", "header": "Gemeinde", "flex": 1}
+    ],
+    "filters": [
+        {"dataIndex": "netz", "type": "listnetz", "label": "Land"},
+        {"dataIndex": "umw_id", "type": "listumw", "label": "Umweltbereich", "multiselect":true}
+    ]
+}
+]
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)