From dda6b0448692281d07c97dee9486b3d724924b4d Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Thu, 13 Apr 2017 16:59:19 +0200 Subject: [PATCH 01/21] set feature version for #247 sakuli se --- pom.xml | 5 +++-- src/common/pom.xml | 7 ++++--- src/core/pom.xml | 7 ++++--- src/docs/pom.xml | 7 ++++--- src/installer/pom.xml | 7 ++++--- src/integration-test/pom.xml | 7 ++++--- src/java-dsl/pom.xml | 7 ++++--- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index c5f423f9..e47f213a 100644 --- a/pom.xml +++ b/pom.xml @@ -17,12 +17,13 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se pom sakuli-parent diff --git a/src/common/pom.xml b/src/common/pom.xml index 9588e729..db2989c6 100644 --- a/src/common/pom.xml +++ b/src/common/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml common - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se common maven module for common used resources diff --git a/src/core/pom.xml b/src/core/pom.xml index 1b3dfe4c..0f6eb6e0 100644 --- a/src/core/pom.xml +++ b/src/core/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml core - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se core core module for all sakuli functionality diff --git a/src/docs/pom.xml b/src/docs/pom.xml index 2535e5bd..b23c9f59 100644 --- a/src/docs/pom.xml +++ b/src/docs/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml docs - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se docs maven module to build the markdown api docs from jsdoc diff --git a/src/installer/pom.xml b/src/installer/pom.xml index f7e56b96..226c06bf 100644 --- a/src/installer/pom.xml +++ b/src/installer/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml installer - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se maven module to build the IzPack-Java Installer diff --git a/src/integration-test/pom.xml b/src/integration-test/pom.xml index 06ac4fc2..8d71a6ad 100644 --- a/src/integration-test/pom.xml +++ b/src/integration-test/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml integration-test - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se integration-test integration test module for sakuli diff --git a/src/java-dsl/pom.xml b/src/java-dsl/pom.xml index 4befef1b..2794079f 100644 --- a/src/java-dsl/pom.xml +++ b/src/java-dsl/pom.xml @@ -17,18 +17,19 @@ ~ limitations under the License. --> - + 4.0.0 org.sakuli root - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml java-dsl - 1.1.0-SNAPSHOT + v1.1.0-SNAPSHOT-241_sakuli_se Java DSL Specific Java-DSL for using Sakuli directly over Java From c6d1f9cdac5ec22ddbef771e0157ef0de9736db1 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 19 Apr 2017 11:52:55 +0200 Subject: [PATCH 02/21] #247 extract OCR tessdata to separate maven module --- pom.xml | 18 ++- src/common/pom.xml | 4 +- src/core/descriptor_zip_release.xml | 4 + src/core/pom.xml | 11 +- src/docs/pom.xml | 4 +- src/installer/pom.xml | 4 +- src/integration-test/pom.xml | 4 +- src/java-dsl/pom.xml | 4 +- src/ocr-tessdata-extractor/pom.xml | 65 +++++++++++ .../org/sakuli/ocr/tessdata/JarReader.java | 110 ++++++++++++++++++ .../ocr/tessdata/OcrTessdataLibExtractor.java | 84 +++++++++++++ .../ocr/tessdata/lib}/configs/ambigs.train | 0 .../ocr/tessdata/lib}/configs/api_config | 0 .../ocr/tessdata/lib}/configs/box.train | 0 .../tessdata/lib}/configs/box.train.stderr | 0 .../sakuli/ocr/tessdata/lib}/configs/digits | 0 .../org/sakuli/ocr/tessdata/lib}/configs/hocr | 0 .../sakuli/ocr/tessdata/lib}/configs/inter | 0 .../sakuli/ocr/tessdata/lib}/configs/kannada | 0 .../sakuli/ocr/tessdata/lib}/configs/linebox | 0 .../sakuli/ocr/tessdata/lib}/configs/logfile | 0 .../sakuli/ocr/tessdata/lib}/configs/makebox | 0 .../sakuli/ocr/tessdata/lib}/configs/quiet | 0 .../sakuli/ocr/tessdata/lib}/configs/rebox | 0 .../ocr/tessdata/lib}/configs/strokewidth | 0 .../org/sakuli/ocr/tessdata/lib}/configs/unlv | 0 .../sakuli/ocr/tessdata/lib}/eng.cube.bigrams | 0 .../sakuli/ocr/tessdata/lib}/eng.cube.fold | 0 .../org/sakuli/ocr/tessdata/lib}/eng.cube.lm | 0 .../org/sakuli/ocr/tessdata/lib}/eng.cube.nn | Bin .../sakuli/ocr/tessdata/lib}/eng.cube.params | 0 .../sakuli/ocr/tessdata/lib}/eng.cube.size | 0 .../ocr/tessdata/lib}/eng.cube.word-freq | 0 .../ocr/tessdata/lib}/eng.tesseract_cube.nn | Bin .../sakuli/ocr/tessdata/lib}/eng.traineddata | Bin .../ocr/tessdata/lib}/tessconfigs/batch | 0 .../tessdata/lib}/tessconfigs/batch.nochop | 0 .../ocr/tessdata/lib}/tessconfigs/matdemo | 0 .../ocr/tessdata/lib}/tessconfigs/msdemo | 0 .../ocr/tessdata/lib}/tessconfigs/nobatch | 0 .../ocr/tessdata/lib}/tessconfigs/segdemo | 0 .../tessdata/OcrTessdataLibExtractorIT.java | 54 +++++++++ .../tessdata/OcrTessdataLibExtractorTest.java | 47 ++++++++ 43 files changed, 396 insertions(+), 17 deletions(-) create mode 100644 src/ocr-tessdata-extractor/pom.xml create mode 100644 src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java create mode 100644 src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/ambigs.train (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/api_config (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/box.train (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/box.train.stderr (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/digits (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/hocr (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/inter (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/kannada (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/linebox (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/logfile (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/makebox (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/quiet (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/rebox (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/strokewidth (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/configs/unlv (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.bigrams (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.fold (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.lm (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.nn (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.params (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.size (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.cube.word-freq (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.tesseract_cube.nn (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/eng.traineddata (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/batch (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/batch.nochop (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/matdemo (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/msdemo (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/nobatch (100%) rename src/{common/src/main/resources/org/sakuli/common/libs/tessdata => ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib}/tessconfigs/segdemo (100%) create mode 100644 src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java create mode 100644 src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java diff --git a/pom.xml b/pom.xml index e47f213a..69dccce6 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se pom sakuli-parent @@ -35,10 +35,12 @@ src/common + src/ocr-tessdata-extractor src/core src/integration-test src/docs src/java-dsl + src/installer @@ -56,6 +58,7 @@ 1.8.2 6.8.8 2.22.2 + 1.7.7 integration unit ui @@ -426,16 +429,21 @@ logback-classic 1.1.2 + + org.slf4j + slf4j-api + ${dependencies.slf4j.version} + org.slf4j jcl-over-slf4j - 1.7.7 + ${dependencies.slf4j.version} runtime org.slf4j jul-to-slf4j - 1.7.7 + ${dependencies.slf4j.version} @@ -464,7 +472,7 @@ commons-io commons-io - 2.4 + 2.5 joda-time @@ -474,7 +482,7 @@ org.apache.commons commons-lang3 - 3.3.2 + 3.5 diff --git a/src/common/pom.xml b/src/common/pom.xml index db2989c6..b9963de7 100644 --- a/src/common/pom.xml +++ b/src/common/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml common - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se common maven module for common used resources diff --git a/src/core/descriptor_zip_release.xml b/src/core/descriptor_zip_release.xml index 9367fdb1..36883136 100644 --- a/src/core/descriptor_zip_release.xml +++ b/src/core/descriptor_zip_release.xml @@ -74,6 +74,10 @@ META-INF + + ${project.build.unpacked-resources}/org/sakuli/ocr/tessdata/lib + /${sakuli.filename}/libs/tessdata + diff --git a/src/core/pom.xml b/src/core/pom.xml index 0f6eb6e0..d6bbefd0 100644 --- a/src/core/pom.xml +++ b/src/core/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml core - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se core core module for all sakuli functionality @@ -120,6 +120,13 @@ jar true + + org.sakuli + ocr-tessdata-extractor + ${project.version} + jar + true + diff --git a/src/docs/pom.xml b/src/docs/pom.xml index b23c9f59..9dd51784 100644 --- a/src/docs/pom.xml +++ b/src/docs/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml docs - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se docs maven module to build the markdown api docs from jsdoc diff --git a/src/installer/pom.xml b/src/installer/pom.xml index 226c06bf..58d4f480 100644 --- a/src/installer/pom.xml +++ b/src/installer/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml installer - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se maven module to build the IzPack-Java Installer diff --git a/src/integration-test/pom.xml b/src/integration-test/pom.xml index 8d71a6ad..b5224194 100644 --- a/src/integration-test/pom.xml +++ b/src/integration-test/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml integration-test - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se integration-test integration test module for sakuli diff --git a/src/java-dsl/pom.xml b/src/java-dsl/pom.xml index 2794079f..b8bf04b3 100644 --- a/src/java-dsl/pom.xml +++ b/src/java-dsl/pom.xml @@ -24,12 +24,12 @@ org.sakuli root - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se ../../pom.xml java-dsl - v1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-241_sakuli_se Java DSL Specific Java-DSL for using Sakuli directly over Java diff --git a/src/ocr-tessdata-extractor/pom.xml b/src/ocr-tessdata-extractor/pom.xml new file mode 100644 index 00000000..ab00b92d --- /dev/null +++ b/src/ocr-tessdata-extractor/pom.xml @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + + org.sakuli + root + 1.1.0-SNAPSHOT-241_sakuli_se + ../../pom.xml + + + ocr-tessdata-extractor + 1.1.0-SNAPSHOT-241_sakuli_se + ocr-tessdata-extractor + maven module for enable the OCR text recognition function based on tessdata + + jar + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + integration-test + + integration-test + verify + + + + + + + + + commons-io + commons-io + + + org.slf4j + slf4j-api + + + \ No newline at end of file diff --git a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java new file mode 100644 index 00000000..a697aa73 --- /dev/null +++ b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java @@ -0,0 +1,110 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.javaDSL.selenium.testng; + +/** + * @author tschneck + * Date: 4/18/17 + */ + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.net.URL; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +/** + * Reading files from jar file URL, taking care of nested jar + *
    + *
  • jar:file:/C:/Temp/single.jar!/foo
  • + *
  • jar:file:/C:/Temp/outer.jar!/lib/inner.jar!/foo
  • + *
+ * see /tmp/sakuli-tmp1638281192281940163/./org/sakuli/ocr/tessdata/lib/eng.cube.lm + * + * @author Trung + */ +public class JarReader { + + private static final Logger logger = LoggerFactory.getLogger(JarReader.class); + + public static void read(URL jarUrl, InputStreamCallback callback) throws IOException { + if (!"jar".equals(jarUrl.getProtocol())) { + throw new IllegalArgumentException("Jar protocol is expected but get " + jarUrl.getProtocol()); + } + if (callback == null) { + throw new IllegalArgumentException("Callback must not be null"); + } + String jarPath = jarUrl.getPath().substring(5); + String[] paths = jarPath.split("!"); + FileInputStream jarFileInputStream = new FileInputStream(paths[0]); + readStream(jarFileInputStream, paths[0], 1, paths, callback); + } + + private static void readStream(InputStream jarFileInputStream, String name, int i, String[] paths, InputStreamCallback callback) throws IOException { + if (i == paths.length) { + callback.onFile(name, jarFileInputStream); + return; + } + ZipInputStream jarInputStream = new ZipInputStream(jarFileInputStream); + try { + ZipEntry jarEntry = null; + while ((jarEntry = jarInputStream.getNextEntry()) != null) { + String jarEntryName = "/" + jarEntry.getName(); + if (!jarEntry.isDirectory() && jarEntryName.startsWith(paths[i])) { + byte[] byteArray = copyStream(jarInputStream, jarEntry); + logger.debug("Entry {} with size {} and data size {}", jarEntryName, jarEntry.getSize(), byteArray.length); + readStream(new ByteArrayInputStream(byteArray), jarEntryName, i + 1, paths, callback); + } + } + } finally { + jarInputStream.close(); + } + } + + private static byte[] copyStream(InputStream in, ZipEntry entry) + throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long size = entry.getSize(); + if (size > -1) { + byte[] buffer = new byte[1024 * 4]; + int n = 0; + long count = 0; + while (-1 != (n = in.read(buffer)) && count < size) { + baos.write(buffer, 0, n); + count += n; + } + } else { + while (true) { + int b = in.read(); + if (b == -1) { + break; + } + baos.write(b); + } + } + baos.close(); + return baos.toByteArray(); + } + + public static interface InputStreamCallback { + void onFile(String name, InputStream is) throws IOException; + } +} \ No newline at end of file diff --git a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java new file mode 100644 index 00000000..ff9f57c2 --- /dev/null +++ b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java @@ -0,0 +1,84 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.ocr.tessdata; + +import org.apache.commons.io.FileUtils; +import org.sakuli.javaDSL.selenium.testng.JarReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileNotFoundException; +import java.net.URL; +import java.nio.file.FileSystemException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * @author tschneck + * Date: 4/18/17 + */ +public class OcrTessdataLibExtractor { + public static final String TESTDATA = "eng.traineddata"; + private static final Logger LOGGER = LoggerFactory.getLogger(OcrTessdataLibExtractor.class); + + public static void extract(Path outputDir) throws Exception { + extract(outputDir, null); + } + + public static Path extract(Path outputDir, URL tessdataClasspathResourceFolder) throws Exception { + if (tessdataClasspathResourceFolder == null) { + tessdataClasspathResourceFolder = OcrTessdataLibExtractor.class.getResource("lib"); + } + + if (tessdataClasspathResourceFolder.getProtocol().equals("jar")) { + final Path targetDir = outputDir.resolve("org").resolve("sakuli").resolve("ocr").resolve("tessdata").resolve("lib"); + if (!isTessdataLibFolderContentPresent(targetDir)) { + LOGGER.debug("Extract classpath resource '{}' to:{}", tessdataClasspathResourceFolder.toString(), outputDir.toString()); + JarReader.read(tessdataClasspathResourceFolder, (name, is) -> { + Path targetFile = outputDir.resolve("." + name).normalize(); + System.out.println("write file: " + targetFile); + FileUtils.copyInputStreamToFile(is, targetFile.toFile()); + }); + checkTessdataLibFolderContent(targetDir); + } + return targetDir.normalize().toAbsolutePath(); + } else if (tessdataClasspathResourceFolder.getProtocol().equals("file")) { + final Path libPath = Paths.get(tessdataClasspathResourceFolder.toURI()); + LOGGER.debug("Use direct file path for OCR tessdata lib: {}", libPath); + checkTessdataLibFolderContent(libPath); + return libPath.normalize().toAbsolutePath(); + } + throw new FileSystemException("URL type '" + tessdataClasspathResourceFolder.getProtocol() + + "' not supported: " + tessdataClasspathResourceFolder.toString()); + } + + public static void checkTessdataLibFolderContent(Path output) throws FileNotFoundException { + //test the lib content is available + Path testdata = output.resolve(TESTDATA); + if (Files.notExists(testdata)) { + throw new FileNotFoundException("OCR required tessdata lib (e.g. '" + testdata + "') is missing in folder: " + output); + } + LOGGER.debug("Use OCR tessdata lib path: {}", output.toString()); + } + + public static boolean isTessdataLibFolderContentPresent(Path output) { + return Files.exists(output.resolve(TESTDATA)); + } +} diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/ambigs.train b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/ambigs.train similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/ambigs.train rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/ambigs.train diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/api_config b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/api_config similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/api_config rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/api_config diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/box.train b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/box.train similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/box.train rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/box.train diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/box.train.stderr b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/box.train.stderr similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/box.train.stderr rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/box.train.stderr diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/digits b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/digits similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/digits rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/digits diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/hocr b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/hocr similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/hocr rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/hocr diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/inter b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/inter similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/inter rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/inter diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/kannada b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/kannada similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/kannada rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/kannada diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/linebox b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/linebox similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/linebox rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/linebox diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/logfile b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/logfile similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/logfile rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/logfile diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/makebox b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/makebox similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/makebox rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/makebox diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/quiet b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/quiet similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/quiet rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/quiet diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/rebox b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/rebox similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/rebox rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/rebox diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/strokewidth b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/strokewidth similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/strokewidth rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/strokewidth diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/unlv b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/unlv similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/configs/unlv rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/configs/unlv diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.bigrams b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.bigrams similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.bigrams rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.bigrams diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.fold b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.fold similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.fold rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.fold diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.lm b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.lm similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.lm rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.lm diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.nn b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.nn similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.nn rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.nn diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.params b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.params similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.params rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.params diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.size b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.size similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.size rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.size diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.word-freq b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.word-freq similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.cube.word-freq rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.cube.word-freq diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.tesseract_cube.nn b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.tesseract_cube.nn similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.tesseract_cube.nn rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.tesseract_cube.nn diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.traineddata b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.traineddata similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/eng.traineddata rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/eng.traineddata diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/batch b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/batch similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/batch rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/batch diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/batch.nochop b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/batch.nochop similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/batch.nochop rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/batch.nochop diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/matdemo b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/matdemo similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/matdemo rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/matdemo diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/msdemo b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/msdemo similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/msdemo rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/msdemo diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/nobatch b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/nobatch similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/nobatch rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/nobatch diff --git a/src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/segdemo b/src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/segdemo similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/libs/tessdata/tessconfigs/segdemo rename to src/ocr-tessdata-extractor/src/main/resources/org/sakuli/ocr/tessdata/lib/tessconfigs/segdemo diff --git a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java new file mode 100644 index 00000000..ad10b1e2 --- /dev/null +++ b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java @@ -0,0 +1,54 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.ocr.tessdata; + +import org.testng.annotations.Test; + +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * Integration Test for {@link org.sakuli.javaDSL.selenium.testng.JarReader} and {@link OcrTessdataLibExtractor}. + * + * @author tschneck + * Date: 4/18/17 + */ +public class OcrTessdataLibExtractorIT { + @Test + public void testOcrExtraction() throws Exception { + Path tempDirectory = Files.createTempDirectory(Paths.get("target"), "sakuli-tmp"); + + final String jarName = "ocr-tessdata-extractor.jar"; + final Path urlJarFile = Paths.get("target/" + jarName); + assertTrue(Files.exists(urlJarFile)); + final String jarURL = "jar:" + urlJarFile.toUri().toURL().toString() + "!/org/sakuli/ocr/tessdata/lib"; + final URL jarAsResource = new URL(jarURL); + assertEquals(jarAsResource.getProtocol(), "jar"); + Path output = OcrTessdataLibExtractor.extract(tempDirectory, jarAsResource); + assertTrue(Files.exists(output)); + assertTrue(Files.exists(output.resolve("tessconfigs"))); + assertTrue(Files.isDirectory(output)); + assertTrue(Files.isDirectory(output.resolve("tessconfigs"))); + } +} diff --git a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java new file mode 100644 index 00000000..4f635e7e --- /dev/null +++ b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java @@ -0,0 +1,47 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.ocr.tessdata; + +import org.testng.annotations.Test; + +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.testng.Assert.*; + +/** + * Integration Test for {@link org.sakuli.javaDSL.selenium.testng.JarReader} and {@link OcrTessdataLibExtractor}. + * + * @author tschneck + * Date: 4/18/17 + */ +public class OcrTessdataLibExtractorTest { + @Test + public void testOcrExtractionAsFile() throws Exception { + Path tempDirectory = Files.createTempDirectory(Paths.get("target"), "sakuli-tmp"); + final URL libAsFile = OcrTessdataLibExtractor.class.getResource("lib"); + assertEquals(libAsFile.getProtocol(), "file"); + Path output = OcrTessdataLibExtractor.extract(tempDirectory, libAsFile); + assertTrue(Files.exists(output)); + assertTrue(Files.isDirectory(output)); + assertFalse(Files.exists(output.resolve("org"))); + } +} From 46933a292896abc83cb7a7faf52be3ca2d56ea6f Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 19 Apr 2017 14:13:58 +0200 Subject: [PATCH 03/21] try to fix feature build --- docs/development/set-build-env-vars.sh | 7 +++++-- pom.xml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/development/set-build-env-vars.sh b/docs/development/set-build-env-vars.sh index c1509388..fb4a9d2a 100755 --- a/docs/development/set-build-env-vars.sh +++ b/docs/development/set-build-env-vars.sh @@ -15,8 +15,11 @@ SAKULI_VERSION="$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate echo "SAKULI_VERSION=$SAKULI_VERSION" >> $WORKSPACE/myjob.properties VERSION_SURFIX=${SAKULI_VERSION:$(expr index \"$SAKULI_VERSION\" 'SNAPSHOT') +7 } echo "VERSION_SURFIX=$VERSION_SURFIX" >> $WORKSPACE/myjob.properties - -echo "SAKULI_FEATURE_VERSION=$SAKULI_VERSION-$FEATURE_NAME" >> $WORKSPACE/myjob.properties +if [ -z "$VERSION_SURFIX" ] ; then + echo "SAKULI_FEATURE_VERSION=$SAKULI_VERSION-$FEATURE_NAME" >> $WORKSPACE/myjob.properties +else + echo "SAKULI_FEATURE_VERSION=$SAKULI_VERSION" >> $WORKSPACE/myjob.properties +fi # jenkins will use the myjob.properties as environment vars cat $WORKSPACE/myjob.properties diff --git a/pom.xml b/pom.xml index 69dccce6..c759a06e 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ pl.project13.maven git-commit-id-plugin - 2.2.0 + 2.2.2 From 3dcc76f9d787c8ec65f6368589c2a53e455bcc77 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 19 Apr 2017 14:27:18 +0200 Subject: [PATCH 04/21] try to fix feature build --- docs/development/set-build-env-vars.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/development/set-build-env-vars.sh b/docs/development/set-build-env-vars.sh index fb4a9d2a..d0aa2ccc 100755 --- a/docs/development/set-build-env-vars.sh +++ b/docs/development/set-build-env-vars.sh @@ -3,6 +3,7 @@ #GIT_BRANCH=origin/feature/#219_sahi_error #SAKULI_VERSION=v1-SNAPSHOT-219_sahi_error #SAKULI_VERSION=v1-SNAPSHOT +mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version echo "branch= $GIT_BRANCH" SAKULI_BRANCH=${GIT_BRANCH/origin\/} From 65fc0a03322cf8b4637e711d3031760ca68da5cd Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 19 Apr 2017 17:10:32 +0200 Subject: [PATCH 05/21] #247 build up a new module structure to be able to have sahi independent core module --- .../Dockerfile.omd-labs-centos-sakuli | 2 +- .../Dockerfile.omd-labs-debian-sakuli | 2 +- .../Dockerfile.omd-labs-ubuntu-sakuli | 2 +- docs/development/installation-developers.md | 2 +- .../runConfigurations/DEV___Ubuntu.xml | 2 +- .../runConfigurations/DEV___Windows.xml | 2 +- .../runConfigurations/Example___Macos.xml | 2 +- .../runConfigurations/Example___Ubuntu.xml | 2 +- .../runConfigurations/Example___Win7.xml | 2 +- .../runConfigurations/Example___Win8.xml | 2 +- .../SakuliStarter__Template_.xml | 2 +- docs/forwarder-checkmk.md | 2 +- docs/forwarder-gearman.md | 2 +- docs/forwarder-icinga2api.md | 2 +- docs/forwarder-templates.md | 12 +- docs/java-DSL.md | 6 +- pom.xml | 13 +- .../exceptions/NonScreenshotException.java | 10 - .../builder/TestSuiteExampleFactory.java | 25 - .../services/AbstractServiceBaseTest.java | 20 - src/docs/pom.xml | 5 +- src/integration-test/pom.xml | 12 +- .../sakuli/integration/IntegrationTest.java | 2 +- .../service/SahiInitializingService.java | 22 - src/ocr-tessdata-extractor/pom.xml | 2 +- src/{common => sakuli-common}/pom.xml | 6 +- .../org/sakuli/common/bin/helper/.bashrc | 0 .../org/sakuli/common/bin/helper/LOGOFF.bat | 0 .../common/bin/helper/ff_purge_profile.bat | 0 .../sakuli/common/bin/helper/git_prehook.bat | 0 .../sakuli/common/bin/helper/git_status.sh | 0 .../org/sakuli/common/bin/helper/killproc.vbs | 0 .../org/sakuli/common/bin/helper/logoff.vbs | 0 .../sakuli/common/bin/helper/modwindow.vbs | 0 .../sakuli/common/bin/helper/mysql_purge.sh | 0 .../common/bin/helper/procs_to_kill.txt | 0 .../org/sakuli/common/bin/helper/record.bat | 0 .../sakuli/common/bin/helper/resolution.vbs | 0 .../sakuli/common/bin/helper/sakuli_ctrl.vbs | 0 .../sakuli/common/bin/helper/showprocs.vbs | 0 .../sakuli/common/bin/helper/toggle_swap.sh | 0 .../org/sakuli/common/bin/helper/vnc.sh | 0 .../linux/install_firefox_portable.sh | 0 .../linux/set_sakuli_home.sh | 0 .../linux/set_ui_testing_variables.sh | 0 .../win/install_firefox_portable.bat | 0 .../win/ps/install_firefox_portable.ps1 | 0 .../win/ps/modfiy_ui_testing_variables.ps1 | Bin .../win/ps/modfiy_user_permissions.ps1 | Bin .../win/ps/modfiy_user_variables.ps1 | Bin .../installer_scripts/win/set_sakuli_home.bat | 0 .../win/set_ui_testing_variables.bat | 0 .../win/set_user_permissions.bat | 0 .../sakuli/common/bin/resources/robotic1.png | Bin .../sakuli/common/bin/resources/version.txt | 0 .../common/config/sakuli-default.properties | 0 .../common/config/sakuli-log-config.xml | 0 .../templates/check_mk/case_information.twig | 0 .../templates/check_mk/detailed_summary.twig | 0 .../check_mk/detailed_summary_css_styles.twig | 0 .../check_mk/error_message_creator.twig | 0 .../check_mk/exception_screenshot.twig | 0 .../config/templates/check_mk/main.twig | 0 .../templates/check_mk/performance_data.twig | 0 .../templates/check_mk/short_summary.twig | 0 .../templates/check_mk/step_information.twig | 0 .../sakuli/common/libs/js/internal/inject.js | 0 .../org/sakuli/common/libs/js/sakuli.js | 0 .../common/libs/js/sakuli_Application.js | 0 .../common/libs/js/sakuli_Environment.js | 0 .../org/sakuli/common/libs/js/sakuli_Key.js | 0 .../sakuli/common/libs/js/sakuli_Logger.js | 0 .../common/libs/js/sakuli_MouseButton.js | 0 .../sakuli/common/libs/js/sakuli_Region.js | 0 .../sakuli/common/setup/database/Dockerfile | 0 .../setup/database/create_sakuli_database.sql | 0 .../database/migrate_sahi_table_names.sql | 0 .../setup/nagios/CheckMySQLHealthSakuli.pm | 0 .../setup/nagios/check_logon_session.ps1 | 0 .../common/setup/nagios/check_sakuli.cfg | 0 .../common/setup/nagios/check_sakuli.json | 0 .../common/setup/nagios/check_sakuli.php | 21 +- .../setup/nagios/fake_sakuli_results.sh | 0 .../gearman_proxy/sakuli_gearman_proxy.cfg | 0 .../gearman_proxy/sakuli_gearman_proxy.cron | 0 .../gearman_proxy/sakuli_gearman_proxy.pl | 0 .../sakuli/common/setup/nagios/getimage.pl | 0 .../setup/nagios/sakuli_nagios_objects.cfg | 0 .../extinfo-footer-sakuli.ssi | 0 .../sakuli_action_menu.conf | 0 .../sakuli_screenshot_eventhandler.cfg | 0 .../sakuli_screenshot_eventhandler.sh | 0 .../sakuli_screenshots.conf | 0 .../status-footer-sakuli.ssi | 0 .../etc/apache/conf.d/sakuli_screenshots.conf | 0 .../CheckMySQLHealthSakuli.pm | 0 .../omd/etc/cron.d/sakuli_screenshot_cleanup | 0 .../setup/omd/etc/init.d/sakuli_gearman_proxy | 0 .../etc/mod-gearman/sakuli_gearman_proxy.cfg | 0 .../nagios/conf.d/sakuli_nagios_objects.cfg | 0 .../conf.d/sakuli_screenshot_eventhandler.cfg | 0 .../common/setup/omd/etc/nagios/resource.cfg | 0 .../etc/pnp4nagios/templates/check_sakuli.php | 21 +- .../etc/thruk/ssi/extinfo-footer-sakuli.ssi | 0 .../etc/thruk/ssi/status-footer-sakuli.ssi | 0 .../setup/omd/etc/thruk/thruk_local.conf | 0 .../thruk_local.d/sakuli_action_menu.conf | 0 .../omd/local/bin/sakuli_gearman_proxy.pl | 0 .../local/bin/sakuli_screenshot_cleanup.sh | 0 .../plugins/sakuli_screenshot_eventhandler.sh | 0 .../nagios/htdocs/images/logos/sakuli.png | Bin src/sakuli-core/pom.xml | 460 ++++++++++++++++++ .../main/java/org/sakuli/actions/Action.java | 0 .../org/sakuli/actions/ModifySahiTimer.java | 0 .../org/sakuli/actions/TestCaseAction.java | 0 .../actions/environment/Application.java | 0 .../actions/environment/CipherUtil.java | 0 .../actions/environment/CommandLineUtil.java | 0 .../actions/environment/Environment.java | 6 +- .../sakuli/actions/logging/LogToResult.java | 0 .../org/sakuli/actions/logging/Logger.java | 0 .../org/sakuli/actions/screenbased/Key.java | 0 .../actions/screenbased/MouseButton.java | 0 .../sakuli/actions/screenbased/Region.java | 0 .../actions/screenbased/RegionImpl.java | 0 .../screenbased/ScreenshotActions.java | 0 .../actions/screenbased/TypingUtil.java | 0 .../actions/settings/ScreenBasedSettings.java | 0 .../java/org/sakuli/aop/BaseSakuliAspect.java | 0 .../org/sakuli/aop/ModifySahiTimerAspect.java | 0 .../main/java/org/sakuli/aop/RhinoAspect.java | 4 +- .../aop/SahiCommandExecutionAspect.java | 0 .../datamodel/AbstractTestDataEntity.java | 0 .../java/org/sakuli/datamodel/Builder.java | 0 .../java/org/sakuli/datamodel/TestCase.java | 1 - .../org/sakuli/datamodel/TestCaseStep.java | 1 - .../java/org/sakuli/datamodel/TestSuite.java | 1 - .../sakuli/datamodel/actions/ImageLib.java | 0 .../datamodel/actions/ImageLibObject.java | 0 .../sakuli/datamodel/actions/LogLevel.java | 0 .../sakuli/datamodel/actions/LogResult.java | 0 .../org/sakuli/datamodel/actions/Screen.java | 0 .../datamodel/builder/TestCaseBuilder.java | 0 .../builder/TestCaseStepBuilder.java | 18 + .../datamodel/helper/TestCaseHelper.java | 0 .../datamodel/helper/TestCaseStepHelper.java | 0 .../helper/TestDataEntityHelper.java | 18 + .../datamodel/helper/TestSuiteHelper.java | 0 .../properties/AbstractProperties.java | 0 .../properties/ActionProperties.java | 0 .../properties/ForwarderProperties.java | 0 .../properties/SahiProxyProperties.java | 0 .../properties/SakuliProperties.java | 0 .../properties/TestSuiteProperties.java | 0 .../sakuli/datamodel/state/SakuliState.java | 0 .../sakuli/datamodel/state/TestCaseState.java | 0 .../datamodel/state/TestCaseStepState.java | 0 .../datamodel/state/TestSuiteState.java | 0 .../exceptions/NonScreenshotException.java | 28 ++ .../exceptions/SahiActionException.java | 0 .../exceptions/SakuliActionException.java | 0 .../exceptions/SakuliCipherException.java | 0 .../sakuli/exceptions/SakuliException.java | 0 .../exceptions/SakuliExceptionHandler.java | 4 +- .../SakuliExceptionWithScreenshot.java | 0 .../exceptions/SakuliForwarderException.java | 0 .../exceptions/SakuliInitException.java | 0 .../exceptions/SakuliRuntimeException.java | 0 .../exceptions/SakuliValidationException.java | 0 .../org/sakuli/loader/BaseActionLoader.java | 0 .../sakuli/loader/BaseActionLoaderImpl.java | 0 .../java/org/sakuli/loader/BeanLoader.java | 0 .../org/sakuli/loader/ScreenActionLoader.java | 0 .../sakuli/loader/ScreenActionLoaderImpl.java | 0 .../sakuli/services/InitializingService.java | 0 .../services/InitializingServiceHelper.java | 0 .../sakuli/services/PrioritizedService.java | 0 .../PrioritizedServiceComparator.java | 0 .../org/sakuli/services/ResultService.java | 0 .../org/sakuli/services/TeardownService.java | 0 .../services/TeardownServiceHelper.java | 0 .../common/AbstractResultService.java | 0 .../CacheHandlingResultServiceImpl.java | 0 .../common/CommonInitializingServiceImpl.java | 0 .../common/CommonResultServiceImpl.java | 0 .../common/LogCleanUpResultServiceImpl.java | 0 .../AbstractMonitoringTemplateProperties.java | 0 .../forwarder/AbstractOutputBuilder.java | 1 - .../AbstractPerformanceDataBuilder.java | 0 .../AbstractTemplateOutputBuilder.java | 0 .../services/forwarder/OutputState.java | 0 .../services/forwarder/PlaceholderMap.java | 0 .../forwarder/ScreenshotDivConverter.java | 0 .../forwarder/checkmk/CheckMKProperties.java | 0 .../checkmk/CheckMKResultServiceImpl.java | 0 .../checkmk/CheckMKTemplateOutputBuilder.java | 0 .../forwarder/checkmk/ProfileCheckMK.java | 0 .../configuration/AbbreviateFunction.java | 19 +- .../configuration/AbstractFunction.java | 0 .../ExtractScreenshotFunction.java | 0 .../GetOutputDurationFunction.java | 0 .../configuration/GetOutputStateFunction.java | 0 .../configuration/IsBlankFunction.java | 0 .../LeadingWhitespaceRemover.java | 0 .../DatabaseInitializingServiceImpl.java | 0 .../database/DatabaseResultServiceImpl.java | 0 .../forwarder/database/ProfileJdbcDb.java | 0 .../forwarder/database/dao/DaoTestCase.java | 0 .../database/dao/DaoTestCaseStep.java | 0 .../forwarder/database/dao/DaoTestSuite.java | 0 .../forwarder/database/dao/impl/Dao.java | 0 .../database/dao/impl/DaoTestCaseImpl.java | 0 .../dao/impl/DaoTestCaseStepImpl.java | 0 .../database/dao/impl/DaoTestSuiteImpl.java | 0 .../gearman/GearmanCacheService.java | 4 +- .../GearmanInitializingServiceImpl.java | 0 .../forwarder/gearman/GearmanProperties.java | 16 +- .../gearman/GearmanResultServiceImpl.java | 0 .../forwarder/gearman/ProfileGearman.java | 0 .../forwarder/gearman/TextPlaceholder.java | 0 .../services/forwarder/gearman/crypt/Aes.java | 0 .../model/NagiosCachedCheckResult.java | 0 .../gearman/model/NagiosCheckResult.java | 0 .../forwarder/gearman/model/NagiosOutput.java | 0 .../gearman/model/NagiosPayloadString.java | 0 .../gearman/model/PayLoadFields.java | 0 .../gearman/model/ScreenshotDiv.java | 0 .../builder/NagiosCheckResultBuilder.java | 0 .../model/builder/NagiosExceptionBuilder.java | 0 .../model/builder/NagiosFormatter.java | 0 .../model/builder/NagiosOutputBuilder.java | 0 .../builder/NagiosPerformanceDataBuilder.java | 0 .../forwarder/icinga2/Icinga2Properties.java | 0 .../forwarder/icinga2/Icinga2RestCient.java | 0 .../icinga2/Icinga2ResultServiceImpl.java | 0 .../forwarder/icinga2/ProfileIcinga2.java | 0 .../icinga2/model/Icinga2Request.java | 0 .../icinga2/model/Icinga2Result.java | 0 .../builder/Icinga2CheckResultBuilder.java | 0 .../model/builder/Icinga2OutputBuilder.java | 0 .../Icinga2PerformanceDataBuilder.java | 0 .../model/builder/Icinga2RequestBuilder.java | 0 .../org/sakuli/starter/SahiConnector.java | 0 .../org/sakuli/starter/SakuliStarter.java | 0 .../sakuli/starter/helper/CmdPrintHelper.java | 0 .../starter/helper/ConnectionTester.java | 0 .../org/sakuli/starter/helper/SahiProxy.java | 0 .../starter/helper/SakuliFolderHelper.java | 0 .../java/org/sakuli/utils/CleanUpHelper.java | 0 .../org/sakuli/utils/LoggerInitializer.java | 0 .../java/org/sakuli/utils/ResourceHelper.java | 0 .../SakuliPropertyPlaceholderConfigurer.java | 0 .../utils/SpringProfilesInitializer.java | 0 .../java/org/sakuli/utils/SystemHelper.java | 0 .../src/main/resources/applicationContext.xml | 0 .../src/main/resources/beanRefFactory.xml | 0 .../src/main/resources/logback.xml | 0 .../java/org/sakuli/AbstractLogAwareTest.java | 0 .../src/test/java/org/sakuli/BaseTest.java | 2 +- .../src/test/java/org/sakuli/LoggerTest.java | 0 .../java/org/sakuli/MockitoFactoryBean.java | 0 .../org/sakuli/MockitoSpyFactoryBean.java | 0 .../test/java/org/sakuli/PropertyHolder.java | 0 .../sakuli/actions/TestCaseActionTest.java | 0 .../actions/environment/EnvironmentTest.java | 0 .../actions/screenbased/RegionImplTest.java | 0 .../actions/screenbased/RegionTestImpl.java | 0 ...enBasedSettingsSikuliLogSystemOutTest.java | 0 .../screenbased/ScreenBasedSettingsTest.java | 0 .../test/java/org/sakuli/aop/AopBaseTest.java | 0 .../sakuli/aop/ModifySahiTimerAspectTest.java | 0 .../java/org/sakuli/aop/RhinoAspectTest.java | 0 .../aop/SahiCommandExecutionAspectTest.java | 0 .../org/sakuli/builder/ExampleBuilder.java | 0 .../builder/TestCaseExampleBuilder.java | 0 .../builder/TestCaseStepExampleBuilder.java | 0 .../builder/TestSuiteExampleBuilder.java | 0 .../builder/TestSuiteExampleFactory.java | 43 ++ .../datamodel/AbstractTestDataEntityTest.java | 1 - .../sakuli/datamodel/TestCaseStepTest.java | 0 .../org/sakuli/datamodel/TestCaseTest.java | 0 .../org/sakuli/datamodel/TestSuiteTest.java | 5 +- .../datamodel/actions/ImageLibObjectTest.java | 18 + .../datamodel/actions/ImageLibTest.java | 18 + .../builder/TestCaseStepBuilderTest.java | 0 .../helper/TestCaseStepHelperTest.java | 0 .../helper/TestDataEntityHelperTest.java | 18 + .../datamodel/helper/TestSuiteHelperTest.java | 0 .../properties/AbstractPropertiesTest.java | 0 .../properties/ActionPropertiesTest.java | 0 .../datamodel/state/TestCaseStateTest.java | 0 .../state/TestCaseStepStateTest.java | 0 .../datamodel/state/TestSuiteStateTest.java | 0 .../SakuliExceptionHandlerTest.java | 3 +- .../sakuli/loader/BaseActionLoaderTest.java | 0 .../org/sakuli/loader/BeanLoaderTest.java | 0 .../services/AbstractServiceBaseTest.java | 38 ++ .../InitializingServiceHelperTest.java | 0 .../PrioritizedServiceComparatorTest.java | 0 .../services/TeardownServiceHelperTest.java | 0 .../common/AbstractResultServiceTest.java | 0 .../CacheHandlingResultServiceImplTest.java | 0 .../CommonInitializingServiceImplTest.java | 0 .../common/CommonResultServiceImplTest.java | 5 +- .../common/CommonResultServiceMockImpl.java | 2 - .../LogCleanUpResultServiceImplTest.java | 0 .../forwarder/AbstractOutputBuilderTest.java | 7 +- .../AbstractPerformanceDataBuilderTest.java | 0 .../AbstractTemplateOutputBuilderTest.java | 0 .../MonitoringPropertiesTestHelper.java | 0 .../services/forwarder/OutputStateTest.java | 0 .../forwarder/PlaceholderMapTest.java | 0 .../forwarder/ScreenshotDivConverterTest.java | 0 .../checkmk/CheckMKResultServiceImplTest.java | 0 .../CheckMKTemplateOutputBuilderTest.java | 3 +- .../LeadingWhitespaceRemoverTest.java | 2 +- .../DatabaseInitializingServiceImplTest.java | 0 .../DatabaseResultServiceImplTest.java | 0 .../forwarder/database/dao/DaoTest.java | 0 .../dao/impl/DaoTestCaseImplTest.java | 0 .../gearman/GearmanCacheServiceTest.java | 7 +- .../gearman/GearmanResultServiceImplTest.java | 0 .../forwarder/gearman/crypt/AesTest.java | 4 +- .../gearman/model/NagiosCheckResultTest.java | 0 .../gearman/model/ScreenshotDivTest.java | 0 .../builder/NagiosExceptionBuilderTest.java | 0 .../builder/NagiosOutputBuilderTest.java | 0 .../NagiosPerformanceDataBuilderTest.java | 0 .../AbstractIcinga2ForwarderBaseTest.java | 0 .../icinga2/Icinga2RestCientTest.java | 0 .../icinga2/Icinga2ResultServiceImplTest.java | 0 .../icinga2/Icinga2ResultServiceTest.java | 0 .../icinga2/ManualIcinga2ResultTest.java | 0 .../icinga2/model/Icinga2ResultTest.java | 0 .../Icinga2CheckResultBuilderTest.java | 0 .../builder/Icinga2OutputBuilderTest.java | 0 .../Icinga2PerformanceDataBuilderTest.java | 0 .../org/sakuli/starter/SahiConnectorTest.java | 0 .../org/sakuli/starter/SakuliStarterTest.java | 0 .../starter/helper/CmdPrintHelperTest.java | 0 .../starter/helper/ConnectionTesterTest.java | 0 .../sakuli/starter/helper/SahiProxyTest.java | 0 .../helper/SakuliFolderHelperTest.java | 0 .../org/sakuli/utils/CipherUtilsTest.java | 0 .../sakuli/utils/LoggerInitializerTest.java | 0 .../org/sakuli/utils/ResourceHelperTest.java | 0 ...kuliPropertyPlaceholderConfigurerTest.java | 0 .../utils/SpringProfilesInitializerTest.java | 0 .../utils/TestSuitePropertiesTestUtils.java | 0 .../resources/JUnit-applicationContext.xml | 0 .../test/resources/JUnit-beanRefFactory.xml | 0 .../test/resources/JUnit-sakuli.properties | 0 .../_testsuite4JUnit/.cache/gearman.cache | 0 .../resources/_testsuite4JUnit/.gitignore | 0 .../resources/_testsuite4JUnit/case/tc.js | 0 .../_testsuite4JUnit/testsuite.properties | 0 .../_testsuite4JUnit/testsuite.suite | 0 .../_testsuite4aop/testsuite.properties | 0 .../resources/_testsuite4aop/testsuite.suite | 0 .../test/resources/aopTest-beanRefFactory.xml | 0 .../resources/icinga2Test-beanRefFactory.xml | 0 .../resources/loaderTest-beanRefFactory.xml | 0 .../sakuli/aop/aopTest-applicationContext.xml | 0 .../sakuli/datamodel/actions/calc.jpged.jpg | Bin .../sakuli/datamodel/actions/calc.pngfile.PNG | Bin .../sakuli/datamodel/helper/stephelper/tc.js | 0 .../datamodel/helper/unvalid/testsuite.suite | 0 .../datamodel/helper/valid/testsuite.suite | 0 .../helper/valid/validTestCase/_tc.js | 0 .../loader/loaderTest-applicationContext.xml | 0 .../services/common/unvalid/testsuite.suite | 0 .../services/common/valid/testsuite.suite | 0 .../common/valid/validTestCase/_tc.js | 0 .../output/TestCase_CRITICAL_IN_CASE.txt | 0 .../output/TestCase_CRITICAL_IN_SUITE.txt | 0 .../checkmk/output/TestCase_ERRORS.txt | 0 .../forwarder/checkmk/output/TestCase_OK.txt | 0 .../output/TestCase_WARNING_IN_CASE.txt | 0 .../output/TestCase_WARNING_IN_STEP.txt | 0 .../output/TestCase_WARNING_IN_SUITE.txt | 0 .../forwarder/database/dao/impl/computer.png | Bin .../gearman/model/builder/computer.png | Bin .../icinga2-testsuite/testsuite.properties | 0 .../icinga2Test-applicationContext.xml | 0 .../serviceTest-applicationContext.xml | 0 .../sakuli/starter/helper/inject_source.js | 0 .../starter/helper/mock-files/inject_top.txt | 0 .../starter/helper/mock-old-js/inject.js | 0 .../starter/helper/unvalid/testsuite.suite | 0 .../helper/unvalid2/testsuite.properties | 0 .../testsuite.properties | 0 .../org/sakuli/utils/classpath-resource.file | 0 .../testsuite.properties | 0 .../utils/properties-test/target.properties | 0 .../resources/property_test/sakuli.properties | 0 .../suite_folder/testsuite.properties | 0 .../resources/serviceTest-beanRefFactory.xml | 0 src/{installer => sakuli-installer}/pom.xml | 6 +- .../src/main/resources/ProcessPanel.Spec.xml | 0 .../src/main/resources/izpack-installer.xml | 0 .../src/main/resources/langpacks/deu.xml | 0 .../src/main/resources/langpacks/eng.xml | 0 .../src/main/resources/pic/reboot-logo.png | Bin .../src/main/resources/qres/QRes.exe | Bin .../src/main/resources/qres/qres.htm | 18 + .../src/main/resources/reboot-hint.html | 0 .../src/main/resources/reboot-hint.html_deu | 0 src/{java-dsl => sakuli-java-dsl}/pom.xml | 14 +- .../sakuli/javaDSL/TestCaseInitParameter.java | 0 .../javaDSL/aop/ExceptionHandlerAspect.java | 0 .../service/SahiInitializingService.java | 40 ++ .../service/SahiIntializingServiceImpl.java | 18 + ...kuliJavaPropertyPlaceholderConfigurer.java | 0 .../resources/java-dsl-applicationContext.xml | 0 .../resources/java-dsl-beanRefFactory.xml | 0 .../test/java/org/sakuli/example/Example.java | 0 .../sakuli/javaDSL/AbstractSakuliTest.java | 0 .../javaDSL/SakuliExceptionListener.java | 18 + .../org/sakuli/example/test1/placeholder.txt | 0 .../org/sakuli/example/test1/sahi_logo.png | Bin .../org/sakuli/example/testsuite.properties | 0 .../resources/org/sakuli/sakuli.properties | 0 .../descriptor_zip_release.xml | 0 src/{core => sakuli-sahi-setup}/pom.xml | 51 +- .../sahi/config/browser_types/linux.xml | 0 .../sahi/config/browser_types/mac.xml | 0 .../sahi/config/browser_types/win32.xml | 0 .../sahi/config/browser_types/win64.xml | 0 .../config/ff_profile_template/localstore.rdf | 0 .../sahi/config/ff_profile_template/prefs.js | 0 .../userdata/config/download_contenttypes.txt | 0 431 files changed, 938 insertions(+), 189 deletions(-) delete mode 100644 src/core/src/main/java/org/sakuli/exceptions/NonScreenshotException.java delete mode 100644 src/core/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java delete mode 100644 src/core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java delete mode 100644 src/java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiInitializingService.java rename src/{common => sakuli-common}/pom.xml (97%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/.bashrc (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/LOGOFF.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/ff_purge_profile.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/git_prehook.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/git_status.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/killproc.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/logoff.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/modwindow.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/mysql_purge.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/procs_to_kill.txt (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/record.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/resolution.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/sakuli_ctrl.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/showprocs.vbs (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/toggle_swap.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/helper/vnc.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/linux/install_firefox_portable.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/linux/set_sakuli_home.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/linux/set_ui_testing_variables.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/install_firefox_portable.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/ps/install_firefox_portable.ps1 (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/ps/modfiy_ui_testing_variables.ps1 (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/ps/modfiy_user_permissions.ps1 (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/ps/modfiy_user_variables.ps1 (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/set_sakuli_home.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/set_ui_testing_variables.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/installer_scripts/win/set_user_permissions.bat (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/resources/robotic1.png (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/bin/resources/version.txt (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/sakuli-default.properties (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/sakuli-log-config.xml (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/case_information.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/detailed_summary.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/detailed_summary_css_styles.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/error_message_creator.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/exception_screenshot.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/main.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/performance_data.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/short_summary.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/config/templates/check_mk/step_information.twig (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/internal/inject.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_Application.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_Environment.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_Key.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_Logger.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_MouseButton.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/libs/js/sakuli_Region.js (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/database/Dockerfile (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/database/create_sakuli_database.sql (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/database/migrate_sahi_table_names.sql (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/CheckMySQLHealthSakuli.pm (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/check_logon_session.ps1 (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.json (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.php (97%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/fake_sakuli_results.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/gearman_proxy/sakuli_gearman_proxy.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/gearman_proxy/sakuli_gearman_proxy.cron (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/gearman_proxy/sakuli_gearman_proxy.pl (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/getimage.pl (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/sakuli_nagios_objects.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/extinfo-footer-sakuli.ssi (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/sakuli_action_menu.conf (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/sakuli_screenshot_eventhandler.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/sakuli_screenshot_eventhandler.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/sakuli_screenshots.conf (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/nagios/screenshot_history/status-footer-sakuli.ssi (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/apache/conf.d/sakuli_screenshots.conf (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/check_mysql_health/CheckMySQLHealthSakuli.pm (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/cron.d/sakuli_screenshot_cleanup (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/init.d/sakuli_gearman_proxy (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/mod-gearman/sakuli_gearman_proxy.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/nagios/conf.d/sakuli_nagios_objects.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/nagios/conf.d/sakuli_screenshot_eventhandler.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/nagios/resource.cfg (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/pnp4nagios/templates/check_sakuli.php (97%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/thruk/ssi/extinfo-footer-sakuli.ssi (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/thruk/ssi/status-footer-sakuli.ssi (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/thruk/thruk_local.conf (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/etc/thruk/thruk_local.d/sakuli_action_menu.conf (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/local/bin/sakuli_gearman_proxy.pl (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/local/bin/sakuli_screenshot_cleanup.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/local/lib/nagios/plugins/sakuli_screenshot_eventhandler.sh (100%) rename src/{common => sakuli-common}/src/main/resources/org/sakuli/common/setup/omd/local/share/nagios/htdocs/images/logos/sakuli.png (100%) create mode 100644 src/sakuli-core/pom.xml rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/Action.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/ModifySahiTimer.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/TestCaseAction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/environment/Application.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/environment/CipherUtil.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/environment/CommandLineUtil.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/environment/Environment.java (98%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/logging/LogToResult.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/logging/Logger.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/Key.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/MouseButton.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/Region.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/RegionImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/ScreenshotActions.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/screenbased/TypingUtil.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/actions/settings/ScreenBasedSettings.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/aop/BaseSakuliAspect.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/aop/ModifySahiTimerAspect.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/aop/RhinoAspect.java (98%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/aop/SahiCommandExecutionAspect.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/AbstractTestDataEntity.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/Builder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/TestCase.java (99%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/TestCaseStep.java (97%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/TestSuite.java (99%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/actions/ImageLib.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/actions/ImageLibObject.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/actions/LogLevel.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/actions/LogResult.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/actions/Screen.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/builder/TestCaseBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/builder/TestCaseStepBuilder.java (61%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/helper/TestCaseHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/helper/TestCaseStepHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/helper/TestDataEntityHelper.java (69%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/helper/TestSuiteHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/AbstractProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/ActionProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/ForwarderProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/SahiProxyProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/TestSuiteProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/state/SakuliState.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/state/TestCaseState.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/state/TestCaseStepState.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/state/TestSuiteState.java (100%) create mode 100644 src/sakuli-core/src/main/java/org/sakuli/exceptions/NonScreenshotException.java rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SahiActionException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliActionException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliCipherException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java (99%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliExceptionWithScreenshot.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliForwarderException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliInitException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliRuntimeException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/exceptions/SakuliValidationException.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/loader/BaseActionLoader.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/loader/BeanLoader.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/loader/ScreenActionLoader.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/InitializingService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/InitializingServiceHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/PrioritizedService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/PrioritizedServiceComparator.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/ResultService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/TeardownService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/TeardownServiceHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/common/AbstractResultService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/common/CacheHandlingResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/common/CommonInitializingServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/common/CommonResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/common/LogCleanUpResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/AbstractMonitoringTemplateProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/AbstractOutputBuilder.java (99%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/AbstractPerformanceDataBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/AbstractTemplateOutputBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/OutputState.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/PlaceholderMap.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/ScreenshotDivConverter.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/checkmk/CheckMKProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/checkmk/CheckMKResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/checkmk/CheckMKTemplateOutputBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/checkmk/ProfileCheckMK.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/AbbreviateFunction.java (74%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/AbstractFunction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/ExtractScreenshotFunction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/GetOutputDurationFunction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/GetOutputStateFunction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/IsBlankFunction.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/configuration/LeadingWhitespaceRemover.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/DatabaseInitializingServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/DatabaseResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/ProfileJdbcDb.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/DaoTestCase.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/DaoTestCaseStep.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/DaoTestSuite.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/impl/Dao.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/impl/DaoTestCaseImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/impl/DaoTestCaseStepImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/database/dao/impl/DaoTestSuiteImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/GearmanCacheService.java (98%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/GearmanInitializingServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/GearmanProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/GearmanResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/ProfileGearman.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/TextPlaceholder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/crypt/Aes.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/NagiosCachedCheckResult.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/NagiosCheckResult.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/NagiosOutput.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/NagiosPayloadString.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/PayLoadFields.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/ScreenshotDiv.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosCheckResultBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosExceptionBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosFormatter.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosOutputBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosPerformanceDataBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/Icinga2Properties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/Icinga2RestCient.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/Icinga2ResultServiceImpl.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/ProfileIcinga2.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/Icinga2Request.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/Icinga2Result.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2CheckResultBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2OutputBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2PerformanceDataBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2RequestBuilder.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/SahiConnector.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/SakuliStarter.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/helper/CmdPrintHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/helper/ConnectionTester.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/helper/SahiProxy.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/starter/helper/SakuliFolderHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/CleanUpHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/LoggerInitializer.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/ResourceHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/SpringProfilesInitializer.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/SystemHelper.java (100%) rename src/{core => sakuli-core}/src/main/resources/applicationContext.xml (100%) rename src/{core => sakuli-core}/src/main/resources/beanRefFactory.xml (100%) rename src/{core => sakuli-core}/src/main/resources/logback.xml (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/AbstractLogAwareTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/BaseTest.java (97%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/LoggerTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/MockitoFactoryBean.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/MockitoSpyFactoryBean.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/PropertyHolder.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/TestCaseActionTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/environment/EnvironmentTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/screenbased/RegionImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/screenbased/RegionTestImpl.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/screenbased/ScreenBasedSettingsSikuliLogSystemOutTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/screenbased/ScreenBasedSettingsTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/aop/AopBaseTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/aop/ModifySahiTimerAspectTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/aop/RhinoAspectTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/aop/SahiCommandExecutionAspectTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/builder/ExampleBuilder.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/builder/TestCaseExampleBuilder.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/builder/TestCaseStepExampleBuilder.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/builder/TestSuiteExampleBuilder.java (100%) create mode 100644 src/sakuli-core/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/AbstractTestDataEntityTest.java (98%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/TestCaseStepTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/TestCaseTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/TestSuiteTest.java (98%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/actions/ImageLibObjectTest.java (72%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/actions/ImageLibTest.java (54%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/builder/TestCaseStepBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/helper/TestCaseStepHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/helper/TestDataEntityHelperTest.java (64%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/helper/TestSuiteHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/properties/AbstractPropertiesTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/properties/ActionPropertiesTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/state/TestCaseStateTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/state/TestCaseStepStateTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/state/TestSuiteStateTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java (99%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/loader/BaseActionLoaderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/loader/BeanLoaderTest.java (100%) create mode 100644 src/sakuli-core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/InitializingServiceHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/PrioritizedServiceComparatorTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/TeardownServiceHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/AbstractResultServiceTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/CacheHandlingResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/CommonInitializingServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/CommonResultServiceImplTest.java (98%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/CommonResultServiceMockImpl.java (94%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/common/LogCleanUpResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/AbstractOutputBuilderTest.java (99%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/AbstractPerformanceDataBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/AbstractTemplateOutputBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/MonitoringPropertiesTestHelper.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/OutputStateTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/PlaceholderMapTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/ScreenshotDivConverterTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/checkmk/CheckMKResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/checkmk/CheckMKTemplateOutputBuilderTest.java (99%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/configuration/LeadingWhitespaceRemoverTest.java (97%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/database/DatabaseInitializingServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/database/DatabaseResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/database/dao/DaoTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/database/dao/impl/DaoTestCaseImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/GearmanCacheServiceTest.java (97%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/GearmanResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/crypt/AesTest.java (96%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/model/NagiosCheckResultTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/model/ScreenshotDivTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosExceptionBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosOutputBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/gearman/model/builder/NagiosPerformanceDataBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/AbstractIcinga2ForwarderBaseTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/Icinga2RestCientTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/Icinga2ResultServiceImplTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/Icinga2ResultServiceTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/ManualIcinga2ResultTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/model/Icinga2ResultTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2CheckResultBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2OutputBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/forwarder/icinga2/model/builder/Icinga2PerformanceDataBuilderTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/SahiConnectorTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/SakuliStarterTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/helper/CmdPrintHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/helper/ConnectionTesterTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/helper/SahiProxyTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/starter/helper/SakuliFolderHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/CipherUtilsTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/LoggerInitializerTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/ResourceHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/SpringProfilesInitializerTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/TestSuitePropertiesTestUtils.java (100%) rename src/{core => sakuli-core}/src/test/resources/JUnit-applicationContext.xml (100%) rename src/{core => sakuli-core}/src/test/resources/JUnit-beanRefFactory.xml (100%) rename src/{core => sakuli-core}/src/test/resources/JUnit-sakuli.properties (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4JUnit/.cache/gearman.cache (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4JUnit/.gitignore (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4JUnit/case/tc.js (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4JUnit/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4JUnit/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4aop/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/_testsuite4aop/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/aopTest-beanRefFactory.xml (100%) rename src/{core => sakuli-core}/src/test/resources/icinga2Test-beanRefFactory.xml (100%) rename src/{core => sakuli-core}/src/test/resources/loaderTest-beanRefFactory.xml (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/actions/calc.jpged.jpg (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/actions/calc.pngfile.PNG (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/helper/stephelper/tc.js (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/helper/unvalid/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/helper/valid/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/datamodel/helper/valid/validTestCase/_tc.js (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/loader/loaderTest-applicationContext.xml (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/common/unvalid/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/common/valid/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/common/valid/validTestCase/_tc.js (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_CRITICAL_IN_CASE.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_CRITICAL_IN_SUITE.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_ERRORS.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_OK.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_WARNING_IN_CASE.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_WARNING_IN_STEP.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/checkmk/output/TestCase_WARNING_IN_SUITE.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/database/dao/impl/computer.png (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/gearman/model/builder/computer.png (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2-testsuite/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/services/serviceTest-applicationContext.xml (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/starter/helper/inject_source.js (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/starter/helper/mock-files/inject_top.txt (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/starter/helper/mock-old-js/inject.js (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/starter/helper/unvalid/testsuite.suite (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/starter/helper/unvalid2/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/utils/all-persistcence-services/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/utils/classpath-resource.file (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/utils/no-persistcence-services/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/utils/properties-test/target.properties (100%) rename src/{core => sakuli-core}/src/test/resources/property_test/sakuli.properties (100%) rename src/{core => sakuli-core}/src/test/resources/property_test/suite_folder/testsuite.properties (100%) rename src/{core => sakuli-core}/src/test/resources/serviceTest-beanRefFactory.xml (100%) rename src/{installer => sakuli-installer}/pom.xml (98%) rename src/{installer => sakuli-installer}/src/main/resources/ProcessPanel.Spec.xml (100%) rename src/{installer => sakuli-installer}/src/main/resources/izpack-installer.xml (100%) rename src/{installer => sakuli-installer}/src/main/resources/langpacks/deu.xml (100%) rename src/{installer => sakuli-installer}/src/main/resources/langpacks/eng.xml (100%) rename src/{installer => sakuli-installer}/src/main/resources/pic/reboot-logo.png (100%) rename src/{installer => sakuli-installer}/src/main/resources/qres/QRes.exe (100%) rename src/{installer => sakuli-installer}/src/main/resources/qres/qres.htm (93%) rename src/{installer => sakuli-installer}/src/main/resources/reboot-hint.html (100%) rename src/{installer => sakuli-installer}/src/main/resources/reboot-hint.html_deu (100%) rename src/{java-dsl => sakuli-java-dsl}/pom.xml (96%) rename src/{java-dsl => sakuli-java-dsl}/src/main/java/org/sakuli/javaDSL/TestCaseInitParameter.java (100%) rename src/{java-dsl => sakuli-java-dsl}/src/main/java/org/sakuli/javaDSL/aop/ExceptionHandlerAspect.java (100%) create mode 100644 src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiInitializingService.java rename src/{java-dsl => sakuli-java-dsl}/src/main/java/org/sakuli/javaDSL/service/SahiIntializingServiceImpl.java (73%) rename src/{java-dsl => sakuli-java-dsl}/src/main/java/org/sakuli/javaDSL/utils/SakuliJavaPropertyPlaceholderConfigurer.java (100%) rename src/{java-dsl => sakuli-java-dsl}/src/main/resources/java-dsl-applicationContext.xml (100%) rename src/{java-dsl => sakuli-java-dsl}/src/main/resources/java-dsl-beanRefFactory.xml (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/java/org/sakuli/example/Example.java (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/java/org/sakuli/javaDSL/AbstractSakuliTest.java (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/java/org/sakuli/javaDSL/SakuliExceptionListener.java (54%) rename src/{java-dsl => sakuli-java-dsl}/src/test/resources/org/sakuli/example/test1/placeholder.txt (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/resources/org/sakuli/example/test1/sahi_logo.png (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/resources/org/sakuli/example/testsuite.properties (100%) rename src/{java-dsl => sakuli-java-dsl}/src/test/resources/org/sakuli/sakuli.properties (100%) rename src/{core => sakuli-sahi-setup}/descriptor_zip_release.xml (100%) rename src/{core => sakuli-sahi-setup}/pom.xml (91%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/browser_types/linux.xml (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/browser_types/mac.xml (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/browser_types/win32.xml (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/browser_types/win64.xml (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/ff_profile_template/localstore.rdf (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/config/ff_profile_template/prefs.js (100%) rename src/{core => sakuli-sahi-setup}/src/main/resources/sahi/userdata/config/download_contenttypes.txt (100%) diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli index dea62008..ca5f3fe2 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli @@ -19,7 +19,7 @@ ENV REMOTE_GIT git://github.com/ConSol/sakuli.git # fallback if git protocol is not possible ENV REMOTE_HTTPS https://github.com/ConSol/sakuli.git # checkout only this folder -ENV SPARSEDIR src/common/src/main/resources/org/sakuli/common/setup/omd +ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli index 644c1010..fc18e2ac 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli @@ -19,7 +19,7 @@ ENV REMOTE_GIT git://github.com/ConSol/sakuli.git # fallback if git protocol is not possible ENV REMOTE_HTTPS https://github.com/ConSol/sakuli.git # checkout only this folder -ENV SPARSEDIR src/common/src/main/resources/org/sakuli/common/setup/omd +ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli index 8bb780d6..00f7aabc 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli @@ -19,7 +19,7 @@ ENV REMOTE_GIT git://github.com/ConSol/sakuli.git # fallback if git protocol is not possible ENV REMOTE_HTTPS https://github.com/ConSol/sakuli.git # checkout only this folder -ENV SPARSEDIR src/common/src/main/resources/org/sakuli/common/setup/omd +ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ diff --git a/docs/development/installation-developers.md b/docs/development/installation-developers.md index 3724e17a..04602145 100644 --- a/docs/development/installation-developers.md +++ b/docs/development/installation-developers.md @@ -63,7 +63,7 @@ Setup a local MySQL database to save the results of test case executions. The da * __User:__ `sakuli` * __Password:__ `sakuli` * __Database:__ `sakuli` -* __SQL-Script:__ [create_sakuli_database](../../src/common/src/main/resources/org/sakuli/common/setup/database/create_sakuli_database.sql) +* __SQL-Script:__ [create_sakuli_database](../../src/sakuli-common/src/main/resources/org/sakuli/common/setup/database/create_sakuli_database.sql) If you want to use a Docker-Container, you can build and run it with the following commands: diff --git a/docs/development/intellij/runConfigurations/DEV___Ubuntu.xml b/docs/development/intellij/runConfigurations/DEV___Ubuntu.xml index bc59e780..892d18c3 100644 --- a/docs/development/intellij/runConfigurations/DEV___Ubuntu.xml +++ b/docs/development/intellij/runConfigurations/DEV___Ubuntu.xml @@ -22,7 +22,7 @@
diff --git a/src/core/src/main/resources/sahi/config/browser_types/linux.xml b/src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/linux.xml similarity index 100% rename from src/core/src/main/resources/sahi/config/browser_types/linux.xml rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/linux.xml diff --git a/src/core/src/main/resources/sahi/config/browser_types/mac.xml b/src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/mac.xml similarity index 100% rename from src/core/src/main/resources/sahi/config/browser_types/mac.xml rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/mac.xml diff --git a/src/core/src/main/resources/sahi/config/browser_types/win32.xml b/src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/win32.xml similarity index 100% rename from src/core/src/main/resources/sahi/config/browser_types/win32.xml rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/win32.xml diff --git a/src/core/src/main/resources/sahi/config/browser_types/win64.xml b/src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/win64.xml similarity index 100% rename from src/core/src/main/resources/sahi/config/browser_types/win64.xml rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/browser_types/win64.xml diff --git a/src/core/src/main/resources/sahi/config/ff_profile_template/localstore.rdf b/src/sakuli-sahi-setup/src/main/resources/sahi/config/ff_profile_template/localstore.rdf similarity index 100% rename from src/core/src/main/resources/sahi/config/ff_profile_template/localstore.rdf rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/ff_profile_template/localstore.rdf diff --git a/src/core/src/main/resources/sahi/config/ff_profile_template/prefs.js b/src/sakuli-sahi-setup/src/main/resources/sahi/config/ff_profile_template/prefs.js similarity index 100% rename from src/core/src/main/resources/sahi/config/ff_profile_template/prefs.js rename to src/sakuli-sahi-setup/src/main/resources/sahi/config/ff_profile_template/prefs.js diff --git a/src/core/src/main/resources/sahi/userdata/config/download_contenttypes.txt b/src/sakuli-sahi-setup/src/main/resources/sahi/userdata/config/download_contenttypes.txt similarity index 100% rename from src/core/src/main/resources/sahi/userdata/config/download_contenttypes.txt rename to src/sakuli-sahi-setup/src/main/resources/sahi/userdata/config/download_contenttypes.txt From ca3c28e7a7398f8809d2841b6fbd0e12b434793f Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 19 Apr 2017 17:22:39 +0200 Subject: [PATCH 06/21] #247 fix copyright dublicated --- .../org/sakuli/common/setup/nagios/check_sakuli.php | 13 ------------- .../omd/etc/pnp4nagios/templates/check_sakuli.php | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/src/sakuli-common/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.php b/src/sakuli-common/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.php index 99268f7d..9ef813a0 100644 --- a/src/sakuli-common/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.php +++ b/src/sakuli-common/src/main/resources/org/sakuli/common/setup/nagios/check_sakuli.php @@ -21,19 +21,6 @@ # Simon Meggle, # See https://github.com/ConSol/sakuli for more information. -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 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 Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - # helper functions ############################################## # Pad the string with spaces to ensure column alignment diff --git a/src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd/etc/pnp4nagios/templates/check_sakuli.php b/src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd/etc/pnp4nagios/templates/check_sakuli.php index 99268f7d..9ef813a0 100644 --- a/src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd/etc/pnp4nagios/templates/check_sakuli.php +++ b/src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd/etc/pnp4nagios/templates/check_sakuli.php @@ -21,19 +21,6 @@ # Simon Meggle, # See https://github.com/ConSol/sakuli for more information. -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 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 Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - # helper functions ############################################## # Pad the string with spaces to ensure column alignment From fe752190aa21ddd82cf6c4266babf25f5d9b5697 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Thu, 13 Apr 2017 12:18:57 +0200 Subject: [PATCH 07/21] add JAXenter article to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f69de972..fa3a41dc 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ for web sites and common UIs with full Nagios integration](https://rawgit.com/to ## Publications +03/2017: [JAXenter: End-2-End-Testing und -Monitoring im Container-Zeitalter](https://jaxenter.de/sakuli-testing-monitoring-container-54374) (Tobias Schneck) + 01/2017: [Java aktuell: Automatisiertes Testen in Zeiten von Microservices](https://www.consol.de/fileadmin/pdf/news/news-events/01_2017-Java_aktuell-Magazin-Christoph-Deppisch-und-Tobias-Schneck_Automatisiertes-Testen-in-Zeiten-von-Microservices.pdf) (Christoph Deppisch / Tobias Schneck) 10/2016: [Informatik Aktuell: Software-Test im Container: So können Sie Graphical User Interfaces mit Docker und Sakuli testen](https://www.informatik-aktuell.de/entwicklung/methoden/graphical-user-interface-gui-in-containern-testen.html) (Tobias Schneck) From 5075243443e30407cb8aa5332a5cbea3c01cc2c3 Mon Sep 17 00:00:00 2001 From: Simon Meggle Date: Fri, 21 Apr 2017 11:18:14 +0200 Subject: [PATCH 08/21] Added tag fetching to sparse checkout --- docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli | 2 +- docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli | 2 +- docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli index ca5f3fe2..518baf80 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-centos-sakuli @@ -23,7 +23,7 @@ ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ - git fetch origin &&\ + git fetch --tags origin &&\ git config core.sparseCheckout true &&\ echo "$SPARSEDIR" > .git/info/sparse-checkout &&\ git checkout $SOURCE_BRANCH &&\ diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli index fc18e2ac..0f4525b6 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-debian-sakuli @@ -23,7 +23,7 @@ ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ - git fetch origin &&\ + git fetch --tags origin &&\ git config core.sparseCheckout true &&\ echo "$SPARSEDIR" > .git/info/sparse-checkout &&\ git checkout $SOURCE_BRANCH &&\ diff --git a/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli b/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli index 00f7aabc..ffcfc576 100644 --- a/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli +++ b/docker/omd-labs-sakuli/Dockerfile.omd-labs-ubuntu-sakuli @@ -23,7 +23,7 @@ ENV SPARSEDIR src/sakuli-common/src/main/resources/org/sakuli/common/setup/omd RUN echo "Built from $REMOTE_GIT/$SOURCE_BRANCH" > /root/sakuli_git_info && cat /root/sakuli_git_info RUN /bin/bash -c "mkdir $SRCDIR && pushd $SRCDIR && git init &&\ (git remote add -f origin $REMOTE_GIT || git remote set-url origin $REMOTE_HTTPS) &&\ - git fetch origin &&\ + git fetch --tags origin &&\ git config core.sparseCheckout true &&\ echo "$SPARSEDIR" > .git/info/sparse-checkout &&\ git checkout $SOURCE_BRANCH &&\ From 1ffcad0b3c57beb6db7bdb5605e8146de0bf396d Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 24 Apr 2017 21:29:45 +0200 Subject: [PATCH 09/21] #247 big module refactoring to make sakuli-core indepedent from sahi // a new module sakuli-sahi-setup will contain all the sahi stuff --- docs/additional-settings.md | 2 +- docs/development/installation-developers.md | 2 +- pom.xml | 3 +- src/basic-test-util/pom.xml | 118 +++++++++ .../java/org/sakuli/AbstractBaseTest.java | 56 +++++ .../java/org/sakuli/AbstractLogAwareTest.java | 27 +-- .../java/org/sakuli/MockitoFactoryBean.java | 0 .../org/sakuli/MockitoSpyFactoryBean.java | 0 .../test/java/org/sakuli/PropertyHolder.java | 0 src/integration-test/pom.xml | 2 +- .../integration/dao/DaoIntegrationTest.java | 4 +- .../integration/dao/db-applicationContext.xml | 1 - .../integration/dao}/db-beanRefFactory.xml | 0 src/sakuli-common/pom.xml | 2 +- src/sakuli-core/pom.xml | 190 +-------------- .../actions/environment/Environment.java | 38 +-- .../sakuli/actions/logging/LogToResult.java | 3 +- .../actions/logging/LogToResultCallback.java | 36 +++ .../org/sakuli/actions/logging/Logger.java | 5 +- .../sakuli/actions/screenbased/Region.java | 42 ++-- .../UserInterfaceInputAction.java} | 16 +- .../UserInterfaceInputActionCallback.java | 41 ++++ .../java/org/sakuli/aop/BaseSakuliAspect.java | 42 +++- .../sakuli/aop/LogActionExecutedAspect.java | 125 ++++++++++ .../main/java/org/sakuli/aop/RhinoAspect.java | 223 ------------------ ...serInterfaceInputActionExecutedAspect.java | 98 ++++++++ .../sakuli/datamodel/actions/LogLevel.java | 20 +- .../properties/SakuliProperties.java | 11 - .../exceptions/SakuliExceptionHandler.java | 94 ++------ .../sakuli/loader/ActionLoaderCallback.java | 48 ++++ .../org/sakuli/loader/BaseActionLoader.java | 16 +- .../sakuli/loader/BaseActionLoaderImpl.java | 59 +---- .../java/org/sakuli/loader/BeanLoader.java | 6 +- .../sakuli/loader/ScreenActionLoaderImpl.java | 23 -- .../CacheHandlingResultServiceImpl.java | 3 +- .../common/CommonResultServiceImpl.java | 7 +- .../java/org/sakuli/utils/CleanUpHelper.java | 13 +- .../SakuliPropertyPlaceholderConfigurer.java | 130 +--------- .../utils/SpringProfilesInitializer.java | 2 +- .../src/main/resources/applicationContext.xml | 1 - .../src/test/java/org/sakuli/BaseTest.java | 50 +--- .../actions/screenbased/RegionTestImpl.java | 4 +- .../test/java/org/sakuli/aop/AopBaseTest.java | 9 +- ....java => LogActionExecutedAspectTest.java} | 99 ++------ ...nterfaceInputActionExecutedAspectTest.java | 56 +++++ .../SakuliExceptionHandlerCallbackTest.java | 58 +++++ .../SakuliExceptionHandlerTest.java | 19 +- .../loader/ActionLoaderCallbackTest.java | 60 +++++ .../sakuli/loader/BaseActionLoaderTest.java | 68 ++---- .../org/sakuli/loader/BeanLoaderTest.java | 3 +- .../services/AbstractServiceBaseTest.java | 6 +- .../AbstractIcinga2ForwarderBaseTest.java | 2 +- ...kuliPropertyPlaceholderConfigurerTest.java | 78 ------ .../utils/SpringProfilesInitializerTest.java | 3 +- .../resources/JUnit-applicationContext.xml | 1 - .../sakuli/aop/aopTest-applicationContext.xml | 12 +- .../sakuli/aop}/aopTest-beanRefFactory.xml | 4 +- ...ceptionCallbackTest-applicationContext.xml | 34 +++ .../exceptionCallbackTest-beanRefFactory.xml | 28 +++ .../loader/loaderTest-applicationContext.xml | 15 +- .../loader}/loaderTest-beanRefFactory.xml | 4 +- .../icinga2Test-applicationContext.xml | 1 - .../icinga2}/icinga2Test-beanRefFactory.xml | 4 +- .../serviceTest-applicationContext.xml | 8 +- .../services}/serviceTest-beanRefFactory.xml | 4 +- src/sakuli-java-dsl/pom.xml | 8 +- .../service/SahiIntializingServiceImpl.java | 4 +- ...kuliJavaPropertyPlaceholderConfigurer.java | 6 +- .../resources/java-dsl-applicationContext.xml | 2 +- src/sakuli-sahi-setup/pom.xml | 143 +---------- .../org/sakuli/starter/SakuliStarter.java | 5 +- .../sakuli/starter/sahi}/SahiConnector.java | 6 +- .../logging/SahiLogToResultCallback.java | 75 ++++++ .../screenbased/ModifySahiTimerCallback.java} | 84 +++---- .../sakuli/starter/sahi/aop/RhinoAspect.java | 112 +++++++++ .../sahi}/aop/SahiCommandExecutionAspect.java | 5 +- .../sahi}/datamodel/actions/LogResult.java | 15 +- .../properties/SahiProxyProperties.java | 8 +- .../sahi}/exceptions/SahiActionException.java | 5 +- .../starter/sahi}/helper/CmdPrintHelper.java | 2 +- .../sahi}/helper/ConnectionTester.java | 2 +- .../starter/sahi}/helper/SahiProxy.java | 10 +- .../sahi}/helper/SakuliFolderHelper.java | 11 +- .../starter/sahi/loader/SahiActionLoader.java | 40 ++++ .../SahiActionLoaderIntegrationImpl.java | 159 +++++++++++++ ...iStarterPropertyPlaceholderConfigurer.java | 171 ++++++++++++++ .../src/main/resources/beanRefFactory.xml | 2 +- .../sahiStarterApplicationContext.xml | 45 ++++ .../src/test/java/org/sakuli/BaseTest.java | 81 +++++++ .../org/sakuli/builder/ExampleBuilder.java | 30 +++ .../builder/TestCaseExampleBuilder.java | 142 +++++++++++ .../builder/TestCaseStepExampleBuilder.java | 99 ++++++++ .../builder/TestSuiteExampleBuilder.java | 134 +++++++++++ .../builder/TestSuiteExampleFactory.java | 43 ++++ .../org/sakuli/starter/SakuliStarterTest.java | 0 .../starter/sahi}/SahiConnectorTest.java | 18 +- .../logging/SahiLogToResultCallbackTest.java | 222 +++++++++++++++++ .../ModifySahiTimerCallbackTest.java} | 97 ++++---- .../sakuli/starter/sahi/aop/AopBaseTest.java | 66 ++++++ .../aop/SahiCommandExecutionAspectTest.java | 3 +- .../SahiStarterExceptionHandlerTest.java | 160 +++++++++++++ .../sahi}/helper/CmdPrintHelperTest.java | 2 +- .../sahi}/helper/ConnectionTesterTest.java | 2 +- .../starter/sahi}/helper/SahiProxyTest.java | 4 +- .../sahi}/helper/SakuliFolderHelperTest.java | 10 +- .../SahiActionLoaderIntegrationImplTest.java | 85 +++++++ ...rterPropertyPlaceholderConfigurerTest.java | 158 +++++++++++++ .../resources/JUnit-applicationContext.xml | 60 +++++ .../test/resources/JUnit-beanRefFactory.xml | 28 +++ .../test/resources/JUnit-sakuli.properties | 93 ++++++++ .../resources/_testsuite4JUnit/.gitignore | 1 + .../resources/_testsuite4JUnit/case/tc.js | 18 ++ .../_testsuite4JUnit/testsuite.properties | 50 ++++ .../_testsuite4JUnit/testsuite.suite | 6 + .../_testsuite4aop/testsuite.properties | 32 +++ .../resources/_testsuite4aop/testsuite.suite | 1 + .../sahi/aop/aopTest-applicationContext.xml | 111 +++++++++ .../sahi/aop/aopTest-beanRefFactory.xml | 28 +++ ...xceptionHandlerTest-applicationContext.xml | 40 ++++ ...ahiExceptionHandlerTest-beanRefFactory.xml | 28 +++ .../starter/sahi}/helper/inject_source.js | 0 .../sahi}/helper/mock-files/inject_top.txt | 0 .../sahi}/helper/mock-old-js/inject.js | 0 .../sahi}/helper/unvalid/testsuite.suite | 0 .../helper/unvalid2/testsuite.properties | 2 - .../sahi/sahi_proxy/config/inject_top.txt | 1 + .../sahi_proxy/userdata/sahi_testfile.txt | 1 + .../utils/properties-test/target.properties | 19 ++ .../resources/property_test/sakuli.properties | 29 +++ .../suite_folder/testsuite.properties | 26 ++ .../resources/org/sakuli/sakuli.properties | 27 +++ 131 files changed, 3614 insertions(+), 1402 deletions(-) create mode 100644 src/basic-test-util/pom.xml create mode 100644 src/basic-test-util/src/test/java/org/sakuli/AbstractBaseTest.java rename src/{sakuli-core => basic-test-util}/src/test/java/org/sakuli/AbstractLogAwareTest.java (90%) rename src/{sakuli-core => basic-test-util}/src/test/java/org/sakuli/MockitoFactoryBean.java (100%) rename src/{sakuli-core => basic-test-util}/src/test/java/org/sakuli/MockitoSpyFactoryBean.java (100%) rename src/{sakuli-core => basic-test-util}/src/test/java/org/sakuli/PropertyHolder.java (100%) rename src/integration-test/src/test/resources/{ => org/sakuli/integration/dao}/db-beanRefFactory.xml (100%) create mode 100644 src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResultCallback.java rename src/sakuli-core/src/main/java/org/sakuli/actions/{ModifySahiTimer.java => screenbased/UserInterfaceInputAction.java} (69%) create mode 100644 src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputActionCallback.java create mode 100644 src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java delete mode 100644 src/sakuli-core/src/main/java/org/sakuli/aop/RhinoAspect.java create mode 100644 src/sakuli-core/src/main/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspect.java create mode 100644 src/sakuli-core/src/main/java/org/sakuli/loader/ActionLoaderCallback.java rename src/sakuli-core/src/test/java/org/sakuli/aop/{RhinoAspectTest.java => LogActionExecutedAspectTest.java} (64%) create mode 100644 src/sakuli-core/src/test/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspectTest.java create mode 100644 src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerCallbackTest.java create mode 100644 src/sakuli-core/src/test/java/org/sakuli/loader/ActionLoaderCallbackTest.java rename src/sakuli-core/src/test/resources/{ => org/sakuli/aop}/aopTest-beanRefFactory.xml (83%) create mode 100644 src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-applicationContext.xml create mode 100644 src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-beanRefFactory.xml rename src/sakuli-core/src/test/resources/{ => org/sakuli/loader}/loaderTest-beanRefFactory.xml (83%) rename src/sakuli-core/src/test/resources/{ => org/sakuli/services/forwarder/icinga2}/icinga2Test-beanRefFactory.xml (82%) rename src/sakuli-core/src/test/resources/{ => org/sakuli/services}/serviceTest-beanRefFactory.xml (82%) rename src/{sakuli-core => sakuli-sahi-setup}/src/main/java/org/sakuli/starter/SakuliStarter.java (98%) rename src/{sakuli-core/src/main/java/org/sakuli/starter => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/SahiConnector.java (98%) create mode 100644 src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallback.java rename src/{sakuli-core/src/main/java/org/sakuli/aop/ModifySahiTimerAspect.java => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallback.java} (51%) create mode 100644 src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/RhinoAspect.java rename src/{sakuli-core/src/main/java/org/sakuli => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/aop/SahiCommandExecutionAspect.java (98%) rename src/{sakuli-core/src/main/java/org/sakuli => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/datamodel/actions/LogResult.java (83%) rename src/{sakuli-core/src/main/java/org/sakuli => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/datamodel/properties/SahiProxyProperties.java (97%) rename src/{sakuli-core/src/main/java/org/sakuli => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/exceptions/SahiActionException.java (85%) rename src/{sakuli-core/src/main/java/org/sakuli/starter => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/helper/CmdPrintHelper.java (97%) rename src/{sakuli-core/src/main/java/org/sakuli/starter => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/helper/ConnectionTester.java (98%) rename src/{sakuli-core/src/main/java/org/sakuli/starter => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/helper/SahiProxy.java (96%) rename src/{sakuli-core/src/main/java/org/sakuli/starter => sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi}/helper/SakuliFolderHelper.java (93%) create mode 100644 src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoader.java create mode 100644 src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImpl.java create mode 100644 src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java rename src/{sakuli-core => sakuli-sahi-setup}/src/main/resources/beanRefFactory.xml (93%) create mode 100644 src/sakuli-sahi-setup/src/main/resources/sahiStarterApplicationContext.xml create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/BaseTest.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/ExampleBuilder.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseExampleBuilder.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseStepExampleBuilder.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleBuilder.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java rename src/{sakuli-core => sakuli-sahi-setup}/src/test/java/org/sakuli/starter/SakuliStarterTest.java (100%) rename src/{sakuli-core/src/test/java/org/sakuli/starter => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/SahiConnectorTest.java (93%) create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java rename src/{sakuli-core/src/test/java/org/sakuli/aop/ModifySahiTimerAspectTest.java => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallbackTest.java} (58%) create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/AopBaseTest.java rename src/{sakuli-core/src/test/java/org/sakuli => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/aop/SahiCommandExecutionAspectTest.java (99%) create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java rename src/{sakuli-core/src/test/java/org/sakuli/starter => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/helper/CmdPrintHelperTest.java (96%) rename src/{sakuli-core/src/test/java/org/sakuli/starter => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/helper/ConnectionTesterTest.java (96%) rename src/{sakuli-core/src/test/java/org/sakuli/starter => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/helper/SahiProxyTest.java (97%) rename src/{sakuli-core/src/test/java/org/sakuli/starter => sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi}/helper/SakuliFolderHelperTest.java (93%) create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImplTest.java create mode 100644 src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java create mode 100644 src/sakuli-sahi-setup/src/test/resources/JUnit-applicationContext.xml create mode 100644 src/sakuli-sahi-setup/src/test/resources/JUnit-beanRefFactory.xml create mode 100644 src/sakuli-sahi-setup/src/test/resources/JUnit-sakuli.properties create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/.gitignore create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/case/tc.js create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.properties create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.suite create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.properties create mode 100644 src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.suite create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-beanRefFactory.xml create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-applicationContext.xml create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-beanRefFactory.xml rename src/{sakuli-core/src/test/resources/org/sakuli/starter => sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi}/helper/inject_source.js (100%) rename src/{sakuli-core/src/test/resources/org/sakuli/starter => sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi}/helper/mock-files/inject_top.txt (100%) rename src/{sakuli-core/src/test/resources/org/sakuli/starter => sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi}/helper/mock-old-js/inject.js (100%) rename src/{sakuli-core/src/test/resources/org/sakuli/starter => sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi}/helper/unvalid/testsuite.suite (100%) rename src/{sakuli-core/src/test/resources/org/sakuli/starter => sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi}/helper/unvalid2/testsuite.properties (99%) create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/config/inject_top.txt create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/userdata/sahi_testfile.txt create mode 100644 src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/utils/properties-test/target.properties create mode 100644 src/sakuli-sahi-setup/src/test/resources/property_test/sakuli.properties create mode 100644 src/sakuli-sahi-setup/src/test/resources/property_test/suite_folder/testsuite.properties create mode 100644 src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties diff --git a/docs/additional-settings.md b/docs/additional-settings.md index a22c48e8..ae7ba21a 100644 --- a/docs/additional-settings.md +++ b/docs/additional-settings.md @@ -111,7 +111,7 @@ You can decide whether Sakuli should automatically select an adapter... To encrypt secrets on the command line, Sakuli uses the MAC address of a NIC on the local machine (Windows/Linux). The following command lets Sakuli decide which NIC will be used: sakuli encrypt foo - =========== Calling Sakuli JAR: java -classpath C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT\libs\jav\sakuli.jar;C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT\libs\java\* org.sakuli.starter.SakuliStarter --sakuli_home C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT --encrypt foo =========== + =========== Calling Sakuli JAR: java -classpath C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT\libs\jav\sakuli.jar;C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT\libs\java\* org.sakuli.starter.sahi.SakuliStarter --sakuli_home C:\Program Files (x86)\sakuli\sakuli-v0.9.3-SNAPSHOT --encrypt foo =========== String to Encrypt: foo ... diff --git a/docs/development/installation-developers.md b/docs/development/installation-developers.md index 04602145..2d4345a7 100644 --- a/docs/development/installation-developers.md +++ b/docs/development/installation-developers.md @@ -97,7 +97,7 @@ If you want to use a Docker-Container, you can build and run it with the followi * In order to run Sakuli test cases directly from the IDE, you need to build up a run configuration. For IntelliJ see the predefined run configurations under [intellij/runConfigurations](intellij/runConfigurations) * __classpath of module:__ `sakuli-core` * __working directory:__ `$MODULE_DIR$` - * __main class:__ `org.sakuli.starter.SakuliStarter` + * __main class:__ `org.sakuli.starter.sahi.SakuliStarter` * __program arguments:__ ```-run --sakuli_home --sahi_home ``` e.g. for the provided Win7 example use `-run ../sakuli_test_suites/example src/main/_include ../sahi` diff --git a/pom.xml b/pom.xml index 0ed6164a..94003d25 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ src/ocr-tessdata-extractor + src/basic-test-util src/sakuli-common src/sakuli-core src/sakuli-sahi-setup @@ -101,7 +102,7 @@ **/integration/**/* - + diff --git a/src/basic-test-util/pom.xml b/src/basic-test-util/pom.xml new file mode 100644 index 00000000..d7d13e6e --- /dev/null +++ b/src/basic-test-util/pom.xml @@ -0,0 +1,118 @@ + + + + + 4.0.0 + + + org.sakuli + sakuli-root + 1.1.0-SNAPSHOT-241_sakuli_se + ../../pom.xml + + + basic-test-util + 1.1.0-SNAPSHOT-241_sakuli_se + ${project.artifactId} + + basic module for some internal testing stuff + + jar + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + + + + + + upload + + + performRelease + true + + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + package + + test-jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + test-jar + + + + + + + + + + + + + org.slf4j + slf4j-api + test + + + commons-io + commons-io + test + + + org.springframework + spring-beans + 4.1.4.RELEASE + test + + + diff --git a/src/basic-test-util/src/test/java/org/sakuli/AbstractBaseTest.java b/src/basic-test-util/src/test/java/org/sakuli/AbstractBaseTest.java new file mode 100644 index 00000000..2949b3c4 --- /dev/null +++ b/src/basic-test-util/src/test/java/org/sakuli/AbstractBaseTest.java @@ -0,0 +1,56 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli; + +import java.nio.file.Paths; + +import static org.testng.Assert.assertTrue; + +/** + * @author tschneck Date: 25.07.13 + */ +public abstract class AbstractBaseTest extends AbstractLogAwareTest { + + public static final String SAKULI_HOME_FOLDER_PATH = Paths.get("../sakuli-common/src/main/resources/org/sakuli/common") + .toAbsolutePath().normalize().toString(); + public static final String TEST_FOLDER_PATH = getResource("/_testsuite4JUnit"); + public static final String TEST_CONTEXT_PATH = "JUnit-beanRefFactory.xml"; + + public static void assertRegExMatch(String string, String regex) { + assertTrue(string.matches(regex), + String.format("string '%s' won't match to regex '%s'", string, regex)); + } + + public static void assertContains(String string, String contains) { + assertTrue(string.contains(contains), + String.format("string '%s' won't contain '%s'", string, contains)); + } + + protected String getTestContextPath() { + return TEST_CONTEXT_PATH; + } + + protected String getSakuliHomeFolderPath() { + return SAKULI_HOME_FOLDER_PATH; + } + + protected String getTestFolderPath() { + return TEST_FOLDER_PATH; + } +} diff --git a/src/sakuli-core/src/test/java/org/sakuli/AbstractLogAwareTest.java b/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java similarity index 90% rename from src/sakuli-core/src/test/java/org/sakuli/AbstractLogAwareTest.java rename to src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java index 08602010..4d335c93 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/AbstractLogAwareTest.java +++ b/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java @@ -18,7 +18,6 @@ package org.sakuli; import org.apache.commons.io.FileUtils; -import org.sakuli.datamodel.actions.LogLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterSuite; @@ -39,10 +38,10 @@ * @author Tobias Schneck */ public abstract class AbstractLogAwareTest { - private static final Logger LOGGER = LoggerFactory.getLogger(BaseTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractBaseTest.class); public static String getResource(String resourceName) { - return getResource(resourceName, BaseTest.class); + return getResource(resourceName, AbstractBaseTest.class); } public static String getResource(String resourceName, Class resourceClass) { @@ -152,21 +151,13 @@ public void removeLogLevel() throws Exception { setSahiLogLevel(null); } - protected synchronized void assertLastLine(Path logFile, String filter, LogLevel logLevel, String expectedMessage) throws IOException { - String preFix = null; - switch (logLevel) { - case ERROR: - preFix = "ERROR"; - break; - case INFO: - preFix = "INFO "; - break; - case DEBUG: - preFix = "DEBUG"; - break; - case WARNING: - preFix = "WARN "; - break; + protected synchronized void assertLastLine(Path logFile, String filter, String logLevelName, String expectedMessage) throws IOException { + String preFix = logLevelName; + if ("WARNING".equals(logLevelName)) { + preFix = "WARN "; + } + if ("INFO".equals(logLevelName)) { + preFix = "INFO "; } String lastLineOfLogFile = AbstractLogAwareTest.getLastLineWithContent(logFile, filter); assertEquals(lastLineOfLogFile.substring(0, 5), preFix); diff --git a/src/sakuli-core/src/test/java/org/sakuli/MockitoFactoryBean.java b/src/basic-test-util/src/test/java/org/sakuli/MockitoFactoryBean.java similarity index 100% rename from src/sakuli-core/src/test/java/org/sakuli/MockitoFactoryBean.java rename to src/basic-test-util/src/test/java/org/sakuli/MockitoFactoryBean.java diff --git a/src/sakuli-core/src/test/java/org/sakuli/MockitoSpyFactoryBean.java b/src/basic-test-util/src/test/java/org/sakuli/MockitoSpyFactoryBean.java similarity index 100% rename from src/sakuli-core/src/test/java/org/sakuli/MockitoSpyFactoryBean.java rename to src/basic-test-util/src/test/java/org/sakuli/MockitoSpyFactoryBean.java diff --git a/src/sakuli-core/src/test/java/org/sakuli/PropertyHolder.java b/src/basic-test-util/src/test/java/org/sakuli/PropertyHolder.java similarity index 100% rename from src/sakuli-core/src/test/java/org/sakuli/PropertyHolder.java rename to src/basic-test-util/src/test/java/org/sakuli/PropertyHolder.java diff --git a/src/integration-test/pom.xml b/src/integration-test/pom.xml index 9ef3475e..4433e80a 100644 --- a/src/integration-test/pom.xml +++ b/src/integration-test/pom.xml @@ -30,7 +30,7 @@ integration-test 1.1.0-SNAPSHOT-241_sakuli_se - ${artifactId} + ${project.artifactId} integration test module for sakuli jar diff --git a/src/integration-test/src/test/java/org/sakuli/integration/dao/DaoIntegrationTest.java b/src/integration-test/src/test/java/org/sakuli/integration/dao/DaoIntegrationTest.java index 17a74907..6dc75d01 100644 --- a/src/integration-test/src/test/java/org/sakuli/integration/dao/DaoIntegrationTest.java +++ b/src/integration-test/src/test/java/org/sakuli/integration/dao/DaoIntegrationTest.java @@ -23,7 +23,6 @@ import org.mockito.MockitoAnnotations; import org.sakuli.actions.screenbased.RegionImpl; import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.actions.LogResult; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.exceptions.SakuliException; import org.sakuli.exceptions.SakuliExceptionHandler; @@ -52,7 +51,7 @@ */ @Test(groups = GROUP) public abstract class DaoIntegrationTest implements IntegrationTest { - public static final String TEST_CONTEXT_PATH = "db-beanRefFactory.xml"; + public static final String TEST_CONTEXT_PATH = "org/sakuli/integration/dao/db-beanRefFactory.xml"; @InjectMocks protected D testling; @@ -98,7 +97,6 @@ protected void initExceptionHandlerMock(SakuliExceptionHandler sakuliExceptionHa throw (Throwable) invocation.getArguments()[0]; }).when(sakuliExceptionHandlerMock).handleException(any(Throwable.class)); doCallRealMethod().when(sakuliExceptionHandlerMock).handleException(any(Throwable.class), anyBoolean()); - doCallRealMethod().when(sakuliExceptionHandlerMock).handleException(any(LogResult.class)); doCallRealMethod().when(sakuliExceptionHandlerMock).handleException(anyString(), anyBoolean()); doCallRealMethod().when(sakuliExceptionHandlerMock).handleException(anyString(), any(RegionImpl.class), anyBoolean()); doCallRealMethod().when(sakuliExceptionHandlerMock).handleException(any(Throwable.class), any(RegionImpl.class), anyBoolean()); diff --git a/src/integration-test/src/test/resources/org/sakuli/integration/dao/db-applicationContext.xml b/src/integration-test/src/test/resources/org/sakuli/integration/dao/db-applicationContext.xml index 191fa3c3..a7364165 100644 --- a/src/integration-test/src/test/resources/org/sakuli/integration/dao/db-applicationContext.xml +++ b/src/integration-test/src/test/resources/org/sakuli/integration/dao/db-applicationContext.xml @@ -31,7 +31,6 @@ - diff --git a/src/integration-test/src/test/resources/db-beanRefFactory.xml b/src/integration-test/src/test/resources/org/sakuli/integration/dao/db-beanRefFactory.xml similarity index 100% rename from src/integration-test/src/test/resources/db-beanRefFactory.xml rename to src/integration-test/src/test/resources/org/sakuli/integration/dao/db-beanRefFactory.xml diff --git a/src/sakuli-common/pom.xml b/src/sakuli-common/pom.xml index e1a248ed..f1ab341b 100644 --- a/src/sakuli-common/pom.xml +++ b/src/sakuli-common/pom.xml @@ -30,7 +30,7 @@ sakuli-common 1.1.0-SNAPSHOT-241_sakuli_se - ${artifactId} + ${project.artifactId} maven module for common used resources jar diff --git a/src/sakuli-core/pom.xml b/src/sakuli-core/pom.xml index 87c9dd79..d50c0ca6 100644 --- a/src/sakuli-core/pom.xml +++ b/src/sakuli-core/pom.xml @@ -30,7 +30,7 @@ sakuli-core 1.1.0-SNAPSHOT-241_sakuli_se - ${artifactId} + ${project.artifactId} core module for all sakuli functionality @@ -38,23 +38,9 @@ sakuli-core-${project.version} - - - - - - - - - - - - - - @@ -72,12 +58,6 @@ ${maven.compiler.source} ${maven.compiler.source} ${maven.compiler.source} - - - net.sf.sahi - sahi - - true ${project.build.sourceEncoding} true @@ -97,38 +77,6 @@ org.apache.maven.plugins maven-dependency-plugin - @@ -153,84 +101,11 @@ - - - - - - + upload @@ -241,30 +116,6 @@ - - - org.apache.maven.plugins @@ -277,18 +128,12 @@ jar-no-fork - - - org.apache.maven.plugins maven-javadoc-plugin - - - attach-javadocs @@ -365,10 +210,6 @@ - - commons-cli - commons-cli - commons-codec commons-codec @@ -390,24 +231,6 @@ commons-lang3 - - - - net.sf.sahi - sahi - - - - net.sf.sahi - ant-sahi - - - - - org.mozilla - rhino - - @@ -455,6 +278,15 @@ org.jtwig jtwig-spaceless-extension + + + + ${project.groupId} + basic-test-util + ${project.version} + test-jar + test +
diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java b/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java index b144a425..7ddf8378 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java @@ -18,14 +18,13 @@ package org.sakuli.actions.environment; -import net.sf.sahi.util.OSUtils; import org.sakuli.actions.Action; -import org.sakuli.actions.ModifySahiTimer; import org.sakuli.actions.environment.CommandLineUtil.CommandLineResult; import org.sakuli.actions.logging.LogToResult; import org.sakuli.actions.screenbased.Region; import org.sakuli.actions.screenbased.RegionImpl; import org.sakuli.actions.screenbased.TypingUtil; +import org.sakuli.actions.screenbased.UserInterfaceInputAction; import org.sakuli.datamodel.properties.ActionProperties; import org.sakuli.exceptions.SakuliException; import org.sakuli.loader.BeanLoader; @@ -49,6 +48,7 @@ */ public class Environment implements Action { + private static String osName = System.getProperty("os.name"); protected final Logger logger = LoggerFactory.getLogger(this.getClass()); private final boolean resumeOnException; private ScreenActionLoader loader; @@ -229,7 +229,7 @@ public Environment cleanClipboard() { * * @return this {@link Environment}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "paste the current clipboard into the focus", logClassInstance = false) public Environment pasteClipboard() { int mod = Key.getHotkeyModifier(); @@ -246,7 +246,7 @@ public Environment pasteClipboard() { * * @return this {@link Environment}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "copy the current selection to the clipboard", logClassInstance = false) public Environment copyIntoClipboard() { int mod = Key.getHotkeyModifier(); @@ -261,7 +261,7 @@ public Environment copyIntoClipboard() { /** * {@link org.sakuli.actions.screenbased.TypingUtil#paste(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false) public Environment paste(String text) { return typingUtil.paste(text); @@ -270,7 +270,7 @@ public Environment paste(String text) { /** * {@link org.sakuli.actions.screenbased.TypingUtil#pasteMasked(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false, logArgs = false) public Environment pasteMasked(String text) { return typingUtil.pasteMasked(text); @@ -279,7 +279,7 @@ public Environment pasteMasked(String text) { /** * {@link org.sakuli.actions.screenbased.TypingUtil#pasteAndDecrypt(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false, logArgs = false) public Environment pasteAndDecrypt(String text) { return typingUtil.pasteAndDecrypt(text); @@ -288,7 +288,7 @@ public Environment pasteAndDecrypt(String text) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#type(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type over system keyboard", logClassInstance = false) public Environment type(String text) { return typingUtil.type(text, null); @@ -297,7 +297,7 @@ public Environment type(String text) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#type(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type with pressed modifiers", logClassInstance = false) public Environment type(String text, String optModifiers) { return typingUtil.type(text, optModifiers); @@ -306,7 +306,7 @@ public Environment type(String text, String optModifiers) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#typeMasked(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type over system keyboard", logClassInstance = false, logArgs = false) public Environment typeMasked(String text) { return typingUtil.typeMasked(text, null); @@ -315,7 +315,7 @@ public Environment typeMasked(String text) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#typeMasked(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type with pressed modifiers", logClassInstance = false, logArgs = false) public Environment typeMasked(String text, String optModifiers) { return typingUtil.typeMasked(text, optModifiers); @@ -324,7 +324,7 @@ public Environment typeMasked(String text, String optModifiers) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#typeAndDecrypt(String, String)} . */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "decrypt and type over system keyboard", logClassInstance = false, logArgs = false) public Environment typeAndDecrypt(String text) { return typingUtil.typeAndDecrypt(text, null); @@ -333,7 +333,7 @@ public Environment typeAndDecrypt(String text) { /** * See {@link org.sakuli.actions.screenbased.TypingUtil#typeAndDecrypt(String, String)} . */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "decrypt and type with pressed modifiers", logClassInstance = false, logArgs = false) public Environment typeAndDecrypt(String text, String optModifiers) { return typingUtil.typeAndDecrypt(text, optModifiers); @@ -342,7 +342,7 @@ public Environment typeAndDecrypt(String text, String optModifiers) { /** * See {@link TypingUtil#keyDown(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "press key down", logClassInstance = false) public Environment keyDown(String keys) { return typingUtil.keyDown(keys); @@ -351,7 +351,7 @@ public Environment keyDown(String keys) { /** * See {@link TypingUtil#keyUp(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "press key up", logClassInstance = false) public Environment keyUp(String keys) { return typingUtil.keyUp(keys); @@ -360,7 +360,7 @@ public Environment keyUp(String keys) { /** * See {@link TypingUtil#write(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "interpret and write the following expresion", logClassInstance = false) public Environment write(String text) { return typingUtil.write(text); @@ -395,7 +395,7 @@ public String decryptSecret(String secret) { */ @LogToResult(logClassInstance = false, logArgs = false) public boolean isWindows() { - switch (OSUtils.identifyOS()) { + switch (osName) { case "xp": return true; case "nt": @@ -410,7 +410,7 @@ public boolean isWindows() { */ @LogToResult(logClassInstance = false, logArgs = false) public boolean isLinux() { - switch (OSUtils.identifyOS()) { + switch (osName) { case "linux": return true; default: @@ -423,7 +423,7 @@ public boolean isLinux() { */ @LogToResult(logClassInstance = false, logArgs = false) public String getOsIdentifier() { - return OSUtils.identifyOS(); + return osName; } diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResult.java b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResult.java index 962a0b47..c66b6ddf 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResult.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResult.java @@ -18,6 +18,7 @@ package org.sakuli.actions.logging; +import org.sakuli.aop.LogActionExecutedAspect; import org.sakuli.datamodel.actions.LogLevel; import java.lang.annotation.*; @@ -25,7 +26,7 @@ /** * This Annotation should be used do log actions in the package {@link org.sakuli.actions}. * All annotated methods or constructors will be called by the aspect - * {@link org.sakuli.aop.RhinoAspect}. + * {@link LogActionExecutedAspect}. * * @author Tobias Schneck */ diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResultCallback.java b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResultCallback.java new file mode 100644 index 00000000..18b7122c --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/LogToResultCallback.java @@ -0,0 +1,36 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.actions.logging; + +import org.aspectj.lang.JoinPoint; + +/** + * Will be triggered everytime an annotated method with @{@link LogToResult} will be called. + * The trigger will be executed from {@link org.sakuli.aop.LogActionExecutedAspect}. + * + * @author tschneck + * Date: 4/24/17 + */ +public interface LogToResultCallback { + + /** + * will be triggered if an action event should be logged. + */ + void doActionLog(JoinPoint joinPoint, LogToResult logToResult); +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/logging/Logger.java b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/Logger.java index 174dbe72..f5e1a1ab 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/logging/Logger.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/logging/Logger.java @@ -18,11 +18,12 @@ package org.sakuli.actions.logging; +import org.sakuli.aop.LogActionExecutedAspect; import org.sakuli.datamodel.actions.LogLevel; /** - * The logging will take place in the {@link org.sakuli.aop.RhinoAspect}. - * This are only EntryPoints for {@link org.sakuli.aop.RhinoAspect#doLoggingLog(org.aspectj.lang.JoinPoint, LogToResult)}. + * The logging will take place in the {@link LogActionExecutedAspect}. + * This are only EntryPoints for {@link LogActionExecutedAspect#doLoggingLog(org.aspectj.lang.JoinPoint, LogToResult)}. * * @author tschneck * Date: 24.06.13 diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/Region.java b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/Region.java index 467b5df6..1d4d3845 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/Region.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/Region.java @@ -19,7 +19,6 @@ package org.sakuli.actions.screenbased; import org.sakuli.actions.Action; -import org.sakuli.actions.ModifySahiTimer; import org.sakuli.actions.environment.Environment; import org.sakuli.actions.logging.LogToResult; import org.sakuli.loader.BeanLoader; @@ -146,7 +145,7 @@ public Region exists(String imageName, int seconds) { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region click() { return update(regionImpl.clickMe()); @@ -157,7 +156,7 @@ public Region click() { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region doubleClick() { return update(regionImpl.doubleClickMe()); @@ -168,7 +167,7 @@ public Region doubleClick() { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region rightClick() { return update(regionImpl.rightClickMe()); @@ -179,7 +178,7 @@ public Region rightClick() { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region mouseMove() { return update(regionImpl.mouseMoveMe()); @@ -198,7 +197,7 @@ public Region mouseMove() { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region mouseDown(MouseButton mouseButton) { return update(regionImpl.mouseDown(mouseButton)); @@ -217,7 +216,7 @@ public Region mouseDown(MouseButton mouseButton) { * * @return the {@link Region} or NULL on errors. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region mouseUp(MouseButton mouseButton) { return update(regionImpl.mouseUp(mouseButton)); @@ -229,11 +228,12 @@ public Region mouseUp(MouseButton mouseButton) { * @param targetRegion {@link Region} object of the target * @return the tragetRegion or null on failure */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region dragAndDropTo(Region targetRegion) { return update(regionImpl.dragAndDropTo(targetRegion.getRegionImpl())); } + /** * Blocks and waits until a target which is specified by the optImageName is found in the hole {@link Screen} within * a given time period in seconds. @@ -251,7 +251,7 @@ public Region waitForImage(String imageName, int seconds) { /** * {@link TypingUtil#paste(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false) public Region paste(String text) { return typingUtil.paste(text); @@ -260,7 +260,7 @@ public Region paste(String text) { /** * {@link TypingUtil#pasteMasked(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false, logArgs = false) public Region pasteMasked(String text) { return typingUtil.pasteMasked(text); @@ -269,7 +269,7 @@ public Region pasteMasked(String text) { /** * {@link TypingUtil#pasteAndDecrypt(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(logClassInstance = false, logArgs = false) public Region pasteAndDecrypt(String text) { return typingUtil.pasteAndDecrypt(text); @@ -278,7 +278,7 @@ public Region pasteAndDecrypt(String text) { /** * See {@link TypingUtil#type(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type over system keyboard", logClassInstance = false) public Region type(String text) { return typingUtil.type(text, null); @@ -287,7 +287,7 @@ public Region type(String text) { /** * See {@link TypingUtil#type(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type with pressed modifiers", logClassInstance = false) public Region type(String text, String optModifiers) { return typingUtil.type(text, optModifiers); @@ -296,7 +296,7 @@ public Region type(String text, String optModifiers) { /** * See {@link TypingUtil#typeMasked(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type over system keyboard", logClassInstance = false, logArgs = false) public Region typeMasked(String text) { return typingUtil.typeMasked(text, null); @@ -305,7 +305,7 @@ public Region typeMasked(String text) { /** * See {@link TypingUtil#typeMasked(String, String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "type with pressed modifiers", logClassInstance = false, logArgs = false) public Region typeMasked(String text, String optModifiers) { return typingUtil.typeMasked(text, optModifiers); @@ -314,7 +314,7 @@ public Region typeMasked(String text, String optModifiers) { /** * See {@link TypingUtil#typeAndDecrypt(String, String)} . */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "decrypt and type over system keyboard", logClassInstance = false, logArgs = false) public Region typeAndDecrypt(String text) { return typingUtil.typeAndDecrypt(text, null); @@ -323,7 +323,7 @@ public Region typeAndDecrypt(String text) { /** * See {@link TypingUtil#typeAndDecrypt(String, String)} . */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "decrypt and type with pressed modifiers", logClassInstance = false, logArgs = false) public Region typeAndDecrypt(String text, String optModifiers) { return typingUtil.typeAndDecrypt(text, optModifiers); @@ -332,7 +332,7 @@ public Region typeAndDecrypt(String text, String optModifiers) { /** * See {@link TypingUtil#keyDown(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "press key down", logClassInstance = false) public Region keyDown(String keys) { return typingUtil.keyDown(keys); @@ -341,7 +341,7 @@ public Region keyDown(String keys) { /** * See {@link TypingUtil#keyUp(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "press key up", logClassInstance = false) public Region keyUp(String keys) { return typingUtil.keyUp(keys); @@ -350,7 +350,7 @@ public Region keyUp(String keys) { /** * See {@link TypingUtil#write(String)}. */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult(message = "interpret and write the following expresion", logClassInstance = false) public Region write(String text) { return typingUtil.write(text); @@ -362,7 +362,7 @@ public Region write(String text) { * @param amountOfChars number of chars to delete * @return this {@link Region} or null on errors */ - @ModifySahiTimer + @UserInterfaceInputAction @LogToResult public Region deleteChars(int amountOfChars) { return update(regionImpl.deleteChars(amountOfChars)); diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/ModifySahiTimer.java b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputAction.java similarity index 69% rename from src/sakuli-core/src/main/java/org/sakuli/actions/ModifySahiTimer.java rename to src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputAction.java index ce13dd64..b7eea7bc 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/ModifySahiTimer.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputAction.java @@ -16,18 +16,20 @@ * limitations under the License. */ -package org.sakuli.actions; - -import org.sakuli.datamodel.properties.SahiProxyProperties; +package org.sakuli.actions.screenbased; import java.lang.annotation.*; /** - * This Annotation should be used for all actions in the package {@link org.sakuli.actions}, if the - * annotated method should be modify the Sahi request timer in respect of the property {@link SahiProxyProperties#REQUEST_DELAY_MS} + * This Annotation should be used for all actions in the package {@link org.sakuli.actions}, if the Action use a native + * UI input action like typing or clicking. + *

+ * This is need to fix some issues with Sahi Proxy: + * To prevent missing UI event like a key press the Sahi request timer will be modified in respect of the property + * {@code SahiProxyProperties#REQUEST_DELAY_MS} *

* All annoted methods or constructor will be called by the aspect - * {@link org.sakuli.aop.ModifySahiTimerAspect}. + * {@code org.sakuli.aop.ModifySahiTimerAspect}. *

* * @author Tobias Schneck @@ -35,6 +37,6 @@ @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface ModifySahiTimer { +public @interface UserInterfaceInputAction { } diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputActionCallback.java b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputActionCallback.java new file mode 100644 index 00000000..c118fa3b --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/screenbased/UserInterfaceInputActionCallback.java @@ -0,0 +1,41 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.actions.screenbased; + +import org.aspectj.lang.JoinPoint; + +/** + * Will be triggered everytime an annotated method with @{@link UserInterfaceInputActionCallback} will be called. + * The trigger will be executed from {@link org.sakuli.aop.UserInterfaceInputActionExecutedAspect}. + * + * @author tschneck + * Date: 4/24/17 + */ +public interface UserInterfaceInputActionCallback { + + /** + * will be triggered everytime BEFORE an UI input action like typing will executed. + */ + void beforeUserInterfaceInput(JoinPoint joinPoint); + + /** + * will be triggered everytime AFTER an UI input action like typing will executed. + */ + void afterUserInterfaceInput(JoinPoint joinPoint); +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/BaseSakuliAspect.java b/src/sakuli-core/src/main/java/org/sakuli/aop/BaseSakuliAspect.java index ae8d4275..d69a2888 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/aop/BaseSakuliAspect.java +++ b/src/sakuli-core/src/main/java/org/sakuli/aop/BaseSakuliAspect.java @@ -18,32 +18,40 @@ package org.sakuli.aop; +import org.apache.commons.lang.ArrayUtils; import org.aspectj.lang.JoinPoint; +import org.sakuli.actions.logging.LogToResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.Iterator; +import static org.apache.commons.lang.StringUtils.isNotEmpty; +import static org.apache.commons.lang.StringUtils.removeEnd; +import static org.apache.commons.lang3.StringUtils.removeStart; + /** * @author tschneck * Date: 23.09.14 */ public abstract class BaseSakuliAspect { + public static final String ALREADY_PROCESSED = "{{SAKULI_EX}}"; + /** * @return the {@link Logger} for the assigned joinPoint. */ - protected Logger getLogger(JoinPoint joinPoint) { + public static Logger getLogger(JoinPoint joinPoint) { return LoggerFactory.getLogger(joinPoint.getSignature().getDeclaringType()); } - public String getClassAndMethodAsString(JoinPoint joinPoint) { + public static String getClassAndMethodAsString(JoinPoint joinPoint) { return String.format("%s.%s()", joinPoint.getSignature().getDeclaringType().getSimpleName(), joinPoint.getSignature().getName()); } - public String printArgs(JoinPoint joinPoint, boolean logArgs) { + public static String printArgs(JoinPoint joinPoint, boolean logArgs) { StringBuilder builder = new StringBuilder(); builder.append("["); Iterator iterator = Arrays.asList(joinPoint.getArgs()).iterator(); @@ -69,7 +77,7 @@ public String printArgs(JoinPoint joinPoint, boolean logArgs) { return builder.append("]").toString(); } - public String printArray(Object[] objects) { + public static String printArray(Object[] objects) { StringBuilder sb = new StringBuilder("["); for (Object o : objects) { if (sb.toString().length() > 1) { @@ -80,4 +88,30 @@ public String printArray(Object[] objects) { sb.append("]"); return sb.toString(); } + + /** + * @return based on the different arguments of the {@link LogToResult} annotation an different output {@link String} + */ + public static StringBuilder createLoggingString(JoinPoint joinPoint, LogToResult logToResult) { + if (logToResult.logArgsOnly()) { + return new StringBuilder(removeEnd(removeStart(printArgs(joinPoint, logToResult.logArgs()), "["), "]")); + } + + StringBuilder message = new StringBuilder(); + //log class instance? + if (logToResult.logClassInstance() && joinPoint.getTarget() != null) { + message.append("\"").append(joinPoint.getTarget().toString()).append("\" "); + } + message.append(getClassAndMethodAsString(joinPoint)); + + //add message if needed + if (isNotEmpty(logToResult.message())) { + message.append(" - ").append(logToResult.message()); + } + //add args if needed + if (ArrayUtils.isNotEmpty(joinPoint.getArgs())) { + message.append(" with arg(s) ").append(printArgs(joinPoint, logToResult.logArgs())); + } + return message; + } } diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java b/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java new file mode 100644 index 00000000..9423d013 --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java @@ -0,0 +1,125 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.aop; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.sakuli.actions.logging.LogToResult; +import org.sakuli.actions.logging.LogToResultCallback; +import org.sakuli.loader.BeanLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * Aspect for all Actions under {@link org.sakuli.actions} + * + * @author tschneck Date: 17.10.13 + */ +@Aspect +@Component +public class LogActionExecutedAspect extends BaseSakuliAspect { + + protected final static Logger logger = LoggerFactory.getLogger(LogActionExecutedAspect.class); + + /** + * Pointcut for the {@link org.sakuli.actions.TestCaseAction} class to do an {@link + * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} + */ + @Before("execution(* org.sakuli.actions.TestCaseAction.*(..)) &&" + + "@annotation(logToResult)") + public void doTestCaseActionLog(JoinPoint joinPoint, LogToResult logToResult) { + addActionLog(joinPoint, logToResult); + } + + /** + * Pointcut for the {@link org.sakuli.actions.environment} classes to do an {@link + * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} + */ + @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + + "@annotation(logToResult)") + public void doScreenBasedActionLog(JoinPoint joinPoint, LogToResult logToResult) { + addActionLog(joinPoint, logToResult); + } + + /** + * Pointcut for the {@link org.sakuli.actions.environment} classes to do an {@link + * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} + */ + @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + + "@annotation(logToResult)") + public void doEnvironmentLog(JoinPoint joinPoint, LogToResult logToResult) { + addActionLog(joinPoint, logToResult); + } + + /** + * Pointcut for the {@link org.sakuli.actions.logging} classes to do an {@link #addActionLog(org.aspectj.lang.JoinPoint, + * org.sakuli.actions.logging.LogToResult)} + */ + @Before("execution(* org.sakuli.actions.logging.*.*(..)) &&" + + "@annotation(logToResult)") + public void doLoggingLog(JoinPoint joinPoint, LogToResult logToResult) { + addActionLog(joinPoint, logToResult); + } + + /** + * Method to do all Logs for the action classes annotated with {@link org.sakuli.actions.logging.LogToResult}. A log + * entry will created at the sakuli log files and at the sahi HTML over the callback {@link LogToResultCallback}. + * + * @param joinPoint {@link JoinPoint} object of the calling aspect + * @param logToResult {@link LogToResult} Annotation + */ + protected void addActionLog(JoinPoint joinPoint, LogToResult logToResult) { + Logger logger = getLogger(joinPoint); + if (logToResult != null) { + StringBuilder message = createLoggingString(joinPoint, logToResult); + + //log the action to log file and print + switch (logToResult.level()) { + case ERROR: + logger.error(message.toString()); + break; + case INFO: + logger.info(message.toString()); + break; + case DEBUG: + logger.debug(message.toString()); + break; + case WARNING: + logger.warn(message.toString()); + break; + } + } + callLoggingCallbacks(joinPoint, logToResult); + } + + /** + * Calls all defined implementations of {@link } as Callback. + * NOTE: Because a class can only compiled/weaved by aspectj once, this behaviour is needed to be modular. + */ + protected void callLoggingCallbacks(JoinPoint joinPoint, LogToResult logToResult) { + BeanLoader.loadMultipleBeans(LogToResultCallback.class).values().stream() + .filter(Objects::nonNull) + .forEach(cb -> cb.doActionLog(joinPoint, logToResult)); + } + +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/RhinoAspect.java b/src/sakuli-core/src/main/java/org/sakuli/aop/RhinoAspect.java deleted file mode 100644 index 3718d35e..00000000 --- a/src/sakuli-core/src/main/java/org/sakuli/aop/RhinoAspect.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. - * - * Copyright 2013 - 2015 the original author or authors. - * - * 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. - */ - -package org.sakuli.aop; - -import net.sf.sahi.report.Report; -import net.sf.sahi.report.ResultType; -import net.sf.sahi.rhino.RhinoScriptRunner; -import org.apache.commons.lang.ArrayUtils; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.sakuli.actions.logging.LogToResult; -import org.sakuli.datamodel.actions.LogResult; -import org.sakuli.loader.BaseActionLoader; -import org.sakuli.loader.BaseActionLoaderImpl; -import org.sakuli.loader.BeanLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import static org.apache.commons.lang.StringUtils.isNotEmpty; -import static org.apache.commons.lang.StringUtils.removeEnd; -import static org.apache.commons.lang3.StringUtils.removeStart; - -/** - * Aspect for the External Sahi Library {@link net.sf.sahi} - * - * @author tschneck Date: 17.10.13 - */ -@Aspect -@Component -public class RhinoAspect extends BaseSakuliAspect { - - public static final String ALREADY_PROCESSED = "{{SAKULI_EX}}"; - protected final static Logger logger = LoggerFactory.getLogger(RhinoAspect.class); - - /** - * Aspect to fetch the {@link RhinoScriptRunner} at the start of a test case script. The {@link RhinoScriptRunner} - * will then saved in the {@link BaseActionLoaderImpl} for forther usage. - * - * @param joinPoint injected joinPoint of the execution - */ - @After("execution(* net.sf.sahi.rhino.RhinoScriptRunner.setReporter*(*))") - public void getRhinoScriptRunner(JoinPoint joinPoint) { - BaseActionLoader environmentLoader = BeanLoader.loadBaseActionLoader(); - if (joinPoint.getTarget() instanceof RhinoScriptRunner) { - logger.info("Add RhinoScriptRunner to the JavaBackEnd"); - environmentLoader.setRhinoScriptRunner((RhinoScriptRunner) joinPoint.getTarget()); - } else { - logger.warn(joinPoint.getTarget().getClass().getName() + " could not added to the JavaBackEnd!"); - } - } - - /** - * Pointcut for the {@link org.sakuli.actions.TestCaseAction} class to do an {@link - * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} - */ - @Before("execution(* org.sakuli.actions.TestCaseAction.*(..)) &&" + - "@annotation(logToResult)") - public void doTestCaseActionLog(JoinPoint joinPoint, LogToResult logToResult) { - addActionLog(joinPoint, logToResult); - } - - /** - * Pointcut for the {@link org.sakuli.actions.environment} classes to do an {@link - * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} - */ - @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + - "@annotation(logToResult)") - public void doScreenBasedActionLog(JoinPoint joinPoint, LogToResult logToResult) { - addActionLog(joinPoint, logToResult); - } - - /** - * Pointcut for the {@link org.sakuli.actions.environment} classes to do an {@link - * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} - */ - @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + - "@annotation(logToResult)") - public void doEnvironmentLog(JoinPoint joinPoint, LogToResult logToResult) { - addActionLog(joinPoint, logToResult); - } - - /** - * Pointcut for the {@link org.sakuli.actions.logging} classes to do an {@link #addActionLog(org.aspectj.lang.JoinPoint, - * org.sakuli.actions.logging.LogToResult)} - */ - @Before("execution(* org.sakuli.actions.logging.*.*(..)) &&" + - "@annotation(logToResult)") - public void doLoggingLog(JoinPoint joinPoint, LogToResult logToResult) { - addActionLog(joinPoint, logToResult); - } - - /** - * Method to do all Logs for the action classes annotated with {@link org.sakuli.actions.logging.LogToResult}. A log - * entry will created at the sakuli log files and at the sahi HTML {@link net.sf.sahi.report.Report}. - * - * @param joinPoint {@link JoinPoint} object of the calling aspect - * @param logToResult {@link LogToResult} Annotation - */ - protected void addActionLog(JoinPoint joinPoint, LogToResult logToResult) { - Logger logger = getLogger(joinPoint); - if (logToResult != null) { - StringBuilder message = createLoggingString(joinPoint, logToResult); - - //log the action to log file and print - switch (logToResult.level()) { - case ERROR: - logger.error(message.toString()); - break; - case INFO: - logger.info(message.toString()); - break; - case DEBUG: - logger.debug(message.toString()); - break; - case WARNING: - logger.warn(message.toString()); - message.insert(0, "WARNING: "); - break; - } - if (logToResult.level().getResultType() != null) { - Report sahiReport = BeanLoader.loadBaseActionLoader().getSahiReport(); - if (sahiReport != null) { - sahiReport.addResult( - message.toString(), - logToResult.level().getResultType(), - joinPoint.getSignature().getDeclaringTypeName(), - ""); - } - } - } - } - - /** - * @return based on the different arguments of the {@link LogToResult} annotation an different output {@link String} - */ - protected StringBuilder createLoggingString(JoinPoint joinPoint, LogToResult logToResult) { - if (logToResult.logArgsOnly()) { - return new StringBuilder(removeEnd(removeStart(printArgs(joinPoint, logToResult.logArgs()), "["), "]")); - } - - StringBuilder message = new StringBuilder(); - //log class instance? - if (logToResult.logClassInstance() && joinPoint.getTarget() != null) { - message.append("\"").append(joinPoint.getTarget().toString()).append("\" "); - } - message.append(getClassAndMethodAsString(joinPoint)); - - //add message if needed - if (isNotEmpty(logToResult.message())) { - message.append(" - ").append(logToResult.message()); - } - //add args if needed - if (ArrayUtils.isNotEmpty(joinPoint.getArgs())) { - message.append(" with arg(s) ").append(printArgs(joinPoint, logToResult.logArgs())); - } - return message; - } - - /** - * Aspect to fetch all Logs from the Sahi-Proxy by the method {@link net.sf.sahi.ant.Report} and do an trusty - * exception handling on top of that. - * - * @param joinPoint injected joinPoint of the execution - */ - @Before("execution(* net.sf.sahi.report.Report.addResult(..))") - public void doHandleRhinoException(JoinPoint joinPoint) { - // Read out all args - Object[] args = joinPoint.getArgs(); - ResultType resultType; - if (args[1] instanceof ResultType) { - resultType = (ResultType) args[1]; - } else { - resultType = ResultType.getType((String) args[1]); - } - - LogResult logResult = new LogResult( - (String) args[0], - resultType, - (String) args[2], - (String) args[3] - ); - - if (logResult.getFailureMsg() == null || !logResult.getFailureMsg().contains(ALREADY_PROCESSED)) { - //log and handle exception from sahi actions - if (ResultType.ERROR.equals(resultType) - || ResultType.FAILURE.equals(resultType)) { - - BaseActionLoader environmentLoader = BeanLoader.loadBaseActionLoader(); - environmentLoader.getExceptionHandler().handleException(logResult); - } - - /** - * all Actions in Package {@link org.sakuli.actions} should be already logged by - * {@link #doAddActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)}. - */ - else if (logResult.getDebugInfo() == null - || !logResult.getDebugInfo().startsWith("org.sakuli.actions.")) { - logger.info(logResult.getMessage()); - } - } - - } - -} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspect.java b/src/sakuli-core/src/main/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspect.java new file mode 100644 index 00000000..ccccd4bf --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspect.java @@ -0,0 +1,98 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.aop; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.sakuli.actions.screenbased.UserInterfaceInputAction; +import org.sakuli.actions.screenbased.UserInterfaceInputActionCallback; +import org.sakuli.loader.BeanLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * Aspect for the External Sahi Libary {@link net.sf.sahi} + * + * @author tschneck + * Date: 17.10.13 + */ +@Aspect +@Component +public class UserInterfaceInputActionExecutedAspect extends BaseSakuliAspect { + + protected final static Logger logger = LoggerFactory.getLogger(UserInterfaceInputActionExecutedAspect.class); + + /** + * Before Pointcut for the {@link org.sakuli.actions.environment} class + * to do an {@link #triggerBeforeCallbacks(JoinPoint)}. + */ + @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + + "@annotation(userInterfaceInputAction)") + public void doEnvironmentBefore(JoinPoint joinPoint, UserInterfaceInputAction userInterfaceInputAction) { + triggerBeforeCallbacks(joinPoint); + } + + /** + * Before Pointcut for the {@link org.sakuli.actions.screenbased} class + * to do an {@link #triggerBeforeCallbacks(JoinPoint)}. + */ + @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + + "@annotation(userInterfaceInputAction)") + public void doScreenbasedBefore(JoinPoint joinPoint, UserInterfaceInputAction userInterfaceInputAction) { + triggerBeforeCallbacks(joinPoint); + } + + /** + * After Pointcut for the {@link org.sakuli.actions.environment} class + * to do an {@link #triggerAfterCallbacks(JoinPoint)}. + */ + @After("execution(* org.sakuli.actions.environment.*.*(..)) &&" + + "@annotation(userInterfaceInputAction)") + public void doEnvironmentAfter(JoinPoint joinPoint, UserInterfaceInputAction userInterfaceInputAction) { + triggerAfterCallbacks(joinPoint); + } + + /** + * After for the {@link org.sakuli.actions.screenbased} class + * to do an {@link #triggerAfterCallbacks(JoinPoint)}. + */ + @After("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + + "@annotation(userInterfaceInputAction)") + public void doScreenbasedAfter(JoinPoint joinPoint, UserInterfaceInputAction userInterfaceInputAction) { + triggerAfterCallbacks(joinPoint); + } + + void triggerBeforeCallbacks(JoinPoint joinPoint) { + BeanLoader.loadMultipleBeans(UserInterfaceInputActionCallback.class).values().stream() + .filter(Objects::nonNull) + .forEach(cb -> cb.beforeUserInterfaceInput(joinPoint)); + } + + void triggerAfterCallbacks(JoinPoint joinPoint) { + BeanLoader.loadMultipleBeans(UserInterfaceInputActionCallback.class).values().stream() + .filter(Objects::nonNull) + .forEach(cb -> cb.afterUserInterfaceInput(joinPoint)); + } + +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogLevel.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogLevel.java index b8f1db5a..2c1e9d61 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogLevel.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogLevel.java @@ -18,24 +18,12 @@ package org.sakuli.datamodel.actions; -import net.sf.sahi.report.ResultType; - /** * @author Tobias Schneck */ public enum LogLevel { - ERROR(ResultType.ERROR), - INFO(ResultType.INFO), - DEBUG(null), - WARNING(ResultType.INFO); - - private ResultType resultType; - - LogLevel(ResultType resultType) { - this.resultType = resultType; - } - - public ResultType getResultType() { - return resultType; - } + ERROR, + INFO, + DEBUG, + WARNING } diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java index a1bd7984..70c4fd44 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java @@ -38,7 +38,6 @@ public class SakuliProperties extends AbstractProperties { public static final String SAKULI_DEFAULT_PROPERTIES_FILE_APPENDER = File.separator + "sakuli-default.properties"; public static final String SAKULI_HOME_FOLDER = "sakuli.home.folder"; public static final String SUPPRESS_RESUMED_EXCEPTIONS = "sakuli.exception.suppressResumedExceptions"; - public static final String JAVASCRIPT_ENGINE = "sakuli.javascript.engine"; public static final String LOG_FOLDER = "sakuli.log.folder"; public static final String LOG_MAX_AGE = "sakuli.log.maxAge"; public static final String LOG_PATTERN = "sakuli.log.pattern"; @@ -63,8 +62,6 @@ public class SakuliProperties extends AbstractProperties { private Path sakuliHomeFolder; @Value("${" + SUPPRESS_RESUMED_EXCEPTIONS + ":" + SUPPRESS_RESUMED_EXCEPTIONS_DEFAULT + "}") private boolean suppressResumedExceptions; - @Value("${" + JAVASCRIPT_ENGINE + ":" + JAVASCRIPT_ENGINE_DEFAULT + "}") - private boolean loadJavaScriptEngine; @Value("${" + LOG_FOLDER + "}") private String logFolderPropertyValue; @Value("${" + LOG_MAX_AGE + ":" + LOG_MAX_AGE_DEFAULT + "}") @@ -229,14 +226,6 @@ public void setLogLevelRoot(String logLevelRoot) { this.logLevelRoot = logLevelRoot; } - public boolean isLoadJavaScriptEngine() { - return loadJavaScriptEngine; - } - - public void setLoadJavaScriptEngine(boolean loadJavaScriptEngine) { - this.loadJavaScriptEngine = loadJavaScriptEngine; - } - public String getForwarderTemplateFolder() { return forwarderTemplateFolder; } diff --git a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java index 5963f3ee..60c1601d 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java +++ b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java @@ -18,13 +18,13 @@ package org.sakuli.exceptions; -import net.sf.sahi.report.ResultType; import org.sakuli.actions.screenbased.RegionImpl; -import org.sakuli.aop.RhinoAspect; +import org.sakuli.aop.BaseSakuliAspect; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.actions.LogResult; +import org.sakuli.loader.ActionLoaderCallback; +import org.sakuli.loader.BeanLoader; import org.sakuli.loader.ScreenActionLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +36,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author tschneck Date: 12.07.13 @@ -129,16 +130,11 @@ public void handleException(Throwable e) { if (e.getMessage() == null) { e = new SakuliException(e, e.getClass().getSimpleName()); } - - //e.g. Proxy Exception should only be handled if no other exceptions have been added - if (!(e instanceof SakuliInitException) || - (!containsException(loader.getTestSuite()))) { - //if the exception have been already processed do no exception handling! - if (isAlreadyProcessed(e)) { - logger.debug("ALREADY PROCESSED: " + e.getMessage(), e); - } else { - processException(e); - } + //if the exception have been already processed do no exception handling! + if (isAlreadyProcessed(e)) { + logger.debug("ALREADY PROCESSED: " + e.getMessage(), e); + } else { + processException(e); } } @@ -152,41 +148,34 @@ protected void processException(Throwable e) { SakuliException transformedException = transformException(e); //Do different exception handling for different use cases: - if (!resumeToTestExcecution(e)) { + if (resumeToTestExcecution(e) + && loader.getSakuliProperties().isSuppressResumedExceptions()) { + //if suppressResumedExceptions == true and is a resume to test exception + logger.debug(transformedException.getMessage(), transformedException); + } else { //normal handling logger.error(transformedException.getMessage(), transformedException); saveException(transformedException); - - // a {@link SakuliForwarderException}, should only added to the report and not stop sahi, because - // this error types only on already started the tear down of test suite. - if (e instanceof SakuliForwarderException) { - addExceptionToSahiReport(transformedException); - } - //stop the execution and add to report if the exception is not caused by Sahi - else if (!(e instanceof SahiActionException)) { - stopExecutionAndAddExceptionToSahiReport(transformedException); - } - } - //if exceptions should not stop the test case execution - else if (!loader.getSakuliProperties().isSuppressResumedExceptions()) { - // if suppressResumedExceptions == false - logger.error(e.getMessage(), transformedException); - saveException(transformedException); - addExceptionToSahiReport(transformedException); - } else { - //if suppressResumedExceptions == true - logger.debug(transformedException.getMessage(), transformedException); + triggerCallbacks(transformedException); } processedExceptions.add(e); processedExceptions.add(transformedException); } + /** + * Triggers some {@link ActionLoaderCallback#handleException(SakuliException)} implementations. + */ + void triggerCallbacks(SakuliException transformedException) { + BeanLoader.loadMultipleBeans(ActionLoaderCallback.class).values().stream().filter(Objects::nonNull) + .forEach(cb -> cb.handleException(transformedException)); + } + /** * @return true if the exception have been already processed by Sakuli */ public boolean isAlreadyProcessed(Throwable e) { String message = e.getMessage() != null ? e.getMessage() : e.toString(); - return message.contains(RhinoAspect.ALREADY_PROCESSED) + return message.contains(BaseSakuliAspect.ALREADY_PROCESSED) || message.contains(("Logging exception:")) || processedExceptions.contains(e); } @@ -216,35 +205,6 @@ void saveException(SakuliException e) { loader.getTestSuite().refreshState(); } - /** - * save the exception to the current sahi report (HTML Report in the log folder). - * - * @param e any {@link SakuliException} - */ - private void addExceptionToSahiReport(SakuliException e) { - if (loader.getSahiReport() != null) { - loader.getSahiReport().addResult( - e.getMessage(), - ResultType.ERROR, - e.getStackTrace().toString(), - e.getMessage() + RhinoAspect.ALREADY_PROCESSED); - } - } - - /** - * stops the execution of the current test case and add the exception to the sahi report (HTML Report in the log - * folder). - * - * @param e any {@link SakuliException} - */ - private void stopExecutionAndAddExceptionToSahiReport(SakuliException e) { - if (loader.getRhinoScriptRunner() != null) { - loader.getRhinoScriptRunner().setStopOnError(true); - loader.getRhinoScriptRunner().setHasError(); - throw new RuntimeException(RhinoAspect.ALREADY_PROCESSED + e.getMessage()); - } - } - /** * transforms any {@link Throwable} to SakuliException. If the property 'sakuli.screenshot.onError=true' is set, the * methods add a Screenshot. @@ -292,10 +252,6 @@ public void handleException(Throwable e, RegionImpl lastRegion, boolean resumeOn )); } - public void handleException(LogResult logResult) { - handleException(new SahiActionException(logResult)); - } - private T addResumeOnException(T e, boolean resumeOnException) { if (resumeOnException) { resumeExceptions.add(e); @@ -310,7 +266,7 @@ private T addResumeOnException(T e, boolean resumeOnExcept public void throwCollectedResumedExceptions() { if (resumeExceptions.size() > 0) { SakuliRuntimeException e = new SakuliRuntimeException("test contains some suppressed resumed exceptions!"); - resumeExceptions.stream().forEach(t -> e.addSuppressed(t)); + resumeExceptions.forEach(e::addSuppressed); throw e; } } diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/ActionLoaderCallback.java b/src/sakuli-core/src/main/java/org/sakuli/loader/ActionLoaderCallback.java new file mode 100644 index 00000000..611735cd --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/ActionLoaderCallback.java @@ -0,0 +1,48 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.loader; + +import org.sakuli.datamodel.TestCase; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.exceptions.SakuliExceptionHandler; + +/** + * Hookable Callback interface which will be used to trigger some behaviours during a sakuli Action. + * + * @author tschneck + * Date: 4/19/17 + */ +public interface ActionLoaderCallback { + + + /** + * Will be called after the basic initializing of a new {@link TestCase}. + */ + void initTestCase(TestCase testCase); + + /** + * Will be called after a exception is handled in {@link SakuliExceptionHandler}. + */ + void handleException(SakuliException transformedException); + + /** + * Will be called from {@link BeanLoader#releaseContext()}. + */ + void releaseContext(); +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java index 5f120e30..0d04727f 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java @@ -18,17 +18,15 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.actions.environment.CipherUtil; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; import org.sakuli.datamodel.actions.ImageLib; import org.sakuli.datamodel.properties.ActionProperties; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.datamodel.state.TestCaseStepState; import org.sakuli.exceptions.SakuliException; import org.sakuli.exceptions.SakuliExceptionHandler; @@ -51,20 +49,14 @@ public interface BaseActionLoader { void setCurrentTestCase(TestCase testCase); /** - * @return the first Step in state {@link org.sakuli.datamodel.state.TestCaseStepState#INIT} - * or {@link org.sakuli.datamodel.state.TestCaseStepState#ERRORS} in the current {@link TestCase}, + * @return the first Step in state {@link TestCaseStepState#INIT} + * or {@link TestCaseStepState#ERRORS} in the current {@link TestCase}, * if there is one present. */ TestCaseStep getCurrentTestCaseStep(); ImageLib getImageLib(); - RhinoScriptRunner getRhinoScriptRunner(); - - void setRhinoScriptRunner(RhinoScriptRunner scriptRunner); - - Report getSahiReport(); - CipherUtil getCipherUtil(); /** @@ -95,7 +87,5 @@ public interface BaseActionLoader { ActionProperties getActionProperties(); - SahiProxyProperties getSahiProxyProperties(); - TestSuiteProperties getTestSuitePropeties(); } diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java index f11bb843..62442c1b 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java @@ -18,15 +18,12 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.actions.environment.CipherUtil; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; import org.sakuli.datamodel.actions.ImageLib; import org.sakuli.datamodel.properties.ActionProperties; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.exceptions.SakuliException; @@ -43,6 +40,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.SortedSet; /** @@ -68,13 +66,11 @@ public class BaseActionLoaderImpl implements BaseActionLoader { @Autowired private ActionProperties actionProperties; @Autowired - private SahiProxyProperties sahiProxyProperties; - + private CleanUpHelper cleanUpHelper; /** * ** Fields which will be filled at runtime *** */ private TestCase currentTestCase; - private RhinoScriptRunner rhinoScriptRunner; private ImageLib imageLib = new ImageLib(); @Override @@ -98,31 +94,24 @@ public void init(String testCaseID, String... imagePaths) { public void init(String testCaseID, Path... imagePaths) { try { //set the current test case - if (testSuite.getTestCase(testCaseID) == null) { + this.currentTestCase = testSuite.getTestCase(testCaseID); + if (this.currentTestCase == null) { throw new SakuliException("Can't identify current test case in function init() in class SakuliBasedAction"); } - this.currentTestCase = testSuite.getTestCase(testCaseID); addImagePaths(imagePaths); - - if (sakuliProperties.isLoadJavaScriptEngine()) { - //add the "sakuli-delay-active" var to the script runner context - if (rhinoScriptRunner == null || rhinoScriptRunner.getSession() == null) { - //could be possible if the aspectj compiler won't worked correctly, see RhinoAspect#getRhinoScriptRunner - throw new SakuliException(String.format("cannot init rhino script runner with sakuli custom delay variable '%s'", - SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR)); - } - String isRequestDelayActive = String.valueOf(sahiProxyProperties.isRequestDelayActive()); - rhinoScriptRunner.getSession().setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, isRequestDelayActive); - LOGGER.info("set isRequestDelayActive={}", isRequestDelayActive); - } - cleanUp(); + callInitTestCaseCallback(); + cleanUpHelper.releaseAllModifiers(); } catch (SakuliException e) { exceptionHandler.handleException(e); } } - protected void cleanUp() { - CleanUpHelper.releaseAllModifiers(); + /** + * hook to call additional init actions + */ + protected void callInitTestCaseCallback() { + BeanLoader.loadMultipleBeans(ActionLoaderCallback.class).values().stream().filter(Objects::nonNull) + .forEach(bean -> bean.initTestCase(currentTestCase)); } @Override @@ -157,15 +146,6 @@ public void setActionProperties(ActionProperties actionProperties) { this.actionProperties = actionProperties; } - @Override - public SahiProxyProperties getSahiProxyProperties() { - return this.sahiProxyProperties; - } - - public void setSahiProxyProperties(SahiProxyProperties sahiProxyProperties) { - this.sahiProxyProperties = sahiProxyProperties; - } - @Override public TestSuiteProperties getTestSuitePropeties() { return this.testSuiteProperties; @@ -228,21 +208,6 @@ public void setImageLib(ImageLib imageLib) { this.imageLib = imageLib; } - @Override - public RhinoScriptRunner getRhinoScriptRunner() { - return rhinoScriptRunner; - } - - public void setRhinoScriptRunner(RhinoScriptRunner rhinoScriptRunner) { - this.rhinoScriptRunner = rhinoScriptRunner; - - } - - @Override - public Report getSahiReport() { - return rhinoScriptRunner == null ? null : rhinoScriptRunner.getReport(); - } - @Override public CipherUtil getCipherUtil() { return cipherUtil; diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java index f8fdd094..703adbac 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java @@ -23,7 +23,6 @@ import org.sakuli.actions.environment.Environment; import org.sakuli.actions.screenbased.Region; import org.sakuli.exceptions.SakuliInitException; -import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanFactory; @@ -42,6 +41,9 @@ */ public class BeanLoader { protected static final Logger logger = LoggerFactory.getLogger(BeanLoader.class); + /** + * Will be defined in module which imports the `sakuli-core` maven module + */ public static String CONTEXT_PATH = "beanRefFactory.xml"; public static BaseActionLoader loadBaseActionLoader() { @@ -117,7 +119,7 @@ private static BeanFactory getBeanFactory() { * Release the context and shuts the hole context down */ public static void releaseContext() { - loadBean(SakuliPropertyPlaceholderConfigurer.class).restoreProperties(); + loadBean(ActionLoaderCallback.class).releaseContext(); BeanFactory beanFactory = getBeanFactory(); if (beanFactory instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) beanFactory).close(); diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java b/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java index da80dd63..7a4b347a 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java @@ -18,8 +18,6 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.actions.environment.CipherUtil; import org.sakuli.actions.screenbased.ScreenshotActions; import org.sakuli.actions.settings.ScreenBasedSettings; @@ -29,7 +27,6 @@ import org.sakuli.datamodel.actions.ImageLib; import org.sakuli.datamodel.actions.Screen; import org.sakuli.datamodel.properties.ActionProperties; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.exceptions.SakuliException; @@ -130,11 +127,6 @@ public ActionProperties getActionProperties() { return baseLoader.getActionProperties(); } - @Override - public SahiProxyProperties getSahiProxyProperties() { - return baseLoader.getSahiProxyProperties(); - } - @Override public TestSuiteProperties getTestSuitePropeties() { return baseLoader.getTestSuitePropeties(); @@ -169,19 +161,4 @@ public TestCaseStep getCurrentTestCaseStep() { public ImageLib getImageLib() { return baseLoader.getImageLib(); } - - @Override - public RhinoScriptRunner getRhinoScriptRunner() { - return baseLoader.getRhinoScriptRunner(); - } - - @Override - public void setRhinoScriptRunner(RhinoScriptRunner scriptRunner) { - baseLoader.setRhinoScriptRunner(scriptRunner); - } - - @Override - public Report getSahiReport() { - return baseLoader.getSahiReport(); - } } diff --git a/src/sakuli-core/src/main/java/org/sakuli/services/common/CacheHandlingResultServiceImpl.java b/src/sakuli-core/src/main/java/org/sakuli/services/common/CacheHandlingResultServiceImpl.java index 161b8bbc..85000f1a 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/services/common/CacheHandlingResultServiceImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/services/common/CacheHandlingResultServiceImpl.java @@ -20,6 +20,7 @@ import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; +import org.sakuli.datamodel.TestSuite; import org.sakuli.datamodel.helper.TestCaseStepHelper; import org.sakuli.datamodel.state.TestSuiteState; import org.sakuli.exceptions.SakuliRuntimeException; @@ -33,7 +34,7 @@ /** * The CacheHandlingResultService will manage the cached steps definitions in the file `steps.cache`. - * If the {@link org.sakuli.datamodel.TestSuite#state} is NOT {@link TestSuiteState#ERRORS} or {@link TestSuiteState#RUNNING} it will + * If the {@link TestSuite#state} is NOT {@link TestSuiteState#ERRORS} or {@link TestSuiteState#RUNNING} it will * remove all present not called step definitions and persist its. * This Service MUST be called as first Service before all other {@link org.sakuli.services.ResultService}s * diff --git a/src/sakuli-core/src/main/java/org/sakuli/services/common/CommonResultServiceImpl.java b/src/sakuli-core/src/main/java/org/sakuli/services/common/CommonResultServiceImpl.java index 8cf9ede1..bd0e5077 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/services/common/CommonResultServiceImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/services/common/CommonResultServiceImpl.java @@ -22,6 +22,7 @@ import org.sakuli.utils.CleanUpHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.function.Predicate; @@ -35,6 +36,8 @@ @Component public class CommonResultServiceImpl extends AbstractResultService { private static Logger LOGGER = LoggerFactory.getLogger(CommonResultServiceImpl.class); + @Autowired + private CleanUpHelper cleanUpHelper; @Override public int getServicePriority() { @@ -80,8 +83,8 @@ private void logTestCaseStateDetailInfo(Predicate predicate) { public void cleanUp() { try { - CleanUpHelper.cleanClipboard(); - CleanUpHelper.releaseAllModifiers(); + cleanUpHelper.cleanClipboard(); + cleanUpHelper.releaseAllModifiers(); } catch (Throwable e) { LOGGER.warn("Some unexpected errors during the clean up procedure:", e); } diff --git a/src/sakuli-core/src/main/java/org/sakuli/utils/CleanUpHelper.java b/src/sakuli-core/src/main/java/org/sakuli/utils/CleanUpHelper.java index 4ecc7688..021c24f6 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/utils/CleanUpHelper.java +++ b/src/sakuli-core/src/main/java/org/sakuli/utils/CleanUpHelper.java @@ -20,10 +20,12 @@ import org.sakuli.actions.environment.Application; import org.sakuli.actions.screenbased.Key; -import org.sakuli.loader.BeanLoader; +import org.sakuli.loader.ScreenActionLoader; import org.sikuli.script.IRobot; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import java.util.Arrays; @@ -31,18 +33,21 @@ * @author tschneck * Date: 2/26/16 */ +@Component public class CleanUpHelper { private static final Logger LOGGER = LoggerFactory.getLogger(CleanUpHelper.class); + @Autowired + private ScreenActionLoader screenActionLoader; - public static void releaseAllModifiers() { - IRobot robot = BeanLoader.loadScreenActionLoader().getScreen().getRobot(); + public void releaseAllModifiers() { + IRobot robot = screenActionLoader.getScreen().getRobot(); LOGGER.debug("release all modifier keys!"); Arrays.asList(Key.C_CTRL, Key.C_ALT, Key.C_ALTGR, Key.C_SHIFT, Key.C_WIN, Key.C_CAPS_LOCK) .forEach(i -> robot.typeChar(i, IRobot.KeyMode.RELEASE_ONLY)); } - public static void cleanClipboard() { + public void cleanClipboard() { LOGGER.debug("clear Clipboard content!"); Application.setClipboard(" "); } diff --git a/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java b/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java index e3ccbdfd..c2964e93 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java +++ b/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java @@ -20,19 +20,17 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import javax.annotation.PreDestroy; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.*; +import java.util.Iterator; +import java.util.Properties; import static org.apache.commons.lang.StringUtils.isNotEmpty; @@ -46,18 +44,11 @@ public class SakuliPropertyPlaceholderConfigurer extends PropertyPlaceholderConf public static String TEST_SUITE_FOLDER_VALUE; public static String SAKULI_HOME_FOLDER_VALUE; - public static String SAHI_HOME_VALUE; public static String TEST_SUITE_BROWSER; + private static Logger LOGGER = LoggerFactory.getLogger(SakuliPropertyPlaceholderConfigurer.class); protected boolean loadSakuliProperties = true; protected boolean loadSakuliDefaultProperties = true; protected boolean loadTestSuiteProperties = true; - protected boolean writePropertiesToSahiConfig = true; - private Logger logger = LoggerFactory.getLogger(this.getClass()); - private Map> modifiedSahiConfigProps; - - public SakuliPropertyPlaceholderConfigurer() { - modifiedSahiConfigProps = new HashMap<>(); - } @Override protected void loadProperties(Properties props) throws IOException { @@ -69,15 +60,10 @@ protected void loadProperties(Properties props) throws IOException { loadSakuliDefaultProperties(props); loadSakuliProperties(props); loadTestSuiteProperties(props); - //overwrite if set sahi proxy home - if (isNotEmpty(SAHI_HOME_VALUE)) { - props.setProperty(SahiProxyProperties.PROXY_HOME_FOLDER, SAHI_HOME_VALUE); - props.setProperty(SahiProxyProperties.PROXY_CONFIG_FOLDER, SAHI_HOME_VALUE + File.separator + "userdata"); - } + if (isNotEmpty(TEST_SUITE_BROWSER)) { props.setProperty(TestSuiteProperties.BROWSER_NAME, TEST_SUITE_BROWSER); } - modifySahiProperties(props); super.loadProperties(props); } @@ -98,27 +84,6 @@ protected void loadTestSuiteProperties(Properties props) { addPropertiesFromFile(props, testSuitePropFile, loadTestSuiteProperties); } - @PreDestroy - public void restoreProperties() { - try { - for (Map.Entry> entry : modifiedSahiConfigProps.entrySet()) { - String propFile = entry.getKey(); - logger.debug("restore properties file '{}' with properties '{}'", propFile, entry.getValue()); - PropertiesConfiguration propConfig = new PropertiesConfiguration(propFile); - propConfig.setAutoSave(true); - for (Map.Entry propEntry : entry.getValue().entrySet()) { - String propKey = propEntry.getKey(); - if (propConfig.containsKey(propKey)) { - propConfig.clearProperty(propKey); - } - propConfig.addProperty(propKey, propEntry.getValue()); - } - } - } catch (ConfigurationException e) { - logger.error("Error in restore sahi config properties", e); - } - } - /** * Reads in the properties for a specific file * @@ -126,9 +91,9 @@ public void restoreProperties() { * @param filePath path to readable properties file * @param active activate or deactivate the function */ - protected void addPropertiesFromFile(Properties props, String filePath, boolean active) { + public void addPropertiesFromFile(Properties props, String filePath, boolean active) { if (active) { - logger.info("read in properties from '{}'", filePath); + LOGGER.info("read in properties from '{}'", filePath); try { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(filePath); Iterator keyIt = propertiesConfiguration.getKeys(); @@ -143,20 +108,7 @@ protected void addPropertiesFromFile(Properties props, String filePath, boolean } } - protected void modifySahiProperties(Properties props) { - if (writePropertiesToSahiConfig) { - String sahiConfigFolderPath = resolve(props.getProperty(SahiProxyProperties.PROXY_CONFIG_FOLDER), props); - - String sahiPropConfig = Paths.get(sahiConfigFolderPath + SahiProxyProperties.SAHI_PROPERTY_FILE_APPENDER).normalize().toAbsolutePath().toString(); - modifyPropertiesConfiguration(sahiPropConfig, SahiProxyProperties.userdataPropertyNames, props); - modifySahiProxyPortPropertiesConfiguration(sahiPropConfig, props); - String sahiLogPropConfig = Paths.get(sahiConfigFolderPath + SahiProxyProperties.SAHI_LOG_PROPERTY_FILE_APPENDER).normalize().toAbsolutePath().toString(); - modifyPropertiesConfiguration(sahiLogPropConfig, SahiProxyProperties.logPropertyNames, props); - } - } - - - private String resolve(String string, Properties props) { + protected String resolve(String string, Properties props) { if (string != null) { int i = string.indexOf("${"); if (i >= 0) { @@ -170,66 +122,6 @@ private String resolve(String string, Properties props) { return string; } - /** - * writes the {@link SahiProxyProperties#PROXY_PORT} value as {@link SahiProxyProperties#SAHI_PROPERTY_PROXY_PORT_MAPPING} - * property to sahiConfigPropertyFilePath! - */ - protected void modifySahiProxyPortPropertiesConfiguration(String sahiConfigPropertyFilePath, Properties props) { - final String sahiProxyPort = props.getProperty(SahiProxyProperties.PROXY_PORT); - if (sahiProxyPort != null) { - try { - PropertiesConfiguration propConfig = new PropertiesConfiguration(sahiConfigPropertyFilePath); - propConfig.setAutoSave(true); - final String sahiMappingPropertyProxyPort = SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING; - - if (propConfig.containsKey(sahiMappingPropertyProxyPort)) { - propConfig.clearProperty(sahiMappingPropertyProxyPort); - } - //remove property after the test execution, so that the installation can't break - addToModifiedPropertiesMap(sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, null); - propConfig.addProperty(sahiMappingPropertyProxyPort, sahiProxyPort); - logger.debug("modify properties file '{}' with '{}={}'", sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, sahiProxyPort); - } catch (ConfigurationException e) { - logger.error("modify sahi properties went wrong", e); - } - } - } - - /** - * Modifies the properties file 'propFilePathToConfig' with assigned key from the resource properties. - */ - protected void modifyPropertiesConfiguration(String propFilePathToConfig, List updateKeys, Properties resourceProps) { - try { - PropertiesConfiguration propConfig = new PropertiesConfiguration(propFilePathToConfig); - propConfig.setAutoSave(true); - Properties temProps = new Properties(); - for (String propKey : updateKeys) { - String resolve = resolve(resourceProps.getProperty(propKey), resourceProps); - if (resolve != null) { - if (propConfig.containsKey(propKey)) { - addToModifiedPropertiesMap(propFilePathToConfig, propKey, propConfig.getProperty(propKey)); - propConfig.clearProperty(propKey); - } - temProps.put(propKey, resolve); - propConfig.addProperty(propKey, resolve); - } - } - logger.debug("modify properties file '{}' with '{}'", propFilePathToConfig, temProps.toString()); - } catch (ConfigurationException e) { - logger.error("modify sahi properties went wrong", e); - } - - } - - protected void addToModifiedPropertiesMap(String propFilePath, String propKey, Object propertyValue) { - Map propMap = modifiedSahiConfigProps.get(propFilePath); - if (propMap == null) { - propMap = new HashMap<>(); - } - propMap.put(propKey, propertyValue); - modifiedSahiConfigProps.put(propFilePath, propMap); - } - public boolean isLoadSakuliDefaultProperties() { return loadSakuliDefaultProperties; } @@ -253,12 +145,4 @@ public boolean isLoadTestSuiteProperties() { public void setLoadTestSuiteProperties(boolean loadTestSuiteProperties) { this.loadTestSuiteProperties = loadTestSuiteProperties; } - - public boolean isWritePropertiesToSahiConfig() { - return writePropertiesToSahiConfig; - } - - public void setWritePropertiesToSahiConfig(boolean writePropertiesToSahiConfig) { - this.writePropertiesToSahiConfig = writePropertiesToSahiConfig; - } } diff --git a/src/sakuli-core/src/main/java/org/sakuli/utils/SpringProfilesInitializer.java b/src/sakuli-core/src/main/java/org/sakuli/utils/SpringProfilesInitializer.java index dc761c13..cc764ff3 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/utils/SpringProfilesInitializer.java +++ b/src/sakuli-core/src/main/java/org/sakuli/utils/SpringProfilesInitializer.java @@ -60,7 +60,7 @@ public void afterPropertiesSet() throws Exception { ctx.getEnvironment().setActiveProfiles(configuredProfiles); ctx.refresh(); } else if (configuredProfiles.length == 0) { - logger.info("no spring context profile activated", configuredProfiles); + logger.info("no spring context profile activated"); } } diff --git a/src/sakuli-core/src/main/resources/applicationContext.xml b/src/sakuli-core/src/main/resources/applicationContext.xml index 3761a635..8922df69 100644 --- a/src/sakuli-core/src/main/resources/applicationContext.xml +++ b/src/sakuli-core/src/main/resources/applicationContext.xml @@ -38,7 +38,6 @@ - diff --git a/src/sakuli-core/src/test/java/org/sakuli/BaseTest.java b/src/sakuli-core/src/test/java/org/sakuli/BaseTest.java index 2814b2b6..2ef5c995 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/BaseTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/BaseTest.java @@ -18,9 +18,8 @@ package org.sakuli; -import net.sf.sahi.report.Report; -import org.apache.commons.lang3.StringUtils; import org.mockito.internal.util.MockUtil; +import org.sakuli.datamodel.actions.LogLevel; import org.sakuli.loader.BaseActionLoader; import org.sakuli.loader.BaseActionLoaderImpl; import org.sakuli.loader.BeanLoader; @@ -28,55 +27,22 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import java.io.File; +import java.io.IOException; +import java.nio.file.Path; -import static org.mockito.Mockito.*; -import static org.testng.Assert.assertTrue; +import static org.mockito.Mockito.reset; /** * @author tschneck Date: 25.07.13 */ -public abstract class BaseTest extends AbstractLogAwareTest { +public abstract class BaseTest extends AbstractBaseTest { - public static final String SAKULI_HOME_FOLDER_PATH = StringUtils.replace( - "../sakuli-common/src/main/resources/org/sakuli/common", "/", File.separator); - public static final String SAHI_FOLDER_PATH = ".." + File.separator + "sahi"; - public static final String TEST_FOLDER_PATH = getResource("/_testsuite4JUnit"); - public static final String TEST_CONTEXT_PATH = "JUnit-beanRefFactory.xml"; protected BaseActionLoader loaderMock; - - public static void assertRegExMatch(String string, String regex) { - assertTrue(string.matches(regex), - String.format("string '%s' won't match to regex '%s'", string, regex)); - } - - public static void assertContains(String string, String contains) { - assertTrue(string.contains(contains), - String.format("string '%s' won't contain '%s'", string, contains)); - } - - protected String getTestContextPath() { - return TEST_CONTEXT_PATH; - } - - protected String getSahiFolderPath() { - return SAHI_FOLDER_PATH; - } - - protected String getSakuliHomeFolderPath() { - return SAKULI_HOME_FOLDER_PATH; - } - - protected String getTestFolderPath() { - return TEST_FOLDER_PATH; - } - @BeforeClass(alwaysRun = true) public void setContextProperties() { SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = getTestFolderPath(); SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = getSakuliHomeFolderPath(); - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = getSahiFolderPath(); BeanLoader.CONTEXT_PATH = getTestContextPath(); BeanLoader.refreshContext(); initBaseActionLoader(); @@ -86,7 +52,6 @@ protected void initBaseActionLoader() { loaderMock = BeanLoader.loadBean(BaseActionLoaderImpl.class); if (new MockUtil().isMock(loaderMock)) { reset(loaderMock); - when(loaderMock.getSahiReport()).thenReturn(mock(Report.class)); } } @@ -94,7 +59,10 @@ protected void initBaseActionLoader() { public void tearDown() throws Exception { SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = BaseTest.TEST_FOLDER_PATH; SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; BeanLoader.CONTEXT_PATH = BaseTest.TEST_CONTEXT_PATH; } + + protected synchronized void assertLastLine(Path logFile, String filter, LogLevel logLevel, String expectedMessage) throws IOException { + super.assertLastLine(logFile, filter, logLevel.name(), expectedMessage); + } } diff --git a/src/sakuli-core/src/test/java/org/sakuli/actions/screenbased/RegionTestImpl.java b/src/sakuli-core/src/test/java/org/sakuli/actions/screenbased/RegionTestImpl.java index a567ceaf..172d78c9 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/actions/screenbased/RegionTestImpl.java +++ b/src/sakuli-core/src/test/java/org/sakuli/actions/screenbased/RegionTestImpl.java @@ -19,12 +19,12 @@ package org.sakuli.actions.screenbased; import org.sakuli.actions.logging.LogToResult; -import org.sakuli.aop.RhinoAspectTest; +import org.sakuli.aop.LogActionExecutedAspectTest; import org.sakuli.datamodel.actions.LogLevel; import org.sakuli.loader.ScreenActionLoader; /** - * Test class for {@link RhinoAspectTest#testdoScreenBasedActionLog()} + * Test class for {@link LogActionExecutedAspectTest#testdoScreenBasedActionLog()} * * @author tschneck Date: 23.05.14 */ diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/AopBaseTest.java b/src/sakuli-core/src/test/java/org/sakuli/aop/AopBaseTest.java index e4b44c1c..61ebf9d5 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/aop/AopBaseTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/aop/AopBaseTest.java @@ -18,8 +18,6 @@ package org.sakuli.aop; -import net.sf.sahi.playback.SahiScript; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.BaseTest; import org.sakuli.PropertyHolder; import org.sakuli.exceptions.SakuliExceptionHandler; @@ -29,7 +27,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.reset; /** * @author tschneck Date: 23.09.14 @@ -50,15 +48,12 @@ protected String getTestFolderPath() { @Override protected String getTestContextPath() { - return "aopTest-beanRefFactory.xml"; + return "org/sakuli/aop/aopTest-beanRefFactory.xml"; } protected void initMocks() { SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); reset(sakuliExceptionHandler); - SahiScript sahiScriptMock = mock(SahiScript.class); - when(sahiScriptMock.jsString()).thenReturn(""); - new RhinoScriptRunner(sahiScriptMock); } } diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/RhinoAspectTest.java b/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java similarity index 64% rename from src/sakuli-core/src/test/java/org/sakuli/aop/RhinoAspectTest.java rename to src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java index d9313a1e..0d7eaa99 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/aop/RhinoAspectTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java @@ -18,20 +18,16 @@ package org.sakuli.aop; -import net.sf.sahi.report.Report; -import net.sf.sahi.report.ResultType; -import net.sf.sahi.report.TestResult; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.sakuli.actions.TestCaseAction; import org.sakuli.actions.environment.Environment; import org.sakuli.actions.logging.LogToResult; +import org.sakuli.actions.logging.LogToResultCallback; import org.sakuli.actions.logging.Logger; import org.sakuli.actions.screenbased.RegionTestImpl; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.actions.LogLevel; -import org.sakuli.datamodel.actions.LogResult; -import org.sakuli.exceptions.SakuliExceptionHandler; import org.sakuli.loader.BaseActionLoader; import org.sakuli.loader.BeanLoader; import org.sakuli.loader.ScreenActionLoader; @@ -39,23 +35,14 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.util.Collection; + import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -public class RhinoAspectTest extends AopBaseTest { - - @DataProvider(name = "resultTypes") - public static Object[][] resultTypes() { - return new Object[][]{ - {ResultType.INFO}, - {ResultType.ERROR}, - {ResultType.SKIPPED}, - {ResultType.SUCCESS} - }; - } +public class LogActionExecutedAspectTest extends AopBaseTest { @DataProvider(name = "logLevel") public static Object[][] logLevel() { @@ -67,70 +54,9 @@ public static Object[][] logLevel() { }; } - @Test - public void testGetRhinoScriptRunner() throws Exception { - initMocks(); - - /** - * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler - * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it - * with the option 'Execute After Make'. - */ - assertNotNull(BeanLoader.loadBaseActionLoader().getSahiReport()); - } - - @Test(dataProvider = "resultTypes") - public void testDoHandleRhinoException(ResultType resultTyp) throws Exception { - initMocks(); - /** - * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler - * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it - * with the option 'Execute After Make'. - */ - Report sahiReport = BeanLoader.loadBaseActionLoader().getSahiReport(); - int lisSize = sahiReport.getListResult().size(); - assertNotNull(sahiReport); - sahiReport.addResult("TEST-ENTRY", resultTyp, "bla", "TEST-ENTRY"); - verifySahiReport(resultTyp, lisSize); - } - - @Test(dataProvider = "resultTypes") - public void testDoHandleRhinoExceptionResultString(ResultType resultTyp) throws Exception { - initMocks(); - /** - * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler - * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it - * with the option 'Execute After Make'. - */ - Report sahiReport = BeanLoader.loadBaseActionLoader().getSahiReport(); - int lisSize = sahiReport.getListResult().size(); - assertNotNull(sahiReport); - sahiReport.addResult("TEST-ENTRY", resultTyp.getName(), "bla", "TEST-ENTRY"); - verifySahiReport(resultTyp, lisSize); - } - - private void verifySahiReport(ResultType resultTyp, int initialListSize) { - if (resultTyp != null) { - Report sahiReport2 = BeanLoader.loadBaseActionLoader().getSahiReport(); - int newLisSize = sahiReport2.getListResult().size(); - assertEquals(newLisSize, initialListSize + 1); - TestResult testResult = sahiReport2.getListResult().get(newLisSize - 1); - assertNotNull(testResult); - - SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); - if (resultTyp.equals(ResultType.ERROR) || resultTyp.equals(ResultType.FAILURE)) { - verify(sakuliExceptionHandler).handleException(any(LogResult.class)); - } else { - verify(sakuliExceptionHandler, never()).handleException(any(LogResult.class)); - } - } - } - @Test(dataProvider = "logLevel") public void testAddActionLog(LogLevel logLevel) throws Exception { initMocks(); - Report sahiReport = BeanLoader.loadBaseActionLoader().getSahiReport(); - final int lisSize = sahiReport.getListResult().size(); final String classContent = "Test-Action-Content"; final String className = TestCaseAction.class.getSimpleName(); @@ -157,14 +83,17 @@ public void testAddActionLog(LogLevel logLevel) throws Exception { when(logToResult.message()).thenReturn(sampleMessage); when(logToResult.logArgs()).thenReturn(true); when(logToResult.level()).thenReturn(logLevel); - RhinoAspect testling = BeanLoader.loadBean(RhinoAspect.class); + LogActionExecutedAspect testling = BeanLoader.loadBean(LogActionExecutedAspect.class); testling.addActionLog(jp, logToResult); assertLastLine(logFile, className, logLevel, "\"" + classContent + "\" " + className + "." + methodName + "() - " + sampleMessage + " with arg(s) [" + arg1 + ", " + arg2 + "]" ); - verifySahiReport(logLevel.getResultType(), lisSize); + final Collection callbacks = BeanLoader.loadMultipleBeans(LogToResultCallback.class).values(); + assertEquals(callbacks.size(), 1); + final LogToResultCallback cb = callbacks.stream().findFirst().get(); + verify(cb).doActionLog(any(), eq(logToResult)); //hide args when(logToResult.logArgs()).thenReturn(false); @@ -173,6 +102,8 @@ public void testAddActionLog(LogLevel logLevel) throws Exception { "\"" + classContent + "\" " + className + "." + methodName + "() - " + sampleMessage + " with arg(s) [****, ****]" ); + verify(cb, times(2)).doActionLog(any(), eq(logToResult)); + //without class values when(logToResult.logClassInstance()).thenReturn(false); @@ -181,18 +112,22 @@ public void testAddActionLog(LogLevel logLevel) throws Exception { className + "." + methodName + "() - " + sampleMessage + " with arg(s) [****, ****]" ); + verify(cb, times(3)).doActionLog(any(), eq(logToResult)); //without args when(jp.getArgs()).thenReturn(null); testling.addActionLog(jp, logToResult); assertLastLine(logFile, className, logLevel, className + "." + methodName + "() - " + sampleMessage); + verify(cb, times(4)).doActionLog(any(), eq(logToResult)); + //without message when(logToResult.message()).thenReturn(null); testling.addActionLog(jp, logToResult); assertLastLine(logFile, className, logLevel, className + "." + methodName + "()"); + verify(cb, times(5)).doActionLog(any(), eq(logToResult)); } @Test @@ -242,7 +177,7 @@ public void testCreateLoggingString() throws Exception { LogToResult annotation = mock(LogToResult.class); when(annotation.logArgsOnly()).thenReturn(true); when(annotation.logArgs()).thenReturn(true); - StringBuilder result = BeanLoader.loadBean(RhinoAspect.class).createLoggingString(jp, annotation); + StringBuilder result = BaseSakuliAspect.createLoggingString(jp, annotation); assertEquals(result.toString(), "TEST, arguments"); } } \ No newline at end of file diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspectTest.java b/src/sakuli-core/src/test/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspectTest.java new file mode 100644 index 00000000..a50f28c5 --- /dev/null +++ b/src/sakuli-core/src/test/java/org/sakuli/aop/UserInterfaceInputActionExecutedAspectTest.java @@ -0,0 +1,56 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.aop; + +import org.sakuli.actions.environment.Environment; +import org.sakuli.actions.screenbased.TypingUtil; +import org.sakuli.actions.screenbased.UserInterfaceInputActionCallback; +import org.sakuli.datamodel.actions.LogLevel; +import org.sakuli.loader.BeanLoader; +import org.springframework.test.util.ReflectionTestUtils; +import org.testng.annotations.Test; + +import java.util.Collection; + +import static org.mockito.Mockito.*; +import static org.testng.Assert.assertEquals; + +/** + * @author tschneck + * Date: 4/24/17 + */ +public class UserInterfaceInputActionExecutedAspectTest extends AopBaseTest { + + @Test + public void testDoEnvironmentLog() throws Exception { + TypingUtil typingUtil = mock(TypingUtil.class); + Environment testAction = new Environment(false); + ReflectionTestUtils.setField(testAction, "typingUtil", typingUtil); + testAction.type("nothing"); + + verify(typingUtil).type(anyString(), anyString()); + assertLastLine(logFile, testAction.getClass().getSimpleName(), LogLevel.INFO, + "Environment.type() - type over system keyboard with arg(s) [nothing]"); + final Collection callbacks = BeanLoader.loadMultipleBeans(UserInterfaceInputActionCallback.class).values(); + assertEquals(callbacks.size(), 1); + final UserInterfaceInputActionCallback cb = callbacks.stream().findFirst().get(); + verify(cb).afterUserInterfaceInput(any()); + verify(cb).beforeUserInterfaceInput(any()); + } +} \ No newline at end of file diff --git a/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerCallbackTest.java b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerCallbackTest.java new file mode 100644 index 00000000..fbba4730 --- /dev/null +++ b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerCallbackTest.java @@ -0,0 +1,58 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.exceptions; + +import org.sakuli.BaseTest; +import org.sakuli.loader.ActionLoaderCallback; +import org.sakuli.loader.BeanLoader; +import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.Collection; + +import static org.mockito.Mockito.verify; + +/** + * @author tschneck + * Date: 4/19/17 + */ +public class SakuliExceptionHandlerCallbackTest { + @BeforeMethod + public void setUp() throws Exception { + SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = BaseTest.TEST_FOLDER_PATH; + SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; + BeanLoader.CONTEXT_PATH = "org/sakuli/exceptions/exceptionCallbackTest-beanRefFactory.xml"; + BeanLoader.refreshContext(); + } + + + @Test + public void testHandleExceptionCallback() throws Exception { + final SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); + Assert.assertNotNull(sakuliExceptionHandler); + SakuliException exception = new SakuliInitException("test it"); + sakuliExceptionHandler.triggerCallbacks(exception); + + final Collection callbacks = BeanLoader.loadMultipleBeans(ActionLoaderCallback.class).values(); + Assert.assertEquals(callbacks.size(), 1); + verify(callbacks.stream().findFirst().get()).handleException(exception); + } +} \ No newline at end of file diff --git a/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java index 261f496e..3356c685 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java @@ -18,11 +18,10 @@ package org.sakuli.exceptions; -import net.sf.sahi.report.Report; -import net.sf.sahi.report.ResultType; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.Spy; import org.sakuli.BaseTest; import org.sakuli.actions.screenbased.RegionImpl; import org.sakuli.actions.screenbased.ScreenshotActions; @@ -65,9 +64,8 @@ public class SakuliExceptionHandlerTest extends BaseTest { private SakuliProperties sakuliProperties; @Mock private ActionProperties actionProperties; - @Mock - private Report sahiReport; + @Spy @InjectMocks private SakuliExceptionHandler testling; @@ -90,7 +88,6 @@ private void setUp() throws Exception { when(actionProperties.isTakeScreenshots()).thenReturn(true); when(loader.getSakuliProperties()).thenReturn(sakuliProperties); when(sakuliProperties.isSuppressResumedExceptions()).thenReturn(false); - when(loader.getSahiReport()).thenReturn(sahiReport); when(loader.getTestSuite()).thenReturn(testSuite); when(loader.getCurrentTestCase()).thenReturn(testCase); @@ -121,6 +118,7 @@ public void testHandleActionException() throws Exception { assertTrue(testSuite.getException() instanceof SakuliException); assertEquals(testSuite.getException().getMessage(), testExcMessage); assertEquals(testSuite.getScreenShotPath(), expectedScreenshotPath); + verify(testling).triggerCallbacks(any(SakuliExceptionWithScreenshot.class)); } @Test @@ -131,6 +129,7 @@ public void testHandleExceptionForTestCases() throws Exception { assertTrue(testCase.getException() instanceof SakuliExceptionWithScreenshot); assertEquals(testCase.getException().getMessage(), testExcMessage); assertEquals(testCase.getScreenShotPath(), expectedScreenshotPath); + verify(testling).triggerCallbacks(any(SakuliExceptionWithScreenshot.class)); //test Suppressed String excpMessage2 = "ExceptionSuppressed"; @@ -138,12 +137,14 @@ public void testHandleExceptionForTestCases() throws Exception { assertEquals(testCase.getExceptionMessages(false), testExcMessage + "\n\t\tSuppressed EXCEPTION: " + excpMessage2); assertEquals(testCase.getState(), TestCaseState.ERRORS); assertEquals(testSuite.getState(), TestSuiteState.ERRORS); + verify(testling, times(2)).triggerCallbacks(any(SakuliExceptionWithScreenshot.class)); //test Proxy Exception when(loader.getCurrentTestCase()).thenReturn(null); testling.handleException(new SakuliInitException("FAILURE")); - Assert.assertNull(testSuite.getException()); + Assert.assertEquals(testSuite.getException().getMessage(), "FAILURE"); assertTrue(testling.isAlreadyProcessed(testExc)); + verify(testling, times(3)).triggerCallbacks(any(SakuliException.class)); } @Test @@ -175,7 +176,6 @@ public void testSakuliForwarderException() throws Exception { testling.handleException(forwarderException, true); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class)); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); - verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertEquals(testSuite.getException(), forwarderException); assertTrue(testling.resumeToTestExcecution(testSuite.getException())); assertTrue(testling.isAlreadyProcessed(testSuite.getException())); @@ -190,7 +190,6 @@ public void testSakuliForwarderException2() throws Exception { testling.handleException(forwarderException); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class)); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); - verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertEquals(testSuite.getException(), forwarderException); assertTrue(testling.isAlreadyProcessed(testSuite.getException())); } @@ -204,7 +203,6 @@ public void testSakuliActionExceptionTakeUnsuccessfulScreenshotFromRegion() thro testling.handleException(sakuliActionException, mock(RegionImpl.class), true); verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); - verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); assertTrue(testling.resumeToTestExcecution(testSuite.getException())); @@ -221,7 +219,6 @@ public void testSakuliActionExceptionTakeSuccessfulScreenshotFromRegion() throws testling.handleException(sakuliActionException, mock(RegionImpl.class), true); verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); - verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); assertTrue(testling.resumeToTestExcecution(testSuite.getException())); @@ -229,7 +226,7 @@ public void testSakuliActionExceptionTakeSuccessfulScreenshotFromRegion() throws } @Test - public void testHandleSakuliProxyExceptionForTestCases() throws Exception { + public void testHandleSakuliInitExceptionForTestCases() throws Exception { setUp(); when(loader.getCurrentTestCase()).thenReturn(null); testling.handleException(new SakuliInitException(testExcMessage)); diff --git a/src/sakuli-core/src/test/java/org/sakuli/loader/ActionLoaderCallbackTest.java b/src/sakuli-core/src/test/java/org/sakuli/loader/ActionLoaderCallbackTest.java new file mode 100644 index 00000000..00bdc12e --- /dev/null +++ b/src/sakuli-core/src/test/java/org/sakuli/loader/ActionLoaderCallbackTest.java @@ -0,0 +1,60 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.loader; + +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.TestSuite; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.nio.file.Paths; +import java.util.Collection; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; + +/** + * @author tschneck + * Date: 4/19/17 + */ +public class ActionLoaderCallbackTest extends BeanLoaderTest { + @Test + public void testInitTestCase() throws Exception { + final String testCaseID = "test-action-hook"; + final TestCase testCase = new TestCase(testCaseID, testCaseID); + Assert.assertNotNull(BeanLoader.loadBaseActionLoader()); + final Collection callbacks = BeanLoader.loadMultipleBeans(ActionLoaderCallback.class).values(); + Assert.assertEquals(callbacks.size(), 1); + when(BeanLoader.loadBean(TestSuite.class).getTestCase(any())).thenReturn(testCase); + + BeanLoader.loadBaseActionLoader().init(testCaseID, Paths.get(".")); + verify(BeanLoader.loadBean(SakuliExceptionHandler.class), never()).handleException(any()); + verify(callbacks.stream().findFirst().get()).initTestCase(testCase); + } + + @Test + public void testReleaseCallback() throws Exception { + final Collection callbacks = BeanLoader.loadMultipleBeans(ActionLoaderCallback.class).values(); + Assert.assertEquals(callbacks.size(), 1); + BeanLoader.releaseContext(); + verify(callbacks.stream().findFirst().get()).releaseContext(); + + } +} \ No newline at end of file diff --git a/src/sakuli-core/src/test/java/org/sakuli/loader/BaseActionLoaderTest.java b/src/sakuli-core/src/test/java/org/sakuli/loader/BaseActionLoaderTest.java index 49dc0dd8..cbcc3a08 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/loader/BaseActionLoaderTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/loader/BaseActionLoaderTest.java @@ -18,19 +18,18 @@ package org.sakuli.loader; -import net.sf.sahi.rhino.RhinoScriptRunner; -import net.sf.sahi.session.Session; import org.joda.time.DateTime; -import org.mockito.*; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestSuite; import org.sakuli.datamodel.builder.TestCaseStepBuilder; -import org.sakuli.datamodel.properties.SahiProxyProperties; -import org.sakuli.datamodel.properties.SakuliProperties; -import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.datamodel.state.TestCaseStepState; import org.sakuli.exceptions.SakuliException; import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.utils.CleanUpHelper; import org.springframework.test.util.ReflectionTestUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -45,20 +44,12 @@ * autor tschneck */ public class BaseActionLoaderTest { - @Mock - private RhinoScriptRunner rhinoScriptRunner; - @Mock - private Session session; - @Mock - private SahiProxyProperties sahiProxyProperties; - @Mock - private TestSuiteProperties testSuiteProperties; @Mock private TestSuite testSuite; @Mock private SakuliExceptionHandler exceptionHandler; @Mock - private SakuliProperties sakuliProperties; + private CleanUpHelper cleanUpHelper; @Spy @InjectMocks @@ -67,45 +58,7 @@ public class BaseActionLoaderTest { @BeforeMethod public void init() { MockitoAnnotations.initMocks(this); - when(rhinoScriptRunner.getSession()).thenReturn(session); - doNothing().when(testling).cleanUp(); - } - - @Test - public void testInit() throws Exception { - String testCaseId = "xyz"; - when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId)); - when(sahiProxyProperties.isRequestDelayActive()).thenReturn(true); - when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true); - testling.init(testCaseId, "."); - verify(exceptionHandler, never()).handleException(any(Exception.class)); - verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "true"); - } - - @Test - public void testInitNoSahiDelay() throws Exception { - String testCaseId = "xyz"; - when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId)); - when(sahiProxyProperties.isRequestDelayActive()).thenReturn(false); - when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true); - testling.init(testCaseId, "."); - verify(exceptionHandler, never()).handleException(any(Exception.class)); - verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "false"); - } - - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - @Test - public void testInitNoSahiSession() throws Exception { - String testCaseId = "xyz"; - when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId)); - when(rhinoScriptRunner.getSession()).thenReturn(null); - when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true); - - ArgumentCaptor ac = ArgumentCaptor.forClass(SakuliException.class); - testling.init(testCaseId, "."); - verify(exceptionHandler).handleException(ac.capture()); - assertEquals(ac.getValue().getMessage(), "cannot init rhino script runner with sakuli custom delay variable 'sakuli-delay-active'"); - verify(session, never()).setVariable(anyString(), anyString()); + doNothing().when(testling).callInitTestCaseCallback(); } @Test @@ -114,6 +67,8 @@ public void testInitTCNull() throws Exception { when(testSuite.getTestCase(testCaseId)).thenReturn(null); testling.init(testCaseId, "."); verify(exceptionHandler, times(1)).handleException(any(SakuliException.class)); + verify(testling, never()).callInitTestCaseCallback(); + verify(cleanUpHelper, never()).releaseAllModifiers(); } @Test @@ -122,6 +77,9 @@ public void testInitImagePathNull() throws Exception { when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("test", testCaseId)); testling.init(testCaseId, new String[]{}); verify(exceptionHandler, times(0)).handleException(any(IOException.class)); + verify(testling).callInitTestCaseCallback(); + verify(cleanUpHelper).releaseAllModifiers(); + } @Test @@ -130,6 +88,8 @@ public void testInitImagePathEmpty() throws Exception { when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("test", testCaseId)); testling.init(testCaseId, new String[0]); verify(exceptionHandler, times(0)).handleException(any(IOException.class)); + verify(testling).callInitTestCaseCallback(); + verify(cleanUpHelper).releaseAllModifiers(); } @Test diff --git a/src/sakuli-core/src/test/java/org/sakuli/loader/BeanLoaderTest.java b/src/sakuli-core/src/test/java/org/sakuli/loader/BeanLoaderTest.java index 248fd5f0..8f441518 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/loader/BeanLoaderTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/loader/BeanLoaderTest.java @@ -32,8 +32,7 @@ public class BeanLoaderTest { public void setUp() throws Exception { SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = BaseTest.TEST_FOLDER_PATH; SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; - BeanLoader.CONTEXT_PATH = "loaderTest-beanRefFactory.xml"; + BeanLoader.CONTEXT_PATH = "org/sakuli/loader/loaderTest-beanRefFactory.xml"; BeanLoader.refreshContext(); } diff --git a/src/sakuli-core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java b/src/sakuli-core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java index c8df9c78..c210f957 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/services/AbstractServiceBaseTest.java @@ -28,11 +28,7 @@ public abstract class AbstractServiceBaseTest extends BaseTest { @Override protected String getTestContextPath() { - return "serviceTest-beanRefFactory.xml"; + return "org/sakuli/services/serviceTest-beanRefFactory.xml"; } - @Override - protected String getSahiFolderPath() { - return null; - } } diff --git a/src/sakuli-core/src/test/java/org/sakuli/services/forwarder/icinga2/AbstractIcinga2ForwarderBaseTest.java b/src/sakuli-core/src/test/java/org/sakuli/services/forwarder/icinga2/AbstractIcinga2ForwarderBaseTest.java index 8f97f089..1d5cc346 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/services/forwarder/icinga2/AbstractIcinga2ForwarderBaseTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/services/forwarder/icinga2/AbstractIcinga2ForwarderBaseTest.java @@ -31,7 +31,7 @@ public abstract class AbstractIcinga2ForwarderBaseTest extends AbstractServiceBa @Override protected String getTestContextPath() { System.setProperty(SPRING_PROFILES_ACTIVE, "ICINGA2"); - return "icinga2Test-beanRefFactory.xml"; + return "org/sakuli/services/forwarder/icinga2/icinga2Test-beanRefFactory.xml"; } @Override diff --git a/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java b/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java index e1b376f6..b645da07 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java @@ -18,15 +18,12 @@ package org.sakuli.utils; -import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.lang3.StringUtils; -import org.mockito.ArgumentCaptor; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.sakuli.BaseTest; import org.sakuli.PropertyHolder; import org.sakuli.datamodel.properties.ActionProperties; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.loader.BeanLoader; @@ -38,8 +35,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; import java.util.Properties; import static org.mockito.Mockito.*; @@ -55,7 +50,6 @@ public class SakuliPropertyPlaceholderConfigurerTest { public void setContextProperties() { SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = PPROPERTY_TEST_FOLDER_PATH; SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; BeanLoader.CONTEXT_PATH = BaseTest.TEST_CONTEXT_PATH; BeanLoader.refreshContext(); } @@ -63,7 +57,6 @@ public void setContextProperties() { @BeforeMethod public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - testling.setWritePropertiesToSahiConfig(false); testling.setLoadSakuliDefaultProperties(true); testling.setLoadSakuliProperties(true); testling.setLoadTestSuiteProperties(true); @@ -77,14 +70,12 @@ public void testLoadPropertiesTestSuiteFolder() throws Exception { testling.loadProperties(props); verify(props).put(TestSuiteProperties.TEST_SUITE_FOLDER, PPROPERTY_TEST_FOLDER_PATH); verify(props).put(SakuliProperties.SAKULI_HOME_FOLDER, BaseTest.SAKULI_HOME_FOLDER_PATH); - verify(props).put(SahiProxyProperties.PROXY_HOME_FOLDER, BaseTest.SAHI_FOLDER_PATH); verify(testling, never()).addPropertiesFromFile(props, Paths.get(BaseTest.SAKULI_HOME_FOLDER_PATH).normalize().toAbsolutePath().toString() + SakuliProperties.SAKULI_DEFAULT_PROPERTIES_FILE_APPENDER, true); verify(testling, never()).addPropertiesFromFile(props, Paths.get(PPROPERTY_TEST_FOLDER_PATH).getParent().normalize().toAbsolutePath().toString() + SakuliProperties.SAKULI_PROPERTIES_FILE_APPENDER, true); verify(testling).addPropertiesFromFile(props, Paths.get(PPROPERTY_TEST_FOLDER_PATH).normalize().toAbsolutePath().toString() + TestSuiteProperties.TEST_SUITE_PROPERTIES_FILE_APPENDER, true); - verify(testling, never()).modifyPropertiesConfiguration(anyString(), anyListOf(String.class), any(Properties.class)); assertNull(props.getProperty(ActionProperties.ENCRYPTION_INTERFACE_AUTODETECT), null); assertEquals(props.getProperty(TestSuiteProperties.SUITE_ID), "0001_testsuite_example"); } @@ -128,15 +119,6 @@ public void testLoadSakuliPropertiesFolder() throws Exception { assertEquals(props.getProperty("sakuli.forwarder.gearman.server.host"), "test-gearman-host"); } - @Test - public void testLoadPropertiesSahiHomeNotset() throws Exception { - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = ""; - Properties props = spy(new Properties()); - testling.loadProperties(props); - verify(props, never()).put(SahiProxyProperties.PROXY_HOME_FOLDER, ""); - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; - } - @Test public void testAddPropertiesFromFile() throws Exception { Path sakuliPropFile = Paths.get(getClass().getResource("/JUnit-sakuli.properties").toURI()); @@ -181,64 +163,4 @@ public void testTestSuiteBrowser() throws IOException { assertEquals(props.get(TestSuiteProperties.BROWSER_NAME), browserName); } - @SuppressWarnings("unchecked") - @Test - public void testModifySahiProperties() throws Exception { - Properties props = new Properties(); - doNothing().when(testling).modifyPropertiesConfiguration(anyString(), anyListOf(String.class), any(Properties.class)); - testling.setWritePropertiesToSahiConfig(true); - testling.modifySahiProperties(props); - - ArgumentCaptor argumentCaptorSahiProp = ArgumentCaptor.forClass(List.class); - ArgumentCaptor argumentCaptorLogProp = ArgumentCaptor.forClass(List.class); - verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_PROPERTY_FILE_APPENDER), argumentCaptorSahiProp.capture(), eq(props)); - verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_LOG_PROPERTY_FILE_APPENDER), argumentCaptorLogProp.capture(), eq(props)); - - assertTrue(argumentCaptorSahiProp.getValue().containsAll( - Arrays.asList("logs.dir", "ext.http.proxy.enable", "ext.http.proxy.host", "ext.http.proxy.port", - "ext.http.proxy.auth.enable", "ext.http.proxy.auth.name", "ext.http.proxy.auth.password", - "ext.https.proxy.enable", "ext.https.proxy.host", "ext.https.proxy.port", - "ext.https.proxy.auth.enable", "ext.https.proxy.auth.name", "ext.https.proxy.auth.password", - "ext.http.both.proxy.bypass_hosts", "ssl.client.keystore.type", "ssl.client.cert.path", "ssl.client.cert.password")), - "currently contains: " + argumentCaptorSahiProp.getValue().toString()); - assertTrue(argumentCaptorLogProp.getValue().containsAll( - Arrays.asList("handlers", "java.util.logging.ConsoleHandler.level", "java.util.logging.FileHandler.level", - "java.util.logging.ConsoleHandler.formatter", "java.util.logging.FileHandler.formatter", - "java.util.logging.FileHandler.limit", "java.util.logging.FileHandler.count", - "java.util.logging.FileHandler.pattern")), - "currently contains: " + argumentCaptorLogProp.getValue().toString()); - } - - @Test - public void testModifyPropertyFile() throws Exception { - Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); - - Properties basicProps = new Properties(); - basicProps.put("test.prop.1", "test-value-1"); - basicProps.put("test.prop.2", "test-value-2"); - testling.modifyPropertiesConfiguration(targetProps.toAbsolutePath().toString(), Arrays.asList("test.prop.1", "test.prop.2"), basicProps); - PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString("test.prop.1"), "test-value-1"); - assertEquals(targetProfConf.getString("test.prop.2"), "test-value-2"); - - testling.restoreProperties(); - targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString("test.prop.1"), "xyz"); - assertEquals(targetProfConf.getString("test.prop.2"), "zyx"); - } - - @Test - public void testModifySahiProxyPortInPropertyFile() throws Exception { - Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); - - Properties basicProps = new Properties(); - basicProps.put(SahiProxyProperties.PROXY_PORT, "9000"); - testling.modifySahiProxyPortPropertiesConfiguration(targetProps.toAbsolutePath().toString(), basicProps); - PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), "9000"); - - testling.restoreProperties(); - targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), null); - } } diff --git a/src/sakuli-core/src/test/java/org/sakuli/utils/SpringProfilesInitializerTest.java b/src/sakuli-core/src/test/java/org/sakuli/utils/SpringProfilesInitializerTest.java index a05a0359..886045e0 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/utils/SpringProfilesInitializerTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/utils/SpringProfilesInitializerTest.java @@ -72,8 +72,7 @@ public void testGetConfiguredProfiles(boolean database, boolean gearman, String[ @Test(dataProvider = "profileProperties") public void testAfterPropertiesSet(String propertyFile, int countOfResultServices) throws Exception { SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; - BeanLoader.CONTEXT_PATH = "loaderTest-beanRefFactory.xml"; + BeanLoader.CONTEXT_PATH = "org/sakuli/loader/loaderTest-beanRefFactory.xml"; Path testProps = Paths.get(getClass().getResource(propertyFile).toURI()); SakuliPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = testProps.toString(); diff --git a/src/sakuli-core/src/test/resources/JUnit-applicationContext.xml b/src/sakuli-core/src/test/resources/JUnit-applicationContext.xml index 79191caf..4a696db2 100644 --- a/src/sakuli-core/src/test/resources/JUnit-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/JUnit-applicationContext.xml @@ -34,7 +34,6 @@ - diff --git a/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml index 28dfe31f..e6aaa7b6 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml @@ -41,7 +41,6 @@ - @@ -71,10 +70,6 @@ - - - - @@ -97,6 +92,13 @@ + + + + + + + diff --git a/src/sakuli-core/src/test/resources/aopTest-beanRefFactory.xml b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-beanRefFactory.xml similarity index 83% rename from src/sakuli-core/src/test/resources/aopTest-beanRefFactory.xml rename to src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-beanRefFactory.xml index 9318d4ed..a663bc31 100644 --- a/src/sakuli-core/src/test/resources/aopTest-beanRefFactory.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-beanRefFactory.xml @@ -21,8 +21,8 @@ - + class="org.springframework.context.support.ClassPathXmlApplicationContext"> + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-applicationContext.xml new file mode 100644 index 00000000..10d107c7 --- /dev/null +++ b/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-applicationContext.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-beanRefFactory.xml b/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-beanRefFactory.xml new file mode 100644 index 00000000..424547c5 --- /dev/null +++ b/src/sakuli-core/src/test/resources/org/sakuli/exceptions/exceptionCallbackTest-beanRefFactory.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-applicationContext.xml index 6aa2bdc7..8319ec14 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-applicationContext.xml @@ -22,13 +22,14 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + + @@ -37,7 +38,6 @@ - @@ -67,11 +67,14 @@ - - - - + + + + + + + diff --git a/src/sakuli-core/src/test/resources/loaderTest-beanRefFactory.xml b/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-beanRefFactory.xml similarity index 83% rename from src/sakuli-core/src/test/resources/loaderTest-beanRefFactory.xml rename to src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-beanRefFactory.xml index 9bdfbee8..c7c2e84a 100644 --- a/src/sakuli-core/src/test/resources/loaderTest-beanRefFactory.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/loader/loaderTest-beanRefFactory.xml @@ -21,8 +21,8 @@ - + class="org.springframework.context.support.ClassPathXmlApplicationContext"> + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml index 6e6de5a9..f05209dd 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml @@ -33,7 +33,6 @@ - diff --git a/src/sakuli-core/src/test/resources/icinga2Test-beanRefFactory.xml b/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-beanRefFactory.xml similarity index 82% rename from src/sakuli-core/src/test/resources/icinga2Test-beanRefFactory.xml rename to src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-beanRefFactory.xml index 0820f53e..7785e071 100644 --- a/src/sakuli-core/src/test/resources/icinga2Test-beanRefFactory.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/services/forwarder/icinga2/icinga2Test-beanRefFactory.xml @@ -21,9 +21,9 @@ + class="org.springframework.context.support.ClassPathXmlApplicationContext"> + value="org/sakuli/services/forwarder/icinga2/icinga2Test-applicationContext.xml"/> \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-applicationContext.xml index ecf61531..46415ba1 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-applicationContext.xml @@ -36,7 +36,6 @@ - @@ -90,14 +89,13 @@ - - - - + + + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/serviceTest-beanRefFactory.xml b/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-beanRefFactory.xml similarity index 82% rename from src/sakuli-core/src/test/resources/serviceTest-beanRefFactory.xml rename to src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-beanRefFactory.xml index f6d14ff4..dc83b287 100644 --- a/src/sakuli-core/src/test/resources/serviceTest-beanRefFactory.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/services/serviceTest-beanRefFactory.xml @@ -21,8 +21,8 @@ - + class="org.springframework.context.support.ClassPathXmlApplicationContext"> + \ No newline at end of file diff --git a/src/sakuli-java-dsl/pom.xml b/src/sakuli-java-dsl/pom.xml index af995381..ee4ee89e 100644 --- a/src/sakuli-java-dsl/pom.xml +++ b/src/sakuli-java-dsl/pom.xml @@ -30,14 +30,14 @@ sakuli-java-dsl 1.1.0-SNAPSHOT-241_sakuli_se - ${artifactId} + ${project.artifactId} Specific Java-DSL for using Sakuli directly over Java jar ${project.parent.basedir} ${test.group.unit},${test.group.sakuliDSL} - + true @@ -65,7 +65,7 @@ ${project.groupId} - sakuli-core + sakuli-sahi-setup true @@ -219,7 +219,7 @@ ${project.groupId} - sakuli-core + sakuli-sahi-setup ${project.parent.version} diff --git a/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiIntializingServiceImpl.java b/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiIntializingServiceImpl.java index 2e6809a0..78f540a8 100644 --- a/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiIntializingServiceImpl.java +++ b/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/service/SahiIntializingServiceImpl.java @@ -20,11 +20,11 @@ import net.sf.sahi.client.Browser; import net.sf.sahi.config.Configuration; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.exceptions.SakuliInitException; import org.sakuli.services.InitializingService; -import org.sakuli.starter.SahiConnector; +import org.sakuli.starter.sahi.SahiConnector; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/utils/SakuliJavaPropertyPlaceholderConfigurer.java b/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/utils/SakuliJavaPropertyPlaceholderConfigurer.java index 2583c082..0de9f6f7 100644 --- a/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/utils/SakuliJavaPropertyPlaceholderConfigurer.java +++ b/src/sakuli-java-dsl/src/main/java/org/sakuli/javaDSL/utils/SakuliJavaPropertyPlaceholderConfigurer.java @@ -18,22 +18,20 @@ package org.sakuli.javaDSL.utils; -import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; -import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.sakuli.starter.sahi.utils.SahiStarterPropertyPlaceholderConfigurer; import java.util.Properties; /** * @author Tobias Schneck */ -public class SakuliJavaPropertyPlaceholderConfigurer extends SakuliPropertyPlaceholderConfigurer { +public class SakuliJavaPropertyPlaceholderConfigurer extends SahiStarterPropertyPlaceholderConfigurer { @Override protected void loadSakuliDefaultProperties(Properties props) { super.loadSakuliDefaultProperties(props); props.put(TestSuiteProperties.LOAD_TEST_CASES_AUTOMATIC_PROPERTY, "false"); - props.put(SakuliProperties.JAVASCRIPT_ENGINE, "false"); } @Override diff --git a/src/sakuli-java-dsl/src/main/resources/java-dsl-applicationContext.xml b/src/sakuli-java-dsl/src/main/resources/java-dsl-applicationContext.xml index d4536ebc..a497be3e 100644 --- a/src/sakuli-java-dsl/src/main/resources/java-dsl-applicationContext.xml +++ b/src/sakuli-java-dsl/src/main/resources/java-dsl-applicationContext.xml @@ -21,7 +21,7 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + diff --git a/src/sakuli-sahi-setup/pom.xml b/src/sakuli-sahi-setup/pom.xml index 3c5613fe..c621b481 100644 --- a/src/sakuli-sahi-setup/pom.xml +++ b/src/sakuli-sahi-setup/pom.xml @@ -30,7 +30,7 @@ sakuli-sahi-setup 1.1.0-SNAPSHOT-241_sakuli_se - ${artifactId} + ${project.artifactId} module for all sahi based functionality @@ -310,94 +310,9 @@ sakuli-core ${project.version} - + net.sf.sahi sahi @@ -408,59 +323,27 @@ ant-sahi - <!– Sahi API Dependencies–> + org.mozilla rhino - <!– SikuliX-Java Library (FULL LIBRARY) - is part of the sikuli-setup.jar–> - <!– well be needed for Functions like App() and so on...–> - - com.sikulix - sikulixapi - - - com.sikulix - sikulixlibslux - + - com.sikulix - sikulixlibsmac - - - com.sikulix - sikulixlibswin - - - org.gearman - gearman-java + commons-cli + commons-cli - <!– JAX-RS 2 client –> - - javax.ws.rs - javax.ws.rs-api - - - org.glassfish.jersey.core - jersey-client - - <!– jackson json parser –> - - org.glassfish.jersey.media - jersey-media-json-jackson - - <!– jtwig template engine –> + - org.jtwig - jtwig-core + ${project.groupId} + basic-test-util + ${project.version} + test-jar + test - - org.jtwig - jtwig-spaceless-extension - -->
diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/SakuliStarter.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/SakuliStarter.java similarity index 98% rename from src/sakuli-core/src/main/java/org/sakuli/starter/SakuliStarter.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/SakuliStarter.java index 40bacf69..eb04ffb9 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/SakuliStarter.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/SakuliStarter.java @@ -28,8 +28,9 @@ import org.sakuli.loader.BeanLoader; import org.sakuli.services.InitializingServiceHelper; import org.sakuli.services.TeardownServiceHelper; -import org.sakuli.starter.helper.CmdPrintHelper; -import org.sakuli.starter.helper.SakuliFolderHelper; +import org.sakuli.starter.sahi.SahiConnector; +import org.sakuli.starter.sahi.helper.CmdPrintHelper; +import org.sakuli.starter.sahi.helper.SakuliFolderHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/SahiConnector.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java similarity index 98% rename from src/sakuli-core/src/main/java/org/sakuli/starter/SahiConnector.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java index b6c4e6cf..a0249698 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/SahiConnector.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java @@ -16,19 +16,19 @@ * limitations under the License. */ -package org.sakuli.starter; +package org.sakuli.starter.sahi; import net.sf.sahi.ant.Report; import net.sf.sahi.test.TestRunner; import net.sf.sahi.util.Utils; import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.exceptions.SakuliException; import org.sakuli.exceptions.SakuliExceptionHandler; import org.sakuli.exceptions.SakuliInitException; import org.sakuli.services.InitializingServiceHelper; -import org.sakuli.starter.helper.SahiProxy; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.helper.SahiProxy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallback.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallback.java new file mode 100644 index 00000000..88bc3ade --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallback.java @@ -0,0 +1,75 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.action.logging; + +import net.sf.sahi.report.Report; +import net.sf.sahi.report.ResultType; +import org.aspectj.lang.JoinPoint; +import org.sakuli.actions.logging.LogToResult; +import org.sakuli.actions.logging.LogToResultCallback; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.datamodel.actions.LogResult; +import org.sakuli.starter.sahi.loader.SahiActionLoader; +import org.springframework.stereotype.Component; + +import static org.sakuli.aop.BaseSakuliAspect.createLoggingString; +import static org.sakuli.datamodel.actions.LogLevel.WARNING; + +/** + * Implementation to log results to the SahiReport. + * Based on the Callback interface {@link LogToResultCallback} + * + * @author tschneck + * Date: 4/24/17 + */ +@Component +public class SahiLogToResultCallback implements LogToResultCallback { + + + /** + * Method to do all Log Actions for the Sahi Report for the action classes annotated with {@link LogToResult}. A log + * entry will created at the sakuli log files and at the sahi HTML {@link Report}. + * + * @param joinPoint {@link JoinPoint} object of the calling aspect + * @param logToResult {@link LogToResult} Annotation + */ + @Override + public void doActionLog(JoinPoint joinPoint, LogToResult logToResult) { + if (logToResult != null) { + StringBuilder message = createLoggingString(joinPoint, logToResult); + + //log the action to log file and print + if (WARNING.equals(logToResult.level())) { + message.insert(0, "WARNING: "); + } + ResultType resultType = LogResult.lookupResultType(logToResult.level()); + if (resultType != null) { + Report sahiReport = BeanLoader.loadBean(SahiActionLoader.class).getSahiReport(); + if (sahiReport != null) { + sahiReport.addResult( + message.toString(), + resultType, + joinPoint.getSignature().getDeclaringTypeName(), + ""); + } + } + } + } + +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/ModifySahiTimerAspect.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallback.java similarity index 51% rename from src/sakuli-core/src/main/java/org/sakuli/aop/ModifySahiTimerAspect.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallback.java index 6aa914f5..a9b5f1e3 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/aop/ModifySahiTimerAspect.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallback.java @@ -16,76 +16,44 @@ * limitations under the License. */ -package org.sakuli.aop; +package org.sakuli.starter.sahi.action.screenbased; import net.sf.sahi.rhino.RhinoScriptRunner; import net.sf.sahi.session.Session; import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.sakuli.actions.ModifySahiTimer; -import org.sakuli.datamodel.properties.SahiProxyProperties; -import org.sakuli.loader.BaseActionLoader; +import org.sakuli.actions.screenbased.UserInterfaceInputActionCallback; +import org.sakuli.aop.BaseSakuliAspect; import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.loader.SahiActionLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** - * Aspect for the External Sahi Libary {@link net.sf.sahi} + * Callback handler for the {@link UserInterfaceInputActionCallback} interface. * * @author tschneck * Date: 17.10.13 */ -@Aspect @Component -public class ModifySahiTimerAspect extends BaseSakuliAspect { +public class ModifySahiTimerCallback implements UserInterfaceInputActionCallback { - protected final static Logger logger = LoggerFactory.getLogger(ModifySahiTimerAspect.class); - /** - * Before Pointcut for the {@link org.sakuli.actions.environment} class - * to do an {@link #modifySahiTimer(JoinPoint, boolean)}. - */ - @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + - "@annotation(modifySahiTimer)") - public void doEnvironmentBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer) { - modifySahiTimer(joinPoint, true); - } + private final static Logger LOGGER = LoggerFactory.getLogger(ModifySahiTimerCallback.class); - /** - * Before Pointcut for the {@link org.sakuli.actions.screenbased} class - * to do an {@link #modifySahiTimer(JoinPoint, boolean)}. - */ - @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + - "@annotation(modifySahiTimer)") - public void doScreenbasedBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer) { + @Override + public void beforeUserInterfaceInput(JoinPoint joinPoint) { modifySahiTimer(joinPoint, true); } - /** - * After Pointcut for the {@link org.sakuli.actions.environment} class - * to do an {@link #modifySahiTimer(JoinPoint, boolean)}. - */ - @After("execution(* org.sakuli.actions.environment.*.*(..)) &&" + - "@annotation(modifySahiTimer)") - public void doEnvironmentAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer) { - modifySahiTimer(joinPoint, false); - } - - /** - * After for the {@link org.sakuli.actions.screenbased} class - * to do an {@link #modifySahiTimer(JoinPoint, boolean)}. - */ - @After("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + - "@annotation(modifySahiTimer)") - public void doScreenbasedAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer) { + @Override + public void afterUserInterfaceInput(JoinPoint joinPoint) { modifySahiTimer(joinPoint, false); } void modifySahiTimer(JoinPoint joinPoint, boolean beforeMethod) { - BaseActionLoader loader = BeanLoader.loadBaseActionLoader(); + SahiActionLoader loader = BeanLoader.loadBean(SahiActionLoader.class); SahiProxyProperties sahiProxyProperties = loader.getSahiProxyProperties(); if (sahiProxyProperties != null && sahiProxyProperties.isRequestDelayActive()) { @@ -100,36 +68,44 @@ void modifySahiTimer(JoinPoint joinPoint, boolean beforeMethod) { //short sleep to ensure that browser context can read out the value try { - logger.info("wait {}ms for sahi refresh", sahiProxyProperties.getRequestDelayRefreshMs()); + LOGGER.info("wait {}ms for sahi refresh", sahiProxyProperties.getRequestDelayRefreshMs()); Thread.sleep(sahiProxyProperties.getRequestDelayRefreshMs()); } catch (InterruptedException e) { - BeanLoader.loadBaseActionLoader().getExceptionHandler().handleException(e, true); + loader.getBaseActionLoader().getExceptionHandler().handleException(e, true); } - logger.info("sahi-proxy-timer modified to {} ms", delay.toString()); + LOGGER.info("sahi-proxy-timer modified to {} ms", delay.toString()); } else { - logger.info("reset sahi-proxy-timer"); + LOGGER.info("reset sahi-proxy-timer"); session.setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_TIME_VAR, null); } } } } - protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { - Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); + protected Integer determineDelay(JoinPoint joinPoint, SahiActionLoader loader) { + Integer delay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); - int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); + int typeDelayMs = loader.getBaseActionLoader().getActionProperties().getTypeDelayMs(); - return length * (typeDelayMs + deleay); + return length * (typeDelayMs + delay); } } } - return deleay; + return delay; + } + + //wrapping needed for testing + Logger getLogger(JoinPoint joinPoint) { + return BaseSakuliAspect.getLogger(joinPoint); } + String getClassAndMethodAsString(JoinPoint joinPoint) { + return BaseSakuliAspect.getClassAndMethodAsString(joinPoint); + } } diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/RhinoAspect.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/RhinoAspect.java new file mode 100644 index 00000000..adeca342 --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/RhinoAspect.java @@ -0,0 +1,112 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.aop; + +import net.sf.sahi.report.ResultType; +import net.sf.sahi.rhino.RhinoScriptRunner; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.sakuli.actions.logging.LogToResult; +import org.sakuli.aop.BaseSakuliAspect; +import org.sakuli.aop.LogActionExecutedAspect; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.loader.BaseActionLoaderImpl; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.datamodel.actions.LogResult; +import org.sakuli.starter.sahi.exceptions.SahiActionException; +import org.sakuli.starter.sahi.loader.SahiActionLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Aspect for the External Sahi Library {@link net.sf.sahi} + * + * @author tschneck Date: 17.10.13 + */ +@Aspect +@Component +public class RhinoAspect extends BaseSakuliAspect { + + protected final static Logger logger = LoggerFactory.getLogger(LogActionExecutedAspect.class); + + /** + * Aspect to fetch the {@link RhinoScriptRunner} at the start of a test case script. The {@link RhinoScriptRunner} + * will then saved in the {@link BaseActionLoaderImpl} for forther usage. + * + * @param joinPoint injected joinPoint of the execution + */ + @After("execution(* net.sf.sahi.rhino.RhinoScriptRunner.setReporter*(*))") + public void getRhinoScriptRunner(JoinPoint joinPoint) { + if (joinPoint.getTarget() instanceof RhinoScriptRunner) { + logger.info("Add RhinoScriptRunner to the JavaBackEnd"); + BeanLoader.loadBean(SahiActionLoader.class).setRhinoScriptRunner((RhinoScriptRunner) joinPoint.getTarget()); + } else { + logger.warn(joinPoint.getTarget().getClass().getName() + " could not added to the JavaBackEnd!"); + } + } + + /** + * Aspect to fetch all Logs from the Sahi-Proxy by the method {@link net.sf.sahi.ant.Report} and do an trusty + * exception handling on top of that. + * + * @param joinPoint injected joinPoint of the execution + */ + @Before("execution(* net.sf.sahi.report.Report.addResult(..))") + public void doHandleRhinoException(JoinPoint joinPoint) { + // Read out all args + Object[] args = joinPoint.getArgs(); + ResultType resultType; + if (args[1] instanceof ResultType) { + resultType = (ResultType) args[1]; + } else { + resultType = ResultType.getType((String) args[1]); + } + + LogResult logResult = new LogResult( + (String) args[0], + resultType, + (String) args[2], + (String) args[3] + ); + + if (logResult.getFailureMsg() == null || !logResult.getFailureMsg().contains(ALREADY_PROCESSED)) { + //log and handle exception from sahi actions + if (ResultType.ERROR.equals(resultType) + || ResultType.FAILURE.equals(resultType)) { + + BaseActionLoader environmentLoader = BeanLoader.loadBaseActionLoader(); + environmentLoader.getExceptionHandler().handleException(new SahiActionException(logResult)); + } + + /** + * all Actions in Package {@link org.sakuli.actions} should be already logged by + * {@link #doaddSahiActionLog(JoinPoint, LogToResult)}. + */ + else if (logResult.getDebugInfo() == null + || !logResult.getDebugInfo().startsWith("org.sakuli.actions.")) { + logger.info(logResult.getMessage()); + } + } + + } + +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/SahiCommandExecutionAspect.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspect.java similarity index 98% rename from src/sakuli-core/src/main/java/org/sakuli/aop/SahiCommandExecutionAspect.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspect.java index a01add9b..9314027a 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/aop/SahiCommandExecutionAspect.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspect.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.aop; +package org.sakuli.starter.sahi.aop; import net.sf.sahi.config.Configuration; import org.apache.commons.exec.CommandLine; @@ -27,6 +27,7 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; +import org.sakuli.aop.BaseSakuliAspect; import org.sakuli.exceptions.SakuliInitException; import org.sakuli.loader.BeanLoader; import org.slf4j.Logger; @@ -77,7 +78,7 @@ public String[] getCommandTokens(ProceedingJoinPoint joinPoint, String commandSt /** * Catch exceptions that would have been droped from {@link net.sf.sahi.util.Utils} of all 'execute*' methods and * forward it to the exception Handler. - * + *

* Exceptions which thrown by missing "keytool" command, will be ignored , due to the internal exception handling * strategie at the point {@link Configuration#getKeytoolPath()}. * diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogResult.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/actions/LogResult.java similarity index 83% rename from src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogResult.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/actions/LogResult.java index 3a4afe56..8da52161 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/actions/LogResult.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/actions/LogResult.java @@ -16,10 +16,13 @@ * limitations under the License. */ -package org.sakuli.datamodel.actions; +package org.sakuli.starter.sahi.datamodel.actions; import net.sf.sahi.report.ResultType; import net.sf.sahi.report.TestResult; +import org.sakuli.datamodel.actions.LogLevel; + +import java.util.Arrays; /** * Wrapper for the {@link TestResult} class with getters. @@ -41,6 +44,16 @@ public LogResult(String message, ResultType type, String debugInfo, String failu this.failureMsg = clean(failureMsg); } + public static ResultType lookupResultType(LogLevel logLevel) { + if (LogLevel.ERROR.equals(logLevel)) { + return ResultType.ERROR; + } + if (Arrays.asList(LogLevel.INFO, LogLevel.WARNING).contains(logLevel)) { + return ResultType.INFO; + } + return null; + } + private static String clean(String string) { if (string != null) { return string.replace("\n", " ").trim(); diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SahiProxyProperties.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java similarity index 97% rename from src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SahiProxyProperties.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java index fecab4d7..429b0e86 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SahiProxyProperties.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java @@ -16,9 +16,12 @@ * limitations under the License. */ -package org.sakuli.datamodel.properties; +package org.sakuli.starter.sahi.datamodel.properties; -import org.sakuli.starter.helper.SahiProxy; +import org.sakuli.datamodel.properties.AbstractProperties; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.starter.sahi.helper.SahiProxy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +40,6 @@ * @author tschneck Date: 14.05.14 */ @Component -@SuppressWarnings("unused") public class SahiProxyProperties extends AbstractProperties { public static final String PROXY_HOME_FOLDER = "sahi.proxy.homePath"; diff --git a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SahiActionException.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/exceptions/SahiActionException.java similarity index 85% rename from src/sakuli-core/src/main/java/org/sakuli/exceptions/SahiActionException.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/exceptions/SahiActionException.java index fa31f526..ed1663e9 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SahiActionException.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/exceptions/SahiActionException.java @@ -16,9 +16,10 @@ * limitations under the License. */ -package org.sakuli.exceptions; +package org.sakuli.starter.sahi.exceptions; -import org.sakuli.datamodel.actions.LogResult; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.starter.sahi.datamodel.actions.LogResult; /** * @author Tobias Schneck diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/CmdPrintHelper.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/CmdPrintHelper.java similarity index 97% rename from src/sakuli-core/src/main/java/org/sakuli/starter/helper/CmdPrintHelper.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/CmdPrintHelper.java index 91be1f04..f6706b7b 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/CmdPrintHelper.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/CmdPrintHelper.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/ConnectionTester.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/ConnectionTester.java similarity index 98% rename from src/sakuli-core/src/main/java/org/sakuli/starter/helper/ConnectionTester.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/ConnectionTester.java index 7fca5015..510330ea 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/ConnectionTester.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/ConnectionTester.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestSuite; diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/SahiProxy.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SahiProxy.java similarity index 96% rename from src/sakuli-core/src/main/java/org/sakuli/starter/helper/SahiProxy.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SahiProxy.java index 85538082..e571f868 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/SahiProxy.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SahiProxy.java @@ -16,15 +16,14 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import net.sf.sahi.Proxy; import net.sf.sahi.config.Configuration; -import org.apache.commons.io.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.exceptions.SakuliInitException; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +32,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -103,10 +103,10 @@ public void startProxy(boolean asyncron) throws SakuliInitException, FileNotFoun protected void injectCustomJavaScriptFiles() throws IOException { File injectFile = props.getSahiJSInjectConfigFile().toFile(); - String injectFileString = FileUtils.readFileToString(injectFile, Charsets.UTF_8); + String injectFileString = FileUtils.readFileToString(injectFile, StandardCharsets.UTF_8); if (!injectFileString.contains(SAKULI_INJECT_SCRIPT_TAG)) { injectFileString = StringUtils.replace(injectFileString, SAHI_INJECT_END, SAKULI_INJECT_SCRIPT_TAG + "\r\n" + SAHI_INJECT_END); - FileUtils.writeStringToFile(injectFile, injectFileString, Charsets.UTF_8); + FileUtils.writeStringToFile(injectFile, injectFileString, StandardCharsets.UTF_8); logger.info("added '{}' to Sahi inject config file '{}'", SAKULI_INJECT_SCRIPT_TAG, props.getSahiJSInjectConfigFile().toString()); } diff --git a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/SakuliFolderHelper.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SakuliFolderHelper.java similarity index 93% rename from src/sakuli-core/src/main/java/org/sakuli/starter/helper/SakuliFolderHelper.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SakuliFolderHelper.java index 66d60fd7..e484096d 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/starter/helper/SakuliFolderHelper.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/helper/SakuliFolderHelper.java @@ -16,12 +16,13 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.apache.commons.lang.StringUtils; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.utils.SahiStarterPropertyPlaceholderConfigurer; import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +102,7 @@ public static Path normalizePath(String path) { */ public static String checkSakuliHomeFolderAndSetContextVariables(String sakuliMainFolderPath, String tempLogCache) throws FileNotFoundException { Path normalizedPath = normalizePath(sakuliMainFolderPath); - Path mainFolderPath = normalizedPath != null ? normalizedPath : getAlternativeSakuliMainFolder(); + Path mainFolderPath = normalizedPath != null ? normalizedPath : getAlternativeSakuliMainFolder(); if (!Files.exists(mainFolderPath)) { throw new FileNotFoundException("SAKULI HOME folder \"" + mainFolderPath + "\" does not exist!"); } @@ -139,8 +140,8 @@ public static String checkSahiProxyHomeAndSetContextVariables(String sahiProxyHo if (sahiFolder == null || !Files.exists(sahiFolder)) { throw new FileNotFoundException("sahi folder \"" + sahiProxyHomePath + "\" does not exist!"); } - SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = sahiFolder.toString(); - return tempLogCache + "\nset property '" + SahiProxyProperties.PROXY_HOME_FOLDER + "' to \"" + SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE + "\""; + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = sahiFolder.toString(); + return tempLogCache + "\nset property '" + SahiProxyProperties.PROXY_HOME_FOLDER + "' to \"" + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE + "\""; } /** diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoader.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoader.java new file mode 100644 index 00000000..5bf130ec --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoader.java @@ -0,0 +1,40 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.loader; + +import net.sf.sahi.report.Report; +import net.sf.sahi.rhino.RhinoScriptRunner; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; + +/** + * @author tschneck + * Date: 4/19/17 + */ +public interface SahiActionLoader { + SahiProxyProperties getSahiProxyProperties(); + + RhinoScriptRunner getRhinoScriptRunner(); + + void setRhinoScriptRunner(RhinoScriptRunner rhinoScriptRunner); + + Report getSahiReport(); + + BaseActionLoader getBaseActionLoader(); +} diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImpl.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImpl.java new file mode 100644 index 00000000..73bd7f90 --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImpl.java @@ -0,0 +1,159 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.loader; + +import net.sf.sahi.report.Report; +import net.sf.sahi.report.ResultType; +import net.sf.sahi.rhino.RhinoScriptRunner; +import org.sakuli.aop.BaseSakuliAspect; +import org.sakuli.datamodel.TestCase; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.exceptions.SakuliForwarderException; +import org.sakuli.loader.ActionLoaderCallback; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.loader.BaseActionLoaderImpl; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.exceptions.SahiActionException; +import org.sakuli.starter.sahi.utils.SahiStarterPropertyPlaceholderConfigurer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +/** + * @author tschneck + * Date: 4/19/17 + */ +@Component +public class SahiActionLoaderIntegrationImpl implements ActionLoaderCallback, SahiActionLoader { + public static final Logger LOGGER = LoggerFactory.getLogger(SahiActionLoaderIntegrationImpl.class); + + @Autowired + private SahiProxyProperties sahiProxyProperties; + @Autowired + private SakuliExceptionHandler exceptionHandler; + @Qualifier(BaseActionLoaderImpl.QUALIFIER) + @Autowired + private BaseActionLoader loader; + /** + * ** Fields which will be filled at runtime *** + */ + private RhinoScriptRunner rhinoScriptRunner; + + @Override + public void initTestCase(TestCase testCase) { +// if (sakuliProperties.isLoadJavaScriptEngine()) { + //add the "sakuli-delay-active" var to the script runner context + if (rhinoScriptRunner == null || rhinoScriptRunner.getSession() == null) { + //could be possible if the aspectj compiler won't worked correctly, see RhinoAspect#getRhinoScriptRunner + exceptionHandler.handleException(String.format("cannot init rhino script runner with sakuli custom delay variable '%s'", + SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR), false); + } else { + String isRequestDelayActive = String.valueOf(sahiProxyProperties.isRequestDelayActive()); + rhinoScriptRunner.getSession().setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, isRequestDelayActive); + LOGGER.debug("set isRequestDelayActive={} for testcase '{}'", isRequestDelayActive, testCase.getId()); + } + } + + @Override + public void handleException(SakuliException transformedException) { + if (!loader.getSakuliProperties().isSuppressResumedExceptions()) { + addExceptionToSahiReport(transformedException); + } else { + // a {@link SakuliForwarderException}, should only added to the report and not stop sahi, because + // this error types only on already started the tear down of test suite. + if (transformedException instanceof SakuliForwarderException) { + addExceptionToSahiReport(transformedException); + } + //stop the execution and add to report if the exception is not caused by Sahi + else if (!(transformedException instanceof SahiActionException)) { + stopExecutionAndAddExceptionToSahiReport(transformedException); + } + } + + } + + @Override + public void releaseContext() { + BeanLoader.loadBean(SahiStarterPropertyPlaceholderConfigurer.class).restoreProperties(); + } + + /** + * save the exception to the current sahi report (HTML Report in the log folder). + * + * @param e any {@link SakuliException} + */ + private void addExceptionToSahiReport(SakuliException e) { + if (getSahiReport() != null) { + getSahiReport().addResult( + e.getMessage(), + ResultType.ERROR, + e.getStackTrace().toString(), + e.getMessage() + BaseSakuliAspect.ALREADY_PROCESSED); + } + } + + /** + * stops the execution of the current test case and add the exception to the sahi report (HTML Report in the log + * folder). + * + * @param e any {@link SakuliException} + */ + private void stopExecutionAndAddExceptionToSahiReport(SakuliException e) { + addExceptionToSahiReport(e); + if (getRhinoScriptRunner() != null) { + getRhinoScriptRunner().setStopOnError(true); + getRhinoScriptRunner().setHasError(); + throw new RuntimeException(BaseSakuliAspect.ALREADY_PROCESSED + e.getMessage()); + } + } + + @Override + public SahiProxyProperties getSahiProxyProperties() { + return sahiProxyProperties; + } + + public void setSahiProxyProperties(SahiProxyProperties sahiProxyProperties) { + this.sahiProxyProperties = sahiProxyProperties; + } + + @Override + public RhinoScriptRunner getRhinoScriptRunner() { + return rhinoScriptRunner; + } + + @Override + public void setRhinoScriptRunner(RhinoScriptRunner rhinoScriptRunner) { + this.rhinoScriptRunner = rhinoScriptRunner; + + } + + @Override + public Report getSahiReport() { + return rhinoScriptRunner == null ? null : rhinoScriptRunner.getReport(); + } + + @Override + public BaseActionLoader getBaseActionLoader() { + return this.loader; + } +} diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java new file mode 100644 index 00000000..dc06954b --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java @@ -0,0 +1,171 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.utils; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; + +import javax.annotation.PreDestroy; +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import static org.apache.commons.lang.StringUtils.isNotEmpty; + +/** + * Overrides the default {@link PropertyPlaceholderConfigurer} to dynamically load the properties files in the {@link + * TestSuiteProperties#TEST_SUITE_FOLDER} and {@link SakuliProperties#SAKULI_HOME_FOLDER}. + * + * @author tschneck Date: 11.05.14 + */ +public class SahiStarterPropertyPlaceholderConfigurer extends SakuliPropertyPlaceholderConfigurer { + + public static String SAHI_HOME_VALUE; + private static Logger LOGGER = LoggerFactory.getLogger(SahiStarterPropertyPlaceholderConfigurer.class); + protected boolean writePropertiesToSahiConfig = true; + private Map> modifiedSahiConfigProps; + + public SahiStarterPropertyPlaceholderConfigurer() { + modifiedSahiConfigProps = new HashMap<>(); + } + + @Override + protected void loadProperties(Properties props) throws IOException { + super.loadProperties(props); + //overwrite if set sahi proxy home + if (isNotEmpty(SAHI_HOME_VALUE)) { + props.setProperty(SahiProxyProperties.PROXY_HOME_FOLDER, SAHI_HOME_VALUE); + props.setProperty(SahiProxyProperties.PROXY_CONFIG_FOLDER, SAHI_HOME_VALUE + File.separator + "userdata"); + } + modifySahiProperties(props); + } + + @PreDestroy + public void restoreProperties() { + try { + for (Map.Entry> entry : modifiedSahiConfigProps.entrySet()) { + String propFile = entry.getKey(); + LOGGER.debug("restore properties file '{}' with properties '{}'", propFile, entry.getValue()); + PropertiesConfiguration propConfig = new PropertiesConfiguration(propFile); + propConfig.setAutoSave(true); + for (Map.Entry propEntry : entry.getValue().entrySet()) { + String propKey = propEntry.getKey(); + if (propConfig.containsKey(propKey)) { + propConfig.clearProperty(propKey); + } + propConfig.addProperty(propKey, propEntry.getValue()); + } + } + } catch (ConfigurationException e) { + LOGGER.error("Error in restore sahi config properties", e); + } + } + + protected void modifySahiProperties(Properties props) { + if (writePropertiesToSahiConfig) { + String sahiConfigFolderPath = resolve(props.getProperty(SahiProxyProperties.PROXY_CONFIG_FOLDER), props); + + String sahiPropConfig = Paths.get(sahiConfigFolderPath + SahiProxyProperties.SAHI_PROPERTY_FILE_APPENDER).normalize().toAbsolutePath().toString(); + modifyPropertiesConfiguration(sahiPropConfig, SahiProxyProperties.userdataPropertyNames, props); + modifySahiProxyPortPropertiesConfiguration(sahiPropConfig, props); + String sahiLogPropConfig = Paths.get(sahiConfigFolderPath + SahiProxyProperties.SAHI_LOG_PROPERTY_FILE_APPENDER).normalize().toAbsolutePath().toString(); + modifyPropertiesConfiguration(sahiLogPropConfig, SahiProxyProperties.logPropertyNames, props); + } + } + + + /** + * Modifies the properties file 'propFilePathToConfig' with assigned key from the resource properties. + */ + protected void modifyPropertiesConfiguration(String propFilePathToConfig, List updateKeys, Properties resourceProps) { + try { + PropertiesConfiguration propConfig = new PropertiesConfiguration(propFilePathToConfig); + propConfig.setAutoSave(true); + Properties temProps = new Properties(); + for (String propKey : updateKeys) { + String resolve = resolve(resourceProps.getProperty(propKey), resourceProps); + if (resolve != null) { + if (propConfig.containsKey(propKey)) { + addToModifiedPropertiesMap(propFilePathToConfig, propKey, propConfig.getProperty(propKey)); + propConfig.clearProperty(propKey); + } + temProps.put(propKey, resolve); + propConfig.addProperty(propKey, resolve); + } + } + LOGGER.debug("modify properties file '{}' with '{}'", propFilePathToConfig, temProps.toString()); + } catch (ConfigurationException e) { + LOGGER.error("modify sahi properties went wrong", e); + } + + } + + /** + * writes the {@link SahiProxyProperties#PROXY_PORT} value as {@link SahiProxyProperties#SAHI_PROPERTY_PROXY_PORT_MAPPING} + * property to sahiConfigPropertyFilePath! + */ + protected void modifySahiProxyPortPropertiesConfiguration(String sahiConfigPropertyFilePath, Properties props) { + final String sahiProxyPort = props.getProperty(SahiProxyProperties.PROXY_PORT); + if (sahiProxyPort != null) { + try { + PropertiesConfiguration propConfig = new PropertiesConfiguration(sahiConfigPropertyFilePath); + propConfig.setAutoSave(true); + final String sahiMappingPropertyProxyPort = SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING; + + if (propConfig.containsKey(sahiMappingPropertyProxyPort)) { + propConfig.clearProperty(sahiMappingPropertyProxyPort); + } + //remove property after the test execution, so that the installation can't break + addToModifiedPropertiesMap(sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, null); + propConfig.addProperty(sahiMappingPropertyProxyPort, sahiProxyPort); + LOGGER.debug("modify properties file '{}' with '{}={}'", sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, sahiProxyPort); + } catch (ConfigurationException e) { + LOGGER.error("modify sahi properties went wrong", e); + } + } + } + + protected void addToModifiedPropertiesMap(String propFilePath, String propKey, Object propertyValue) { + Map propMap = modifiedSahiConfigProps.get(propFilePath); + if (propMap == null) { + propMap = new HashMap<>(); + } + propMap.put(propKey, propertyValue); + modifiedSahiConfigProps.put(propFilePath, propMap); + } + + public boolean isWritePropertiesToSahiConfig() { + return writePropertiesToSahiConfig; + } + + public void setWritePropertiesToSahiConfig(boolean writePropertiesToSahiConfig) { + this.writePropertiesToSahiConfig = writePropertiesToSahiConfig; + } +} diff --git a/src/sakuli-core/src/main/resources/beanRefFactory.xml b/src/sakuli-sahi-setup/src/main/resources/beanRefFactory.xml similarity index 93% rename from src/sakuli-core/src/main/resources/beanRefFactory.xml rename to src/sakuli-sahi-setup/src/main/resources/beanRefFactory.xml index a035b09e..fae96cab 100644 --- a/src/sakuli-core/src/main/resources/beanRefFactory.xml +++ b/src/sakuli-sahi-setup/src/main/resources/beanRefFactory.xml @@ -22,6 +22,6 @@ - + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/main/resources/sahiStarterApplicationContext.xml b/src/sakuli-sahi-setup/src/main/resources/sahiStarterApplicationContext.xml new file mode 100644 index 00000000..4ccf7ef5 --- /dev/null +++ b/src/sakuli-sahi-setup/src/main/resources/sahiStarterApplicationContext.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/BaseTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/BaseTest.java new file mode 100644 index 00000000..b7a3f08e --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/BaseTest.java @@ -0,0 +1,81 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli; + +import net.sf.sahi.report.Report; +import net.sf.sahi.rhino.RhinoScriptRunner; +import org.mockito.internal.util.MockUtil; +import org.sakuli.datamodel.actions.LogLevel; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.loader.SahiActionLoader; +import org.sakuli.starter.sahi.utils.SahiStarterPropertyPlaceholderConfigurer; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; + +import java.io.IOException; +import java.nio.file.Path; + +import static org.mockito.Mockito.*; + +/** + * @author tschneck Date: 25.07.13 + */ +public abstract class BaseTest extends AbstractBaseTest { + public static final String SAHI_FOLDER_PATH = getResource("starter/sahi/sahi_proxy"); + + protected SahiActionLoader loaderMock; + + @BeforeClass(alwaysRun = true) + public void setContextProperties() { + SahiStarterPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = getTestFolderPath(); + SahiStarterPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = getSakuliHomeFolderPath(); + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = getSahiFolderPath(); + BeanLoader.CONTEXT_PATH = getTestContextPath(); + BeanLoader.refreshContext(); + initBaseActionLoader(); + } + + protected String getSahiFolderPath() { + return SAHI_FOLDER_PATH; + } + + protected void initBaseActionLoader() { + loaderMock = BeanLoader.loadBean(SahiActionLoader.class); + if (new MockUtil().isMock(loaderMock)) { + reset(loaderMock); + when(loaderMock.getSahiReport()).thenReturn(mock(Report.class)); + } else { + RhinoScriptRunner runnermock = mock(RhinoScriptRunner.class); + when(runnermock.getReport()).thenReturn(mock(Report.class)); + loaderMock.setRhinoScriptRunner(runnermock); + } + } + + @AfterClass(alwaysRun = true) + public void tearDown() throws Exception { + SahiStarterPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = BaseTest.TEST_FOLDER_PATH; + SahiStarterPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; + BeanLoader.CONTEXT_PATH = BaseTest.TEST_CONTEXT_PATH; + } + + protected synchronized void assertLastLine(Path logFile, String filter, LogLevel logLevel, String expectedMessage) throws IOException { + super.assertLastLine(logFile, filter, logLevel.name(), expectedMessage); + } +} diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/ExampleBuilder.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/ExampleBuilder.java new file mode 100644 index 00000000..a12c7189 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/ExampleBuilder.java @@ -0,0 +1,30 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.builder; + +/** + * Marker interface for all builders for testing reasons + * + * @author tschneck + * Date: 11.07.14 + */ +public interface ExampleBuilder { + + T buildExample(); +} diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseExampleBuilder.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseExampleBuilder.java new file mode 100644 index 00000000..7b6281f7 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseExampleBuilder.java @@ -0,0 +1,142 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.builder; + +import org.apache.commons.lang.time.DateUtils; +import org.joda.time.DateTime; +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.TestCaseStep; +import org.sakuli.datamodel.state.TestCaseState; +import org.sakuli.exceptions.SakuliException; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @author tschneck + * Date: 08.05.2014 + */ +public class TestCaseExampleBuilder implements ExampleBuilder { + + + private List steps; + private String name; + private String id; + private TestCaseState state; + private Date startDate; + private Date stopDate; + private int warningTime; + private int criticalTime; + private SakuliException exception; + private Path testCaseFile; + private String lastURL; + private String startURL; + private DateTime creationDate; + + + public TestCaseExampleBuilder() { + name = "Unit Test Case"; + id = "UNIT_TEST_CASE_" + System.nanoTime(); + state = TestCaseState.OK; + startDate = new Date(); + stopDate = DateUtils.addSeconds(startDate, 3); + warningTime = 4; + criticalTime = 5; + startURL = "http://www.start-url.com"; + lastURL = "http://www.last-url.com"; + steps = Collections.singletonList(new TestCaseStepExampleBuilder().buildExample()); + } + + @Override + public TestCase buildExample() { + TestCase testCase = new TestCase(name, id); + testCase.setState(state); + testCase.setStartDate(startDate); + testCase.setStopDate(stopDate); + testCase.setWarningTime(warningTime); + testCase.setCriticalTime(criticalTime); + testCase.addException(exception); + testCase.setTcFile(testCaseFile); + testCase.setStartUrl(startURL); + testCase.setLastURL(lastURL); + testCase.setSteps(steps); + if (creationDate != null) { + testCase.setCreationDate(creationDate); + } + return testCase; + } + + public TestCaseExampleBuilder withName(String name) { + this.name = name; + return this; + } + + public TestCaseExampleBuilder withId(String id) { + this.id = id; + return this; + } + + public TestCaseExampleBuilder withState(TestCaseState testCaseState) { + this.state = testCaseState; + return this; + } + + + public TestCaseExampleBuilder withStartDate(Date startDate) { + this.startDate = startDate; + return this; + } + + public TestCaseExampleBuilder withStopDate(Date stopDate) { + this.stopDate = stopDate; + return this; + } + + public TestCaseExampleBuilder withWarningTime(int warningTime) { + this.warningTime = warningTime; + return this; + } + + public TestCaseExampleBuilder withTestCaseSteps(List testCaseSteps) { + this.steps = testCaseSteps; + return this; + } + + public TestCaseExampleBuilder withCriticalTime(int criticalTime) { + this.criticalTime = criticalTime; + return this; + } + + public TestCaseExampleBuilder withException(SakuliException exception) { + this.exception = exception; + return this; + } + + public TestCaseExampleBuilder withTestCaseFile(Path testCaseFile) { + this.testCaseFile = testCaseFile; + return this; + } + + public TestCaseExampleBuilder withCreationDate(DateTime creationDate) { + this.creationDate = creationDate; + return this; + } +} diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseStepExampleBuilder.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseStepExampleBuilder.java new file mode 100644 index 00000000..2b4f90f4 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestCaseStepExampleBuilder.java @@ -0,0 +1,99 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.builder; + +import org.apache.commons.lang.time.DateUtils; +import org.joda.time.DateTime; +import org.sakuli.datamodel.TestCaseStep; +import org.sakuli.datamodel.builder.TestCaseStepBuilder; +import org.sakuli.datamodel.state.TestCaseStepState; +import org.sakuli.exceptions.SakuliException; + +import java.util.Date; + +/** + * @author tschneck + * Date: 14.07.14 + */ +public class TestCaseStepExampleBuilder implements ExampleBuilder { + private TestCaseStepState state; + private String name; + private int warningTime; + private Date stopDate; + private Date startDate; + private SakuliException exception; + private DateTime creationDate; + + public TestCaseStepExampleBuilder() { + this.state = TestCaseStepState.OK; + this.name = "step for unit test"; + this.warningTime = 4; + this.startDate = new Date(); + this.stopDate = DateUtils.addSeconds(startDate, 3); + this.creationDate = new DateTime(); + } + + @Override + public TestCaseStep buildExample() { + TestCaseStep step = new TestCaseStepBuilder(name).build(); + step.setStartDate(startDate); + step.setStopDate(stopDate); + step.setWarningTime(warningTime); + step.setName(name); + step.setState(state); + step.addException(exception); + step.setCreationDate(creationDate); + return step; + } + + public TestCaseStepExampleBuilder withState(TestCaseStepState state) { + this.state = state; + return this; + } + + public TestCaseStepExampleBuilder withStartDate(Date startDate) { + this.startDate = startDate; + return this; + } + + public TestCaseStepExampleBuilder withStopDate(Date stopDate) { + this.stopDate = stopDate; + return this; + } + + public TestCaseStepExampleBuilder withWarningTime(int warningTime) { + this.warningTime = warningTime; + return this; + } + + public TestCaseStepExampleBuilder withName(String name) { + this.name = name; + return this; + } + + public TestCaseStepExampleBuilder withException(SakuliException e) { + this.exception = e; + return this; + } + + public TestCaseStepExampleBuilder withCreationDate(DateTime creationDate) { + this.creationDate = creationDate; + return this; + } +} diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleBuilder.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleBuilder.java new file mode 100644 index 00000000..35031fca --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleBuilder.java @@ -0,0 +1,134 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.builder; + +import org.apache.commons.lang.time.DateUtils; +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.TestSuite; +import org.sakuli.datamodel.state.TestSuiteState; +import org.sakuli.exceptions.SakuliException; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; + +/** + * @author tschneck + * Date: 08.05.2014 + */ +public class TestSuiteExampleBuilder implements ExampleBuilder { + + private TestSuiteState state; + private String host; + private String id; + private Date stopDate; + private Date startDate; + private SakuliException exception; + private List testCases; + private int warningTime; + private int criticalTime; + private Path folder; + private String browserInfo; + + + public TestSuiteExampleBuilder() { + this.state = TestSuiteState.RUNNING; + this.host = "localhost"; + this.id = "UnitTest_" + System.nanoTime(); + this.startDate = new GregorianCalendar(2014, 7, 17, 14, 0).getTime(); + this.stopDate = DateUtils.addMinutes(startDate, 2); + this.testCases = Collections.singletonList(new TestCaseExampleBuilder().buildExample()); + this.warningTime = 0; + this.criticalTime = 0; + this.folder = null; + this.browserInfo = "firefox"; + } + + public TestSuite buildExample() { + TestSuite testSuite = new TestSuite(); + testSuite.setName("Unit Test Sample Test Suite"); + testSuite.setId(id); + testSuite.setStartDate(startDate); + testSuite.setStopDate(stopDate); + testSuite.setWarningTime(warningTime); + testSuite.setCriticalTime(criticalTime); + testSuite.setState(state); + testSuite.setHost(host); + testSuite.setBrowserInfo("Firefox Test Browser"); + testSuite.addException(exception); + testSuite.setTestSuiteFolder(folder); + testSuite.setBrowserInfo(browserInfo); + for (TestCase testCase : testCases) { + testSuite.addTestCase(testCase.getId(), testCase); + } + return testSuite; + } + + public TestSuiteExampleBuilder withState(TestSuiteState state) { + this.state = state; + return this; + } + + public TestSuiteExampleBuilder withHost(String host) { + this.host = host; + return this; + } + + public TestSuiteExampleBuilder withId(String id) { + this.id = id; + return this; + } + + public TestSuiteExampleBuilder withStopDate(Date stopDate) { + this.stopDate = stopDate; + return this; + } + + public TestSuiteExampleBuilder withStartDate(Date startDate) { + this.startDate = startDate; + return this; + } + + public TestSuiteExampleBuilder withException(SakuliException exception) { + this.exception = exception; + return this; + } + + public TestSuiteExampleBuilder withTestCases(List testCases) { + this.testCases = testCases; + return this; + } + + public TestSuiteExampleBuilder withWarningTime(int warningTime) { + this.warningTime = warningTime; + return this; + } + + public TestSuiteExampleBuilder withCriticalTime(int criticalTime) { + this.criticalTime = criticalTime; + return this; + } + + public TestSuiteExampleBuilder withTestSuiteFolder(Path folder) { + this.folder = folder; + return this; + } +} diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java new file mode 100644 index 00000000..510ccdac --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/builder/TestSuiteExampleFactory.java @@ -0,0 +1,43 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.builder; + +import org.sakuli.datamodel.TestSuite; +import org.springframework.beans.factory.FactoryBean; + +/** + * @author tschneck + * Date: 09.04.15 + */ +public class TestSuiteExampleFactory implements FactoryBean { + @Override + public TestSuite getObject() throws Exception { + return new TestSuiteExampleBuilder().buildExample(); + } + + @Override + public Class getObjectType() { + return TestSuite.class; + } + + @Override + public boolean isSingleton() { + return true; + } +} diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/SakuliStarterTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/SakuliStarterTest.java similarity index 100% rename from src/sakuli-core/src/test/java/org/sakuli/starter/SakuliStarterTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/SakuliStarterTest.java diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/SahiConnectorTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java similarity index 93% rename from src/sakuli-core/src/test/java/org/sakuli/starter/SahiConnectorTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java index ce5ca4ea..db2b75be 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/starter/SahiConnectorTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.starter; +package org.sakuli.starter.sahi; import net.sf.sahi.ant.Report; import net.sf.sahi.report.ResultType; @@ -26,13 +26,16 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.Spy; -import org.sakuli.BaseTest; import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.actions.LogResult; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; -import org.sakuli.exceptions.*; -import org.sakuli.starter.helper.SahiProxy; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.exceptions.SakuliExceptionWithScreenshot; +import org.sakuli.exceptions.SakuliInitException; +import org.sakuli.starter.sahi.datamodel.actions.LogResult; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.exceptions.SahiActionException; +import org.sakuli.starter.sahi.helper.SahiProxy; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -46,9 +49,10 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; +import static org.sakuli.AbstractBaseTest.*; -public class SahiConnectorTest extends BaseTest { +public class SahiConnectorTest { @Mock private SakuliExceptionHandler sakuliExceptionHandler; @Mock diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java new file mode 100644 index 00000000..ece63d0f --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java @@ -0,0 +1,222 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.action.logging; + +import net.sf.sahi.report.Report; +import net.sf.sahi.report.ResultType; +import net.sf.sahi.report.TestResult; +import org.sakuli.actions.TestCaseAction; +import org.sakuli.actions.environment.Environment; +import org.sakuli.actions.logging.Logger; +import org.sakuli.actions.screenbased.Region; +import org.sakuli.actions.screenbased.RegionImpl; +import org.sakuli.actions.screenbased.TypingUtil; +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.actions.LogLevel; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.loader.BeanLoader; +import org.sakuli.loader.ScreenActionLoader; +import org.sakuli.starter.sahi.aop.AopBaseTest; +import org.sakuli.starter.sahi.exceptions.SahiActionException; +import org.sakuli.starter.sahi.loader.SahiActionLoader; +import org.springframework.test.util.ReflectionTestUtils; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; +import static org.testng.Assert.*; + +public class SahiLogToResultCallbackTest extends AopBaseTest { + + @DataProvider(name = "resultTypes") + public static Object[][] resultTypes() { + return new Object[][]{ + {ResultType.INFO}, + {ResultType.ERROR}, + {ResultType.SKIPPED}, + {ResultType.SUCCESS} + }; + + } + + @DataProvider(name = "logLevel") + public static Object[][] logLevel() { + return new Object[][]{ + {LogLevel.INFO}, + {LogLevel.DEBUG}, + {LogLevel.ERROR}, + {LogLevel.WARNING}, + }; + } + + + /** + * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler For IntelliJ you can + * make a right click on the maven target 'aspectj:compile' and mark it with the option 'Execute After Make'. + */ + @Test + public void testCallEnvironmentMethod() throws Exception { + ScreenActionLoader loaderMock = mock(ScreenActionLoader.class); + TypingUtil typingUtil = mock(TypingUtil.class); + when(typingUtil.type(anyString(), anyString())).thenReturn(null); + Environment env = new Environment(false); + ReflectionTestUtils.setField(env, "typingUtil", typingUtil); + ReflectionTestUtils.setField(env, "loader", loaderMock); + env.type("BLA"); + assertLastLine(logFile, "Environment", LogLevel.INFO, "Environment.type() - type over system keyboard with arg(s) [BLA]"); + verifySahiReportLogEntry(ResultType.INFO, "Environment.type() - type over system keyboard with arg(s) [BLA]"); + } + + @Test + public void testCallRegionMethod() throws Exception { + TypingUtil typingUtil = mock(TypingUtil.class); + when(typingUtil.type(anyString(), anyString())).thenReturn(null); + Region region = new RegionTestMock(); + ReflectionTestUtils.setField(region, "typingUtil", typingUtil); + region.type("BLA"); + assertLastLine(logFile, "Region", LogLevel.INFO, "Region.type() - type over system keyboard with arg(s) [BLA]"); + verifySahiReportLogEntry(ResultType.INFO, "Region.type() - type over system keyboard with arg(s) [BLA]"); + } + + @Test + public void testGetRhinoScriptRunner() throws Exception { + initMocks(); + + /** + * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler + * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it + * with the option 'Execute After Make'. + */ + assertNotNull(BeanLoader.loadBean(SahiActionLoader.class).getSahiReport()); + } + + @Test(dataProvider = "resultTypes") + public void testDoHandleRhinoException(ResultType resultTyp) throws Exception { + initMocks(); + /** + * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler + * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it + * with the option 'Execute After Make'. + */ + Report sahiReport = BeanLoader.loadBean(SahiActionLoader.class).getSahiReport(); + int lisSize = sahiReport.getListResult().size(); + assertNotNull(sahiReport); + sahiReport.addResult("TEST-ENTRY", resultTyp, "bla", "TEST-ENTRY"); + verifySahiReport(resultTyp, lisSize); + } + + @Test(dataProvider = "resultTypes") + public void testDoHandleRhinoExceptionResultString(ResultType resultTyp) throws Exception { + initMocks(); + /** + * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler + * For IntelliJ you can make a right click on the maven target 'aspectj:compile' and mark it + * with the option 'Execute After Make'. + */ + Report sahiReport = BeanLoader.loadBean(SahiActionLoader.class).getSahiReport(); + int lisSize = sahiReport.getListResult().size(); + assertNotNull(sahiReport); + sahiReport.addResult("TEST-ENTRY", resultTyp.getName(), "bla", "TEST-ENTRY"); + verifySahiReport(resultTyp, lisSize); + } + + @Test + public void testDoEnvironmentLog() throws Exception { + initMocks(); + Environment testAction = new Environment(false); + testAction.sleep(1); + + verifySahiReportLogEntry(ResultType.INFO, "Environment.sleep() - sleep and do nothing for x seconds with arg(s) [1]"); + } + + @Test + public void testDoLoggingLog() throws Exception { + initMocks(); + Logger.logInfo("INFO-LOG"); + verifySahiReportLogEntry(ResultType.INFO, "INFO-LOG"); + } + + @Test + public void testDoTestCaseActionLog() throws Exception { + initMocks(); + BaseActionLoader loader = mock(BaseActionLoader.class); + TestCase sampleTc = new TestCase("test", "testID"); + when(loader.getCurrentTestCase()).thenReturn(sampleTc); + TestCaseAction testAction = new TestCaseAction(); + ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class); + testAction.init("testID", 3, 4, "imagefolder1", "imagefolder2"); + + verifySahiReportLogEntry(ResultType.INFO, + "\"test case [" + sampleTc.getActionValueString() + "]\" TestCaseAction.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]"); + } + + private void verifySahiReport(ResultType resultTyp, int initialListSize) { + if (resultTyp != null) { + Report sahiReport2 = BeanLoader.loadBean(SahiActionLoader.class).getSahiReport(); + int newLisSize = sahiReport2.getListResult().size(); + assertEquals(newLisSize, initialListSize + 1); + TestResult testResult = sahiReport2.getListResult().get(newLisSize - 1); + assertNotNull(testResult); + + SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); + if (resultTyp.equals(ResultType.ERROR) || resultTyp.equals(ResultType.FAILURE)) { + verify(sakuliExceptionHandler).handleException(any(SahiActionException.class)); + } else { + verify(sakuliExceptionHandler, never()).handleException(any(SahiActionException.class)); + } + } + } + + private void verifySahiReportLogEntry(ResultType resultTyp, String message) { + if (resultTyp != null) { + Report sahiReport2 = BeanLoader.loadBean(SahiActionLoader.class).getSahiReport(); + final List listResult = sahiReport2.getListResult(); + assertTrue(listResult.size() > 0, "List of TestResult is empty!"); + TestResult testResult = listResult.stream() + .filter(r -> ((String) ReflectionTestUtils.getField(r, "message")).contains(message)) + .findFirst().orElseGet(null); + assertNotNull(testResult, "no result in sahi report found, which contains:" + message); + assertEquals(ReflectionTestUtils.getField(testResult, "type"), resultTyp); + + SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); + if (resultTyp.equals(ResultType.ERROR) || resultTyp.equals(ResultType.FAILURE)) { + verify(sakuliExceptionHandler).handleException(any(SahiActionException.class)); + } else { + verify(sakuliExceptionHandler, never()).handleException(any(SahiActionException.class)); + } + } + } + + private class RegionTestMock extends Region { + public RegionTestMock() { + super(mock(RegionImpl.class)); + } + + @Override + public ScreenActionLoader getScreenActionLoader() { + return mock(ScreenActionLoader.class); + } + } + +} \ No newline at end of file diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/ModifySahiTimerAspectTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallbackTest.java similarity index 58% rename from src/sakuli-core/src/test/java/org/sakuli/aop/ModifySahiTimerAspectTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallbackTest.java index c08b23b6..d87c3516 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/aop/ModifySahiTimerAspectTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/screenbased/ModifySahiTimerCallbackTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.aop; +package org.sakuli.starter.sahi.action.screenbased; import net.sf.sahi.rhino.RhinoScriptRunner; import net.sf.sahi.session.Session; @@ -25,59 +25,53 @@ import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.sakuli.actions.environment.Environment; -import org.sakuli.actions.screenbased.Region; -import org.sakuli.actions.screenbased.RegionImpl; import org.sakuli.actions.screenbased.TypingUtil; +import org.sakuli.actions.screenbased.UserInterfaceInputActionCallback; import org.sakuli.datamodel.actions.LogLevel; -import org.sakuli.datamodel.properties.SahiProxyProperties; -import org.sakuli.loader.BaseActionLoader; import org.sakuli.loader.BeanLoader; -import org.sakuli.loader.ScreenActionLoader; +import org.sakuli.starter.sahi.aop.AopBaseTest; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.loader.SahiActionLoader; import org.slf4j.LoggerFactory; import org.springframework.test.util.ReflectionTestUtils; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Collection; + import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; -import static org.testng.Assert.assertEquals; +import static org.testng.Assert.*; -public class ModifySahiTimerAspectTest extends AopBaseTest { +public class ModifySahiTimerCallbackTest extends AopBaseTest { @Spy - private ModifySahiTimerAspect testling; + private ModifySahiTimerCallback testling; @Override @BeforeMethod public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); + BeanLoader.loadBean(SahiProxyProperties.class).setRequestDelayMs(null); } - /** - * If the test fails in your IDE, make sure that your compiler use the correct AspectJ-Compiler For IntelliJ you can - * make a right click on the maven target 'aspectj:compile' and mark it with the option 'Execute After Make'. - */ @Test - public void testCallEnvironmentMethod() throws Exception { - ScreenActionLoader loaderMock = mock(ScreenActionLoader.class); + public void testCallbackTriggered() throws Exception { + final Collection callbacks = BeanLoader.loadMultipleBeans(UserInterfaceInputActionCallback.class).values(); + assertEquals(callbacks.size(), 1); TypingUtil typingUtil = mock(TypingUtil.class); - when(typingUtil.type(anyString(), anyString())).thenReturn(null); - Environment env = new Environment(false); - ReflectionTestUtils.setField(env, "typingUtil", typingUtil); - ReflectionTestUtils.setField(env, "loader", loaderMock); - env.type("BLA"); - assertLastLine(logFile, "Environment", LogLevel.INFO, "Environment.type() - type over system keyboard with arg(s) [BLA]"); - } + Environment testAction = new Environment(false); + ReflectionTestUtils.setField(testAction, "typingUtil", typingUtil); + testAction.type("nothing"); + + verify(typingUtil).type(anyString(), anyString()); + assertLastLine(logFile, testAction.getClass().getSimpleName(), LogLevel.INFO, + "Environment.type() - type over system keyboard with arg(s) [nothing]"); + final UserInterfaceInputActionCallback cb = callbacks.stream().findFirst().get(); + verify(cb).afterUserInterfaceInput(any()); + verify(cb).beforeUserInterfaceInput(any()); - @Test - public void testCallRegionMethod() throws Exception { - TypingUtil typingUtil = mock(TypingUtil.class); - when(typingUtil.type(anyString(), anyString())).thenReturn(null); - Region region = new RegionTestMock(); - ReflectionTestUtils.setField(region, "typingUtil", typingUtil); - region.type("BLA"); - assertLastLine(logFile, "Environment", LogLevel.INFO, "Environment.type() - type over system keyboard with arg(s) [BLA]"); } @Test @@ -85,10 +79,11 @@ public void testModifySahiTimer() throws Exception { RhinoScriptRunner runner = mock(RhinoScriptRunner.class); Session session = mock(Session.class); when(runner.getSession()).thenReturn(session); - BaseActionLoader baseActionLoader = BeanLoader.loadBaseActionLoader(); - baseActionLoader.setRhinoScriptRunner(runner); - when(baseActionLoader.getSahiProxyProperties().isRequestDelayActive()).thenReturn(true); - doReturn(1000).when(testling).determineDelay(any(JoinPoint.class), any(BaseActionLoader.class)); + SahiActionLoader sahiActionLoader = BeanLoader.loadBean(SahiActionLoader.class); + sahiActionLoader.setRhinoScriptRunner(runner); + sahiActionLoader.getSahiProxyProperties().setRequestDelayMs(500); + assertTrue(sahiActionLoader.getSahiProxyProperties().isRequestDelayActive()); + doReturn(1000).when(testling).determineDelay(any(JoinPoint.class), any(SahiActionLoader.class)); doReturn(LoggerFactory.getLogger(this.getClass())).when(testling).getLogger(any(JoinPoint.class)); doReturn("sig.method()").when(testling).getClassAndMethodAsString(any(JoinPoint.class)); @@ -96,13 +91,13 @@ public void testModifySahiTimer() throws Exception { //test modifcation of timer to 1000ms testling.modifySahiTimer(mock(JoinPoint.class), true); verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_TIME_VAR, "1000"); - verify(baseActionLoader.getExceptionHandler(), never()).handleException(any(Throwable.class)); + verify(sahiActionLoader.getBaseActionLoader().getExceptionHandler(), never()).handleException(any(Throwable.class)); assertLastLine(logFile, "sahi-proxy-timer", LogLevel.INFO, "sahi-proxy-timer modified to 1000 ms"); //test reset timer testling.modifySahiTimer(mock(JoinPoint.class), false); verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_TIME_VAR, null); - verify(baseActionLoader.getExceptionHandler(), never()).handleException(any(Throwable.class)); + verify(sahiActionLoader.getBaseActionLoader().getExceptionHandler(), never()).handleException(any(Throwable.class)); assertLastLine(logFile, "sahi-proxy-timer", LogLevel.INFO, "reset sahi-proxy-timer"); } @@ -111,9 +106,9 @@ public void testDisabledModifySahiTimer() throws Exception { RhinoScriptRunner runner = mock(RhinoScriptRunner.class); Session session = mock(Session.class); when(runner.getSession()).thenReturn(session); - BaseActionLoader baseActionLoader = BeanLoader.loadBaseActionLoader(); - baseActionLoader.setRhinoScriptRunner(runner); - when(baseActionLoader.getSahiProxyProperties().isRequestDelayActive()).thenReturn(false); + SahiActionLoader sahiActionLoader = BeanLoader.loadBean(SahiActionLoader.class); + sahiActionLoader.setRhinoScriptRunner(runner); + assertFalse(sahiActionLoader.getSahiProxyProperties().isRequestDelayActive()); doReturn(LoggerFactory.getLogger(this.getClass())).when(testling).getLogger(any(JoinPoint.class)); doReturn("sig.method()").when(testling).getClassAndMethodAsString(any(JoinPoint.class)); @@ -122,23 +117,24 @@ public void testDisabledModifySahiTimer() throws Exception { testling.modifySahiTimer(mock(JoinPoint.class), true); testling.modifySahiTimer(mock(JoinPoint.class), false); verify(session, never()).setVariable(anyString(), anyString()); - verify(baseActionLoader.getExceptionHandler(), never()).handleException(any(Throwable.class)); + verify(sahiActionLoader.getBaseActionLoader().getExceptionHandler(), never()).handleException(any(Throwable.class)); //test no session available - when(baseActionLoader.getSahiProxyProperties().isRequestDelayActive()).thenReturn(true); + sahiActionLoader.getSahiProxyProperties().setRequestDelayMs(500); + assertTrue(sahiActionLoader.getSahiProxyProperties().isRequestDelayActive()); when(runner.getSession()).thenReturn(null); testling.modifySahiTimer(mock(JoinPoint.class), true); testling.modifySahiTimer(mock(JoinPoint.class), false); verify(session, never()).setVariable(anyString(), anyString()); - verify(baseActionLoader.getExceptionHandler(), never()).handleException(any(Throwable.class)); + verify(sahiActionLoader.getBaseActionLoader().getExceptionHandler(), never()).handleException(any(Throwable.class)); } @Test public void testDetermineDelay() throws Exception { - BaseActionLoader loader = BeanLoader.loadBaseActionLoader(); - when(loader.getSahiProxyProperties().getRequestDelayMs()).thenReturn(500); - loader.getActionProperties().setTypeDelay(0.05); + SahiActionLoader loader = BeanLoader.loadBean(SahiActionLoader.class); + loader.getSahiProxyProperties().setRequestDelayMs(500); + loader.getBaseActionLoader().getActionProperties().setTypeDelay(0.05); JoinPoint joinPoint = mock(JoinPoint.class); Signature signature = mock(Signature.class); @@ -153,15 +149,4 @@ public void testDetermineDelay() throws Exception { when(joinPoint.getArgs()).thenReturn(new String[]{"12characters", "MOD"}); assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 12 * 550); } - - private class RegionTestMock extends Region { - public RegionTestMock() { - super(mock(RegionImpl.class)); - } - - @Override - public ScreenActionLoader getScreenActionLoader() { - return mock(ScreenActionLoader.class); - } - } } \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/AopBaseTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/AopBaseTest.java new file mode 100644 index 00000000..eba5c51c --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/AopBaseTest.java @@ -0,0 +1,66 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.aop; + +import net.sf.sahi.playback.SahiScript; +import net.sf.sahi.rhino.RhinoScriptRunner; +import org.sakuli.BaseTest; +import org.sakuli.PropertyHolder; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.loader.SahiActionLoader; +import org.testng.annotations.BeforeMethod; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.mockito.Mockito.*; + +/** + * @author tschneck Date: 23.09.14 + */ +public abstract class AopBaseTest extends BaseTest { + + protected Path logFile; + + @BeforeMethod(alwaysRun = true) + public void setUp() throws Exception { + initMocks(); + logFile = Paths.get(BeanLoader.loadBean(PropertyHolder.class).getLogFile()); + } + + @Override + protected String getTestFolderPath() { + return getResource("/_testsuite4aop"); + } + + @Override + protected String getTestContextPath() { + return "org/sakuli/starter/sahi/aop/aopTest-beanRefFactory.xml"; + } + + protected void initMocks() { + SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class); + reset(sakuliExceptionHandler); + SahiScript sahiScriptMock = mock(SahiScript.class); + when(sahiScriptMock.jsString()).thenReturn(""); + BeanLoader.loadBean(SahiActionLoader.class).setRhinoScriptRunner(new RhinoScriptRunner(sahiScriptMock)); + } +} + diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/SahiCommandExecutionAspectTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspectTest.java similarity index 99% rename from src/sakuli-core/src/test/java/org/sakuli/aop/SahiCommandExecutionAspectTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspectTest.java index 9359e052..45b9d49a 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/aop/SahiCommandExecutionAspectTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/aop/SahiCommandExecutionAspectTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.aop; +package org.sakuli.starter.sahi.aop; import net.sf.sahi.util.Utils; import org.apache.commons.exec.CommandLine; @@ -37,6 +37,7 @@ /** * Test for {@link SahiCommandExecutionAspect} + * * @author tschneck * Date: 2/25/16 */ diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java new file mode 100644 index 00000000..6e9640c5 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java @@ -0,0 +1,160 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.exceptions; + +import net.sf.sahi.report.Report; +import net.sf.sahi.report.ResultType; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.sakuli.BaseTest; +import org.sakuli.actions.screenbased.RegionImpl; +import org.sakuli.actions.screenbased.ScreenshotActions; +import org.sakuli.datamodel.TestSuite; +import org.sakuli.datamodel.properties.ActionProperties; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.state.TestSuiteState; +import org.sakuli.exceptions.*; +import org.sakuli.loader.BaseActionLoaderImpl; +import org.sakuli.loader.BeanLoader; +import org.sakuli.loader.ScreenActionLoader; +import org.springframework.test.util.ReflectionTestUtils; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +public class SahiStarterExceptionHandlerTest extends BaseTest { + + private SakuliExceptionHandler testling; + private Report sahiReport; + private TestSuite testSuite; + private ScreenActionLoader screenActionLoader; + private BaseActionLoaderImpl baseLoader; + + private Path expectedScreenshotPath; + @Mock + private ActionProperties actionProperties; + @Mock + private SakuliProperties sakuliProperties; + @Mock + private ScreenshotActions screenshotActionsMock; + + @BeforeMethod + public void init() throws Exception { + MockitoAnnotations.initMocks(this); + testling = BeanLoader.loadBean(SakuliExceptionHandler.class); + sahiReport = loaderMock.getSahiReport(); + reset(sahiReport); + testSuite = BeanLoader.loadBean(TestSuite.class); + ReflectionTestUtils.setField(testSuite, "exception", null); + screenActionLoader = BeanLoader.loadBean(ScreenActionLoader.class); + baseLoader = BeanLoader.loadBean(BaseActionLoaderImpl.class); + + when(actionProperties.isTakeScreenshots()).thenReturn(true); + when(sakuliProperties.isSuppressResumedExceptions()).thenReturn(false); + when(screenActionLoader.getActionProperties()).thenReturn(actionProperties); + when(screenActionLoader.getSakuliProperties()).thenReturn(sakuliProperties); + when(baseLoader.getSakuliProperties()).thenReturn(sakuliProperties); + when(screenActionLoader.getTestSuite()).thenReturn(testSuite); + + expectedScreenshotPath = Paths.get("src/test/resources/org/sakuli/exceptions/screenshots/test.jpg"); + when(screenshotActionsMock.takeScreenshot(anyString(), any(Path.class))).thenReturn(expectedScreenshotPath); + when(screenActionLoader.getScreenshotActions()).thenReturn(screenshotActionsMock); + } + + @Override + protected String getTestContextPath() { + return "org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-beanRefFactory.xml"; + } + + @Test + public void testSakuliForwarderException() throws Exception { + SakuliForwarderException forwarderException = new SakuliForwarderException("FORWARDER_EXCEPTION"); + + testling.handleException(forwarderException, true); + verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); + assertEquals(testSuite.getException(), forwarderException); + assertTrue(testling.resumeToTestExcecution(testSuite.getException())); + assertTrue(testling.isAlreadyProcessed(testSuite.getException())); + } + + @Test + public void testSakuliForwarderException2() throws Exception { + when(screenActionLoader.getCurrentTestCase()).thenReturn(null); + SakuliForwarderException forwarderException = new SakuliForwarderException("FORWARDER_EXCEPTION"); + + testling.handleException(forwarderException); + verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class)); + verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); + assertEquals(testSuite.getException(), forwarderException); + assertTrue(testling.isAlreadyProcessed(testSuite.getException())); + } + + @Test + public void testSakuliActionExceptionTakeUnsuccessfulScreenshotFromRegion() throws Exception { + when(screenActionLoader.getCurrentTestCase()).thenReturn(null); + SakuliActionException sakuliActionException = new SakuliActionException("ACTION_EXCEPTION"); + + testling.handleException(sakuliActionException, mock(RegionImpl.class), true); + verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); + verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); + assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); + assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); + assertTrue(testling.resumeToTestExcecution(testSuite.getException())); + assertTrue(testling.isAlreadyProcessed(testSuite.getException())); + } + + @Test + public void testSakuliActionExceptionTakeSuccessfulScreenshotFromRegion() throws Exception { + when(screenActionLoader.getCurrentTestCase()).thenReturn(null); + when(screenshotActionsMock.takeScreenshot(anyString(), any(Path.class))).thenReturn(expectedScreenshotPath); + SakuliActionException sakuliActionException = new SakuliActionException("ACTION_EXCEPTION"); + + testling.handleException(sakuliActionException, mock(RegionImpl.class), true); + verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); + verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); + assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); + assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); + assertTrue(testling.resumeToTestExcecution(testSuite.getException())); + assertTrue(testling.isAlreadyProcessed(testSuite.getException())); + } + + @Test + public void testHandleSakuliProxyExceptionForTestCases() throws Exception { + when(screenActionLoader.getCurrentTestCase()).thenReturn(null); + String testExcMessage = "init-exception"; + testling.handleException(new SakuliInitException(testExcMessage)); + assertTrue(testSuite.getException() instanceof NonScreenshotException); + assertEquals(testSuite.getException().getMessage(), testExcMessage); + assertEquals(testSuite.getState(), TestSuiteState.ERRORS); + verify(screenActionLoader, never()).getScreenshotActions(); + } + +} diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/CmdPrintHelperTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/CmdPrintHelperTest.java similarity index 96% rename from src/sakuli-core/src/test/java/org/sakuli/starter/helper/CmdPrintHelperTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/CmdPrintHelperTest.java index b47e9f47..4b1834d9 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/CmdPrintHelperTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/CmdPrintHelperTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.apache.commons.cli.Options; import org.testng.annotations.Test; diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/ConnectionTesterTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/ConnectionTesterTest.java similarity index 96% rename from src/sakuli-core/src/test/java/org/sakuli/starter/helper/ConnectionTesterTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/ConnectionTesterTest.java index 93adb159..fe59dd7c 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/ConnectionTesterTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/ConnectionTesterTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.testng.annotations.Test; diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/SahiProxyTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SahiProxyTest.java similarity index 97% rename from src/sakuli-core/src/test/java/org/sakuli/starter/helper/SahiProxyTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SahiProxyTest.java index 0a031f8d..1f5d3c89 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/SahiProxyTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SahiProxyTest.java @@ -16,14 +16,14 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.sakuli.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/SakuliFolderHelperTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SakuliFolderHelperTest.java similarity index 93% rename from src/sakuli-core/src/test/java/org/sakuli/starter/helper/SakuliFolderHelperTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SakuliFolderHelperTest.java index 4ad3331b..a2288b7e 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/starter/helper/SakuliFolderHelperTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/helper/SakuliFolderHelperTest.java @@ -16,12 +16,13 @@ * limitations under the License. */ -package org.sakuli.starter.helper; +package org.sakuli.starter.sahi.helper; import org.apache.commons.lang3.StringUtils; import org.sakuli.BaseTest; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.sakuli.starter.sahi.utils.SahiStarterPropertyPlaceholderConfigurer; import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -31,9 +32,10 @@ import java.nio.file.Path; import java.nio.file.Paths; +import static org.sakuli.AbstractBaseTest.TEST_FOLDER_PATH; import static org.testng.Assert.*; -public class SakuliFolderHelperTest extends BaseTest { +public class SakuliFolderHelperTest { @DataProvider(name = "windowsPaths") public static Object[][] windowsPaths() { @@ -55,7 +57,7 @@ public void testCheckSahiProxyHomeAndSetContextVariables() throws Exception { final String absoluteSahiPath = Paths.get(TEST_FOLDER_PATH).toAbsolutePath().toString(); String log = ""; log = SakuliFolderHelper.checkSahiProxyHomeAndSetContextVariables(TEST_FOLDER_PATH, log); - assertEquals(SakuliPropertyPlaceholderConfigurer.SAHI_HOME_VALUE, absoluteSahiPath); + assertEquals(SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE, absoluteSahiPath); assertEquals(log, "\nset property '" + SahiProxyProperties.PROXY_HOME_FOLDER + "' to \"" + absoluteSahiPath + "\""); } diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImplTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImplTest.java new file mode 100644 index 00000000..ec179a6c --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/loader/SahiActionLoaderIntegrationImplTest.java @@ -0,0 +1,85 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.loader; + +import net.sf.sahi.rhino.RhinoScriptRunner; +import net.sf.sahi.session.Session; +import org.mockito.*; +import org.sakuli.datamodel.TestCase; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Matchers.eq; + +/** + * @author tschneck + * Date: 4/19/17 + */ +public class SahiActionLoaderIntegrationImplTest { + + public static final String TESTCASE_ID = "testcase1"; + @Mock + private RhinoScriptRunner rhinoScriptRunner; + @Mock + private Session session; + @Mock + private SahiProxyProperties sahiProxyProperties; + @Mock + private SakuliExceptionHandler exceptionHandler; + + @InjectMocks + private SahiActionLoaderIntegrationImpl testling; + + @BeforeMethod + public void init() { + MockitoAnnotations.initMocks(this); + Mockito.when(rhinoScriptRunner.getSession()).thenReturn(session); + } + + @Test + public void testInit() throws Exception { + Mockito.when(sahiProxyProperties.isRequestDelayActive()).thenReturn(true); + testling.initTestCase(new TestCase(TESTCASE_ID, TESTCASE_ID)); + Mockito.verify(exceptionHandler, Mockito.never()).handleException(Matchers.any(Exception.class)); + Mockito.verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "true"); + } + + @Test + public void testInitNoSahiDelay() throws Exception { + Mockito.when(sahiProxyProperties.isRequestDelayActive()).thenReturn(false); + testling.initTestCase(new TestCase(TESTCASE_ID, TESTCASE_ID)); + Mockito.verify(exceptionHandler, Mockito.never()).handleException(Matchers.any(Exception.class)); + Mockito.verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "false"); + } + + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test + public void testInitNoSahiSession() throws Exception { + Mockito.when(rhinoScriptRunner.getSession()).thenReturn(null); + + ArgumentCaptor ac = ArgumentCaptor.forClass(String.class); + testling.initTestCase(new TestCase(TESTCASE_ID, TESTCASE_ID)); + Mockito.verify(exceptionHandler).handleException(ac.capture(), eq(false)); + Assert.assertEquals(ac.getValue(), "cannot init rhino script runner with sakuli custom delay variable 'sakuli-delay-active'"); + Mockito.verify(session, Mockito.never()).setVariable(Matchers.anyString(), Matchers.anyString()); + } +} \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java new file mode 100644 index 00000000..be9c0f93 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java @@ -0,0 +1,158 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.starter.sahi.utils; + +import org.apache.commons.configuration.PropertiesConfiguration; +import org.mockito.ArgumentCaptor; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.sakuli.BaseTest; +import org.sakuli.datamodel.properties.ActionProperties; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.loader.BeanLoader; +import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +import static org.mockito.Mockito.*; +import static org.testng.Assert.*; + +public class SahiStarterPropertyPlaceholderConfigurerTest { + + public static final String PPROPERTY_TEST_FOLDER_PATH = BaseTest.getResource("/property_test/suite_folder"); + @Spy + private SahiStarterPropertyPlaceholderConfigurer testling; + + @BeforeClass(alwaysRun = true) + public void setContextProperties() { + SahiStarterPropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = PPROPERTY_TEST_FOLDER_PATH; + SahiStarterPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE = BaseTest.SAKULI_HOME_FOLDER_PATH; + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; + BeanLoader.CONTEXT_PATH = BaseTest.TEST_CONTEXT_PATH; + BeanLoader.refreshContext(); + } + + @BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + testling.setWritePropertiesToSahiConfig(false); + testling.setLoadSakuliDefaultProperties(true); + testling.setLoadSakuliProperties(true); + testling.setLoadTestSuiteProperties(true); + } + + @Test + public void testLoadPropertiesTestSuiteFolder() throws Exception { + Properties props = spy(new Properties()); + testling.setLoadSakuliProperties(false); + testling.setLoadSakuliDefaultProperties(false); + testling.loadProperties(props); + verify(props).put(TestSuiteProperties.TEST_SUITE_FOLDER, PPROPERTY_TEST_FOLDER_PATH); + verify(props).put(SakuliProperties.SAKULI_HOME_FOLDER, BaseTest.SAKULI_HOME_FOLDER_PATH); + verify(props).put(SahiProxyProperties.PROXY_HOME_FOLDER, BaseTest.SAHI_FOLDER_PATH); + verify(testling, never()).addPropertiesFromFile(props, + Paths.get(BaseTest.SAKULI_HOME_FOLDER_PATH).normalize().toAbsolutePath().toString() + SakuliProperties.SAKULI_DEFAULT_PROPERTIES_FILE_APPENDER, true); + verify(testling, never()).addPropertiesFromFile(props, + Paths.get(PPROPERTY_TEST_FOLDER_PATH).getParent().normalize().toAbsolutePath().toString() + SakuliProperties.SAKULI_PROPERTIES_FILE_APPENDER, true); + verify(testling).addPropertiesFromFile(props, + Paths.get(PPROPERTY_TEST_FOLDER_PATH).normalize().toAbsolutePath().toString() + TestSuiteProperties.TEST_SUITE_PROPERTIES_FILE_APPENDER, true); + verify(testling, never()).modifyPropertiesConfiguration(anyString(), anyListOf(String.class), any(Properties.class)); + assertNull(props.getProperty(ActionProperties.ENCRYPTION_INTERFACE_AUTODETECT), null); + assertEquals(props.getProperty(TestSuiteProperties.SUITE_ID), "0001_testsuite_example"); + } + + + @Test + public void testLoadPropertiesSahiHomeNotset() throws Exception { + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = ""; + Properties props = spy(new Properties()); + testling.loadProperties(props); + verify(props, never()).put(SahiProxyProperties.PROXY_HOME_FOLDER, ""); + SahiStarterPropertyPlaceholderConfigurer.SAHI_HOME_VALUE = BaseTest.SAHI_FOLDER_PATH; + } + + @SuppressWarnings("unchecked") + @Test + public void testModifySahiProperties() throws Exception { + Properties props = new Properties(); + doNothing().when(testling).modifyPropertiesConfiguration(anyString(), anyListOf(String.class), any(Properties.class)); + testling.setWritePropertiesToSahiConfig(true); + testling.modifySahiProperties(props); + + ArgumentCaptor argumentCaptorSahiProp = ArgumentCaptor.forClass(List.class); + ArgumentCaptor argumentCaptorLogProp = ArgumentCaptor.forClass(List.class); + verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_PROPERTY_FILE_APPENDER), argumentCaptorSahiProp.capture(), eq(props)); + verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_LOG_PROPERTY_FILE_APPENDER), argumentCaptorLogProp.capture(), eq(props)); + + assertTrue(argumentCaptorSahiProp.getValue().containsAll( + Arrays.asList("logs.dir", "ext.http.proxy.enable", "ext.http.proxy.host", "ext.http.proxy.port", + "ext.http.proxy.auth.enable", "ext.http.proxy.auth.name", "ext.http.proxy.auth.password", + "ext.https.proxy.enable", "ext.https.proxy.host", "ext.https.proxy.port", + "ext.https.proxy.auth.enable", "ext.https.proxy.auth.name", "ext.https.proxy.auth.password", + "ext.http.both.proxy.bypass_hosts", "ssl.client.keystore.type", "ssl.client.cert.path", "ssl.client.cert.password")), + "currently contains: " + argumentCaptorSahiProp.getValue().toString()); + assertTrue(argumentCaptorLogProp.getValue().containsAll( + Arrays.asList("handlers", "java.util.logging.ConsoleHandler.level", "java.util.logging.FileHandler.level", + "java.util.logging.ConsoleHandler.formatter", "java.util.logging.FileHandler.formatter", + "java.util.logging.FileHandler.limit", "java.util.logging.FileHandler.count", + "java.util.logging.FileHandler.pattern")), + "currently contains: " + argumentCaptorLogProp.getValue().toString()); + } + + @Test + public void testModifyPropertyFile() throws Exception { + Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); + + Properties basicProps = new Properties(); + basicProps.put("test.prop.1", "test-value-1"); + basicProps.put("test.prop.2", "test-value-2"); + testling.modifyPropertiesConfiguration(targetProps.toAbsolutePath().toString(), Arrays.asList("test.prop.1", "test.prop.2"), basicProps); + PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); + assertEquals(targetProfConf.getString("test.prop.1"), "test-value-1"); + assertEquals(targetProfConf.getString("test.prop.2"), "test-value-2"); + + testling.restoreProperties(); + targetProfConf = new PropertiesConfiguration(targetProps.toFile()); + assertEquals(targetProfConf.getString("test.prop.1"), "xyz"); + assertEquals(targetProfConf.getString("test.prop.2"), "zyx"); + } + + @Test + public void testModifySahiProxyPortInPropertyFile() throws Exception { + Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); + + Properties basicProps = new Properties(); + basicProps.put(SahiProxyProperties.PROXY_PORT, "9000"); + testling.modifySahiProxyPortPropertiesConfiguration(targetProps.toAbsolutePath().toString(), basicProps); + PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); + assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), "9000"); + + testling.restoreProperties(); + targetProfConf = new PropertiesConfiguration(targetProps.toFile()); + assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), null); + } +} diff --git a/src/sakuli-sahi-setup/src/test/resources/JUnit-applicationContext.xml b/src/sakuli-sahi-setup/src/test/resources/JUnit-applicationContext.xml new file mode 100644 index 00000000..3f9a983e --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/JUnit-applicationContext.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + classpath:JUnit-sakuli.properties + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/JUnit-beanRefFactory.xml b/src/sakuli-sahi-setup/src/test/resources/JUnit-beanRefFactory.xml new file mode 100644 index 00000000..eea79277 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/JUnit-beanRefFactory.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/JUnit-sakuli.properties b/src/sakuli-sahi-setup/src/test/resources/JUnit-sakuli.properties new file mode 100644 index 00000000..62256edb --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/JUnit-sakuli.properties @@ -0,0 +1,93 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +####################################################################################### +####################################################################################### +# J-UNIT-SAKULI-PROPERTIES-FILE +# +# !!! USE THIS ONLY FOR THE UNIT-TESTS !!! +####################################################################################### +####################################################################################### +# TEST-SUITE-BEHAVIOR-PROPERTIES +# +# Set here the common behavior settings for the test suite. +####################################################################################### +# Defines the browser in witch the test suite should be executed +# values are corresponding to the file +# /userdata/config/browser_types.xml +# +# DEFAULT: firefox +testsuite.browser=firefox +####################################################################################### +# SAKULI-ACTION-PROPERTIES +# +# Set here the common settings for the behavior of +# the sakuli actions during the execution. +####################################################################################### +# If true, the test suite takes screenshots when an error occurs during the execution. +# +# DEFAULT: true +sakuli.screenshot.onError=true +### Controls the default automatic highlighting feature +# en-/disable +# +# DEFAULT: false +sakuli.autoHighlight.enabled=false +# time in seconds for highlighting (float) +# +# DEFAULT: 1.1f +sakuli.highlight.seconds=1.1f +### Sikuli Action Delays +# +#set the default type and click delay in seconds; +sikuli.typeDelay=0.05 +sikuli.clickDelay=0.2 +############################### +# LOGGING & ERROR-SCREENSHOT PROPERTIES +# Set here the common logging settings for sakuli. +# To configure more details see the file 'sakuli-log-config.xml' +############################### +# If you use the feature resumeOnException, for example with 'new Region("foo",true), then you can config +# the exception logging like following: If +# true = Exception will appear in the log and on the test suite result +# false = Exception will NOT appear in the log file and in the test suite result. In that case you +# have to handle it by yourself in the test case, like in this example: +# try{ +# var foo = fooRegion.find("image.png"); +# if (foo == null){ +# throw "your custom exception message"; +# } +# } catch (e) { +# handleYourSelf(e); +# } +# +# DEFAULT: false +sakuli.exception.suppressResumedExceptions=false +# Log pattern for the logging output. +# +# Log pattern for development with java classes: +# sakuli.log.pattern=%-5level %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n +sakuli.log.pattern=%-5level [%d{YYYY-MM-dd HH:mm:ss.SSS}] - %msg%n +# Sets the output folder for the log files +sakuli.log.folder=${sakuli.testsuite.folder}/_logs +# Sets the output folder for the error screenshots (if activated) +sakuli.screenshot.dir=${sakuli.log.folder}/_screenshots +# Output format for the take screenshots. +# Possible values: jpg, png +sakuli.screenshot.format=jpg +#sakuli.screenshot.format=png +sakuli.environment.similarity.default=0.99 \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/.gitignore b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/.gitignore new file mode 100644 index 00000000..f2014ad8 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/.gitignore @@ -0,0 +1 @@ +!*.cache diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/case/tc.js b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/case/tc.js new file mode 100644 index 00000000..73c8eec6 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/case/tc.js @@ -0,0 +1,18 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.properties b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.properties new file mode 100644 index 00000000..e3ac12cd --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.properties @@ -0,0 +1,50 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +####################################################################################### +# TEST-SUITE-META-PROPERTIES +# +# These properties describes the minimum set of configuration for a test suite. +####################################################################################### +# The test suite ID is a unique ID, which identifies the same test suite +# over all executions and configuration changes. +testsuite.id=0001_testsuite_example +####################################################################################### +# OPTIONAL-PROPERTIES for the test suite +# +# If this properties haven NOT been set, the test suite will be configured with the +# default values. +####################################################################################### +# Descriptive name for the current test suite +# DEFAULT: value of 'testsuite.id' +testsuite.name=Sample test suite 4 JUnit +# The warning runtime threshold (seconds) estimates the execution time of the complete +# test suite. If the warning time is exceeded, the test suite will get the state +# 'WARNING'. +# If the threshold is set to 0, the execution time will never exceed, so the state will be always OK! +# DEFAULT:0 +testsuite.warningTime=120 +# The critical runtime threshold (seconds) estimates the execution time of the complete +# test suite. If the cirtical time is exceeded, the test suite will get the state +# 'CRITICAL'. +# If the threshold is set to 0, the execution time will never exceed, so the state will be always OK! +# DEFAULT:0 +testsuite.criticalTime=140 +####################################################################################### +# OVERRIDE-PROPERTIES for the test suite +####################################################################################### +testsuite.browser=firefox \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.suite b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.suite new file mode 100644 index 00000000..275d3332 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4JUnit/testsuite.suite @@ -0,0 +1,6 @@ +offl_wr_applet_JUnit/_tc.js http://99.99.99.16 +//offl_game_applet/_tc.js http://99.99.99.16 + +//oxid_bestell/_tc.js http://99.99.99.16/shop/ +//oxid_bestell_with_sikuli/_tc.js http://99.99.99.16/shop/ + diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.properties b/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.properties new file mode 100644 index 00000000..09a0c1ac --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.properties @@ -0,0 +1,32 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +####################################################################################### +# TEST-SUITE-META-PROPERTIES +# +# These properties describes the minimum set of configuration for a test suite. +####################################################################################### +testsuite.id=0002_testsuite_example +testsuite.name=Sample test suite 4 modifytimer +####################################################################################### +# OVERWRITE-PROPERTIES +# +# To define a specific behaviour to your test, it is possible to overwrite all properties of the Sakuli default +# properties 'sakuli-default.properties'. +# For a short guideline how the property replacement mechanism in Sakuli works and how properties should be +# overwritten, please refer to https://github.com/ConSol/sakuli/blob/master/docs/additional-settings.md +####################################################################################### diff --git a/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.suite b/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.suite new file mode 100644 index 00000000..f2a9ce71 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/_testsuite4aop/testsuite.suite @@ -0,0 +1 @@ +example/_tc.js http://localhost \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml new file mode 100644 index 00000000..e94377fa --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:JUnit-sakuli.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-beanRefFactory.xml b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-beanRefFactory.xml new file mode 100644 index 00000000..c42bdbc3 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-beanRefFactory.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-applicationContext.xml b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-applicationContext.xml new file mode 100644 index 00000000..fc0e0c3c --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-applicationContext.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-beanRefFactory.xml b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-beanRefFactory.xml new file mode 100644 index 00000000..c397251e --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/exceptions/sahiExceptionHandlerTest-beanRefFactory.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/inject_source.js b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/inject_source.js similarity index 100% rename from src/sakuli-core/src/test/resources/org/sakuli/starter/helper/inject_source.js rename to src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/inject_source.js diff --git a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/mock-files/inject_top.txt b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/mock-files/inject_top.txt similarity index 100% rename from src/sakuli-core/src/test/resources/org/sakuli/starter/helper/mock-files/inject_top.txt rename to src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/mock-files/inject_top.txt diff --git a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/mock-old-js/inject.js b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/mock-old-js/inject.js similarity index 100% rename from src/sakuli-core/src/test/resources/org/sakuli/starter/helper/mock-old-js/inject.js rename to src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/mock-old-js/inject.js diff --git a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/unvalid/testsuite.suite b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/unvalid/testsuite.suite similarity index 100% rename from src/sakuli-core/src/test/resources/org/sakuli/starter/helper/unvalid/testsuite.suite rename to src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/unvalid/testsuite.suite diff --git a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/unvalid2/testsuite.properties b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/unvalid2/testsuite.properties similarity index 99% rename from src/sakuli-core/src/test/resources/org/sakuli/starter/helper/unvalid2/testsuite.properties rename to src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/unvalid2/testsuite.properties index f11d3975..ad67e2d8 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/starter/helper/unvalid2/testsuite.properties +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/helper/unvalid2/testsuite.properties @@ -15,7 +15,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - ####################################################################################### # OVERWRITE-PROPERTIES # @@ -24,5 +23,4 @@ # For a short guideline how the property replacement mechanism in Sakuli works and how properties should be # overwritten, please refer to https://github.com/ConSol/sakuli/blob/master/docs/additional-settings.md ####################################################################################### - # empty property file just to ensure the file exists \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/config/inject_top.txt b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/config/inject_top.txt new file mode 100644 index 00000000..cab8486f --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/config/inject_top.txt @@ -0,0 +1 @@ +//JUST NEEDED to pass file-exists tests \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/userdata/sahi_testfile.txt b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/userdata/sahi_testfile.txt new file mode 100644 index 00000000..cab8486f --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/sahi_proxy/userdata/sahi_testfile.txt @@ -0,0 +1 @@ +//JUST NEEDED to pass file-exists tests \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/utils/properties-test/target.properties b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/utils/properties-test/target.properties new file mode 100644 index 00000000..10d2e7cc --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/utils/properties-test/target.properties @@ -0,0 +1,19 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +test.prop.1=xyz +test.prop.2=zyx \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/property_test/sakuli.properties b/src/sakuli-sahi-setup/src/test/resources/property_test/sakuli.properties new file mode 100644 index 00000000..7b14e5d1 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/property_test/sakuli.properties @@ -0,0 +1,29 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +####################################################################################### +# OVERWRITE-PROPERTIES +# +# To define a specific behaviour to your test, it is possible to overwrite all properties of the Sakuli default +# properties 'sakuli-default.properties'. +# For a short guideline how the property replacement mechanism in Sakuli works and how properties should be +# overwritten, please refer to https://github.com/ConSol/sakuli/blob/master/docs/additional-settings.md +####################################################################################### +sakuli.forwarder.gearman.server.host=test-gearman-host +ssl.client.keystore.type=JKS +ssl.client.cert.path=${sakuli.testsuite.folder}/sakuli_keystore +ssl.client.cert.password=sakuli \ No newline at end of file diff --git a/src/sakuli-sahi-setup/src/test/resources/property_test/suite_folder/testsuite.properties b/src/sakuli-sahi-setup/src/test/resources/property_test/suite_folder/testsuite.properties new file mode 100644 index 00000000..298d8aa0 --- /dev/null +++ b/src/sakuli-sahi-setup/src/test/resources/property_test/suite_folder/testsuite.properties @@ -0,0 +1,26 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# +testsuite.id=0001_testsuite_example +####################################################################################### +# OVERWRITE-PROPERTIES +# +# To define a specific behaviour to your test, it is possible to overwrite all properties of the Sakuli default +# properties 'sakuli-default.properties'. +# For a short guideline how the property replacement mechanism in Sakuli works and how properties should be +# overwritten, please refer to https://github.com/ConSol/sakuli/blob/master/docs/additional-settings.md +####################################################################################### diff --git a/src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties b/src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties new file mode 100644 index 00000000..b41caf8a --- /dev/null +++ b/src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties @@ -0,0 +1,27 @@ +# +# Sakuli - Testing and Monitoring-Tool for Websites and common UIs. +# +# Copyright 2013 - 2015 the original author or authors. +# +# 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. +# + +####################################################################################### +# OVERWRITE-PROPERTIES +# +# To define a specific behaviour to your test, it is possible to overwrite all properties of the Sakuli default +# properties 'sakuli-default.properties'. +# For a short guideline how the property replacement mechanism in Sakuli works and how properties should be +# overwritten, please refer to https://github.com/ConSol/sakuli/blob/master/docs/additional-settings.md +####################################################################################### + From 65078e3cc6713166baae89a401238be5c45ff79c Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 24 Apr 2017 21:37:54 +0200 Subject: [PATCH 10/21] #247 fix feature branch version --- pom.xml | 2 +- src/basic-test-util/pom.xml | 4 ++-- src/docs/pom.xml | 4 ++-- src/integration-test/pom.xml | 4 ++-- src/ocr-tessdata-extractor/pom.xml | 4 ++-- src/sakuli-common/pom.xml | 4 ++-- src/sakuli-core/pom.xml | 4 ++-- src/sakuli-installer/pom.xml | 4 ++-- src/sakuli-java-dsl/pom.xml | 4 ++-- src/sakuli-sahi-setup/pom.xml | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index 94003d25..1de50163 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se pom sakuli-parent diff --git a/src/basic-test-util/pom.xml b/src/basic-test-util/pom.xml index d7d13e6e..6b5add56 100644 --- a/src/basic-test-util/pom.xml +++ b/src/basic-test-util/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml basic-test-util - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} basic module for some internal testing stuff diff --git a/src/docs/pom.xml b/src/docs/pom.xml index e9adb751..ceeef15e 100644 --- a/src/docs/pom.xml +++ b/src/docs/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml docs - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se docs maven module to build the markdown api docs from jsdoc diff --git a/src/integration-test/pom.xml b/src/integration-test/pom.xml index 4433e80a..e41f8301 100644 --- a/src/integration-test/pom.xml +++ b/src/integration-test/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml integration-test - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} integration test module for sakuli diff --git a/src/ocr-tessdata-extractor/pom.xml b/src/ocr-tessdata-extractor/pom.xml index ab665f4a..9d9b2352 100644 --- a/src/ocr-tessdata-extractor/pom.xml +++ b/src/ocr-tessdata-extractor/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml ocr-tessdata-extractor - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ocr-tessdata-extractor maven module for enable the OCR text recognition function based on tessdata diff --git a/src/sakuli-common/pom.xml b/src/sakuli-common/pom.xml index f1ab341b..0e5376e3 100644 --- a/src/sakuli-common/pom.xml +++ b/src/sakuli-common/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml sakuli-common - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} maven module for common used resources diff --git a/src/sakuli-core/pom.xml b/src/sakuli-core/pom.xml index d50c0ca6..978cff0c 100644 --- a/src/sakuli-core/pom.xml +++ b/src/sakuli-core/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml sakuli-core - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} core module for all sakuli functionality diff --git a/src/sakuli-installer/pom.xml b/src/sakuli-installer/pom.xml index f7f60774..3b19c21f 100644 --- a/src/sakuli-installer/pom.xml +++ b/src/sakuli-installer/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml sakuli-installer - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se maven module to build the IzPack-Java Installer diff --git a/src/sakuli-java-dsl/pom.xml b/src/sakuli-java-dsl/pom.xml index ee4ee89e..182d7146 100644 --- a/src/sakuli-java-dsl/pom.xml +++ b/src/sakuli-java-dsl/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml sakuli-java-dsl - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} Specific Java-DSL for using Sakuli directly over Java diff --git a/src/sakuli-sahi-setup/pom.xml b/src/sakuli-sahi-setup/pom.xml index c621b481..7f4b82e3 100644 --- a/src/sakuli-sahi-setup/pom.xml +++ b/src/sakuli-sahi-setup/pom.xml @@ -24,12 +24,12 @@ org.sakuli sakuli-root - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ../../pom.xml sakuli-sahi-setup - 1.1.0-SNAPSHOT-241_sakuli_se + 1.1.0-SNAPSHOT-247_sakuli_se ${project.artifactId} module for all sahi based functionality From 13771a82b8b985e6c42d970f80d9de646931877f Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 24 Apr 2017 21:48:55 +0200 Subject: [PATCH 11/21] #247 revert wrong change --- docs/development/installation-developers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/installation-developers.md b/docs/development/installation-developers.md index 2d4345a7..04602145 100644 --- a/docs/development/installation-developers.md +++ b/docs/development/installation-developers.md @@ -97,7 +97,7 @@ If you want to use a Docker-Container, you can build and run it with the followi * In order to run Sakuli test cases directly from the IDE, you need to build up a run configuration. For IntelliJ see the predefined run configurations under [intellij/runConfigurations](intellij/runConfigurations) * __classpath of module:__ `sakuli-core` * __working directory:__ `$MODULE_DIR$` - * __main class:__ `org.sakuli.starter.sahi.SakuliStarter` + * __main class:__ `org.sakuli.starter.SakuliStarter` * __program arguments:__ ```-run --sakuli_home --sahi_home ``` e.g. for the provided Win7 example use `-run ../sakuli_test_suites/example src/main/_include ../sahi` From 8a53164fdc41c39678a3a4b38c4f9080b1ad516d Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Tue, 25 Apr 2017 11:13:35 +0200 Subject: [PATCH 12/21] #247 move jslibfolder property to SahiProxyProperties // update OCR-tessdata exctractor --- src/basic-test-util/pom.xml | 1 - .../ocr/tessdata/OcrTessdataLibExtractor.java | 50 +++++++++++-------- src/sakuli-core/pom.xml | 1 - .../properties/SakuliProperties.java | 24 +++------ ...kuliPropertyPlaceholderConfigurerTest.java | 4 +- src/sakuli-java-dsl/pom.xml | 5 +- .../sakuli/starter/sahi/SahiConnector.java | 2 +- .../properties/SahiProxyProperties.java | 17 ++++++- .../starter/sahi/SahiConnectorTest.java | 6 +-- 9 files changed, 60 insertions(+), 50 deletions(-) diff --git a/src/basic-test-util/pom.xml b/src/basic-test-util/pom.xml index 6b5add56..889ae11e 100644 --- a/src/basic-test-util/pom.xml +++ b/src/basic-test-util/pom.xml @@ -68,7 +68,6 @@ org.apache.maven.plugins maven-source-plugin - 2.4 attach-sources diff --git a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java index ff9f57c2..063fae3e 100644 --- a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java +++ b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java @@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory; import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.FileSystemException; import java.nio.file.Files; @@ -38,35 +40,39 @@ public class OcrTessdataLibExtractor { public static final String TESTDATA = "eng.traineddata"; private static final Logger LOGGER = LoggerFactory.getLogger(OcrTessdataLibExtractor.class); - public static void extract(Path outputDir) throws Exception { - extract(outputDir, null); + public static Path extract(Path outputDir) throws IOException { + return extract(outputDir, null); } - public static Path extract(Path outputDir, URL tessdataClasspathResourceFolder) throws Exception { + public static Path extract(Path outputDir, URL tessdataClasspathResourceFolder) throws IOException { if (tessdataClasspathResourceFolder == null) { tessdataClasspathResourceFolder = OcrTessdataLibExtractor.class.getResource("lib"); } - - if (tessdataClasspathResourceFolder.getProtocol().equals("jar")) { - final Path targetDir = outputDir.resolve("org").resolve("sakuli").resolve("ocr").resolve("tessdata").resolve("lib"); - if (!isTessdataLibFolderContentPresent(targetDir)) { - LOGGER.debug("Extract classpath resource '{}' to:{}", tessdataClasspathResourceFolder.toString(), outputDir.toString()); - JarReader.read(tessdataClasspathResourceFolder, (name, is) -> { - Path targetFile = outputDir.resolve("." + name).normalize(); - System.out.println("write file: " + targetFile); - FileUtils.copyInputStreamToFile(is, targetFile.toFile()); - }); - checkTessdataLibFolderContent(targetDir); + try { + if (tessdataClasspathResourceFolder.getProtocol().equals("jar")) { + final Path targetDir = outputDir.resolve("org").resolve("sakuli").resolve("ocr").resolve("tessdata").resolve("lib"); + if (!isTessdataLibFolderContentPresent(targetDir)) { + LOGGER.debug("Extract classpath resource '{}' to:{}", tessdataClasspathResourceFolder.toString(), outputDir.toString()); + JarReader.read(tessdataClasspathResourceFolder, (name, is) -> { + Path targetFile = outputDir.resolve("." + name).normalize(); + LOGGER.debug("write file: " + targetFile); + FileUtils.copyInputStreamToFile(is, targetFile.toFile()); + }); + checkTessdataLibFolderContent(targetDir); + } + return targetDir.normalize().toAbsolutePath(); + } else if (tessdataClasspathResourceFolder.getProtocol().equals("file")) { + final Path libPath = Paths.get(tessdataClasspathResourceFolder.toURI()); + LOGGER.debug("Use direct file path for OCR tessdata lib: {}", libPath); + checkTessdataLibFolderContent(libPath); + return libPath.normalize().toAbsolutePath(); } - return targetDir.normalize().toAbsolutePath(); - } else if (tessdataClasspathResourceFolder.getProtocol().equals("file")) { - final Path libPath = Paths.get(tessdataClasspathResourceFolder.toURI()); - LOGGER.debug("Use direct file path for OCR tessdata lib: {}", libPath); - checkTessdataLibFolderContent(libPath); - return libPath.normalize().toAbsolutePath(); + throw new FileSystemException("URL type '" + tessdataClasspathResourceFolder.getProtocol() + + "' not supported: " + tessdataClasspathResourceFolder.toString()); + } catch (URISyntaxException e) { + throw new FileNotFoundException("File URL is not valid: " + tessdataClasspathResourceFolder.toString() + + " - " + e.getMessage()); } - throw new FileSystemException("URL type '" + tessdataClasspathResourceFolder.getProtocol() - + "' not supported: " + tessdataClasspathResourceFolder.toString()); } public static void checkTessdataLibFolderContent(Path output) throws FileNotFoundException { diff --git a/src/sakuli-core/pom.xml b/src/sakuli-core/pom.xml index 978cff0c..8d346bf2 100644 --- a/src/sakuli-core/pom.xml +++ b/src/sakuli-core/pom.xml @@ -120,7 +120,6 @@ org.apache.maven.plugins maven-source-plugin - 2.4 attach-sources diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java index 70c4fd44..f7274272 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java @@ -49,14 +49,12 @@ public class SakuliProperties extends AbstractProperties { public static final String FORWARDER_TEMPLATE_FOLDER = "sakuli.forwarder.template.folder"; public static final String CONFIG_FOLDER_APPEDER = File.separator + "config"; public static final String LIBS_FOLDER_APPEDER = File.separator + "libs"; - public static final String JS_LIB_FOLDER_APPEDER = LIBS_FOLDER_APPEDER + File.separator + "js"; // have to be the common/libs older, so that {@link TextRecognizer} can add "tessdata" to the path! public static final String TESSDATA_LIB_FOLDER_APPEDER = LIBS_FOLDER_APPEDER; private static final boolean SUPPRESS_RESUMED_EXCEPTIONS_DEFAULT = false; - private static final boolean JAVASCRIPT_ENGINE_DEFAULT = true; private static final int LOG_MAX_AGE_DEFAULT = 14; private static final String MAX_AGE_GREATER_ZERO = "Property '" + LOG_MAX_AGE + "' have to be greater then 0, please check your 'sakuli.properties' file!"; - + public static String DEFAULT_TESSDATA_LIB_FOLDER = null; @Value("${" + SAKULI_HOME_FOLDER + "}") private String sakuliHomeFolderPropertyValue; private Path sakuliHomeFolder; @@ -82,7 +80,6 @@ public class SakuliProperties extends AbstractProperties { @Value("${" + FORWARDER_TEMPLATE_FOLDER + ":}") private String forwarderTemplateFolder; private Path configFolder; - private Path jsLibFolder; private Path tessDataLibFolder; @PostConstruct @@ -93,10 +90,13 @@ public void initFolders() throws FileNotFoundException, SakuliInitException { configFolder = Paths.get(sakuliHomeFolder + CONFIG_FOLDER_APPEDER); checkFolders(configFolder); - jsLibFolder = Paths.get(sakuliHomeFolder + JS_LIB_FOLDER_APPEDER); - checkFolders(jsLibFolder); - - tessDataLibFolder = Paths.get(sakuliHomeFolder + TESSDATA_LIB_FOLDER_APPEDER); + //noinspection ConstantConditions + //TODO exclude to a seperate Class, with out Load if depedency ocr-tessdata-extractor is there + if (DEFAULT_TESSDATA_LIB_FOLDER == null) { + tessDataLibFolder = Paths.get(sakuliHomeFolder + TESSDATA_LIB_FOLDER_APPEDER); + } else { + tessDataLibFolder = Paths.get(DEFAULT_TESSDATA_LIB_FOLDER); + } checkFolders(tessDataLibFolder); //need not to be checked, will be generated by the logger if it is missing @@ -170,14 +170,6 @@ public void setConfigFolder(Path configFolder) { this.configFolder = configFolder; } - public Path getJsLibFolder() { - return jsLibFolder; - } - - public void setJsLibFolder(Path jsLibFolder) { - this.jsLibFolder = jsLibFolder; - } - public Path getTessDataLibFolder() { return tessDataLibFolder; } diff --git a/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java b/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java index b645da07..a94a88d3 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurerTest.java @@ -148,8 +148,8 @@ public void testTestSuiteFolder() throws IOException { public void testSakuliHomeFolder() throws IOException { SakuliProperties properties = BeanLoader.loadBean(SakuliProperties.class); - assertTrue(Files.exists(properties.getJsLibFolder()), "include folder doesn't exists"); - assertTrue(properties.getJsLibFolder().toString().contains(BaseTest.SAKULI_HOME_FOLDER_PATH.substring(2))); + assertTrue(Files.exists(properties.getSakuliHomeFolder()), "include folder doesn't exists"); + assertTrue(properties.getSakuliHomeFolder().toString().contains(BaseTest.SAKULI_HOME_FOLDER_PATH.substring(2))); assertNotNull(properties.getLogPattern()); } diff --git a/src/sakuli-java-dsl/pom.xml b/src/sakuli-java-dsl/pom.xml index 182d7146..a6081f81 100644 --- a/src/sakuli-java-dsl/pom.xml +++ b/src/sakuli-java-dsl/pom.xml @@ -171,20 +171,19 @@ org.apache.maven.plugins maven-source-plugin - 2.4 attach-sources package - jar + jar-no-fork attach-test-sources verify - test-jar + test-jar-no-fork diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java index a0249698..14a75dc6 100644 --- a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/SahiConnector.java @@ -175,7 +175,7 @@ protected TestRunner getTestRunner() { } protected String getIncludeFolderJsPath() { - String path = sakuliProperties.getJsLibFolder().toAbsolutePath().toString() + File.separator + "sakuli.js"; + String path = sahiProxyProperties.getJsLibFolder().toAbsolutePath().toString() + File.separator + "sakuli.js"; if (path.contains("\\")) { //replace \ with \\ path = path.replaceAll("\\\\", "\\\\\\\\"); diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java index 429b0e86..9a0d9c42 100644 --- a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/datamodel/properties/SahiProxyProperties.java @@ -36,6 +36,8 @@ import java.util.Arrays; import java.util.List; +import static org.sakuli.datamodel.properties.SakuliProperties.LIBS_FOLDER_APPEDER; + /** * @author tschneck Date: 14.05.14 */ @@ -103,6 +105,7 @@ public class SahiProxyProperties extends AbstractProperties { public static final List logPropertyNames = Arrays.asList(SAHI_HANLDER, SAHI_LOG_CONSOLE_HANLDER_LEVEL, SAHI_LOG_FILE_HANDLER, SAHI_LOG_CONSOLE_HANDLER_FORMATTER, SAHI_LOG_FILE_HANDLER_FORMATTER, SAHI_LOG_FILE_HANDLER_LIMIT, SAHI_LOG_FILE_HANDLER_COUNT, SAHI_LOG_FILE_HANDLER_PATERN); + public static final String JS_LIB_FOLDER_APPEDER = LIBS_FOLDER_APPEDER + File.separator + "js"; public static final Logger LOGGER = LoggerFactory.getLogger(SahiProxyProperties.class); @Value("${" + PROXY_HOME_FOLDER + "}") @@ -132,6 +135,8 @@ public class SahiProxyProperties extends AbstractProperties { private Path sahiJSInjectConfigFile; private Path sahiJSInjectSourceFile; private Path sahiJSInjectTargetFile; + private Path jsLibFolder; + @PostConstruct public void initFolders() throws FileNotFoundException { @@ -139,6 +144,8 @@ public void initFolders() throws FileNotFoundException { sahiConfigFolder = Paths.get(sahiConfigFolderPropertyValue).normalize().toAbsolutePath(); if (!testSuiteProperties.isUiTest()) { checkFolders(sahiHomeFolder, sahiConfigFolder); + jsLibFolder = Paths.get(sakuliProperties.getSakuliHomeFolder() + JS_LIB_FOLDER_APPEDER); + checkFolders(jsLibFolder); loadSahiInjectFiles(); } } @@ -151,7 +158,7 @@ public void initFolders() throws FileNotFoundException { */ protected void loadSahiInjectFiles() throws FileNotFoundException { sahiJSInjectConfigFile = Paths.get(sahiHomeFolder.toString() + SAHI_JS_INJECT_CONFIG_FILE_APPENDER); - sahiJSInjectSourceFile = Paths.get(sakuliProperties.getJsLibFolder() + SAHI_JS_INJECT_CODE_FILENAME_APPENDER); + sahiJSInjectSourceFile = Paths.get(getJsLibFolder() + SAHI_JS_INJECT_CODE_FILENAME_APPENDER); checkFiles(sahiJSInjectConfigFile, sahiJSInjectSourceFile); //don't check files and folders => will be created during runtime @@ -214,6 +221,14 @@ public void setMaxConnectTries(Integer maxConnectTries) { this.maxConnectTries = maxConnectTries; } + public Path getJsLibFolder() { + return jsLibFolder; + } + + public void setJsLibFolder(Path jsLibFolder) { + this.jsLibFolder = jsLibFolder; + } + public Path getSahiJSInjectConfigFile() { return sahiJSInjectConfigFile; } diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java index db2b75be..abffe2e8 100644 --- a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/SahiConnectorTest.java @@ -136,7 +136,7 @@ public void testStartSahiTestSuiteReconnect() throws Throwable { @Test public void testGetIncludFolderJsPath() throws Exception { Path pathMock = mock(Path.class); - when(sakuliProperties.getJsLibFolder()).thenReturn(pathMock); + when(sahiProxyProperties.getJsLibFolder()).thenReturn(pathMock); when(pathMock.toAbsolutePath()).thenReturn(pathMock); if (File.separator.equals("/")) { @@ -153,7 +153,7 @@ public void testGetIncludFolderJsPath() throws Exception { @Test public void testReconnectOK() throws Throwable { Path pathMock = mock(Path.class); - when(sakuliProperties.getJsLibFolder()).thenReturn(pathMock); + when(sahiProxyProperties.getJsLibFolder()).thenReturn(pathMock); when(pathMock.toAbsolutePath()).thenReturn(pathMock); when(pathMock.toString()).thenReturn("/sakuli/src/main/include"); @@ -166,7 +166,7 @@ public void testReconnectOK() throws Throwable { @Test(expectedExceptions = InterruptedException.class) public void testReconnectFAILURE() throws Throwable { Path pathMock = mock(Path.class); - when(sakuliProperties.getJsLibFolder()).thenReturn(pathMock); + when(sahiProxyProperties.getJsLibFolder()).thenReturn(pathMock); when(pathMock.toAbsolutePath()).thenReturn(pathMock); when(pathMock.toString()).thenReturn("/sakuli/src/main/include"); From 4df16393227d9d5fdad3ea152653711efe4d66ad Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 26 Apr 2017 01:19:13 +0200 Subject: [PATCH 13/21] #247 first version sakuli-selenium-setup --- pom.xml | 2 +- .../java/org/sakuli/AbstractLogAwareTest.java | 26 +- .../org/sakuli/ocr/tessdata/JarReader.java | 2 +- .../ocr/tessdata/OcrTessdataLibExtractor.java | 1 - .../tessdata/OcrTessdataLibExtractorIT.java | 2 +- .../tessdata/OcrTessdataLibExtractorTest.java | 2 +- .../org/sakuli/common/libs/js/sakuli.js | 2 +- .../testcase/AbstractTestCaseActionImpl.java | 137 ++++++++ .../JavaScriptTestCaseActionImpl.java} | 174 +--------- .../actions/testcase/TestCaseAction.java | 104 ++++++ .../sakuli/aop/LogActionExecutedAspect.java | 16 +- .../datamodel/AbstractTestDataEntity.java | 5 +- .../java/org/sakuli/datamodel/TestCase.java | 18 +- .../org/sakuli/datamodel/TestCaseStep.java | 3 +- .../datamodel/helper/TestSuiteHelper.java | 1 + .../properties/SakuliProperties.java | 3 +- .../exceptions/SakuliExceptionHandler.java | 13 +- .../exceptions/SakuliRuntimeException.java | 2 +- .../java/org/sakuli/loader/BeanLoader.java | 12 +- ...java => TestCaseActionJavaScriptTest.java} | 8 +- .../aop/LogActionExecutedAspectTest.java | 29 +- .../SakuliExceptionHandlerTest.java | 20 ++ .../sakuli/javaDSL/AbstractSakuliTest.java | 12 +- .../logging/SahiLogToResultCallbackTest.java | 6 +- src/sakuli-selenium-setup/.gitignore | 1 + src/sakuli-selenium-setup/pom.xml | 226 +++++++++++++ .../sakuli/SakuliCommonConfigExtractor.java | 85 +++++ .../selenium/JavaTestResourceHelper.java | 71 ++++ .../actions/testcase/SeTestCaseAction.java | 41 +++ .../testcase/TestCaseInitParameter.java | 131 ++++++++ .../sakuli/selenium/testng/SakuliSeTest.java | 305 ++++++++++++++++++ .../selenium/testng/SakuliTestCase.java | 45 +++ .../testng/aop/TestNGActionCallback.java | 59 ++++ ...SakuliSePropertyPlaceholderConfigurer.java | 108 +++++++ .../sakuli-se-applicationContext.xml | 34 ++ .../resources/sakuli-se-beanRefFactory.xml | 27 ++ .../SakuliCommonConfigExtractorTest.java | 54 ++++ .../selenium/testng/SakuliSeTestUnitTest.java | 47 +++ ...liSePropertyPlaceholderConfigurerTest.java | 79 +++++ .../src/test/resources}/sakuli.properties | 1 - 40 files changed, 1697 insertions(+), 217 deletions(-) create mode 100644 src/sakuli-core/src/main/java/org/sakuli/actions/testcase/AbstractTestCaseActionImpl.java rename src/sakuli-core/src/main/java/org/sakuli/actions/{TestCaseAction.java => testcase/JavaScriptTestCaseActionImpl.java} (56%) create mode 100644 src/sakuli-core/src/main/java/org/sakuli/actions/testcase/TestCaseAction.java rename src/sakuli-core/src/test/java/org/sakuli/actions/{TestCaseActionTest.java => TestCaseActionJavaScriptTest.java} (97%) create mode 100644 src/sakuli-selenium-setup/.gitignore create mode 100644 src/sakuli-selenium-setup/pom.xml create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/SakuliCommonConfigExtractor.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/JavaTestResourceHelper.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/SeTestCaseAction.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/TestCaseInitParameter.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliTestCase.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/aop/TestNGActionCallback.java create mode 100644 src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java create mode 100644 src/sakuli-selenium-setup/src/main/resources/sakuli-se-applicationContext.xml create mode 100644 src/sakuli-selenium-setup/src/main/resources/sakuli-se-beanRefFactory.xml create mode 100644 src/sakuli-selenium-setup/src/test/java/org/sakuli/SakuliCommonConfigExtractorTest.java create mode 100644 src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java create mode 100644 src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurerTest.java rename src/{sakuli-selenium-java-dsl/src/test/resources/org/sakuli => sakuli-selenium-setup/src/test/resources}/sakuli.properties (99%) diff --git a/pom.xml b/pom.xml index 1de50163..10e122c0 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ src/sakuli-sahi-setup src/sakuli-installer src/sakuli-java-dsl - + src/sakuli-selenium-setup src/integration-test src/docs diff --git a/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java b/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java index 4d335c93..77098aba 100644 --- a/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java +++ b/src/basic-test-util/src/test/java/org/sakuli/AbstractLogAwareTest.java @@ -137,6 +137,19 @@ private static void waitForLogFile(Path file) { } } + public synchronized static void assertLastLine(Path logFile, String filter, String logLevelName, String expectedMessage) throws IOException { + String preFix = logLevelName; + if ("WARNING".equals(logLevelName)) { + preFix = "WARN "; + } + if ("INFO".equals(logLevelName)) { + preFix = "INFO "; + } + String lastLineOfLogFile = AbstractLogAwareTest.getLastLineWithContent(logFile, filter); + assertEquals(lastLineOfLogFile.substring(0, 5), preFix); + assertEquals(lastLineOfLogFile.substring(lastLineOfLogFile.indexOf("]") + 4), expectedMessage); + } + @BeforeSuite(alwaysRun = true) public void setLogLevel() throws Exception { setSakuliLogLevel("DEBUG"); @@ -150,17 +163,4 @@ public void removeLogLevel() throws Exception { setSikuliLogLevel(null); setSahiLogLevel(null); } - - protected synchronized void assertLastLine(Path logFile, String filter, String logLevelName, String expectedMessage) throws IOException { - String preFix = logLevelName; - if ("WARNING".equals(logLevelName)) { - preFix = "WARN "; - } - if ("INFO".equals(logLevelName)) { - preFix = "INFO "; - } - String lastLineOfLogFile = AbstractLogAwareTest.getLastLineWithContent(logFile, filter); - assertEquals(lastLineOfLogFile.substring(0, 5), preFix); - assertEquals(lastLineOfLogFile.substring(lastLineOfLogFile.indexOf("]") + 4), expectedMessage); - } } diff --git a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java index a697aa73..ea4680e6 100644 --- a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java +++ b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/JarReader.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.sakuli.javaDSL.selenium.testng; +package org.sakuli.ocr.tessdata; /** * @author tschneck diff --git a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java index 063fae3e..529c245d 100644 --- a/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java +++ b/src/ocr-tessdata-extractor/src/main/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractor.java @@ -19,7 +19,6 @@ package org.sakuli.ocr.tessdata; import org.apache.commons.io.FileUtils; -import org.sakuli.javaDSL.selenium.testng.JarReader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java index ad10b1e2..bb44fb5d 100644 --- a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java +++ b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorIT.java @@ -29,7 +29,7 @@ import static org.testng.Assert.assertTrue; /** - * Integration Test for {@link org.sakuli.javaDSL.selenium.testng.JarReader} and {@link OcrTessdataLibExtractor}. + * Integration Test for {@link JarReader} and {@link OcrTessdataLibExtractor}. * * @author tschneck * Date: 4/18/17 diff --git a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java index 4f635e7e..0df35b8e 100644 --- a/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java +++ b/src/ocr-tessdata-extractor/src/test/java/org/sakuli/ocr/tessdata/OcrTessdataLibExtractorTest.java @@ -28,7 +28,7 @@ import static org.testng.Assert.*; /** - * Integration Test for {@link org.sakuli.javaDSL.selenium.testng.JarReader} and {@link OcrTessdataLibExtractor}. + * Integration Test for {@link JarReader} and {@link OcrTessdataLibExtractor}. * * @author tschneck * Date: 4/18/17 diff --git a/src/sakuli-common/src/main/resources/org/sakuli/common/libs/js/sakuli.js b/src/sakuli-common/src/main/resources/org/sakuli/common/libs/js/sakuli.js index 1bb814d7..b287eda4 100644 --- a/src/sakuli-common/src/main/resources/org/sakuli/common/libs/js/sakuli.js +++ b/src/sakuli-common/src/main/resources/org/sakuli/common/libs/js/sakuli.js @@ -272,7 +272,7 @@ function TestCase(warningTime, criticalTime, optImagePathArray) { * init the java backed */ Logger.logDebug("get Backend - step 1 (load backend)"); - that.javaObject = Packages.org.sakuli.loader.BeanLoader.loadTestCaseAction(); + that.javaObject = Packages.org.sakuli.loader.BeanLoader.loadJavaScriptTestCaseAction(); Logger.logDebug("get Backend - step 2 (get the test case id)"); that.tcID = that.javaObject.getIdFromPath(_resolvePath()); diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/AbstractTestCaseActionImpl.java b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/AbstractTestCaseActionImpl.java new file mode 100644 index 00000000..68582660 --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/AbstractTestCaseActionImpl.java @@ -0,0 +1,137 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.actions.testcase; + +import org.apache.commons.lang.StringUtils; +import org.sakuli.actions.logging.LogToResult; +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.TestCaseStep; +import org.sakuli.datamodel.helper.TestDataEntityHelper; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.loader.BeanLoader; + +import java.nio.file.Path; + +/** + * @author tschneck + * Date: 4/25/17 + */ +public abstract class AbstractTestCaseActionImpl implements TestCaseAction { + /** + * Represents the current running TestCase. The object will be set at {@link #init(String, int, int, String...)} and + */ + + protected BaseActionLoader loader; + + public AbstractTestCaseActionImpl() { +// System.out.println("call??????"); + loader = BeanLoader.loadBaseActionLoader(); + } + + @Override + @LogToResult(message = "init a new test case") + public void init(String testCaseID, int warningTime, int criticalTime, String... imagePaths) { + loader.init(testCaseID, imagePaths); + initWarningAndCritical(warningTime, criticalTime); + } + + + @Override + @LogToResult(message = "init a new test case") + public void initWithPaths(String testCaseID, int warningTime, int criticalTime, Path... imagePaths) { + loader.init(testCaseID, imagePaths); + initWarningAndCritical(warningTime, criticalTime); + } + + + @Override + @LogToResult + public void addImagePaths(Path... imagePaths) throws SakuliException { + loader.addImagePaths(imagePaths); + } + + protected void initWarningAndCritical(int warningTime, int criticalTime) { + TestCase currentTestCase = loader.getCurrentTestCase(); + String errormsg = TestDataEntityHelper.checkWarningAndCriticalTime(warningTime, criticalTime, currentTestCase.toStringShort()); + if (errormsg != null) { + handleException(errormsg); + } else { + //if everything is ok set the times + currentTestCase.setWarningTime(warningTime); + currentTestCase.setCriticalTime(criticalTime); + } + } + + protected TestCaseStep findStep(String stepName) { + TestCaseStep newStep = new TestCaseStep(); + newStep.setId(stepName); + for (TestCaseStep step : loader.getCurrentTestCase().getSteps()) { + if (StringUtils.equals(step.getId(), newStep.getId())) { + return step; + } + } + return newStep; + } + + @Override + public void handleException(Throwable e) { + loader.getExceptionHandler().handleException(e, false); + } + + + @Override + public void handleException(String exceptionMessage) { + loader.getExceptionHandler().handleException(exceptionMessage, false); + } + + @Override + public String toString() { + if (loader != null && loader.getCurrentTestCase() != null) { + return "test case [" + loader.getCurrentTestCase().getActionValueString() + "]"; + } + return "test case not initialized"; + } + + @Override + @LogToResult + public String getTestCaseFolderPath() { + try { + return loader.getCurrentTestCase().getTcFolder().toAbsolutePath().toString(); + } catch (Exception e) { + handleException(new SakuliException(e, + String.format("cannot resolve the folder path of the current testcase '%s'", + loader.getCurrentTestCase()))); + return null; + } + } + + @Override + @LogToResult + public String getTestSuiteFolderPath() { + try { + return loader.getTestSuite().getTestSuiteFolder().toAbsolutePath().toString(); + } catch (Exception e) { + handleException(new SakuliException(e, + String.format("cannot resolve the folder path of the current testsuite '%s'", + loader.getTestSuite()))); + return null; + } + } +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/TestCaseAction.java b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/JavaScriptTestCaseActionImpl.java similarity index 56% rename from src/sakuli-core/src/main/java/org/sakuli/actions/TestCaseAction.java rename to src/sakuli-core/src/main/java/org/sakuli/actions/testcase/JavaScriptTestCaseActionImpl.java index 176e5aa1..660fe0de 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/TestCaseAction.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/JavaScriptTestCaseActionImpl.java @@ -16,128 +16,33 @@ * limitations under the License. */ -package org.sakuli.actions; +package org.sakuli.actions.testcase; -import org.apache.commons.lang.StringUtils; import org.sakuli.actions.logging.LogToResult; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.actions.ImageLib; import org.sakuli.datamodel.actions.LogLevel; import org.sakuli.datamodel.helper.TestCaseHelper; import org.sakuli.datamodel.helper.TestCaseStepHelper; -import org.sakuli.datamodel.helper.TestDataEntityHelper; import org.sakuli.exceptions.SakuliActionException; import org.sakuli.exceptions.SakuliException; -import org.sakuli.exceptions.SakuliExceptionHandler; import org.sakuli.exceptions.SakuliValidationException; -import org.sakuli.loader.BaseActionLoader; -import org.sakuli.loader.BaseActionLoaderImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Date; /** * @author tschneck Date: 19.06.13 */ -@Component -public class TestCaseAction { +//TODO move to package `sahi-setup` +//@Component +public class JavaScriptTestCaseActionImpl extends AbstractTestCaseActionImpl { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - /** - * Represents the current running TestCase. The object will be set at {@link #init(String, int, int, String...)} and - * releases at {@link #saveResult(String, String, String, String, String)} - */ - @Autowired - @Qualifier(BaseActionLoaderImpl.QUALIFIER) - private BaseActionLoader loader; - - /**************** - * Init functions for the java script engine. - *********************/ - - /** - * Set the warning and critical Time to the specific test case. - * - * @param testCaseID current ID of the test case - * @param warningTime warning threshold in seconds. If the threshold is set to 0, - * the execution time will never exceed, so the state will be always OK! - * @param criticalTime critical threshold in seconds. If the threshold is set to 0, - * the execution time will never exceed, so the state will be always OK! - * @param imagePaths multiple paths to images - */ - @LogToResult(message = "init a new test case") - public void init(String testCaseID, int warningTime, int criticalTime, String... imagePaths) { - loader.init(testCaseID, imagePaths); - initWarningAndCritical(warningTime, criticalTime); - } - - /** - * Set the warning and critical Time to the specific test case. - * - * @param testCaseID current ID of the test case - * @param warningTime warning threshold in seconds. If the threshold is set to 0, - * the execution time will never exceed, so the state will be always OK! - * @param criticalTime critical threshold in seconds. If the threshold is set to 0, - * the execution time will never exceed, so the state will be always OK! - * @param imagePaths multiple paths to images - */ - @LogToResult(message = "init a new test case") - public void initWithPaths(String testCaseID, int warningTime, int criticalTime, Path... imagePaths) { - loader.init(testCaseID, imagePaths); - initWarningAndCritical(warningTime, criticalTime); - } - - /** - * Adds the additional paths to the current {@link ImageLib} object. - * If a relative path is assigned, the current testcase folder will be used as current directory. - * - * @param imagePaths one or more paths as {@link String} elements - * @throws SakuliException if an IO error occurs - */ - public void addImagePathsAsString(String... imagePaths) throws SakuliException { - for (String path : imagePaths) { - //check if absolute path - if (!path.matches("(\\/\\S*|\\w:\\\\\\S*)")) { - addImagePaths(loader.getCurrentTestCase().getTcFile().getParent().resolve(path)); - } else { - addImagePaths(Paths.get(path)); - } - } - } - - /** - * Adds the additional paths to the current {@link ImageLib} object. - * - * @param imagePaths one or more {@link Path} elements - * @throws SakuliException if an IO error occurs - */ - @LogToResult - public void addImagePaths(Path... imagePaths) throws SakuliException { - loader.addImagePaths(imagePaths); - } - - private void initWarningAndCritical(int warningTime, int criticalTime) { - TestCase currentTestCase = loader.getCurrentTestCase(); - String errormsg = TestDataEntityHelper.checkWarningAndCriticalTime(warningTime, criticalTime, currentTestCase.toStringShort()); - if (errormsg != null) { - handleException(errormsg); - } else { - //if everything is ok set the times - currentTestCase.setWarningTime(warningTime); - currentTestCase.setCriticalTime(criticalTime); - } - } - - /**************** * TEST CASE HANDLING *********************/ @@ -227,17 +132,6 @@ public void addTestCaseStep(String stepName, String startTime, String stopTime, + "\""); } - protected TestCaseStep findStep(String stepName) { - TestCaseStep newStep = new TestCaseStep(); - newStep.setId(stepName); - for (TestCaseStep step : loader.getCurrentTestCase().getSteps()) { - if (StringUtils.equals(step.getId(), newStep.getId())) { - return step; - } - } - return newStep; - } - /** * Creates a new test case based exception with an optional screenshot at the calling time. * Will be called from sakuli.js or in side of 'org.sakuli.javaDSL.AbstractSakuliTest'. @@ -250,30 +144,6 @@ public void throwException(String message, boolean screenshot) { loader.getExceptionHandler().handleException(screenshot ? new SakuliActionException(message) : new SakuliValidationException(message)); } - /** - * calls the method {@link SakuliExceptionHandler#handleException(Throwable)} - * - * @param e the original exception - */ - public void handleException(Throwable e) { - loader.getExceptionHandler().handleException(e, false); - } - - /** - * @param exceptionMessage String message - */ - public void handleException(String exceptionMessage) { - loader.getExceptionHandler().handleException(exceptionMessage, false); - } - - @Override - public String toString() { - if (loader != null && loader.getCurrentTestCase() != null) { - return "test case [" + loader.getCurrentTestCase().getActionValueString() + "]"; - } - return "test case not initialized"; - } - /**************** * TEST CASE INFO FUNCTIONS *********************/ @@ -313,34 +183,16 @@ public void setLastURL(String lastURL) { loader.getCurrentTestCase().setLastURL(lastURL); } - /** - * @return the folder path of the current testcase as {@link String}. - */ - @LogToResult - public String getTestCaseFolderPath() { - try { - return loader.getCurrentTestCase().getTcFile().getParent().toAbsolutePath().toString(); - } catch (Exception e) { - handleException(new SakuliException(e, - String.format("cannot resolve the folder path of the current testcase '%s'", - loader.getCurrentTestCase()))); - return null; - } - } - /** - * @return the folder path of the current testsuite as {@link String}. - */ - @LogToResult - public String getTestSuiteFolderPath() { - try { - return loader.getTestSuite().getTestSuiteFolder().toAbsolutePath().toString(); - } catch (Exception e) { - handleException(new SakuliException(e, - String.format("cannot resolve the folder path of the current testsuite '%s'", - loader.getTestSuite()))); - return null; + @Override + public void addImagePathsAsString(String... imagePaths) throws SakuliException { + for (String path : imagePaths) { + //check if absolute path + if (!path.matches("(\\/\\S*|\\w:\\\\\\S*)")) { + addImagePaths(loader.getCurrentTestCase().getTcFile().getParent().resolve(path)); + } else { + addImagePaths(Paths.get(path)); + } } } - } diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/TestCaseAction.java b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/TestCaseAction.java new file mode 100644 index 00000000..c8ce5f3d --- /dev/null +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/testcase/TestCaseAction.java @@ -0,0 +1,104 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.actions.testcase; + +import org.sakuli.actions.logging.LogToResult; +import org.sakuli.datamodel.actions.ImageLib; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.exceptions.SakuliExceptionHandler; + +import java.nio.file.Path; + +/** + * @author tschneck + * Date: 4/25/17 + */ +public interface TestCaseAction { + /** + * Set the warning and critical Time to the specific test case. + * + * @param testCaseID current ID of the test case + * @param warningTime warning threshold in seconds. If the threshold is set to 0, + * the execution time will never exceed, so the state will be always OK! + * @param criticalTime critical threshold in seconds. If the threshold is set to 0, + * the execution time will never exceed, so the state will be always OK! + * @param imagePaths multiple paths to images + */ + @LogToResult(message = "init a new test case") + void init(String testCaseID, int warningTime, int criticalTime, String... imagePaths); + + /** + * Set the warning and critical Time to the specific test case. + * + * @param testCaseID current ID of the test case + * @param warningTime warning threshold in seconds. If the threshold is set to 0, + * the execution time will never exceed, so the state will be always OK! + * @param criticalTime critical threshold in seconds. If the threshold is set to 0, + * the execution time will never exceed, so the state will be always OK! + * @param imagePaths multiple paths to images + */ + @LogToResult(message = "init a new test case") + void initWithPaths(String testCaseID, int warningTime, int criticalTime, Path... imagePaths); + + /** + * Adds the additional paths to the current {@link ImageLib} object. + * If a relative path is assigned, the current testcase folder will be used as current directory. + * + * @param imagePaths one or more paths as {@link String} elements + * @throws SakuliException if an IO error occurs + */ + void addImagePathsAsString(String... imagePaths) throws SakuliException; + + /** + * Adds the additional paths to the current {@link ImageLib} object. + * + * @param imagePaths one or more {@link Path} elements + * @throws SakuliException if an IO error occurs + */ + @LogToResult + void addImagePaths(Path... imagePaths) throws SakuliException; + + + /** + * calls the method {@link SakuliExceptionHandler#handleException(Throwable)} + * + * @param e the original exception + */ + void handleException(Throwable e); + + /** + * @param exceptionMessage String message + */ + void handleException(String exceptionMessage); + + @Override + String toString(); + + /** + * @return the folder path of the current testcase as {@link String}. + */ + @LogToResult + String getTestCaseFolderPath(); + + /** + * @return the folder path of the current testsuite as {@link String}. + */ + @LogToResult + String getTestSuiteFolderPath(); +} diff --git a/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java b/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java index 9423d013..6e9ae503 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java +++ b/src/sakuli-core/src/main/java/org/sakuli/aop/LogActionExecutedAspect.java @@ -23,6 +23,8 @@ import org.aspectj.lang.annotation.Before; import org.sakuli.actions.logging.LogToResult; import org.sakuli.actions.logging.LogToResultCallback; +import org.sakuli.actions.testcase.AbstractTestCaseActionImpl; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.loader.BeanLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,10 +44,20 @@ public class LogActionExecutedAspect extends BaseSakuliAspect { protected final static Logger logger = LoggerFactory.getLogger(LogActionExecutedAspect.class); /** - * Pointcut for the {@link org.sakuli.actions.TestCaseAction} class to do an {@link + * Pointcut for the {@link JavaScriptTestCaseActionImpl} class to do an {@link * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} */ - @Before("execution(* org.sakuli.actions.TestCaseAction.*(..)) &&" + + @Before("execution(* org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl.*(..)) &&" + + "@annotation(logToResult)") + public void doJavaScriptTestCaseActionLog(JoinPoint joinPoint, LogToResult logToResult) { + addActionLog(joinPoint, logToResult); + } + + /** + * Pointcut for the {@link AbstractTestCaseActionImpl} class to do an {@link + * #addActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)} + */ + @Before("execution(* org.sakuli.actions.testcase.AbstractTestCaseActionImpl.*(..)) &&" + "@annotation(logToResult)") public void doTestCaseActionLog(JoinPoint joinPoint, LogToResult logToResult) { addActionLog(joinPoint, logToResult); diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/AbstractTestDataEntity.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/AbstractTestDataEntity.java index 086d7f5d..33baed07 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/AbstractTestDataEntity.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/AbstractTestDataEntity.java @@ -20,6 +20,7 @@ import org.apache.commons.lang.StringUtils; import org.joda.time.DateTime; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.state.SakuliState; import org.sakuli.exceptions.SakuliExceptionHandler; import org.sakuli.exceptions.SakuliExceptionWithScreenshot; @@ -52,8 +53,8 @@ public abstract class AbstractTestDataEntity { /** - * {@link #id} and {@link # startUrl} will be set with the method {@link org.sakuli.starter.SahiConnector#init()} + * {@link #id} and {@link # startUrl} will be set with the method {@code org.sakuli.starter.SahiConnector#init()} */ private String startUrl; /** - * will be set with the method {@link org.sakuli.actions.TestCaseAction#saveResult(String, String, String, + * will be set with the method {@link JavaScriptTestCaseActionImpl#saveResult(String, String, String, * String, String)} */ private String lastURL; private List steps; private Path tcFile; + private Path tcFolder; /** * Creates a TestCase @@ -56,8 +58,8 @@ public TestCase(String name, String testCaseId) { this.name = name; this.id = testCaseId; /** - * needed to be set to -1, so the function {@link org.sakuli.actions.TestCaseAction#addTestCaseStep(String, String, String, String, int)} - * can check if the method {@link org.sakuli.actions.TestCaseAction#initTestCaseWarningAndCritical(String, int, int)} + * needed to be set to -1, so the function {@link JavaScriptTestCaseActionImpl#addTestCaseStep(String, String, String, String, int)} + * can check if the method {@link JavaScriptTestCaseActionImpl#initTestCaseWarningAndCritical(String, int, int)} * have been called at the beginning of this test case. */ warningTime = -1; @@ -181,6 +183,14 @@ public void setTcFile(Path tcFile) { this.tcFile = tcFile; } + public Path getTcFolder() { + return tcFolder; + } + + public void setTcFolder(Path tcFolder) { + this.tcFolder = tcFolder; + } + /** * @return all {@link TestCaseStep}s as {@link SortedSet} or a empty set if no test case steps are specified. diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/TestCaseStep.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/TestCaseStep.java index 9ef3398c..bbd855f6 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/TestCaseStep.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/TestCaseStep.java @@ -19,12 +19,13 @@ package org.sakuli.datamodel; import org.apache.commons.lang.StringUtils; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.state.TestCaseStepState; import org.sakuli.exceptions.SakuliException; /** * test case step based Exceptions and critical times will be currently not supported in {@link - * org.sakuli.actions.TestCaseAction}. + * JavaScriptTestCaseActionImpl}. * * @author tschneck Date: 18.06.13 */ diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/helper/TestSuiteHelper.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/helper/TestSuiteHelper.java index 01044c70..b0face6f 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/helper/TestSuiteHelper.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/helper/TestSuiteHelper.java @@ -82,6 +82,7 @@ public static HashMap loadTestCases(TestSuiteProperties proper TestCaseHelper.convertTestCaseFileToID(tcFileName)); tc.setStartUrl(startURL); tc.setTcFile(tcFile); + tc.setTcFolder(tcFile.getParent()); tc.setSteps(TestCaseStepHelper.readCachedStepDefinitions(tcFile)); //set the Map with the test case id as key tcMap.put(tc.getId(), tc); diff --git a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java index f7274272..281d4a5d 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java +++ b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/SakuliProperties.java @@ -34,7 +34,8 @@ @Component public class SakuliProperties extends AbstractProperties { - public static final String SAKULI_PROPERTIES_FILE_APPENDER = File.separator + "sakuli.properties"; + public static final String SAKULI_PROPERTIES_FILE_NAME = "sakuli.properties"; + public static final String SAKULI_PROPERTIES_FILE_APPENDER = File.separator + SAKULI_PROPERTIES_FILE_NAME; public static final String SAKULI_DEFAULT_PROPERTIES_FILE_APPENDER = File.separator + "sakuli-default.properties"; public static final String SAKULI_HOME_FOLDER = "sakuli.home.folder"; public static final String SUPPRESS_RESUMED_EXCEPTIONS = "sakuli.exception.suppressResumedExceptions"; diff --git a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java index 60c1601d..4e76443a 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java +++ b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java @@ -147,6 +147,8 @@ public void handleException(Throwable e) { protected void processException(Throwable e) { SakuliException transformedException = transformException(e); + processedExceptions.add(e); + processedExceptions.add(transformedException); //Do different exception handling for different use cases: if (resumeToTestExcecution(e) && loader.getSakuliProperties().isSuppressResumedExceptions()) { @@ -158,8 +160,6 @@ protected void processException(Throwable e) { saveException(transformedException); triggerCallbacks(transformedException); } - processedExceptions.add(e); - processedExceptions.add(transformedException); } /** @@ -175,8 +175,15 @@ void triggerCallbacks(SakuliException transformedException) { */ public boolean isAlreadyProcessed(Throwable e) { String message = e.getMessage() != null ? e.getMessage() : e.toString(); - return message.contains(BaseSakuliAspect.ALREADY_PROCESSED) + boolean processed = message.contains(BaseSakuliAspect.ALREADY_PROCESSED) || message.contains(("Logging exception:")) || processedExceptions.contains(e); + + //check also caused exception to don't process wrapped exceptions twice + //noinspection SimplifiableIfStatement + if (!processed && e.getCause() != null) { + return isAlreadyProcessed(e.getCause()); + } + return processed; } /** diff --git a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliRuntimeException.java b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliRuntimeException.java index 8297c4dd..06244590 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliRuntimeException.java +++ b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliRuntimeException.java @@ -19,7 +19,7 @@ package org.sakuli.exceptions; /** - * Wrapper for alle sakuli runtime exceptins + * Wrapper for all sakuli runtime exceptions * * @author Tobias Schneck */ diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java index 703adbac..9ce9fcc7 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BeanLoader.java @@ -18,10 +18,11 @@ package org.sakuli.loader; -import org.sakuli.actions.TestCaseAction; import org.sakuli.actions.environment.Application; import org.sakuli.actions.environment.Environment; import org.sakuli.actions.screenbased.Region; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; +import org.sakuli.actions.testcase.TestCaseAction; import org.sakuli.exceptions.SakuliInitException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,9 +55,14 @@ public static ScreenActionLoader loadScreenActionLoader() { return loadBean(ScreenActionLoader.class); } + //TODO move to package `sahi-setup` + public static JavaScriptTestCaseActionImpl loadJavaScriptTestCaseAction() { + logger.debug("load JavaSriptTestCaseAction object over BeanFactory."); + return new JavaScriptTestCaseActionImpl(); + } + public static TestCaseAction loadTestCaseAction() { - logger.debug("create new TestCaseAction object over BeanFactory."); - return getBeanFactory().getBean(TestCaseAction.class); + return loadJavaScriptTestCaseAction(); } public static Application loadApplication(String applicationNameOrPath, String resumeOnException) throws SakuliInitException { diff --git a/src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionTest.java b/src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionJavaScriptTest.java similarity index 97% rename from src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionTest.java rename to src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionJavaScriptTest.java index c81bdaf0..8905eae9 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/actions/TestCaseActionJavaScriptTest.java @@ -23,6 +23,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.sakuli.BaseTest; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; @@ -50,9 +51,9 @@ /** * @author tschneck Date: 25.07.13 */ -public class TestCaseActionTest extends BaseTest { +public class TestCaseActionJavaScriptTest extends BaseTest { @InjectMocks - private TestCaseAction testling; + private JavaScriptTestCaseActionImpl testling; @Mock private TestSuite testSuiteMock; @Mock @@ -229,7 +230,8 @@ public void testHandleException() throws Exception { public void testGetTestCaseFolderPath() throws Exception { String folderName = "test_case_folder"; Path folderpath = Paths.get(TEST_FOLDER_PATH + File.separator + folderName + File.separator + "tc.js"); - sample.setTcFile(folderpath); + //will be used in TestSuiteHelper like that + sample.setTcFolder(folderpath.getParent()); assertEquals(testling.getTestCaseFolderPath(), Paths.get(TEST_FOLDER_PATH + File.separator + folderName).toAbsolutePath().toString()); diff --git a/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java b/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java index 0d7eaa99..5f7db112 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/aop/LogActionExecutedAspectTest.java @@ -20,12 +20,12 @@ import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; -import org.sakuli.actions.TestCaseAction; import org.sakuli.actions.environment.Environment; import org.sakuli.actions.logging.LogToResult; import org.sakuli.actions.logging.LogToResultCallback; import org.sakuli.actions.logging.Logger; import org.sakuli.actions.screenbased.RegionTestImpl; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.actions.LogLevel; import org.sakuli.loader.BaseActionLoader; @@ -59,22 +59,22 @@ public void testAddActionLog(LogLevel logLevel) throws Exception { initMocks(); final String classContent = "Test-Action-Content"; - final String className = TestCaseAction.class.getSimpleName(); + final String className = JavaScriptTestCaseActionImpl.class.getSimpleName(); final String methodName = "actionMethod"; final String sampleMessage = "sample-message-for-log"; final String arg1 = "ARG1"; final String arg2 = "NULL"; - TestCaseAction testAction = mock(TestCaseAction.class); + JavaScriptTestCaseActionImpl testAction = mock(JavaScriptTestCaseActionImpl.class); when(testAction.toString()).thenReturn(classContent); JoinPoint jp = mock(JoinPoint.class); when(jp.getTarget()).thenReturn(testAction); Signature signature = mock(Signature.class); when(jp.getSignature()).thenReturn(signature); - when(signature.getDeclaringType()).thenReturn(TestCaseAction.class); + when(signature.getDeclaringType()).thenReturn(JavaScriptTestCaseActionImpl.class); when(signature.getName()).thenReturn(methodName); - when(signature.getDeclaringTypeName()).thenReturn(TestCaseAction.class.getName()); + when(signature.getDeclaringTypeName()).thenReturn(JavaScriptTestCaseActionImpl.class.getName()); when(jp.getArgs()).thenReturn(new Object[]{arg1, null}); @@ -162,12 +162,27 @@ public void testDoTestCaseActionLog() throws Exception { BaseActionLoader loader = mock(BaseActionLoader.class); TestCase sampleTc = new TestCase("test", "testID"); when(loader.getCurrentTestCase()).thenReturn(sampleTc); - TestCaseAction testAction = new TestCaseAction(); + JavaScriptTestCaseActionImpl testAction = new JavaScriptTestCaseActionImpl(); ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class); testAction.init("testID", 3, 4, "imagefolder1", "imagefolder2"); + assertLastLine(logFile, "AbstractTestCaseActionImpl", LogLevel.INFO, + "\"test case [" + sampleTc.getActionValueString() + "]\" AbstractTestCaseActionImpl.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]"); + } + + @Test + public void testDoJavaScriptTestCaseActionLog() throws Exception { + initMocks(); + BaseActionLoader loader = mock(BaseActionLoader.class); + TestCase sampleTc = new TestCase("test-js", "test-js-ID"); + sampleTc.setLastURL("last-url"); + when(loader.getCurrentTestCase()).thenReturn(sampleTc); + JavaScriptTestCaseActionImpl testAction = new JavaScriptTestCaseActionImpl(); + ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class); + assertEquals(testAction.getLastURL(), "last-url"); + assertLastLine(logFile, testAction.getClass().getSimpleName(), LogLevel.INFO, - "\"test case [" + sampleTc.getActionValueString() + "]\" TestCaseAction.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]"); + "\"test case [" + sampleTc.getActionValueString() + "]\" JavaScriptTestCaseActionImpl.getLastURL() - return 'lastURL'"); } @Test diff --git a/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java index 3356c685..0509cb31 100644 --- a/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java +++ b/src/sakuli-core/src/test/java/org/sakuli/exceptions/SakuliExceptionHandlerTest.java @@ -110,6 +110,26 @@ public void testHandleException() throws Exception { assertTrue(testling.isAlreadyProcessed(testSuite.getException())); } + @Test + public void testIsAlreadyProcessed() throws Exception { + setUp(); + when(loader.getCurrentTestCase()).thenReturn(null); + final Exception e1 = new Exception(testExcMessage); + testling.handleException(e1); + verify(testling).processException(e1); + assertTrue(testSuite.getException() instanceof SakuliException); + assertEquals(testSuite.getException().getMessage(), testExcMessage); + + //test Suppressed + assertTrue(testling.isAlreadyProcessed(e1)); + final Exception e2 = new Exception(e1); + assertTrue(testling.isAlreadyProcessed(e2)); + testling.handleException(e2); + verify(testling).processException(any()); + assertEquals(testSuite.getException().getMessage(), testExcMessage); + assertEquals(testSuite.getState(), TestSuiteState.ERRORS); + } + @Test public void testHandleActionException() throws Exception { setUp(); diff --git a/src/sakuli-java-dsl/src/test/java/org/sakuli/javaDSL/AbstractSakuliTest.java b/src/sakuli-java-dsl/src/test/java/org/sakuli/javaDSL/AbstractSakuliTest.java index 69b0f949..571e977e 100644 --- a/src/sakuli-java-dsl/src/test/java/org/sakuli/javaDSL/AbstractSakuliTest.java +++ b/src/sakuli-java-dsl/src/test/java/org/sakuli/javaDSL/AbstractSakuliTest.java @@ -22,7 +22,7 @@ import net.sf.sahi.test.ProcessHelper; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; -import org.sakuli.actions.TestCaseAction; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.TestSuite; import org.sakuli.datamodel.builder.TestCaseBuilder; import org.sakuli.exceptions.SakuliException; @@ -58,7 +58,7 @@ public abstract class AbstractSakuliTest { public static final String SAKULI_TEST = "sakuli-test"; protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSakuliTest.class); protected ExecutorService executorService; - protected TestCaseAction testCaseAction; + protected JavaScriptTestCaseActionImpl javaScriptTestCaseAction; protected Browser browser; private int counter; private DateTime startTime; @@ -134,7 +134,7 @@ public void initTC() throws Exception { initSahiBrowser(); testSuite.addTestCase(new TestCaseBuilder(testCaseName, initParameter.getTestCaseId()).build()); - testCaseAction = BeanLoader.loadTestCaseAction(); + javaScriptTestCaseAction = BeanLoader.loadJavaScriptTestCaseAction(); //add the the testcase folder as image folder if (Files.exists(getTestCaseFolder())) { @@ -159,7 +159,7 @@ private void initSahiBrowser() { */ protected void initTestCaseAction(TestCaseInitParameter initParameter) { List imagePaths = initParameter.getImagePaths(); - testCaseAction.initWithPaths(this.initParameter.getTestCaseId(), + javaScriptTestCaseAction.initWithPaths(this.initParameter.getTestCaseId(), this.initParameter.getWarningTime(), this.initParameter.getCriticalTime(), imagePaths.toArray(new Path[imagePaths.size()]) @@ -174,7 +174,7 @@ public void initTcStep() throws Exception { @AfterMethod(alwaysRun = true) public void saveTcStep() throws Throwable { - testCaseAction.addTestCaseStep("step " + counter, + javaScriptTestCaseAction.addTestCaseStep("step " + counter, String.valueOf(startTime.getMillis()), String.valueOf(DateTime.now().getMillis()), 0 @@ -188,7 +188,7 @@ public void stopTC() throws Exception { } String testCaseName = this.getClass().getSimpleName(); LOGGER.info("............................ SAVE RESULTS OF TEST-CASE '{}' - {}", initParameter.getTestCaseId(), testCaseName); - testCaseAction.saveResult(initParameter.getTestCaseId(), + javaScriptTestCaseAction.saveResult(initParameter.getTestCaseId(), String.valueOf(startTimeCase.getMillis()), String.valueOf(DateTime.now().getMillis()), null, diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java index ece63d0f..2ca7fe04 100644 --- a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/action/logging/SahiLogToResultCallbackTest.java @@ -21,12 +21,12 @@ import net.sf.sahi.report.Report; import net.sf.sahi.report.ResultType; import net.sf.sahi.report.TestResult; -import org.sakuli.actions.TestCaseAction; import org.sakuli.actions.environment.Environment; import org.sakuli.actions.logging.Logger; import org.sakuli.actions.screenbased.Region; import org.sakuli.actions.screenbased.RegionImpl; import org.sakuli.actions.screenbased.TypingUtil; +import org.sakuli.actions.testcase.JavaScriptTestCaseActionImpl; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.actions.LogLevel; import org.sakuli.exceptions.SakuliExceptionHandler; @@ -163,12 +163,12 @@ public void testDoTestCaseActionLog() throws Exception { BaseActionLoader loader = mock(BaseActionLoader.class); TestCase sampleTc = new TestCase("test", "testID"); when(loader.getCurrentTestCase()).thenReturn(sampleTc); - TestCaseAction testAction = new TestCaseAction(); + JavaScriptTestCaseActionImpl testAction = new JavaScriptTestCaseActionImpl(); ReflectionTestUtils.setField(testAction, "loader", loader, BaseActionLoader.class); testAction.init("testID", 3, 4, "imagefolder1", "imagefolder2"); verifySahiReportLogEntry(ResultType.INFO, - "\"test case [" + sampleTc.getActionValueString() + "]\" TestCaseAction.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]"); + "\"test case [" + sampleTc.getActionValueString() + "]\" AbstractTestCaseActionImpl.init() - init a new test case with arg(s) [testID, 3, 4, [imagefolder1, imagefolder2]]"); } private void verifySahiReport(ResultType resultTyp, int initialListSize) { diff --git a/src/sakuli-selenium-setup/.gitignore b/src/sakuli-selenium-setup/.gitignore new file mode 100644 index 00000000..9795432f --- /dev/null +++ b/src/sakuli-selenium-setup/.gitignore @@ -0,0 +1 @@ +test-output/ \ No newline at end of file diff --git a/src/sakuli-selenium-setup/pom.xml b/src/sakuli-selenium-setup/pom.xml new file mode 100644 index 00000000..eb030c2b --- /dev/null +++ b/src/sakuli-selenium-setup/pom.xml @@ -0,0 +1,226 @@ + + + + + 4.0.0 + + + org.sakuli + sakuli-root + 1.1.0-SNAPSHOT-247_sakuli_se + ../../pom.xml + + + sakuli-selenium-setup + 1.1.0-SNAPSHOT-247_sakuli_se + ${project.artifactId} + Specific Java-DSL for using Sakuli and Selenium directly over Java + + jar + + + ${test.group.unit},${test.group.sakuliDSL} + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + ${test.excluded.groups} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + ${maven-failsafe-plugin.skip} + + **/*.class + + ${test.included.groups} + ${test.excluded.groups} + + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + + true + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + + + + + + + + + upload-release + + + performRelease + true + + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + package + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + + + + + + ${project.groupId} + ocr-tessdata-extractor + ${project.version} + + + ${project.groupId} + sakuli-core + ${project.version} + + + ${project.groupId} + sakuli-common + ${project.version} + + + org.testng + testng + compile + true + + + ${project.groupId} + basic-test-util + ${project.version} + test-jar + test + + + diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/SakuliCommonConfigExtractor.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/SakuliCommonConfigExtractor.java new file mode 100644 index 00000000..890a0fe0 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/SakuliCommonConfigExtractor.java @@ -0,0 +1,85 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli; + +import org.apache.commons.io.FileUtils; +import org.sakuli.ocr.tessdata.JarReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.FileSystemException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * @author tschneck + * Date: 4/18/17 + */ +public class SakuliCommonConfigExtractor { + public static final String TESTDATA = "sakuli-default.properties"; + private static final Logger LOGGER = LoggerFactory.getLogger(SakuliCommonConfigExtractor.class); + + public static Path extract(Path outputDir) throws IOException { + return extract(outputDir, null); + } + + public static Path extract(Path outputDir, URL confResourceUrl) throws IOException { + if (confResourceUrl == null) { + //load config fils from classpath + confResourceUrl = SakuliCommonConfigExtractor.class.getResource("common/config"); + } + try { + if (confResourceUrl.getProtocol().equals("jar")) { + final Path targetDir = outputDir.resolve("org").resolve("sakuli").resolve("common").resolve("config"); + LOGGER.debug("Extract classpath resource '{}' to:{}", confResourceUrl.toString(), outputDir.toString()); + JarReader.read(confResourceUrl, (name, is) -> { + Path targetFile = outputDir.resolve("." + name).normalize(); + LOGGER.debug("write file: " + targetFile); + FileUtils.copyInputStreamToFile(is, targetFile.toFile()); + }); + checkTestFilePresent(targetDir); + return targetDir.normalize().toAbsolutePath(); + } else if (confResourceUrl.getProtocol().equals("file")) { + final Path libPath = Paths.get(confResourceUrl.toURI()); + LOGGER.debug("Use direct file path for OCR tessdata lib: {}", libPath); + checkTestFilePresent(libPath); + return libPath.normalize().toAbsolutePath(); + } + throw new FileSystemException("URL type '" + confResourceUrl.getProtocol() + + "' not supported: " + confResourceUrl.toString()); + } catch (URISyntaxException e) { + throw new FileNotFoundException("File URL is not valid: " + confResourceUrl.toString() + " - " + e.getMessage()); + } + } + + public static void checkTestFilePresent(Path output) throws FileNotFoundException { + //test the config content is available + Path testdata = output.resolve(TESTDATA); + if (Files.notExists(testdata)) { + throw new FileNotFoundException("Sakuli requires '" + testdata + "'. It is missing in folder: " + output); + } + LOGGER.debug("Sakuli default config extracted: {}", output.toString()); + } + +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/JavaTestResourceHelper.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/JavaTestResourceHelper.java new file mode 100644 index 00000000..d5b3e4d4 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/JavaTestResourceHelper.java @@ -0,0 +1,71 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium; + +import org.apache.commons.lang3.StringUtils; +import org.sakuli.exceptions.SakuliRuntimeException; +import org.sakuli.utils.ResourceHelper; + +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.Optional; + +public class JavaTestResourceHelper { + public JavaTestResourceHelper() { + } + + public static Path resolveImagePath(Class testClass, String imagePaths) { + if (StringUtils.isNotBlank(imagePaths)) { + try { + return ResourceHelper.getClasspathResource(testClass, imagePaths, + String.format("Image path '%s' for class '%s' not found!", imagePaths, testClass.getName())) + .toAbsolutePath(); + } catch (NoSuchFileException e) { + throw new SakuliRuntimeException(e); + } + } + return null; + } + + public static Optional getTestCaseFolder(Class realTestClass) { + try { + final Path classpathResource = ResourceHelper.getClasspathResource(realTestClass, ".", "no-message"); + return Optional.of(classpathResource); + } catch (NoSuchFileException e) { + return Optional.empty(); + } + } + + public static Path getTestSuiteRootFolder() { + Path resourcePath = resolveResource(JavaTestResourceHelper.class, "/"); + if (Files.exists(resourcePath)) { + return resourcePath.normalize().toAbsolutePath(); + } + throw new SakuliRuntimeException("Cannot load test suites root folder! Should be at normal test 'src/test/resources'"); + } + + public static Path resolveResource(Class aClass, String resourceName) { + try { + return ResourceHelper.getClasspathResource(aClass, resourceName, "cannot resolve resource '" + resourceName + "' from classpath!"); + } catch (NoSuchFileException e) { + throw new SakuliRuntimeException("cannot resolve resource '" + resourceName + "' from classpath!", e); + } + } +} \ No newline at end of file diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/SeTestCaseAction.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/SeTestCaseAction.java new file mode 100644 index 00000000..0ddc75fd --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/SeTestCaseAction.java @@ -0,0 +1,41 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.actions.testcase; + +import org.sakuli.actions.testcase.AbstractTestCaseActionImpl; +import org.sakuli.actions.testcase.TestCaseAction; +import org.sakuli.exceptions.SakuliException; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; + +/** + * Will be called from the testcases to execute {@link TestCaseAction} + * + * @author tschneck + * Date: 4/25/17 + */ +public class SeTestCaseAction extends AbstractTestCaseActionImpl implements TestCaseAction { + @Override + public void addImagePathsAsString(String... imagePaths) throws SakuliException { + this.addImagePaths(Arrays.stream(imagePaths).map(s -> Paths.get(s)).toArray(Path[]::new)); + } + +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/TestCaseInitParameter.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/TestCaseInitParameter.java new file mode 100644 index 00000000..3298dffb --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/actions/testcase/TestCaseInitParameter.java @@ -0,0 +1,131 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.actions.testcase; + +import org.sakuli.datamodel.TestCase; +import org.sakuli.exceptions.SakuliRuntimeException; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; + +/** + * @author Tobias Schneck + */ +public class TestCaseInitParameter { + + private String testCaseId; + private Path testCaseFolder; + private int warningTime; + private int criticalTime; + private List imagePaths; + private Date startDate; + + /** + * Configures the init parameters with testCaseId and the testCaseFolderName. Warning and critical time will be 0 + * per default. + * + * @param testCaseId identifier of a {@link TestCase} + */ + public TestCaseInitParameter(String testCaseId) { + this.testCaseId = testCaseId; + warningTime = 0; + criticalTime = 0; + startDate = new Date(); + imagePaths = new ArrayList<>(); + } + + public static Path checkFolder(Path path) { + if (Files.exists(path)) { + return path; + } + throw new SakuliRuntimeException(String.format("The required folder '%s' does not exist!", path.toAbsolutePath().toString())); + } + + public TestCaseInitParameter withWarningTime(int warningTime) { + this.warningTime = warningTime; + return this; + } + + public TestCaseInitParameter withCriticalTime(int criticalTime) { + this.criticalTime = criticalTime; + return this; + } + + public TestCaseInitParameter withStartDate(Date startDate) { + this.startDate = startDate; + return this; + } + + public TestCaseInitParameter withId(String id) { + this.testCaseId = id; + return this; + } + + public TestCaseInitParameter withTestCaseFolder(Path testCaseFolder) { + this.testCaseFolder = testCaseFolder; + addImagePath(testCaseFolder); + return this; + } + + public TestCaseInitParameter addImagePath(Path... imagePaths) { + if (imagePaths != null) { + Arrays.stream(imagePaths) + .filter(Objects::nonNull) + .forEach(p -> this.imagePaths.add(checkFolder(p))); + } + return this; + } + + public String getTestCaseId() { + return testCaseId; + } + + public Path getTestCaseFolder() { + return testCaseFolder; + } + + public int getWarningTime() { + return warningTime; + } + + public int getCriticalTime() { + return criticalTime; + } + + public Date getStartDate() { + return startDate; + } + + public List getImagePaths() { + return imagePaths; + } + + @Override + public String toString() { + return "TestCaseInitParameter{" + + "testCaseId='" + testCaseId + '\'' + + ", warningTime=" + warningTime + + ", criticalTime=" + criticalTime + + ", startDate=" + startDate + + ", testCaseFolder" + testCaseFolder + + ", imagePaths=" + imagePaths + + '}'; + } +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java new file mode 100644 index 00000000..c556ffff --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java @@ -0,0 +1,305 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.sakuli.datamodel.TestCase; +import org.sakuli.datamodel.TestSuite; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.exceptions.SakuliRuntimeException; +import org.sakuli.loader.BaseActionLoader; +import org.sakuli.loader.BeanLoader; +import org.sakuli.selenium.JavaTestResourceHelper; +import org.sakuli.selenium.actions.testcase.TestCaseInitParameter; +import org.sakuli.selenium.testng.utils.SakuliSePropertyPlaceholderConfigurer; +import org.sakuli.services.InitializingServiceHelper; +import org.sakuli.services.TeardownServiceHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.*; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +/** + * TODO TS cleanup and docu + * + * @author tschneck + * Date: 4/13/17 + */ +public class SakuliSeTest implements ITestListener, IInvokedMethodListener2 { + private static final Logger LOGGER = LoggerFactory.getLogger(SakuliSeTest.class); + + protected static String extractTestCaseId(ITestResult testResult) { + return testResult.getInstanceName() + '#' + testResult.getMethod().getMethodName(); + } + + protected static boolean isMethodSakuliTestMethod(IInvokedMethod method) { + return method.isTestMethod() && getSakuliTestCaseAnnotation(method).isPresent(); + } + + protected static Optional getSakuliTestCaseAnnotation(IInvokedMethod method) { + return Stream.of(getMethodAnnotations(method)) + .filter(a -> a instanceof SakuliTestCase) + .map(sa -> (SakuliTestCase) sa) + .findFirst(); + } + + protected static Annotation[] getMethodAnnotations(IInvokedMethod method) { + if (method.getTestMethod() != null && + method.getTestMethod().getConstructorOrMethod() != null && + method.getTestMethod().getConstructorOrMethod().getMethod() != null) { + return method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotations(); + } + return new Annotation[]{}; + } + + @Override + public void onTestStart(ITestResult result) { + + } + + @Override + public void onTestSuccess(ITestResult result) { + + } + + @Override + public void onTestFailure(ITestResult result) { + if (result.getThrowable() != null) { + SakuliExceptionHandler exceptionHandler = BeanLoader.loadBaseActionLoader().getExceptionHandler(); + exceptionHandler.handleException(result.getThrowable(), true); + } + } + + @Override + public void onTestSkipped(ITestResult result) { + + } + + @Override + public void onTestFailedButWithinSuccessPercentage(ITestResult result) { + + } + + @Override + public void onStart(ITestContext context) { + initTestSuite(context); + } + + @Override + public void onFinish(ITestContext context) { + tearDownSuite(context); + } + + /** + * Initialize the Spring context of the Sakuli test suite and invokes all configured Initializing Services. + * + * @param context + */ + protected void initTestSuite(ITestContext context) { + LOGGER.info("............................INITIALIZE SAKULI-CONTEXT"); + BeanLoader.CONTEXT_PATH = "sakuli-se-beanRefFactory.xml"; + SakuliSePropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = JavaTestResourceHelper.getTestSuiteRootFolder().toString(); + SakuliSePropertyPlaceholderConfigurer.setSakuliProperty(SakuliProperties.LOG_FOLDER, getTestSuiteOutputFolder(context).toString()); + SakuliSePropertyPlaceholderConfigurer.setTestSuiteProperty(TestSuiteProperties.SUITE_ID, context.getSuite().getName()); + try { + InitializingServiceHelper.invokeInitializingServcies(); + } catch (FileNotFoundException e) { + throw new SakuliRuntimeException(e); + } + } + + @Override + public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) { + if (isMethodSakuliTestMethod(method)) { + TestCaseInitParameter initParameter = new TestCaseInitParameter(resolveTestCaseId(method, testResult)); + + //add the the testcase folder to the Builder and add the image folder + JavaTestResourceHelper.getTestCaseFolder(testResult.getMethod().getRealClass()) + .filter(Files::exists) + .ifPresent(initParameter::withTestCaseFolder); + + getSakuliTestCaseAnnotation(method).ifPresent(sa -> initParameter + .withWarningTime(sa.warningTime()) + .withCriticalTime(sa.criticalTime()) + //adds additional image paths + .addImagePath( + JavaTestResourceHelper.resolveImagePath(testResult.getMethod().getRealClass(), sa.additionalImagePaths()) + ) + ); + + if (testResult.getStartMillis() > 0) { + initParameter.withStartDate(new Date(testResult.getStartMillis())); + } + initTestCaseAction(initParameter); + } + } + + @Override + public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) { + if (isMethodSakuliTestMethod(method)) { + String testCaseId = resolveTestCaseId(method, testResult); + + LOGGER.info("............................ SAVE RESULTS OF TEST-CASE '{}'", testCaseId); + final BaseActionLoader loader = BeanLoader.loadBaseActionLoader(); + if (loader.getCurrentTestCase() == null) { + loader.getExceptionHandler().handleException("Can't load current testcase: Id ?:" + testCaseId, false); + } + if (!loader.getCurrentTestCase().getId().equals(testCaseId)) { + loader.getExceptionHandler().handleException( + "testcaseID '" + testCaseId + "' to save the test case Result ist is not matching with: " + loader.getCurrentTestCase().getId(), false); + } + //set TestCase vars + TestCase tc = loader.getCurrentTestCase(); + tc.setStopDate(new Date()); // use enddate of TestNG? + LOGGER.debug("test case duration = " + tc.getDuration()); + tc.refreshState(); + //release current test case -> indicates that this case is finished + loader.setCurrentTestCase(null); + } + } + + protected String resolveTestCaseId(IInvokedMethod method, ITestResult testResult) { + return getSakuliTestCaseAnnotation(method) + .map(SakuliTestCase::testCaseName) + .filter(StringUtils::isNoneBlank) + .orElse(extractTestCaseId(testResult)); + } + +// private String resolveImagePath(Class testClass, String imagePaths) { +// return javaTestResourceHelper.resolveImagePath(testClass, imagePaths); +// } +// +// private Optional getTestCaseFolder(Class realTestClass) { +// return javaTestResourceHelper.getTestCaseFolder(realTestClass); +// } + + /** + * Initialize the image folders, warning time and critical time for the current testcase with the assigned + * initParameter. + * + * @param initParameter a initialized object of {@link TestCaseInitParameter}. + */ + protected void initTestCaseAction(TestCaseInitParameter initParameter) { + BeanLoader.loadBaseActionLoader().getTestSuite() + .addTestCase(new TestCase(initParameter.getTestCaseId(), initParameter.getTestCaseId())); + List imagePaths = initParameter.getImagePaths(); + BeanLoader.loadTestCaseAction().initWithPaths(initParameter.getTestCaseId(), + initParameter.getWarningTime(), + initParameter.getCriticalTime(), + imagePaths.toArray(new Path[imagePaths.size()]) + ); + BeanLoader.loadBaseActionLoader().getCurrentTestCase().setStartDate(initParameter.getStartDate()); + BeanLoader.loadBaseActionLoader().getCurrentTestCase().setTcFolder(initParameter.getTestCaseFolder()); + } + + +// @BeforeMethod(alwaysRun = true) +// public void initTcStep() throws Exception { +// counter++; +// startTime = DateTime.now(); +// } +/* + @AfterMethod(alwaysRun = true) + public void saveTcStep() throws Throwable { + testCaseAction.addTestCaseStep("step " + counter, + String.valueOf(startTime.getMillis()), + String.valueOf(DateTime.now().getMillis()), + 0 + ); + }*/ +/* + @AfterClass(alwaysRun = true) + public void stopTC() throws Exception { + if (executorService != null) { + executorService.awaitTermination(1, TimeUnit.MILLISECONDS); + } + String testCaseName = this.getClass().getSimpleName(); + LOGGER.info("............................ SAVE RESULTS OF TEST-CASE '{}' - {}", initParameter.getTestCaseId(), testCaseName); + testCaseAction.saveResult(initParameter.getTestCaseId(), + String.valueOf(startTimeCase.getMillis()), + String.valueOf(DateTime.now().getMillis()), + null, + null + ); + if (browser != null) { + browser.close(); + } + }*/ +// +// protected String getTestSuiteRootFolder() { +// return javaTestResourceHelper.getTestSuiteRootFolder(); +// } + + /** + * @param context + * @return the matching resource folder of the package of the current class! + */ + protected Path getTestSuiteOutputFolder(ITestContext context) { + Path outputFolder = Paths.get(context.getOutputDirectory()).resolve("sakuli_result").normalize().toAbsolutePath(); + if (!Files.exists(outputFolder)) { + try { + FileUtils.forceMkdir(outputFolder.toFile()); + } catch (IOException e) { + throw new SakuliRuntimeException(String.format("Cannot create folder '%s'", outputFolder.toString()), e); + } + } + return outputFolder; + + } + + protected void tearDownSuite(ITestContext context) { + TestSuite testSuite = BeanLoader.loadBaseActionLoader().getTestSuite(); + if (testSuite != null) { + LOGGER.info("========== TEAR-DOWN SAKULI TEST SUITE '{}' ==========", testSuite.getId()); + testSuite.setStopDate(context.getEndDate() == null ? DateTime.now().toDate() : context.getEndDate()); + TeardownServiceHelper.invokeTeardownServices(); + } + } + + + @Override + public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { + + } + + @Override + public void afterInvocation(IInvokedMethod method, ITestResult testResult) { + + } + + /* protected Path getTestCaseFolder() { + return Paths.get(getTestSuiteOutputFolder() + File.separator + initParameter.getTestCaseFolderName()); + }*/ + + +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliTestCase.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliTestCase.java new file mode 100644 index 00000000..b1378051 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliTestCase.java @@ -0,0 +1,45 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.METHOD; + +/** + * Tells the {@link SakuliSeTest}-Listener to respect this method in the Sakuli-Test-Context + * + * @author tschneck + * Date: 4/13/17 + */ +@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) +@Target({METHOD}) +@Inherited +public @interface SakuliTestCase { + + String testCaseName() default ""; + + int warningTime() default 0; + + int criticalTime() default 0; + + String additionalImagePaths() default ""; +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/aop/TestNGActionCallback.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/aop/TestNGActionCallback.java new file mode 100644 index 00000000..71752992 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/aop/TestNGActionCallback.java @@ -0,0 +1,59 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng.aop; + +import org.sakuli.datamodel.TestCase; +import org.sakuli.exceptions.SakuliException; +import org.sakuli.exceptions.SakuliExceptionHandler; +import org.sakuli.loader.ActionLoaderCallback; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Call for some Java based action handling. + * + * @author tschneck Date: 17.10.13 + */ +@Component +public class TestNGActionCallback implements ActionLoaderCallback { + @Autowired + private SakuliExceptionHandler exceptionHandler; + + @Override + public void initTestCase(TestCase testCase) { + + } + + /** + * Throw the handled Exception as {@link AssertionError} after {@link SakuliExceptionHandler#processException(Throwable)} to stop the current + * test case execution of an JAVA test. + */ + @Override + public void handleException(SakuliException transformedException) { + if (transformedException == null || exceptionHandler.resumeToTestExcecution(transformedException)) { + return; + } + throw new AssertionError(transformedException); + } + + @Override + public void releaseContext() { + + } +} diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java new file mode 100644 index 00000000..127dc8c9 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java @@ -0,0 +1,108 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng.utils; + +import org.apache.commons.io.FileUtils; +import org.sakuli.SakuliCommonConfigExtractor; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.ocr.tessdata.OcrTessdataLibExtractor; +import org.sakuli.utils.ResourceHelper; +import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.Properties; + +import static org.sakuli.datamodel.properties.SakuliProperties.SAKULI_PROPERTIES_FILE_NAME; +import static org.sakuli.datamodel.properties.TestSuiteProperties.TEST_SUITE_PROPERTIES_FILE_NAME; + +/** + * @author Tobias Schneck + */ +public class SakuliSePropertyPlaceholderConfigurer extends SakuliPropertyPlaceholderConfigurer { + public static final String SAKULI_TEMPFOLDER_NAME = ".sakuli"; + private static Logger LOGGER = LoggerFactory.getLogger(SakuliSePropertyPlaceholderConfigurer.class); + private static Properties testsuiteJavaProps = new Properties(); + private static Properties sakuliJavaProps = new Properties(); + + public static void setTestSuiteProperty(String key, String value) { + testsuiteJavaProps.setProperty(key, value); + } + + public static void setSakuliProperty(String key, String value) { + sakuliJavaProps.setProperty(key, value); + } + + @Override + protected void loadProperties(Properties props) throws IOException { + SAKULI_HOME_FOLDER_VALUE = extractSakuliDefaultConfigFiles().toString(); + SakuliProperties.DEFAULT_TESSDATA_LIB_FOLDER = extractOcrLibFiles().toString(); + super.loadProperties(props); + } + + protected Path extractSakuliDefaultConfigFiles() throws IOException { + return SakuliCommonConfigExtractor.extract(getSakuliTempRoot()).getParent(); + } + + protected Path extractOcrLibFiles() throws IOException { + return OcrTessdataLibExtractor.extract(getSakuliTempRoot()); + } + + public Path getSakuliTempRoot() throws IOException { + final Path tmpRoot = FileUtils.getTempDirectory().toPath().resolve(SAKULI_TEMPFOLDER_NAME); + if (!Files.exists(tmpRoot)) { + FileUtils.forceMkdir(tmpRoot.toFile()); + } + return tmpRoot; + } + + @Override + protected void loadSakuliDefaultProperties(Properties props) { + super.loadSakuliDefaultProperties(props); + props.put(TestSuiteProperties.LOAD_TEST_CASES_AUTOMATIC_PROPERTY, "false"); + } + + @Override + protected void loadSakuliProperties(Properties props) { + try { + final Path sakuliProperties = ResourceHelper.getClasspathResource(this.getClass(), "/" + SAKULI_PROPERTIES_FILE_NAME, ""); + addPropertiesFromFile(props, sakuliProperties.toAbsolutePath().toString(), isLoadSakuliProperties()); + } catch (NoSuchFileException e) { + LOGGER.info("'" + SAKULI_PROPERTIES_FILE_NAME + "' file not present ... skip loading"); + } + props.putAll(sakuliJavaProps); + } + + @Override + protected void loadTestSuiteProperties(Properties props) { + try { + final Path testsuiteProperties = ResourceHelper.getClasspathResource(this.getClass(), "/" + TEST_SUITE_PROPERTIES_FILE_NAME, ""); + addPropertiesFromFile(props, testsuiteProperties.toAbsolutePath().toString(), isLoadTestSuiteProperties()); + } catch (NoSuchFileException e) { + LOGGER.info("'" + TEST_SUITE_PROPERTIES_FILE_NAME + "' file not present ... skip loading"); + } + props.putAll(testsuiteJavaProps); + } + +} diff --git a/src/sakuli-selenium-setup/src/main/resources/sakuli-se-applicationContext.xml b/src/sakuli-selenium-setup/src/main/resources/sakuli-se-applicationContext.xml new file mode 100644 index 00000000..8d3faf3a --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/resources/sakuli-se-applicationContext.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/src/sakuli-selenium-setup/src/main/resources/sakuli-se-beanRefFactory.xml b/src/sakuli-selenium-setup/src/main/resources/sakuli-se-beanRefFactory.xml new file mode 100644 index 00000000..34225a93 --- /dev/null +++ b/src/sakuli-selenium-setup/src/main/resources/sakuli-se-beanRefFactory.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/src/sakuli-selenium-setup/src/test/java/org/sakuli/SakuliCommonConfigExtractorTest.java b/src/sakuli-selenium-setup/src/test/java/org/sakuli/SakuliCommonConfigExtractorTest.java new file mode 100644 index 00000000..e51ef9b9 --- /dev/null +++ b/src/sakuli-selenium-setup/src/test/java/org/sakuli/SakuliCommonConfigExtractorTest.java @@ -0,0 +1,54 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli; + +import org.sakuli.datamodel.properties.TestSuiteProperties; +import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.testng.annotations.Test; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Properties; + +import static org.testng.Assert.*; + +/** + * @author tschneck + * Date: 4/24/17 + */ +public class SakuliCommonConfigExtractorTest { + @Test + public void testExtract() throws Exception { + Path tempDirectory = Files.createTempDirectory(Paths.get("target"), "sakuli-conf-tmp"); + Path output = SakuliCommonConfigExtractor.extract(tempDirectory); + + assertTrue(Files.exists(output)); + assertTrue(Files.isDirectory(output)); + final Path sakuliDefaultProp = output.resolve("sakuli-default.properties"); + assertTrue(Files.exists(sakuliDefaultProp)); + assertFalse(Files.isDirectory(sakuliDefaultProp)); + Properties props = new Properties(); + new SakuliPropertyPlaceholderConfigurer().addPropertiesFromFile(props, sakuliDefaultProp.toString(), true); + assertTrue(props.size() > 0); + assertEquals(props.getProperty(TestSuiteProperties.WARNING_TIME), "0"); + + } + +} \ No newline at end of file diff --git a/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java new file mode 100644 index 00000000..1bf9b5a3 --- /dev/null +++ b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java @@ -0,0 +1,47 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng; + +//import org.sakuli.selenium.testng.SakuliTestCase; + +import org.sakuli.loader.BeanLoader; +import org.testng.Assert; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +import java.nio.file.Paths; + +//import org.testng.annotations.Listeners; +//import org.sakuli.selenium.testng.SakuliSeTest; + +/** + * @author Tobias Schneck + */ +@Listeners(SakuliSeTest.class) +public class SakuliSeTestUnitTest { + + @Test + @SakuliTestCase + public void testFolder() throws Exception { + Assert.assertEquals(BeanLoader.loadTestCaseAction().getTestCaseFolderPath(), + Paths.get(getClass().getResource(".").toURI()).normalize().toAbsolutePath().toString()); + Assert.assertEquals(BeanLoader.loadTestCaseAction().getTestSuiteFolderPath(), + Paths.get(getClass().getResource("/").toURI()).normalize().toAbsolutePath().toString()); + } +} diff --git a/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurerTest.java b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurerTest.java new file mode 100644 index 00000000..8903b6cb --- /dev/null +++ b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurerTest.java @@ -0,0 +1,79 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2017 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng.utils; + +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.sakuli.SakuliCommonConfigExtractor; +import org.sakuli.datamodel.properties.SakuliProperties; +import org.sakuli.ocr.tessdata.OcrTessdataLibExtractor; +import org.sakuli.utils.SakuliPropertyPlaceholderConfigurer; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Properties; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; +import static org.testng.Assert.*; + +/** + * @author tschneck + * Date: 4/25/17 + */ +public class SakuliSePropertyPlaceholderConfigurerTest { + + @Spy + private SakuliSePropertyPlaceholderConfigurer testling; + private Path tmpFolder; + + @BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + tmpFolder = Files.createTempDirectory(Paths.get("target"), ".sakuli-tmp"); + when(testling.getSakuliTempRoot()).thenReturn(tmpFolder); + doNothing().when(testling).loadSakuliDefaultProperties(any()); + doNothing().when(testling).loadSakuliProperties(any()); + doNothing().when(testling).loadTestSuiteProperties(any()); + } + + @Test + public void testExtractSakuliDefaultConfigFiles() throws Exception { + final Path target = testling.extractSakuliDefaultConfigFiles(); + assertNotNull(target); + assertTrue(Files.exists(target)); + SakuliCommonConfigExtractor.checkTestFilePresent(target.resolve("config")); + testling.loadProperties(mock(Properties.class)); + assertEquals(SakuliPropertyPlaceholderConfigurer.SAKULI_HOME_FOLDER_VALUE, target.toString()); + } + + @Test + public void testExtractSakuliOcrLibFiles() throws Exception { + final Path target = testling.extractOcrLibFiles(); + assertNotNull(target); + assertTrue(Files.exists(target)); + OcrTessdataLibExtractor.checkTessdataLibFolderContent(target); + testling.loadProperties(mock(Properties.class)); + assertEquals(SakuliProperties.DEFAULT_TESSDATA_LIB_FOLDER, target.toString()); + } + +} \ No newline at end of file diff --git a/src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties b/src/sakuli-selenium-setup/src/test/resources/sakuli.properties similarity index 99% rename from src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties rename to src/sakuli-selenium-setup/src/test/resources/sakuli.properties index b41caf8a..ab456940 100644 --- a/src/sakuli-selenium-java-dsl/src/test/resources/org/sakuli/sakuli.properties +++ b/src/sakuli-selenium-setup/src/test/resources/sakuli.properties @@ -15,7 +15,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - ####################################################################################### # OVERWRITE-PROPERTIES # From 615ce8d9b518ee83bd2ea21e8594921f95e64163 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 26 Apr 2017 02:24:11 +0200 Subject: [PATCH 14/21] #247 disable screen dependent test, so they can run on the CI --- .../sakuli/selenium/testng/SakuliSeTest.java | 2 +- .../SakuliSePropertyPlaceholderConfigurer.java | 1 + .../selenium/testng/SakuliSeTestUnitTest.java | 17 ++++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java index c556ffff..7063c6af 100644 --- a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/SakuliSeTest.java @@ -127,7 +127,7 @@ public void onFinish(ITestContext context) { */ protected void initTestSuite(ITestContext context) { LOGGER.info("............................INITIALIZE SAKULI-CONTEXT"); - BeanLoader.CONTEXT_PATH = "sakuli-se-beanRefFactory.xml"; + BeanLoader.CONTEXT_PATH = SakuliSePropertyPlaceholderConfigurer.SE_CONTEXT_PATH; SakuliSePropertyPlaceholderConfigurer.TEST_SUITE_FOLDER_VALUE = JavaTestResourceHelper.getTestSuiteRootFolder().toString(); SakuliSePropertyPlaceholderConfigurer.setSakuliProperty(SakuliProperties.LOG_FOLDER, getTestSuiteOutputFolder(context).toString()); SakuliSePropertyPlaceholderConfigurer.setTestSuiteProperty(TestSuiteProperties.SUITE_ID, context.getSuite().getName()); diff --git a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java index 127dc8c9..9864d455 100644 --- a/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java +++ b/src/sakuli-selenium-setup/src/main/java/org/sakuli/selenium/testng/utils/SakuliSePropertyPlaceholderConfigurer.java @@ -42,6 +42,7 @@ */ public class SakuliSePropertyPlaceholderConfigurer extends SakuliPropertyPlaceholderConfigurer { public static final String SAKULI_TEMPFOLDER_NAME = ".sakuli"; + public static String SE_CONTEXT_PATH = "sakuli-se-beanRefFactory.xml"; private static Logger LOGGER = LoggerFactory.getLogger(SakuliSePropertyPlaceholderConfigurer.class); private static Properties testsuiteJavaProps = new Properties(); private static Properties sakuliJavaProps = new Properties(); diff --git a/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java index 1bf9b5a3..2c16df11 100644 --- a/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java +++ b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/SakuliSeTestUnitTest.java @@ -18,26 +18,29 @@ package org.sakuli.selenium.testng; -//import org.sakuli.selenium.testng.SakuliTestCase; import org.sakuli.loader.BeanLoader; import org.testng.Assert; -import org.testng.annotations.Listeners; +import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import java.nio.file.Paths; -//import org.testng.annotations.Listeners; -//import org.sakuli.selenium.testng.SakuliSeTest; /** * @author Tobias Schneck */ -@Listeners(SakuliSeTest.class) +//@Listeners(SakuliSeTest.class) public class SakuliSeTestUnitTest { - @Test - @SakuliTestCase + @BeforeSuite + public void setUp() throws Exception { +// SakuliSePropertyPlaceholderConfigurer.SE_CONTEXT_PATH = AbstractBaseTest.TEST_CONTEXT_PATH; + } + + //TODO TS make screen unindepedent + @Test(enabled = false) +// @SakuliTestCase public void testFolder() throws Exception { Assert.assertEquals(BeanLoader.loadTestCaseAction().getTestCaseFolderPath(), Paths.get(getClass().getResource(".").toURI()).normalize().toAbsolutePath().toString()); From a7f5214b1ceaf14ce22addc3ecbd3cd022dedd2a Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Thu, 4 May 2017 09:47:27 +0200 Subject: [PATCH 15/21] add protoype of example test --- .../selenium/testng/example/Example2Test.java | 45 ++++++++++++++++++ .../sakuli/selenium/testng/example/first.png | Bin 0 -> 7486 bytes .../selenium/testng/example/test_pics/625.png | Bin 0 -> 7486 bytes 3 files changed, 45 insertions(+) create mode 100644 src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/example/Example2Test.java create mode 100644 src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/first.png create mode 100644 src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/test_pics/625.png diff --git a/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/example/Example2Test.java b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/example/Example2Test.java new file mode 100644 index 00000000..43ef98b1 --- /dev/null +++ b/src/sakuli-selenium-setup/src/test/java/org/sakuli/selenium/testng/example/Example2Test.java @@ -0,0 +1,45 @@ +/* + * Sakuli - Testing and Monitoring-Tool for Websites and common UIs. + * + * Copyright 2013 - 2015 the original author or authors. + * + * 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. + */ + +package org.sakuli.selenium.testng.example; + +import org.sakuli.actions.screenbased.Region; +import org.sakuli.selenium.testng.SakuliSeTest; +import org.sakuli.selenium.testng.SakuliTestCase; +import org.testng.Assert; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +/** + * TODO: make cleaner + * + * @author Tobias Schneck + */ +//@Listeners(SakuliSeTest.class) +//@Test(suiteName = "mysakulisuiteXXXX", enabled = false) +public class Example2Test { + + @Test(enabled = false) + @SakuliTestCase(testCaseName = "test-example", additionalImagePaths = "test_pics", warningTime = 2) + public void test1() throws Exception { + new Region().find("first"); + new Region().find("625"); + //TODO testcasestep + Assert.assertTrue(false); + } +} diff --git a/src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/first.png b/src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/first.png new file mode 100644 index 0000000000000000000000000000000000000000..ec1136503a8319e11cf457bc3c1b944e77530e9f GIT binary patch literal 7486 zcmZX2byO7I*7hI_DJ|V4&5)8qcb9Za3c>&b4BcHK-Q5yW5<{1C3{nCENGeE5Nxc5< z`+oP{wZ5~~IcJ}}pJ&(k=d2T}t*L~IO^FQv0B}{5<#qq=mVc)JCi>s?%x_@<0Kl$s zl9SU`k&~m>_HeUzaOo090uFS)$3)%=2u&{F zldiiMOJmeX6CXTdvPzoX1DJ)fo&rPZpUa1%HDW?$Z#_c@xPXyX+-&IOR#eMaHGPs0 zfMCerCffmkwci**Xa*GSqd6r|?&F1Fjr3vgqR0@?mdFY!lgx)*GU$Cl_Xt~Kuw)~T ziy$hpWuw`av#BC5!B3a9({+#f$$OqMvW`gQ_l92_p5w_4^78JH8>$0dq7U|S^?w|28PT_<eu{j3J22d9#JJ~Ohv6@S)s7Jce)DttD0qlLyV6K^GV%EU}`6X6ws zEla#5xb<>N)H;k!X@RwqU@*pP+hf~cTgHa$Ow2t?MCJo4#fLTJxia;66J3_-NNDI~ z%w>}L%b)M_#|Uj{eQ`TJ1VjYHN+>_7>l9^a!`W3{@Y&&%7tCvPX!$CY>*7`wEXcp5 z^}=aQ@k_dkxKoLG`G#Te!`Ar6jOq-h%ntSolMJ?6&_tR!vnjnPgTMM!=Mkr9NnU8) zXKGW|bhFkqtPYe8ci$X%Yd}^&(!Krd%iD=_CTtiG6=(^pmrWT!iS)#l6O5=(yQpw? z{ON?@MCLdMrCxtOUE(mWb{Ksac*&;#R1hCF8n%o38dv#(MK$I_D3KbwsZ;H|PI;HA zWtvc0_IUMpZklPD8%MBycI9^UhZ^0I`5F(U-FObUuZBWuUR`gaf4mV&$cZ(HSk-Oq zeoMAsF;zO_nLnCs$bWJG$N16M8S7Vehy5G%$I`;6kf6}L5E^Bd(6keLUVr{_VRC_M zNuo})MgifmwC$AcoImH+uWidqv67%V;yaSn*6AJ6X5`=NU3e9dRIHgWEtYSPKibJ` z&bltR?y*k0&Iji1Cg_&!w(rKclMiHlc>Z91*L_Ea`y6-s`725&c>;M2dDC;8=ef9a z6gr6#2^r*HDc4_(P>54FP@M4fSU<~M&b7_b&ovW{)SyxKt?*a>Gu3E6Z6DBV(v0F6 zCyJ0j!dC)jWyctoZSobOhn>~H6Y>+s8QmGkx}&OwLMtJa zQ<|B1pQbIQYxA|lg1y}#W1gZv&NFK}oHLwLe|`xVysf^#pQiIbxWDN-_DO9QSW8_G z_Q-@e`Zt2#f(!h9_<4YTN)!qtW@k^zO)gm&SjaZKYDnJT+2HK%3M8NlE+i_Hv;-o_ zksL_YAhDpspsAoYk5`YJ_g$!sC^9JDP|=Mjx$tUJgh&s_+xbre2w2!SsyGgu8dVy3 z+d0wju%53Fp0nvorO~Ytq7N8Zix1F7Q$>NWo`jx}5z^|=oN>*IHSsnH$C0**)Uf}M zYcafBJc#B~LFxJf@VBwiqbVdcl(3@s0J4xIseaJ+fQ zHJh|JG&{RyAzMw6nPk=6;}+1jpN?#@*zldUN|rM5gPe@{gSD9c{yR z{5&Q)N~>L~?W$)GYxCptiu3F9K4r=FFk5|F__psw4a|)nmH*lp#z5aeU2SW&w-viHIQQ5=7NN%d#&ddA=Iw0|2#e?Le~p?+ox;vDvJNMDXgiO zhCzIFf?}6t_r!;1!?$Cg-Ui7t&vVA3Vh6F?ckN#P<{ex&Ue&30{CeG_)S|h1?>p_U zf?R*_b=whQ*|76uLJMB_>-ZXpv~boobqDy+KlL?-f5Pw&_P*=*q*+(r^2-$5YcWr- z0_mCi^y!mIx0AEL8kZ|AI1PF*VqG|x&%MX}$28qUEjff~n+X)8^0@nJuBa3|nwQi{ zy(DFUP;};WieAn9oa|)_RTd)_`=fxHi-Cv?ucz9vkgUYfYCfk>PK4CjX#vd@|DeS(Tc(5t&}R7 zn)pAAwtD6JB0v4e$NON zaHUCd?i@LaD3TUSz$h-xoKwM3Y*UN&it%fqCaG~_V?I^FLsY1z@2osLO5S*!o6?9K zp#nOkCSe!VR=V2p-IN6F!Iu`}z$c0)z?By;f4iYf763rWb<#J28fmDDy>WZTV{PkZ zW5)w~2l@M|1pp*qVt>VVc2H}2*gF?jPcayn@m~nBzw$q75F`D+AW&y8qmhO-y_}ne z9la2bAP+C2BsM)gy@ZFYy_l}N;{VbAp1_QbP$)zU1oH9m;qejRar1Bh@rjCxf_V8s z{QTU15!{}>u25?jx2q@9|2p}9e&p>u-*`AdpiXYC^#Ay^wsG@|8zn#*h>hlK2<=|1`RHRJw7BrdTCn8c-CXbNjB5JbjTSf*cl8d)iQaizPPkSVM3p`u|`C zyW5DjHj6m%ZX&W)quMdl`@ADQ4e=1v4)LIvNKYhOWzQ*>vQ|F@3b^fc`?_twQLsL% z@Hjv}2lrk-T=zctA6PtYIDc=Suru4A(B=tyK18;QUqp9~Q8f5uO7duX4{|^JXPvvb z>l!ir8r!VWf$Vi|3RFqB)D{}wQ7)f6Pj*9jOzxoBwad=qKHb%0`7E%4jqy|Sr3!6< zOJfs^%#pt=hoErAosV~FQdY(Sy{Y0Q)9R*QQ63W>^z-K}g9&cIR>3}g$J4i-RCS;D zP%G^17zYJOR-9CnV-gkGb29^HvDF;JS53an2K}U*^xkG^&T^4v9A-OADWJg^{DP?{ zx1%XT^G$(6Q1FEucu8dmg7vO^nuekfE4SN~>k$OwM^9#?Q_&KD#$@>vMc6+&FN29%l%SU{!S>K#L}R?GHIq6{t5wwOt1z+Y|Ega;HTe3 zG+UdFuO9ab>6Gw}2lW1Y{=OOd^8gDcmGGK|cQ1YOTkva?HXk3iAYd!a91#I>)X!xh zWF@(7I2EU9c1bthobG7&Hz9jcL`c<}N$z3A0Hq^jxfXx_&i$JL_-w z!3ni*+{dMfMQW@A%huXcU?2V70^M$Y(74$w%^7G!IXr%DI1_oao7is&4i%aSrt!^7 zG@0BHdn}wKeY<`Mgl~0G_V)Sba*mzy(ZWy^JM7_aPt6N53w9nn%S7@ce)cx9as~T| zQ3oa-&~)mJelJXhy>$Fe6~DjL4~OL;dnx`jB*Z!0y2ZCaVSkL_Z4YSu6>rYYscDr2 zkBhgUFW(&hh+J?Rto(-8XM-6K;`@FbXB_rmgY=cB+%JXLSNZGvcH}9KX%bouOEf84$!j^5tfgVwYt1 zTu0+;5{+Y`txklLS&lCIU84oH7$lVbLrPXTe8R&%%W)%aWFnsC-<^X1*&_6 zI=Rw=R5kku`6JhlLu)lJpSZnzshux<lM>ym?r;S`XbgQs{eQ*#B& zxS-v>s&z^%-b$(?O?z`Vh}Q0(z$4bPi^)8m7_J*fOyO@W z93UyyF|7XH%TZFDgLc;aXUqPKqeW45`9887^lgO5BT@_c3N zK*TWd3gY%<^hHF`15!a7VGlf_`vlb7jMT`fawfU0gGY8~nFk!gAJy z4hVipM8ZsyP;OTeQBcyH?l4PLF)0p?&F7@^~vTu&An+NUF$v z$D2#j=+3lx$){Yw$}nX+&}}!&X4#q)WN@^8#ginQ2s^lOM&pMoiD}7cjvcBGtd1Jn zjD<$sy{yUpnU*=}&d9_G}eQvARk6wB&OmYMvBegC~vVPQ|Z^+H%g7pdW@ z@T2QD)c;th*^-l|Kr$+V0_QA|HFJBe!Bu{~fP2}$ZDvCH&BPlAEjb##Iu}XRvCP7{ zd!cE3cB&20ytuG6`M4mLdfq5DDA|c%DJ{9@TfOhT@br(Qd$Na#CNU}9Qw_;DIc-7qqfE~FO{H{& z;GogsT(6t0>nDu;gL#pseuqy@eM_W05U@e~W$J4^2>ZHCUMlmFjZsr=jFA69=v%izQ~6%m&F6gfwoGoT>co_L{1-h^h9RyerY!_CRM#AwEK0&I#of-sO7P?`i3GlIF zd+*cZ{aQ;9=nnNFnqYTTLOgR>^?P3yJ99=R zw~fW@btXgL0uVogKCiC{C0*JAu>(C*7*y7iHPS((=1pi(vfO>>I?38QLMNfEFsCWm zfhMa_kcC2^&n9MB?<2s%|G{uMIJT+aS#V^|I++BSccgEW_{M4sDmN-yl~K5vt8_YT zc;<0{qM?BVAzidU^bb3P3HpuEn*aCy@*GZR3(74J(Na`9kia@UAl!SgWMs;pKl8`! zp}zrAY+2Bz&CE!y>pm}3Ntax{b-P$SIc=;FOy?1sehxzT$mr3OBT-AXEMF2a3Mfv;E`yHLkH)tqZP#Jv7#)j(3MQBpQQ7Q!^%*I;O=OaGBQN0oL&n4`jG^rzIoaLT5f`cqo#lp}voRS-4Ta5>cy+Ascy z9bTPR3UATHUx-E|an8iQK1iM(jB=orr`>gO$@g0Beqb_d)p0y<2#vH3PFo4E6c#_P zoKIzyju+jq_(oU|(=!Y63~T6HhU1j+tMSif-`YImy(@q1eP8PtHkD2Tvq^+vrA2-R4XwDYWg* zBUKOKavziQYC-$_i~c1^nr3=^%}+aYKAg$q%p&m~f*He|^OJDUXSUviMo+{i_lF0x z8S9w}VMvo4g=YN+SOgaHW9)v2h@h2&264r-MY!+SIcT$NmeNmDVC>bLh~cfcpc1gh z+3{6SRxwWR`fIrg0Ily9a3}h%EW&pXC+?1HfiEN0t-*3cD(7og?L!bm$j6TGiG8%^ z=?+WN8)z^jrF8auY!uJ%F~n=kuQTfW2CeBHw8W6VkIR zCLMn!oYVAqmo>3#Q|bLZKxu}p{nw)`M8DrCH}v`ku{11wTF*UIK)po=ij?!M_dafF__|ceP@zT! zQ!Rq_^(K#mwo~Mk4uwj9q@JLUc?GV?*2-mCLw_&a-BN*%|F(h9h|-F)9EDs>)U;o+ zx;%M%m;|9?8VCqv(1FL#)9XsV*BRBw1G^8>aI5rFoE+pSEKAcZH7$=W`r@`a@RUxu zDEc4)e#b||WZ0qyza60-MDu!jIugB@9XsER{l2GOBNg5Wc#f}5yrU=-CVHSKMg;C{ zKl{kVDNE^QW;f#EoY$6r9X2RP)J^eVw1Bt={lm34dz<%TISC{Zf}KKjA4O0LKrqqZhUXrvIhr zqWV%d)rOFaBr=9qm1p+p7i9U*-1>UBeY2q0`S9=gw2O;K+)j|uYv3G^ai1nTOBII~ zs8=z>=&`0+7&}DI5b$ELC+O0oi+!;6NbI$dO2xA^2yo0i%r}v_xZmgFWyxC2uI6z# z2LytP1MXl5m~HU_dT`8I5V)xUe4swtVh{IZqDjFmE{l2Uu(SZ?VJ`e7!aM5o)r?T zUUGOVZ0sXz=|XULUZu19X{hRL-v?0^W}UJjE360^;0MLn4-sF@570y);VIJEO6Koq zRROqBa5^Jz%CpD@I2=g2K?p*zo)+i7D)wzIpnJ1!wqdd+>b5HX`e`tc?JYPJORao`kbAk S%KiWOKvGfAl&_by3i}_P+cii4 literal 0 HcmV?d00001 diff --git a/src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/test_pics/625.png b/src/sakuli-selenium-setup/src/test/resources/org/sakuli/selenium/testng/example/test_pics/625.png new file mode 100644 index 0000000000000000000000000000000000000000..ec1136503a8319e11cf457bc3c1b944e77530e9f GIT binary patch literal 7486 zcmZX2byO7I*7hI_DJ|V4&5)8qcb9Za3c>&b4BcHK-Q5yW5<{1C3{nCENGeE5Nxc5< z`+oP{wZ5~~IcJ}}pJ&(k=d2T}t*L~IO^FQv0B}{5<#qq=mVc)JCi>s?%x_@<0Kl$s zl9SU`k&~m>_HeUzaOo090uFS)$3)%=2u&{F zldiiMOJmeX6CXTdvPzoX1DJ)fo&rPZpUa1%HDW?$Z#_c@xPXyX+-&IOR#eMaHGPs0 zfMCerCffmkwci**Xa*GSqd6r|?&F1Fjr3vgqR0@?mdFY!lgx)*GU$Cl_Xt~Kuw)~T ziy$hpWuw`av#BC5!B3a9({+#f$$OqMvW`gQ_l92_p5w_4^78JH8>$0dq7U|S^?w|28PT_<eu{j3J22d9#JJ~Ohv6@S)s7Jce)DttD0qlLyV6K^GV%EU}`6X6ws zEla#5xb<>N)H;k!X@RwqU@*pP+hf~cTgHa$Ow2t?MCJo4#fLTJxia;66J3_-NNDI~ z%w>}L%b)M_#|Uj{eQ`TJ1VjYHN+>_7>l9^a!`W3{@Y&&%7tCvPX!$CY>*7`wEXcp5 z^}=aQ@k_dkxKoLG`G#Te!`Ar6jOq-h%ntSolMJ?6&_tR!vnjnPgTMM!=Mkr9NnU8) zXKGW|bhFkqtPYe8ci$X%Yd}^&(!Krd%iD=_CTtiG6=(^pmrWT!iS)#l6O5=(yQpw? z{ON?@MCLdMrCxtOUE(mWb{Ksac*&;#R1hCF8n%o38dv#(MK$I_D3KbwsZ;H|PI;HA zWtvc0_IUMpZklPD8%MBycI9^UhZ^0I`5F(U-FObUuZBWuUR`gaf4mV&$cZ(HSk-Oq zeoMAsF;zO_nLnCs$bWJG$N16M8S7Vehy5G%$I`;6kf6}L5E^Bd(6keLUVr{_VRC_M zNuo})MgifmwC$AcoImH+uWidqv67%V;yaSn*6AJ6X5`=NU3e9dRIHgWEtYSPKibJ` z&bltR?y*k0&Iji1Cg_&!w(rKclMiHlc>Z91*L_Ea`y6-s`725&c>;M2dDC;8=ef9a z6gr6#2^r*HDc4_(P>54FP@M4fSU<~M&b7_b&ovW{)SyxKt?*a>Gu3E6Z6DBV(v0F6 zCyJ0j!dC)jWyctoZSobOhn>~H6Y>+s8QmGkx}&OwLMtJa zQ<|B1pQbIQYxA|lg1y}#W1gZv&NFK}oHLwLe|`xVysf^#pQiIbxWDN-_DO9QSW8_G z_Q-@e`Zt2#f(!h9_<4YTN)!qtW@k^zO)gm&SjaZKYDnJT+2HK%3M8NlE+i_Hv;-o_ zksL_YAhDpspsAoYk5`YJ_g$!sC^9JDP|=Mjx$tUJgh&s_+xbre2w2!SsyGgu8dVy3 z+d0wju%53Fp0nvorO~Ytq7N8Zix1F7Q$>NWo`jx}5z^|=oN>*IHSsnH$C0**)Uf}M zYcafBJc#B~LFxJf@VBwiqbVdcl(3@s0J4xIseaJ+fQ zHJh|JG&{RyAzMw6nPk=6;}+1jpN?#@*zldUN|rM5gPe@{gSD9c{yR z{5&Q)N~>L~?W$)GYxCptiu3F9K4r=FFk5|F__psw4a|)nmH*lp#z5aeU2SW&w-viHIQQ5=7NN%d#&ddA=Iw0|2#e?Le~p?+ox;vDvJNMDXgiO zhCzIFf?}6t_r!;1!?$Cg-Ui7t&vVA3Vh6F?ckN#P<{ex&Ue&30{CeG_)S|h1?>p_U zf?R*_b=whQ*|76uLJMB_>-ZXpv~boobqDy+KlL?-f5Pw&_P*=*q*+(r^2-$5YcWr- z0_mCi^y!mIx0AEL8kZ|AI1PF*VqG|x&%MX}$28qUEjff~n+X)8^0@nJuBa3|nwQi{ zy(DFUP;};WieAn9oa|)_RTd)_`=fxHi-Cv?ucz9vkgUYfYCfk>PK4CjX#vd@|DeS(Tc(5t&}R7 zn)pAAwtD6JB0v4e$NON zaHUCd?i@LaD3TUSz$h-xoKwM3Y*UN&it%fqCaG~_V?I^FLsY1z@2osLO5S*!o6?9K zp#nOkCSe!VR=V2p-IN6F!Iu`}z$c0)z?By;f4iYf763rWb<#J28fmDDy>WZTV{PkZ zW5)w~2l@M|1pp*qVt>VVc2H}2*gF?jPcayn@m~nBzw$q75F`D+AW&y8qmhO-y_}ne z9la2bAP+C2BsM)gy@ZFYy_l}N;{VbAp1_QbP$)zU1oH9m;qejRar1Bh@rjCxf_V8s z{QTU15!{}>u25?jx2q@9|2p}9e&p>u-*`AdpiXYC^#Ay^wsG@|8zn#*h>hlK2<=|1`RHRJw7BrdTCn8c-CXbNjB5JbjTSf*cl8d)iQaizPPkSVM3p`u|`C zyW5DjHj6m%ZX&W)quMdl`@ADQ4e=1v4)LIvNKYhOWzQ*>vQ|F@3b^fc`?_twQLsL% z@Hjv}2lrk-T=zctA6PtYIDc=Suru4A(B=tyK18;QUqp9~Q8f5uO7duX4{|^JXPvvb z>l!ir8r!VWf$Vi|3RFqB)D{}wQ7)f6Pj*9jOzxoBwad=qKHb%0`7E%4jqy|Sr3!6< zOJfs^%#pt=hoErAosV~FQdY(Sy{Y0Q)9R*QQ63W>^z-K}g9&cIR>3}g$J4i-RCS;D zP%G^17zYJOR-9CnV-gkGb29^HvDF;JS53an2K}U*^xkG^&T^4v9A-OADWJg^{DP?{ zx1%XT^G$(6Q1FEucu8dmg7vO^nuekfE4SN~>k$OwM^9#?Q_&KD#$@>vMc6+&FN29%l%SU{!S>K#L}R?GHIq6{t5wwOt1z+Y|Ega;HTe3 zG+UdFuO9ab>6Gw}2lW1Y{=OOd^8gDcmGGK|cQ1YOTkva?HXk3iAYd!a91#I>)X!xh zWF@(7I2EU9c1bthobG7&Hz9jcL`c<}N$z3A0Hq^jxfXx_&i$JL_-w z!3ni*+{dMfMQW@A%huXcU?2V70^M$Y(74$w%^7G!IXr%DI1_oao7is&4i%aSrt!^7 zG@0BHdn}wKeY<`Mgl~0G_V)Sba*mzy(ZWy^JM7_aPt6N53w9nn%S7@ce)cx9as~T| zQ3oa-&~)mJelJXhy>$Fe6~DjL4~OL;dnx`jB*Z!0y2ZCaVSkL_Z4YSu6>rYYscDr2 zkBhgUFW(&hh+J?Rto(-8XM-6K;`@FbXB_rmgY=cB+%JXLSNZGvcH}9KX%bouOEf84$!j^5tfgVwYt1 zTu0+;5{+Y`txklLS&lCIU84oH7$lVbLrPXTe8R&%%W)%aWFnsC-<^X1*&_6 zI=Rw=R5kku`6JhlLu)lJpSZnzshux<lM>ym?r;S`XbgQs{eQ*#B& zxS-v>s&z^%-b$(?O?z`Vh}Q0(z$4bPi^)8m7_J*fOyO@W z93UyyF|7XH%TZFDgLc;aXUqPKqeW45`9887^lgO5BT@_c3N zK*TWd3gY%<^hHF`15!a7VGlf_`vlb7jMT`fawfU0gGY8~nFk!gAJy z4hVipM8ZsyP;OTeQBcyH?l4PLF)0p?&F7@^~vTu&An+NUF$v z$D2#j=+3lx$){Yw$}nX+&}}!&X4#q)WN@^8#ginQ2s^lOM&pMoiD}7cjvcBGtd1Jn zjD<$sy{yUpnU*=}&d9_G}eQvARk6wB&OmYMvBegC~vVPQ|Z^+H%g7pdW@ z@T2QD)c;th*^-l|Kr$+V0_QA|HFJBe!Bu{~fP2}$ZDvCH&BPlAEjb##Iu}XRvCP7{ zd!cE3cB&20ytuG6`M4mLdfq5DDA|c%DJ{9@TfOhT@br(Qd$Na#CNU}9Qw_;DIc-7qqfE~FO{H{& z;GogsT(6t0>nDu;gL#pseuqy@eM_W05U@e~W$J4^2>ZHCUMlmFjZsr=jFA69=v%izQ~6%m&F6gfwoGoT>co_L{1-h^h9RyerY!_CRM#AwEK0&I#of-sO7P?`i3GlIF zd+*cZ{aQ;9=nnNFnqYTTLOgR>^?P3yJ99=R zw~fW@btXgL0uVogKCiC{C0*JAu>(C*7*y7iHPS((=1pi(vfO>>I?38QLMNfEFsCWm zfhMa_kcC2^&n9MB?<2s%|G{uMIJT+aS#V^|I++BSccgEW_{M4sDmN-yl~K5vt8_YT zc;<0{qM?BVAzidU^bb3P3HpuEn*aCy@*GZR3(74J(Na`9kia@UAl!SgWMs;pKl8`! zp}zrAY+2Bz&CE!y>pm}3Ntax{b-P$SIc=;FOy?1sehxzT$mr3OBT-AXEMF2a3Mfv;E`yHLkH)tqZP#Jv7#)j(3MQBpQQ7Q!^%*I;O=OaGBQN0oL&n4`jG^rzIoaLT5f`cqo#lp}voRS-4Ta5>cy+Ascy z9bTPR3UATHUx-E|an8iQK1iM(jB=orr`>gO$@g0Beqb_d)p0y<2#vH3PFo4E6c#_P zoKIzyju+jq_(oU|(=!Y63~T6HhU1j+tMSif-`YImy(@q1eP8PtHkD2Tvq^+vrA2-R4XwDYWg* zBUKOKavziQYC-$_i~c1^nr3=^%}+aYKAg$q%p&m~f*He|^OJDUXSUviMo+{i_lF0x z8S9w}VMvo4g=YN+SOgaHW9)v2h@h2&264r-MY!+SIcT$NmeNmDVC>bLh~cfcpc1gh z+3{6SRxwWR`fIrg0Ily9a3}h%EW&pXC+?1HfiEN0t-*3cD(7og?L!bm$j6TGiG8%^ z=?+WN8)z^jrF8auY!uJ%F~n=kuQTfW2CeBHw8W6VkIR zCLMn!oYVAqmo>3#Q|bLZKxu}p{nw)`M8DrCH}v`ku{11wTF*UIK)po=ij?!M_dafF__|ceP@zT! zQ!Rq_^(K#mwo~Mk4uwj9q@JLUc?GV?*2-mCLw_&a-BN*%|F(h9h|-F)9EDs>)U;o+ zx;%M%m;|9?8VCqv(1FL#)9XsV*BRBw1G^8>aI5rFoE+pSEKAcZH7$=W`r@`a@RUxu zDEc4)e#b||WZ0qyza60-MDu!jIugB@9XsER{l2GOBNg5Wc#f}5yrU=-CVHSKMg;C{ zKl{kVDNE^QW;f#EoY$6r9X2RP)J^eVw1Bt={lm34dz<%TISC{Zf}KKjA4O0LKrqqZhUXrvIhr zqWV%d)rOFaBr=9qm1p+p7i9U*-1>UBeY2q0`S9=gw2O;K+)j|uYv3G^ai1nTOBII~ zs8=z>=&`0+7&}DI5b$ELC+O0oi+!;6NbI$dO2xA^2yo0i%r}v_xZmgFWyxC2uI6z# z2LytP1MXl5m~HU_dT`8I5V)xUe4swtVh{IZqDjFmE{l2Uu(SZ?VJ`e7!aM5o)r?T zUUGOVZ0sXz=|XULUZu19X{hRL-v?0^W}UJjE360^;0MLn4-sF@570y);VIJEO6Koq zRROqBa5^Jz%CpD@I2=g2K?p*zo)+i7D)wzIpnJ1!wqdd+>b5HX`e`tc?JYPJORao`kbAk S%KiWOKvGfAl&_by3i}_P+cii4 literal 0 HcmV?d00001 From 38b78f236b11264fec32bd80462d08d6e14592e0 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 3 Jul 2017 16:28:20 +0200 Subject: [PATCH 16/21] #247 add sakuli-se-example to docker java build --- .../src_java/common/install/sakuli.sh | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/docker/sakuli-client/src_java/common/install/sakuli.sh b/docker/sakuli-client/src_java/common/install/sakuli.sh index 68833001..bccfa8e4 100644 --- a/docker/sakuli-client/src_java/common/install/sakuli.sh +++ b/docker/sakuli-client/src_java/common/install/sakuli.sh @@ -5,20 +5,25 @@ set -e EXAMPLE_URL=https://github.com/ConSol/sakuli-examples echo "Install Sakuli Java Example: Maven $EXAMPLE_URL to $SAKULI_TEST_SUITE" -mkdir -p /tmp/sakuli-example -cd /tmp/sakuli-example -wget $EXAMPLE_URL/archive/master.zip +tmpdir=/tmp/sakuli-example +mkdir -p $tmpdir +cd $tmpdir +#TODO TS change to master +# https://github.com/ConSol/sakuli-examples/archive/feature/sakuli-se.zip +wget $EXAMPLE_URL/archive/feature/sakuli-se.zip unzip *.zip mkdir -p "$SAKULI_TEST_SUITE" -mv sakuli-examples-master/java-example/* "$SAKULI_TEST_SUITE" -rm -rf /tmp/sakuli-example - -echo "Download Sakuli dependencies for v$SAKULI_VERSION" -cd $SAKULI_TEST_SUITE -ls -la -## clean target after build, so only dependencies are here -mvn test clean -Duser.home=$HOME -Dtest=TriggerDownload -DfailIfNoTests=false -Dsakuli.version=$SAKULI_VERSION +for javasuite in "java-selenium-example" "java-example"; do + echo "Download Sakuli dependencies for v$SAKULI_VERSION" + cd $tmpdir/sakuli-examples-feature-sakuli-se/$javasuite + ls -la + ## clean target after build, so only dependencies are here + mvn test clean -Duser.home=$HOME -Dtest=TriggerDownload -DfailIfNoTests=false -Dsakuli.version=$SAKULI_VERSION +done +mv $tmpdir/sakuli-examples-feature-sakuli-se/java-example/ "$SAKULI_TEST_SUITE" +ls -la "$SAKULI_TEST_SUITE" +rm -rvf $tmpdir echo "add -Dsakuli.version=$SAKULI_VERSION to Maven startup" echo "export MAVEN_OPTS=-Dsakuli.version=$SAKULI_VERSION" >> $HOME/.bashrc -echo 'echo MAVEN_OPTS=$MAVEN_OPTS' >> $HOME/.bashrc \ No newline at end of file +echo 'echo MAVEN_OPTS=$MAVEN_OPTS' >> $HOME/.bashrc From 2e39d03161e2e9194c84d62743aa2a7443be55fe Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 3 Jul 2017 17:12:49 +0200 Subject: [PATCH 17/21] fix build script --- .build/set-build-env-vars.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build/set-build-env-vars.sh b/.build/set-build-env-vars.sh index 57ee65cf..23684bc9 100755 --- a/.build/set-build-env-vars.sh +++ b/.build/set-build-env-vars.sh @@ -12,7 +12,7 @@ echo "SAKULI_BRANCH=$SAKULI_BRANCH" > $WORKSPACE/myjob.properties FEATURE_NAME=${GIT_BRANCH:$(expr index \"$GIT_BRANCH\" '#') -1 } echo "FEATURE_NAME=$FEATURE_NAME" >> $WORKSPACE/myjob.properties -SAKULI_VERSION="$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')" +SAKULI_VERSION="$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v -e '\[' -e 'Download' )" echo "SAKULI_VERSION=$SAKULI_VERSION" >> $WORKSPACE/myjob.properties VERSION_SURFIX=${SAKULI_VERSION:$(expr index \"$SAKULI_VERSION\" 'SNAPSHOT') +7 } echo "VERSION_SURFIX=$VERSION_SURFIX" >> $WORKSPACE/myjob.properties From bcfaa0176cd9bc7cb944b5333be7a56615a7c760 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 3 Jul 2017 20:39:51 +0200 Subject: [PATCH 18/21] #247 fix sakuli-java installation script for docker --- docker/sakuli-client/src_java/common/install/sakuli.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/sakuli-client/src_java/common/install/sakuli.sh b/docker/sakuli-client/src_java/common/install/sakuli.sh index bccfa8e4..4e09123f 100644 --- a/docker/sakuli-client/src_java/common/install/sakuli.sh +++ b/docker/sakuli-client/src_java/common/install/sakuli.sh @@ -20,7 +20,8 @@ for javasuite in "java-selenium-example" "java-example"; do ## clean target after build, so only dependencies are here mvn test clean -Duser.home=$HOME -Dtest=TriggerDownload -DfailIfNoTests=false -Dsakuli.version=$SAKULI_VERSION done -mv $tmpdir/sakuli-examples-feature-sakuli-se/java-example/ "$SAKULI_TEST_SUITE" +rm -rf "$SAKULI_TEST_SUITE" +mv $tmpdir/sakuli-examples-feature-sakuli-se/java-selenium-example "$SAKULI_TEST_SUITE" ls -la "$SAKULI_TEST_SUITE" rm -rvf $tmpdir From fe312c0b5f0ac6a67ab24d024fb97051cb0cc5e9 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Mon, 3 Jul 2017 20:41:53 +0200 Subject: [PATCH 19/21] #247 fix sakuli-java installation script for docker --- docker/sakuli-client/src_java/common/install/sakuli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/sakuli-client/src_java/common/install/sakuli.sh b/docker/sakuli-client/src_java/common/install/sakuli.sh index 4e09123f..2dacdc9e 100644 --- a/docker/sakuli-client/src_java/common/install/sakuli.sh +++ b/docker/sakuli-client/src_java/common/install/sakuli.sh @@ -21,7 +21,7 @@ for javasuite in "java-selenium-example" "java-example"; do mvn test clean -Duser.home=$HOME -Dtest=TriggerDownload -DfailIfNoTests=false -Dsakuli.version=$SAKULI_VERSION done rm -rf "$SAKULI_TEST_SUITE" -mv $tmpdir/sakuli-examples-feature-sakuli-se/java-selenium-example "$SAKULI_TEST_SUITE" +mv $tmpdir/sakuli-examples-feature-sakuli-se/java-example "$SAKULI_TEST_SUITE" ls -la "$SAKULI_TEST_SUITE" rm -rvf $tmpdir From ac1f6607cbefa815ad5bce6f979544e206ac1146 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Wed, 27 Sep 2017 18:22:55 +0200 Subject: [PATCH 20/21] #247 update sakuli_se branch to current dev state --- .../actions/environment/Environment.java | 2 - .../properties/CipherProperties.java | 0 .../exceptions/SakuliExceptionHandler.java | 5 -- .../org/sakuli/loader/BaseActionLoader.java | 8 --- .../sakuli/loader/BaseActionLoaderImpl.java | 2 - .../sakuli/loader/ScreenActionLoaderImpl.java | 2 - .../services/cipher/AbstractCipher.java | 0 .../sakuli/services/cipher/AesCbcCipher.java | 0 .../sakuli/services/cipher/AesKeyHelper.java | 0 .../sakuli/services/cipher/CipherService.java | 0 .../services/cipher/EnvironmentCipher.java | 0 .../cipher/NetworkInterfaceCipher.java | 0 .../services/cipher/ProfileCipherEnv.java | 0 .../cipher/ProfileCipherInterface.java | 0 .../org/sakuli/utils/CommandLineUtil.java | 0 .../utils/EnvironmentPropertyConfigurer.java | 0 .../SakuliPropertyPlaceholderConfigurer.java | 30 ++++++++ .../src/main/resources}/setup/coreconfig.yml | 0 .../main/resources}/setup/gearman-proxy.yml | 0 .../src/main/resources}/setup/grafana.yml | 0 .../src/main/resources}/setup/mod-gearman.yml | 0 .../src/main/resources}/setup/mysql.yml | 0 .../src/main/resources}/setup/omd/.my.cnf.j2 | 0 .../src/main/resources}/setup/omd/.my0.cnf | 0 .../setup/omd/etc/cron.d/sakuli_mysql_purge | 0 .../histou/templates/custom/check_sakuli.php | 18 +++++ .../setup/omd/local/bin/sakuli_mysql_purge.sh | 0 .../src/main/resources}/setup/pnp4nagios.yml | 0 .../src/main/resources}/setup/pretasks.yml | 0 .../resources}/setup/screenshot_history.yml | 0 .../screenbased/ScreenshotActionsTest.java | 0 .../properties/CipherPropertiesTest.java | 2 - .../services/cipher/AesCbcCipherTest.java | 0 .../services/cipher/AesKeyHelperTest.java | 0 .../cipher/EnvironmentCipherTest.java | 0 .../NetworkInterfaceCipherUtilsTest.java | 0 .../EnvironmentPropertyConfigurerTest.java | 0 ...kuliPropertyPlaceholderConfigurerTest.java | 65 ++---------------- .../actions/screenbased/buffered-image.png | Bin .../sakuli/aop/aopTest-applicationContext.xml | 4 -- .../starter/helper/CipherDelegator.java | 2 +- ...iStarterPropertyPlaceholderConfigurer.java | 30 -------- .../starter/helper/CipherDelegatorTest.java | 2 +- .../SahiStarterExceptionHandlerTest.java | 13 ++-- ...rterPropertyPlaceholderConfigurerTest.java | 4 +- .../sahi/aop/aopTest-applicationContext.xml | 5 +- 46 files changed, 62 insertions(+), 132 deletions(-) rename src/{core => sakuli-core}/src/main/java/org/sakuli/datamodel/properties/CipherProperties.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/AbstractCipher.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/AesCbcCipher.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/AesKeyHelper.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/CipherService.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/EnvironmentCipher.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/NetworkInterfaceCipher.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/ProfileCipherEnv.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/services/cipher/ProfileCipherInterface.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/CommandLineUtil.java (100%) rename src/{core => sakuli-core}/src/main/java/org/sakuli/utils/EnvironmentPropertyConfigurer.java (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/coreconfig.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/gearman-proxy.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/grafana.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/mod-gearman.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/mysql.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/omd/.my.cnf.j2 (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/omd/.my0.cnf (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/omd/etc/cron.d/sakuli_mysql_purge (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/omd/etc/histou/templates/custom/check_sakuli.php (92%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/omd/local/bin/sakuli_mysql_purge.sh (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/pnp4nagios.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/pretasks.yml (100%) rename src/{common/src/main/resources/org/sakuli/common => sakuli-core/src/main/resources}/setup/screenshot_history.yml (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/actions/screenbased/ScreenshotActionsTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/datamodel/properties/CipherPropertiesTest.java (97%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/cipher/AesCbcCipherTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/cipher/AesKeyHelperTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/cipher/EnvironmentCipherTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/services/cipher/NetworkInterfaceCipherUtilsTest.java (100%) rename src/{core => sakuli-core}/src/test/java/org/sakuli/utils/EnvironmentPropertyConfigurerTest.java (100%) rename src/{core => sakuli-core}/src/test/resources/org/sakuli/actions/screenbased/buffered-image.png (100%) rename src/{core => sakuli-sahi-setup}/src/main/java/org/sakuli/starter/helper/CipherDelegator.java (99%) rename src/{core => sakuli-sahi-setup}/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java (99%) diff --git a/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java b/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java index 1bdd805b..4a827dcb 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java +++ b/src/sakuli-core/src/main/java/org/sakuli/actions/environment/Environment.java @@ -19,8 +19,6 @@ package org.sakuli.actions.environment; import org.sakuli.actions.Action; -import org.sakuli.actions.environment.CommandLineUtil.CommandLineResult; -import org.sakuli.actions.ModifySahiTimer; import org.sakuli.actions.logging.LogToResult; import org.sakuli.actions.screenbased.Region; import org.sakuli.actions.screenbased.RegionImpl; diff --git a/src/core/src/main/java/org/sakuli/datamodel/properties/CipherProperties.java b/src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/CipherProperties.java similarity index 100% rename from src/core/src/main/java/org/sakuli/datamodel/properties/CipherProperties.java rename to src/sakuli-core/src/main/java/org/sakuli/datamodel/properties/CipherProperties.java diff --git a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java index 7a419a06..b061b939 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java +++ b/src/sakuli-core/src/main/java/org/sakuli/exceptions/SakuliExceptionHandler.java @@ -25,11 +25,6 @@ import org.sakuli.datamodel.TestSuite; import org.sakuli.loader.ActionLoaderCallback; import org.sakuli.loader.BeanLoader; -import org.sakuli.aop.RhinoAspect; -import org.sakuli.datamodel.TestCase; -import org.sakuli.datamodel.TestCaseStep; -import org.sakuli.datamodel.TestSuite; -import org.sakuli.datamodel.actions.LogResult; import org.sakuli.loader.ScreenActionLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java index 235e7f0b..dc13edcb 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoader.java @@ -18,8 +18,6 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; @@ -59,12 +57,6 @@ public interface BaseActionLoader { ImageLib getImageLib(); - RhinoScriptRunner getRhinoScriptRunner(); - - void setRhinoScriptRunner(RhinoScriptRunner scriptRunner); - - Report getSahiReport(); - CipherService getCipherService(); /** diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java index b0c1c5db..596e866b 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/BaseActionLoaderImpl.java @@ -18,8 +18,6 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.datamodel.TestCase; import org.sakuli.datamodel.TestCaseStep; import org.sakuli.datamodel.TestSuite; diff --git a/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java b/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java index cd51bd5d..8c1f7cf2 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java +++ b/src/sakuli-core/src/main/java/org/sakuli/loader/ScreenActionLoaderImpl.java @@ -18,8 +18,6 @@ package org.sakuli.loader; -import net.sf.sahi.report.Report; -import net.sf.sahi.rhino.RhinoScriptRunner; import org.sakuli.actions.screenbased.ScreenshotActions; import org.sakuli.actions.settings.ScreenBasedSettings; import org.sakuli.datamodel.TestCase; diff --git a/src/core/src/main/java/org/sakuli/services/cipher/AbstractCipher.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/AbstractCipher.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/AbstractCipher.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/AbstractCipher.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/AesCbcCipher.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/AesCbcCipher.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/AesCbcCipher.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/AesCbcCipher.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/AesKeyHelper.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/AesKeyHelper.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/AesKeyHelper.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/AesKeyHelper.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/CipherService.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/CipherService.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/CipherService.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/CipherService.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/EnvironmentCipher.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/EnvironmentCipher.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/EnvironmentCipher.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/EnvironmentCipher.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/NetworkInterfaceCipher.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/NetworkInterfaceCipher.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/NetworkInterfaceCipher.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/NetworkInterfaceCipher.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/ProfileCipherEnv.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/ProfileCipherEnv.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/ProfileCipherEnv.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/ProfileCipherEnv.java diff --git a/src/core/src/main/java/org/sakuli/services/cipher/ProfileCipherInterface.java b/src/sakuli-core/src/main/java/org/sakuli/services/cipher/ProfileCipherInterface.java similarity index 100% rename from src/core/src/main/java/org/sakuli/services/cipher/ProfileCipherInterface.java rename to src/sakuli-core/src/main/java/org/sakuli/services/cipher/ProfileCipherInterface.java diff --git a/src/core/src/main/java/org/sakuli/utils/CommandLineUtil.java b/src/sakuli-core/src/main/java/org/sakuli/utils/CommandLineUtil.java similarity index 100% rename from src/core/src/main/java/org/sakuli/utils/CommandLineUtil.java rename to src/sakuli-core/src/main/java/org/sakuli/utils/CommandLineUtil.java diff --git a/src/core/src/main/java/org/sakuli/utils/EnvironmentPropertyConfigurer.java b/src/sakuli-core/src/main/java/org/sakuli/utils/EnvironmentPropertyConfigurer.java similarity index 100% rename from src/core/src/main/java/org/sakuli/utils/EnvironmentPropertyConfigurer.java rename to src/sakuli-core/src/main/java/org/sakuli/utils/EnvironmentPropertyConfigurer.java diff --git a/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java b/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java index c2964e93..7dfcbbf8 100644 --- a/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java +++ b/src/sakuli-core/src/main/java/org/sakuli/utils/SakuliPropertyPlaceholderConfigurer.java @@ -20,6 +20,7 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.sakuli.datamodel.properties.CipherProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.slf4j.Logger; @@ -42,14 +43,36 @@ */ public class SakuliPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { + public static String ENCRYPTION_KEY_VALUE; public static String TEST_SUITE_FOLDER_VALUE; public static String SAKULI_HOME_FOLDER_VALUE; public static String TEST_SUITE_BROWSER; + public static String ENCRYPTION_INTERFACE_VALUE; private static Logger LOGGER = LoggerFactory.getLogger(SakuliPropertyPlaceholderConfigurer.class); protected boolean loadSakuliProperties = true; protected boolean loadSakuliDefaultProperties = true; protected boolean loadTestSuiteProperties = true; + /** + * Determines the encryption mode of the CLI based values and set it to the assigned 'props' + */ + public static void assignEncryptionProperties(Properties props) { + if (isNotEmpty(ENCRYPTION_INTERFACE_VALUE)) { + props.setProperty(CipherProperties.ENCRYPTION_MODE, CipherProperties.ENCRYPTION_MODE_INTERFACE); + if (ENCRYPTION_INTERFACE_VALUE.equals("auto")) { + props.setProperty(CipherProperties.ENCRYPTION_INTERFACE, ""); + props.setProperty(CipherProperties.ENCRYPTION_INTERFACE_AUTODETECT, "true"); + } else { + props.setProperty(CipherProperties.ENCRYPTION_INTERFACE, ENCRYPTION_INTERFACE_VALUE); + props.setProperty(CipherProperties.ENCRYPTION_INTERFACE_AUTODETECT, "false"); + } + } + if (isNotEmpty(ENCRYPTION_KEY_VALUE)) { + props.setProperty(CipherProperties.ENCRYPTION_MODE, CipherProperties.ENCRYPTION_MODE_ENVIRONMENT); + props.setProperty(CipherProperties.ENCRYPTION_KEY, ENCRYPTION_KEY_VALUE); + } + } + @Override protected void loadProperties(Properties props) throws IOException { //load properties set by command args @@ -60,10 +83,13 @@ protected void loadProperties(Properties props) throws IOException { loadSakuliDefaultProperties(props); loadSakuliProperties(props); loadTestSuiteProperties(props); + loadEnvironmentVariablesToProperties(props); if (isNotEmpty(TEST_SUITE_BROWSER)) { props.setProperty(TestSuiteProperties.BROWSER_NAME, TEST_SUITE_BROWSER); } + assignEncryptionProperties(props); + super.loadProperties(props); } @@ -145,4 +171,8 @@ public boolean isLoadTestSuiteProperties() { public void setLoadTestSuiteProperties(boolean loadTestSuiteProperties) { this.loadTestSuiteProperties = loadTestSuiteProperties; } + + protected void loadEnvironmentVariablesToProperties(Properties props) { + EnvironmentPropertyConfigurer.resolveDashedProperties(props); + } } diff --git a/src/common/src/main/resources/org/sakuli/common/setup/coreconfig.yml b/src/sakuli-core/src/main/resources/setup/coreconfig.yml similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/coreconfig.yml rename to src/sakuli-core/src/main/resources/setup/coreconfig.yml diff --git a/src/common/src/main/resources/org/sakuli/common/setup/gearman-proxy.yml b/src/sakuli-core/src/main/resources/setup/gearman-proxy.yml similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/gearman-proxy.yml rename to src/sakuli-core/src/main/resources/setup/gearman-proxy.yml diff --git a/src/common/src/main/resources/org/sakuli/common/setup/grafana.yml b/src/sakuli-core/src/main/resources/setup/grafana.yml similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/grafana.yml rename to src/sakuli-core/src/main/resources/setup/grafana.yml diff --git a/src/common/src/main/resources/org/sakuli/common/setup/mod-gearman.yml b/src/sakuli-core/src/main/resources/setup/mod-gearman.yml similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/mod-gearman.yml rename to src/sakuli-core/src/main/resources/setup/mod-gearman.yml diff --git a/src/common/src/main/resources/org/sakuli/common/setup/mysql.yml b/src/sakuli-core/src/main/resources/setup/mysql.yml similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/mysql.yml rename to src/sakuli-core/src/main/resources/setup/mysql.yml diff --git a/src/common/src/main/resources/org/sakuli/common/setup/omd/.my.cnf.j2 b/src/sakuli-core/src/main/resources/setup/omd/.my.cnf.j2 similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/omd/.my.cnf.j2 rename to src/sakuli-core/src/main/resources/setup/omd/.my.cnf.j2 diff --git a/src/common/src/main/resources/org/sakuli/common/setup/omd/.my0.cnf b/src/sakuli-core/src/main/resources/setup/omd/.my0.cnf similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/omd/.my0.cnf rename to src/sakuli-core/src/main/resources/setup/omd/.my0.cnf diff --git a/src/common/src/main/resources/org/sakuli/common/setup/omd/etc/cron.d/sakuli_mysql_purge b/src/sakuli-core/src/main/resources/setup/omd/etc/cron.d/sakuli_mysql_purge similarity index 100% rename from src/common/src/main/resources/org/sakuli/common/setup/omd/etc/cron.d/sakuli_mysql_purge rename to src/sakuli-core/src/main/resources/setup/omd/etc/cron.d/sakuli_mysql_purge diff --git a/src/common/src/main/resources/org/sakuli/common/setup/omd/etc/histou/templates/custom/check_sakuli.php b/src/sakuli-core/src/main/resources/setup/omd/etc/histou/templates/custom/check_sakuli.php similarity index 92% rename from src/common/src/main/resources/org/sakuli/common/setup/omd/etc/histou/templates/custom/check_sakuli.php rename to src/sakuli-core/src/main/resources/setup/omd/etc/histou/templates/custom/check_sakuli.php index 28556bbb..53ac6ee6 100644 --- a/src/common/src/main/resources/org/sakuli/common/setup/omd/etc/histou/templates/custom/check_sakuli.php +++ b/src/sakuli-core/src/main/resources/setup/omd/etc/histou/templates/custom/check_sakuli.php @@ -1,4 +1,22 @@ argumentCaptorSahiProp = ArgumentCaptor.forClass(List.class); - ArgumentCaptor argumentCaptorLogProp = ArgumentCaptor.forClass(List.class); - verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_PROPERTY_FILE_APPENDER), argumentCaptorSahiProp.capture(), eq(props)); - verify(testling).modifyPropertiesConfiguration(contains(SahiProxyProperties.SAHI_LOG_PROPERTY_FILE_APPENDER), argumentCaptorLogProp.capture(), eq(props)); - - assertTrue(argumentCaptorSahiProp.getValue().containsAll( - Arrays.asList("logs.dir", "ext.http.proxy.enable", "ext.http.proxy.host", "ext.http.proxy.port", - "ext.http.proxy.auth.enable", "ext.http.proxy.auth.name", "ext.http.proxy.auth.password", - "ext.https.proxy.enable", "ext.https.proxy.host", "ext.https.proxy.port", - "ext.https.proxy.auth.enable", "ext.https.proxy.auth.name", "ext.https.proxy.auth.password", - "ext.http.both.proxy.bypass_hosts", "ssl.client.keystore.type", "ssl.client.cert.path", "ssl.client.cert.password")), - "currently contains: " + argumentCaptorSahiProp.getValue().toString()); - assertTrue(argumentCaptorLogProp.getValue().containsAll( - Arrays.asList("handlers", "java.util.logging.ConsoleHandler.level", "java.util.logging.FileHandler.level", - "java.util.logging.ConsoleHandler.formatter", "java.util.logging.FileHandler.formatter", - "java.util.logging.FileHandler.limit", "java.util.logging.FileHandler.count", - "java.util.logging.FileHandler.pattern")), - "currently contains: " + argumentCaptorLogProp.getValue().toString()); - } - - @Test - public void testModifyPropertyFile() throws Exception { - Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); - - Properties basicProps = new Properties(); - basicProps.put("test.prop.1", "test-value-1"); - basicProps.put("test.prop.2", "test-value-2"); - testling.modifyPropertiesConfiguration(targetProps.toAbsolutePath().toString(), Arrays.asList("test.prop.1", "test.prop.2"), basicProps); - PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString("test.prop.1"), "test-value-1"); - assertEquals(targetProfConf.getString("test.prop.2"), "test-value-2"); - - testling.restoreProperties(); - targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString("test.prop.1"), "xyz"); - assertEquals(targetProfConf.getString("test.prop.2"), "zyx"); - } - - @Test - public void testModifySahiProxyPortInPropertyFile() throws Exception { - Path targetProps = Paths.get(this.getClass().getResource("properties-test/target.properties").toURI()); - - Properties basicProps = new Properties(); - basicProps.put(SahiProxyProperties.PROXY_PORT, "9000"); - testling.modifySahiProxyPortPropertiesConfiguration(targetProps.toAbsolutePath().toString(), basicProps); - PropertiesConfiguration targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), "9000"); - - testling.restoreProperties(); - targetProfConf = new PropertiesConfiguration(targetProps.toFile()); - assertEquals(targetProfConf.getString(SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING), null); - } } diff --git a/src/core/src/test/resources/org/sakuli/actions/screenbased/buffered-image.png b/src/sakuli-core/src/test/resources/org/sakuli/actions/screenbased/buffered-image.png similarity index 100% rename from src/core/src/test/resources/org/sakuli/actions/screenbased/buffered-image.png rename to src/sakuli-core/src/test/resources/org/sakuli/actions/screenbased/buffered-image.png diff --git a/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml index d8f801b4..94c06204 100644 --- a/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml +++ b/src/sakuli-core/src/test/resources/org/sakuli/aop/aopTest-applicationContext.xml @@ -66,10 +66,6 @@ - - - - diff --git a/src/core/src/main/java/org/sakuli/starter/helper/CipherDelegator.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/helper/CipherDelegator.java similarity index 99% rename from src/core/src/main/java/org/sakuli/starter/helper/CipherDelegator.java rename to src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/helper/CipherDelegator.java index 0a97ecc2..c6ae672e 100644 --- a/src/core/src/main/java/org/sakuli/starter/helper/CipherDelegator.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/helper/CipherDelegator.java @@ -38,7 +38,7 @@ * {@link org.sakuli.starter.SakuliStarter} directly without Spring context. * * @author tschneck - * Date: 6/28/17 + * Date: 6/28/17 */ public class CipherDelegator { private static final Logger LOGGER = LoggerFactory.getLogger(CipherDelegator.class); diff --git a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java index 0fe3ab4c..154f2a8c 100644 --- a/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java +++ b/src/sakuli-sahi-setup/src/main/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurer.java @@ -20,8 +20,6 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; -import org.sakuli.datamodel.properties.CipherProperties; -import org.sakuli.datamodel.properties.SahiProxyProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.starter.sahi.datamodel.properties.SahiProxyProperties; @@ -58,26 +56,6 @@ public SahiStarterPropertyPlaceholderConfigurer() { modifiedSahiConfigProps = new HashMap<>(); } - /** - * Determines the encryption mode of the CLI based values and set it to the assigned 'props' - */ - public static void assignEncryptionProperties(Properties props) { - if (isNotEmpty(ENCRYPTION_INTERFACE_VALUE)) { - props.setProperty(CipherProperties.ENCRYPTION_MODE, CipherProperties.ENCRYPTION_MODE_INTERFACE); - if (ENCRYPTION_INTERFACE_VALUE.equals("auto")) { - props.setProperty(CipherProperties.ENCRYPTION_INTERFACE, ""); - props.setProperty(CipherProperties.ENCRYPTION_INTERFACE_AUTODETECT, "true"); - } else { - props.setProperty(CipherProperties.ENCRYPTION_INTERFACE, ENCRYPTION_INTERFACE_VALUE); - props.setProperty(CipherProperties.ENCRYPTION_INTERFACE_AUTODETECT, "false"); - } - } - if (isNotEmpty(ENCRYPTION_KEY_VALUE)) { - props.setProperty(CipherProperties.ENCRYPTION_MODE, CipherProperties.ENCRYPTION_MODE_ENVIRONMENT); - props.setProperty(CipherProperties.ENCRYPTION_KEY, ENCRYPTION_KEY_VALUE); - } - } - @Override protected void loadProperties(Properties props) throws IOException { super.loadProperties(props); @@ -87,18 +65,10 @@ protected void loadProperties(Properties props) throws IOException { props.setProperty(SahiProxyProperties.PROXY_HOME_FOLDER, SAHI_HOME_VALUE); props.setProperty(SahiProxyProperties.PROXY_CONFIG_FOLDER, SAHI_HOME_VALUE + File.separator + "userdata"); } - if (isNotEmpty(TEST_SUITE_BROWSER)) { - props.setProperty(TestSuiteProperties.BROWSER_NAME, TEST_SUITE_BROWSER); - } - assignEncryptionProperties(props); modifySahiProperties(props); } - protected void loadEnvironmentVariablesToProperties(Properties props) { - EnvironmentPropertyConfigurer.resolveDashedProperties(props); - } - @PreDestroy public void restoreProperties() { try { diff --git a/src/core/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java similarity index 99% rename from src/core/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java rename to src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java index 816a53ef..df0c2fd4 100644 --- a/src/core/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/helper/CipherDelegatorTest.java @@ -35,7 +35,7 @@ /** * @author tschneck - * Date: 7/1/17 + * Date: 7/1/17 */ public class CipherDelegatorTest { diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java index 6e9640c5..b41b3678 100644 --- a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/exceptions/SahiStarterExceptionHandlerTest.java @@ -82,7 +82,7 @@ public void init() throws Exception { when(screenActionLoader.getTestSuite()).thenReturn(testSuite); expectedScreenshotPath = Paths.get("src/test/resources/org/sakuli/exceptions/screenshots/test.jpg"); - when(screenshotActionsMock.takeScreenshot(anyString(), any(Path.class))).thenReturn(expectedScreenshotPath); + when(screenshotActionsMock.takeScreenshotWithTimestampThrowIOException(any(), any(), any(), any())).thenReturn(expectedScreenshotPath); when(screenActionLoader.getScreenshotActions()).thenReturn(screenshotActionsMock); } @@ -108,8 +108,7 @@ public void testSakuliForwarderException2() throws Exception { SakuliForwarderException forwarderException = new SakuliForwarderException("FORWARDER_EXCEPTION"); testling.handleException(forwarderException); - verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class)); - verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(screenshotActionsMock, never()).takeScreenshotWithTimestampThrowIOException(anyString(), any(Path.class), anyString(), any()); verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertEquals(testSuite.getException(), forwarderException); assertTrue(testling.isAlreadyProcessed(testSuite.getException())); @@ -121,8 +120,7 @@ public void testSakuliActionExceptionTakeUnsuccessfulScreenshotFromRegion() thro SakuliActionException sakuliActionException = new SakuliActionException("ACTION_EXCEPTION"); testling.handleException(sakuliActionException, mock(RegionImpl.class), true); - verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); - verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(screenshotActionsMock).takeScreenshotWithTimestampThrowIOException(anyString(), any(Path.class), anyString(), any()); verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); @@ -133,12 +131,11 @@ public void testSakuliActionExceptionTakeUnsuccessfulScreenshotFromRegion() thro @Test public void testSakuliActionExceptionTakeSuccessfulScreenshotFromRegion() throws Exception { when(screenActionLoader.getCurrentTestCase()).thenReturn(null); - when(screenshotActionsMock.takeScreenshot(anyString(), any(Path.class))).thenReturn(expectedScreenshotPath); + when(screenshotActionsMock.takeScreenshotWithTimestampThrowIOException(anyString(), any(Path.class), any(), any())).thenReturn(expectedScreenshotPath); SakuliActionException sakuliActionException = new SakuliActionException("ACTION_EXCEPTION"); testling.handleException(sakuliActionException, mock(RegionImpl.class), true); - verify(screenshotActionsMock).takeScreenshot(anyString(), any(Path.class)); - verify(screenshotActionsMock, never()).takeScreenshot(anyString(), any(Path.class), anyString()); + verify(screenshotActionsMock).takeScreenshotWithTimestampThrowIOException(anyString(), any(Path.class), anyString(), any()); verify(sahiReport).addResult(anyString(), any(ResultType.class), anyString(), anyString()); assertTrue(testSuite.getException() instanceof SakuliExceptionWithScreenshot); assertEquals(((SakuliExceptionWithScreenshot) testSuite.getException()).getScreenshot(), expectedScreenshotPath); diff --git a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java index be9c0f93..7d79f10c 100644 --- a/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java +++ b/src/sakuli-sahi-setup/src/test/java/org/sakuli/starter/sahi/utils/SahiStarterPropertyPlaceholderConfigurerTest.java @@ -23,7 +23,7 @@ import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.sakuli.BaseTest; -import org.sakuli.datamodel.properties.ActionProperties; +import org.sakuli.datamodel.properties.CipherProperties; import org.sakuli.datamodel.properties.SakuliProperties; import org.sakuli.datamodel.properties.TestSuiteProperties; import org.sakuli.loader.BeanLoader; @@ -81,7 +81,7 @@ public void testLoadPropertiesTestSuiteFolder() throws Exception { verify(testling).addPropertiesFromFile(props, Paths.get(PPROPERTY_TEST_FOLDER_PATH).normalize().toAbsolutePath().toString() + TestSuiteProperties.TEST_SUITE_PROPERTIES_FILE_APPENDER, true); verify(testling, never()).modifyPropertiesConfiguration(anyString(), anyListOf(String.class), any(Properties.class)); - assertNull(props.getProperty(ActionProperties.ENCRYPTION_INTERFACE_AUTODETECT), null); + assertNull(props.getProperty(CipherProperties.ENCRYPTION_INTERFACE_AUTODETECT), null); assertEquals(props.getProperty(TestSuiteProperties.SUITE_ID), "0001_testsuite_example"); } diff --git a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml index e94377fa..5b3154c4 100644 --- a/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml +++ b/src/sakuli-sahi-setup/src/test/resources/org/sakuli/starter/sahi/aop/aopTest-applicationContext.xml @@ -70,10 +70,6 @@ - - - - @@ -96,6 +92,7 @@ + From e6bd7a476346a05c7c56d393f97b0122b82afee3 Mon Sep 17 00:00:00 2001 From: Tobias Schneck Date: Thu, 28 Sep 2017 20:53:40 +0200 Subject: [PATCH 21/21] #247 change example installation of java examples backt to master --- docker/sakuli-client/src_java/common/install/sakuli.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docker/sakuli-client/src_java/common/install/sakuli.sh b/docker/sakuli-client/src_java/common/install/sakuli.sh index 2dacdc9e..0bc1f381 100644 --- a/docker/sakuli-client/src_java/common/install/sakuli.sh +++ b/docker/sakuli-client/src_java/common/install/sakuli.sh @@ -8,20 +8,18 @@ echo "Install Sakuli Java Example: Maven $EXAMPLE_URL to $SAKULI_TEST_SUITE" tmpdir=/tmp/sakuli-example mkdir -p $tmpdir cd $tmpdir -#TODO TS change to master -# https://github.com/ConSol/sakuli-examples/archive/feature/sakuli-se.zip -wget $EXAMPLE_URL/archive/feature/sakuli-se.zip +wget $EXAMPLE_URL/archive/master.zip unzip *.zip mkdir -p "$SAKULI_TEST_SUITE" for javasuite in "java-selenium-example" "java-example"; do echo "Download Sakuli dependencies for v$SAKULI_VERSION" - cd $tmpdir/sakuli-examples-feature-sakuli-se/$javasuite + cd $tmpdir/sakuli-examples-master/$javasuite ls -la ## clean target after build, so only dependencies are here mvn test clean -Duser.home=$HOME -Dtest=TriggerDownload -DfailIfNoTests=false -Dsakuli.version=$SAKULI_VERSION done rm -rf "$SAKULI_TEST_SUITE" -mv $tmpdir/sakuli-examples-feature-sakuli-se/java-example "$SAKULI_TEST_SUITE" +mv $tmpdir/sakuli-examples-master/java-example "$SAKULI_TEST_SUITE" ls -la "$SAKULI_TEST_SUITE" rm -rvf $tmpdir