annotate src/test/java/de/intevation/lada/BaseTest.java @ 1240:961d50dde3c2

Fix dependencies in test deployment.
author Tom Gottfried <tom@intevation.de>
date Wed, 14 Dec 2016 18:32:13 +0100
parents 59bdb52bac1c
children
rev   line source
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 package de.intevation.lada;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
1108
de7184e1370d Added antlr4 dependencies to pom.xml and war archive in tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1087
diff changeset
10 import java.io.File;
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import java.util.List;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import org.jboss.arquillian.container.test.api.Deployment;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import org.jboss.shrinkwrap.api.ShrinkWrap;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import org.jboss.shrinkwrap.api.asset.EmptyAsset;
1108
de7184e1370d Added antlr4 dependencies to pom.xml and war archive in tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1087
diff changeset
17 import org.jboss.shrinkwrap.api.exporter.ZipExporter;
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import org.jboss.shrinkwrap.api.spec.WebArchive;
1108
de7184e1370d Added antlr4 dependencies to pom.xml and war archive in tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1087
diff changeset
19 import org.jboss.shrinkwrap.resolver.api.maven.Maven;
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import org.junit.After;
493
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
21 import org.junit.AfterClass;
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 /**
493
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
24 * Base class for Lada server tests.
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 *
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 */
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 public class BaseTest {
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29
830
454a232c1331 Updated base test.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 790
diff changeset
30 protected static String ARCHIVE_NAME = "lada-server-test.war";
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
757
bc789d180439 Added authentication information to all requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 642
diff changeset
32 public static String TEST_USER = "testeins";
bc789d180439 Added authentication information to all requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 642
diff changeset
33
977
aba3a5384c69 Use a minimal set of master data based on empty database for tests.
Tom Gottfried <tom@intevation.de>
parents: 835
diff changeset
34 public static String TEST_ROLES = "cn=mst_06_status, cn=land_06_stamm";
757
bc789d180439 Added authentication information to all requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 642
diff changeset
35
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 private static Logger logger = Logger.getLogger(BaseTest.class);
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 protected static List<Protocol> testProtocol;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 protected static boolean verboseLogging = false;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 /**
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 * Create a deployable WAR archive.
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 */
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 @Deployment(testable=true)
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 public static WebArchive createDeployment() throws Exception {
1240
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
47 File antlr = Maven.resolver().loadPomFromFile("pom.xml")
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
48 .resolve("org.antlr:antlr4-runtime")
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
49 .withoutTransitivity().asSingleFile();
1233
6ef05e62e3b3 Cleanup GeoTools dependencies, add missing library for tests.
Tom Gottfried <tom@intevation.de>
parents: 1108
diff changeset
50
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 WebArchive archive = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME)
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 .addPackages(true, Package.getPackage("de.intevation.lada"))
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 .addAsResource("log4j.properties", "log4j.properties")
757
bc789d180439 Added authentication information to all requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 642
diff changeset
54 .addAsResource("shibboleth.properties", "shibboleth.properties")
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
1240
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
56 .addAsLibrary(antlr)
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 .addAsResource("META-INF/test-persistence.xml",
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 "META-INF/persistence.xml");
1240
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
59 addWithDependencies("org.geotools:gt-api", archive);
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
60 addWithDependencies("org.geotools:gt-referencing", archive);
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
61 addWithDependencies("org.geotools:gt-epsg-hsql", archive);
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
62 addWithDependencies("org.geotools:gt-opengis", archive);
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
63
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 return archive;
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 }
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 @After
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 public final void printLogs() {
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 for (Protocol p : testProtocol) {
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 logger.info(p.toString(verboseLogging));
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 }
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 }
493
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
73
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
74 @AfterClass
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
75 public static final void afterTests() {
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
76 System.out.println("");
58ce14fbfdaa Comments and output cosmetics.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 492
diff changeset
77 }
1240
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
78
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
79 private static void addWithDependencies(String coordinate, WebArchive archive) {
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
80 File[] files = Maven.resolver().loadPomFromFile("pom.xml")
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
81 .resolve(coordinate).withTransitivity().asFile();
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
82 for (File f : files) {
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
83 archive.addAsLibrary(f);
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
84 }
961d50dde3c2 Fix dependencies in test deployment.
Tom Gottfried <tom@intevation.de>
parents: 1239
diff changeset
85 }
492
164b30723f11 Restructured tests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)