diff --git a/.gitignore b/.gitignore index bb57f02..55f4354 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ log/ target/ .mvn +log.txt +**/pom.xml.versionsBackup \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b95be96..6ed1b72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,10 @@ install: - bash .travis/install_demo_project.sh script: - - mvn package -DdbUser="${DB_USER}" -DdbPass="${DB_PASS}" + - echo "Run Unit tests" + - mvn test + - echo "Run Integration tests" + - mvn verify -Dmaven.skip.test -DdbUser="${DB_USER}" -DdbPass="${DB_PASS}" -DdbUrl="jdbc:oracle:thin:@${DB_URL}" #before_deploy: # - bash .travis/create_release.sh diff --git a/.travis/install_demo_project.sh b/.travis/install_demo_project.sh index 5be2934..61c6319 100644 --- a/.travis/install_demo_project.sh +++ b/.travis/install_demo_project.sh @@ -1,7 +1,7 @@ #!/bin/bash set -ev -PROJECT_FILES_SRC="utplsql-maven-plugin/src/test/resources/simple-project" +PROJECT_FILES_SRC="utplsql-maven-plugin-it/src/it/resources/simple-project" PROJECT_FILES="resources" cat > demo_project.sh.tmp <4.0.0 org.utplsql - utplsql-maven-plugin-build + utplsql-maven-plugin-parent 3.1.0-SNAPSHOT pom - utplsql-maven-plugin Maven Plugin Build + utplsql-maven-plugin Parent https://github.com/utPLSQL/utPLSQL-maven-plugin @@ -18,6 +18,7 @@ utplsql-maven-plugin + utplsql-maven-plugin-it diff --git a/utplsql-maven-plugin-it/pom.xml b/utplsql-maven-plugin-it/pom.xml new file mode 100644 index 0000000..19a9e24 --- /dev/null +++ b/utplsql-maven-plugin-it/pom.xml @@ -0,0 +1,134 @@ + + 4.0.0 + + + org.utplsql + utplsql-maven-plugin-parent + 3.1.0-SNAPSHOT + + utplsql-maven-plugin Integration tests + utplsql-maven-plugin-it + jar + + + UTF-8 + 1.8 + + + + + org.apache.maven + maven-model + 3.0.2 + + + commons-io + commons-io + 2.5 + + + org.apache.maven.shared + maven-verifier + 1.6 + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + true + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-it-resource + process-resources + + add-test-resource + + + + + src/it/resources + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-it-source + process-resources + + add-test-source + + + + src/it/java + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.0 + + + integration-test + + integration-test + + + + verify + + verify + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java b/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java new file mode 100644 index 0000000..ca902e8 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java @@ -0,0 +1,163 @@ +package org.utpsql.maven.plugin.test; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.commons.io.FileUtils; +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class UtPLSQLMojoIT +{ + + private static String pluginVersion = null; + + @BeforeClass + public static void setUp() throws VerificationException, IOException, XmlPullParserException { + // Read plugin pom file + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model = reader.read(new FileReader("../pom.xml")); + + File pomFile = new File("../"); + Verifier verifier = new Verifier(pomFile.getAbsolutePath()); + + // delete plugin + //verifier.deleteArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), "pom" ); + + // install plugin + verifier.setAutoclean(false); + verifier.addCliOption("-Dmaven.skip.test=true"); + verifier.addCliOption("-DskipITs"); + verifier.executeGoal("install"); + + pluginVersion = model.getVersion(); + } + + + @Test + public void testSimpleDefinition() throws Exception + { + + try + { + final String PROJECT_NAME = "simple-project"; + File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/"+ PROJECT_NAME); + + Verifier verifier; + verifier = new Verifier(testProject.getAbsolutePath()); + verifier.addCliOption("-N"); + verifier.addCliOption("-Dutplsql-maven-plugin-version="+pluginVersion); + verifier.addCliOption("-DdbUrl="+System.getProperty("dbUrl")); + verifier.addCliOption("-DdbUser="+System.getProperty("dbUser")); + verifier.addCliOption("-DdbPass="+System.getProperty("dbPass")); + + verifier.executeGoal("test"); + + checkReportsGenerated(PROJECT_NAME,"utplsql/sonar-test-reporter.xml","utplsql/coverage-sonar-reporter.xml"); + } + catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Unexpected Exception running the test of Definition "+e.getMessage()); + } + } + + @Test + public void testRegexDefinition() throws Exception + { + try + { + final String PROJECT_NAME = "regex-project"; + File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/"+ PROJECT_NAME); + + Verifier verifier; + verifier = new Verifier(testProject.getAbsolutePath()); + verifier.addCliOption("-N"); + verifier.addCliOption("-Dutplsql-maven-plugin-version="+pluginVersion); + verifier.addCliOption("-DdbUrl="+System.getProperty("dbUrl")); + verifier.addCliOption("-DdbUser="+System.getProperty("dbUser")); + verifier.addCliOption("-DdbPass="+System.getProperty("dbPass")); + + verifier.executeGoal("test"); + + checkReportsGenerated(PROJECT_NAME,"utplsql/sonar-test-reporter.xml","utplsql/coverage-sonar-reporter.xml"); + } + catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Unexpected Exception running the test of Definition"); + } + } + + @Test + public void testTypeMappingDefinition() throws Exception + { + try + { + final String PROJECT_NAME = "type-mapping-project"; + File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/"+ PROJECT_NAME); + + Verifier verifier; + verifier = new Verifier(testProject.getAbsolutePath()); + verifier.addCliOption("-N"); + verifier.addCliOption("-Dutplsql-maven-plugin-version="+pluginVersion); + verifier.addCliOption("-DdbUrl="+System.getProperty("dbUrl")); + verifier.addCliOption("-DdbUser="+System.getProperty("dbUser")); + verifier.addCliOption("-DdbPass="+System.getProperty("dbPass")); + + verifier.executeGoal("test"); + + checkReportsGenerated(PROJECT_NAME,"utplsql/sonar-test-reporter.xml","utplsql/coverage-sonar-reporter.xml"); + } + catch (Exception e) + { + e.printStackTrace(); + Assert.fail("Unexpected Exception running the test of Definition"); + } + } + + /** + * + * @param files + */ + private void checkReportsGenerated(String projectName, String... files) + { + for (String filename : files) + { + File outputFile = new File("target/test-classes/"+projectName+"/target",filename); + File expectedOutputFile = new File("target/test-classes/"+projectName+"/expected-output", filename); + + Assert.assertTrue("The reporter for " + filename + " was not generated", outputFile.exists()); + try { + // Duration is set to 1 before comparing contents as it is always different. + // Path separator is set to "/" to ensure windows / linux / mac compatibility + Stream stream = Files.lines(Paths.get("target","test-classes",projectName,"target",filename)); + String outputContent = stream.map(line -> line.replaceAll("(duration=\"[0-9\\.]*\")", "duration=\"1\"")) + .map(line -> line.replaceAll("\\\\", "/")) + .map(line -> line.replaceAll("\r", "").replaceAll("\n", "")) + .collect(Collectors.joining("\n")); + + stream.close(); + Assert.assertEquals("The files differ!", + outputContent, + FileUtils.readFileToString(expectedOutputFile, "utf-8").replace("\r","")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Assert.fail("Unexpected Exception running the test of Definition"); + } + } + } +} diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml similarity index 82% rename from utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml index e4b4222..0628e51 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml similarity index 85% rename from utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml index 712cb69..6e6fad7 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml new file mode 100644 index 0000000..cc7e20e --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-regex-test + 1.0.0 + pom + + utplsql-maven-plugin IT regex + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*bdy + **/*spc + + + + .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) + 2 + 6 + 7 + + + + scripts/test + + **/*bdy + **/*spc + + + + .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) + 2 + 6 + 7 + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy similarity index 100% rename from utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy rename to utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc similarity index 100% rename from utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc rename to utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab similarity index 100% rename from utplsql-maven-plugin/src/test/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab rename to utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy similarity index 100% rename from utplsql-maven-plugin/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy rename to utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc similarity index 100% rename from utplsql-maven-plugin/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc rename to utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml similarity index 81% rename from utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml index 79a7998..5824011 100644 --- a/utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml similarity index 84% rename from utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml index f3ce4f9..1908eac 100644 --- a/utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml new file mode 100644 index 0000000..2e51a04 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml @@ -0,0 +1,76 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-simple-test + 1.0.0 + pom + + utplsql-maven-plugin IT Simple + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*bdy + **/*spc + + + + + + + scripts/tests + + **/*bdy + **/*spc + + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy similarity index 94% rename from utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy rename to utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy index a2ff185..d7f60de 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy @@ -1,28 +1,28 @@ -CREATE OR REPLACE PACKAGE BODY PKG_TEST_ME IS - - -- - -- This - -- - FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER IS - BEGIN - IF PPARAM1 IS NULL THEN - RETURN NULL; - ELSIF PPARAM1 = '1' THEN - RETURN 1; - ELSE - RETURN 0; - END IF; - END FC_TEST_ME; - - PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2) IS - BEGIN - IF PSNAME IS NULL THEN - NULL; - ELSE - INSERT INTO TO_TEST_ME (SNAME) VALUES (PSNAME); - COMMIT; - END IF; - END PR_TEST_ME; - -END PKG_TEST_ME; +CREATE OR REPLACE PACKAGE BODY PKG_TEST_ME IS + + -- + -- This + -- + FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER IS + BEGIN + IF PPARAM1 IS NULL THEN + RETURN NULL; + ELSIF PPARAM1 = '1' THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + END FC_TEST_ME; + + PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2) IS + BEGIN + IF PSNAME IS NULL THEN + NULL; + ELSE + INSERT INTO TO_TEST_ME (SNAME) VALUES (PSNAME); + COMMIT; + END IF; + END PR_TEST_ME; + +END PKG_TEST_ME; / \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc similarity index 97% rename from utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc rename to utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc index 67fe1f8..26b2589 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc @@ -1,8 +1,8 @@ --- --- This package is used TO demonstrate the utPL/SQL possibilities --- -CREATE OR REPLACE PACKAGE PKG_TEST_ME AS - FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER; - PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2); -END PKG_TEST_ME; +-- +-- This package is used TO demonstrate the utPL/SQL possibilities +-- +CREATE OR REPLACE PACKAGE PKG_TEST_ME AS + FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER; + PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2); +END PKG_TEST_ME; / \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/TO_TEST_ME.tab similarity index 100% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab rename to utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/TO_TEST_ME.tab diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy similarity index 96% rename from utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy rename to utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy index 6f347b6..115bc15 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy @@ -1,126 +1,126 @@ -CREATE OR REPLACE PACKAGE BODY TEST_PKG_TEST_ME AS - - --------------------------------------------------------------------------- - PROCEDURE SETUP_GLOBAL IS - BEGIN - -- Put here the code which is valid for all tests and that should be - -- executed once. - NULL; - END SETUP_GLOBAL; - - --------------------------------------------------------------------------- - PROCEDURE TEARDOWN_GLOBAL IS - BEGIN - -- Put here the code that should be called only once after all the test - -- have executed - NULL; - END TEARDOWN_GLOBAL; - - --------------------------------------------------------------------------- - PROCEDURE SETUP_TEST IS - BEGIN - -- Nothing to clean up globally - NULL; - END SETUP_TEST; - - PROCEDURE TEARDOWN_TEST IS - BEGIN - -- Nothing to clean up globally - NULL; - END TEARDOWN_TEST; - - PROCEDURE TEST_FC_INPUT_1 IS - BEGIN - -- Ok this is a real test where I check that the function return 1 - -- when called with a '1' parameter - UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('1')).TO_EQUAL(1); - END; - - PROCEDURE SETUP_TEST_FC_INPUT_1 IS - BEGIN - -- Nothing to be done really - NULL; - END; - - PROCEDURE TEARDOWN_TEST_FC_INPUT_1 IS - BEGIN - -- Nothing to be done really - NULL; - END; - - PROCEDURE TEST_FC_INPUT_0 IS - BEGIN - -- Ok this is a real test where I check that the function return 0 - -- when called with a '0' parameter - UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('0')).TO_EQUAL(0); - END; - - PROCEDURE TEST_FC_INPUT_NULL IS - BEGIN - -- Ok I check that the function return NULL - -- when called with a NULL parameter - UT.EXPECT(PKG_TEST_ME.FC_TEST_ME(NULL)).TO_BE_NULL; - END TEST_FC_INPUT_NULL; - - PROCEDURE TEST_PR_TEST_ME_NULL IS - VNCOUNT1 PLS_INTEGER; - VNCOUNT2 PLS_INTEGER; - BEGIN - -- In this example I check that the procedure does - -- not insert anything when passing it a NULL parameter - SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; - PKG_TEST_ME.PR_TEST_ME(NULL); - SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; - UT.EXPECT(VNCOUNT1).TO_EQUAL(VNCOUNT2); - END; - - PROCEDURE TEST_PR_TEST_ME_NOT_NULL IS - VNCOUNT1 PLS_INTEGER; - VNCOUNT2 PLS_INTEGER; - VSNAME TO_TEST_ME.SNAME%TYPE; - BEGIN - -- In this test I will check that I do insert a value - -- when the parameter is not null. I futher check that - -- the procedure has inserted the value I specified. - SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; - VSNAME := TO_CHAR(VNCOUNT1); - PKG_TEST_ME.PR_TEST_ME(VSNAME); - SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; - - -- Check that I have inserted the value - UT.EXPECT(VNCOUNT1 + 1).TO_EQUAL(VNCOUNT2); - SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; - - -- Check that I inserted the one I said I would insert - UT.EXPECT(VNCOUNT2).TO_EQUAL(1); - DELETE FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; - COMMIT; - END; - - PROCEDURE TEST_PR_TEST_ME_EXISTS IS - BEGIN - -- In case the value exists the procedure should fail with an exception. - BEGIN - PKG_TEST_ME.PR_TEST_ME('EXISTS'); - PKG_TEST_ME.PR_TEST_ME('EXISTS'); - EXCEPTION - WHEN OTHERS THEN - UT.FAIL('Unexpected exception raised'); - END; - END; - - PROCEDURE TEST_PR_TEST_ME_CURSOR IS - TYPE REF_CURSOR IS REF CURSOR; - VEXPECTED REF_CURSOR; - VACTUAL REF_CURSOR; - BEGIN - EXECUTE IMMEDIATE 'TRUNCATE TABLE TO_TEST_ME'; - OPEN VEXPECTED FOR - SELECT T.SNAME FROM TO_TEST_ME T; - OPEN VACTUAL FOR - SELECT T.SNAME FROM TO_TEST_ME T; - UT.EXPECT(VEXPECTED).TO_(EQUAL(VACTUAL)); - END; - -END; -/ +CREATE OR REPLACE PACKAGE BODY TEST_PKG_TEST_ME AS + + --------------------------------------------------------------------------- + PROCEDURE SETUP_GLOBAL IS + BEGIN + -- Put here the code which is valid for all tests and that should be + -- executed once. + NULL; + END SETUP_GLOBAL; + + --------------------------------------------------------------------------- + PROCEDURE TEARDOWN_GLOBAL IS + BEGIN + -- Put here the code that should be called only once after all the test + -- have executed + NULL; + END TEARDOWN_GLOBAL; + + --------------------------------------------------------------------------- + PROCEDURE SETUP_TEST IS + BEGIN + -- Nothing to clean up globally + NULL; + END SETUP_TEST; + + PROCEDURE TEARDOWN_TEST IS + BEGIN + -- Nothing to clean up globally + NULL; + END TEARDOWN_TEST; + + PROCEDURE TEST_FC_INPUT_1 IS + BEGIN + -- Ok this is a real test where I check that the function return 1 + -- when called with a '1' parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('1')).TO_EQUAL(1); + END; + + PROCEDURE SETUP_TEST_FC_INPUT_1 IS + BEGIN + -- Nothing to be done really + NULL; + END; + + PROCEDURE TEARDOWN_TEST_FC_INPUT_1 IS + BEGIN + -- Nothing to be done really + NULL; + END; + + PROCEDURE TEST_FC_INPUT_0 IS + BEGIN + -- Ok this is a real test where I check that the function return 0 + -- when called with a '0' parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('0')).TO_EQUAL(0); + END; + + PROCEDURE TEST_FC_INPUT_NULL IS + BEGIN + -- Ok I check that the function return NULL + -- when called with a NULL parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME(NULL)).TO_BE_NULL; + END TEST_FC_INPUT_NULL; + + PROCEDURE TEST_PR_TEST_ME_NULL IS + VNCOUNT1 PLS_INTEGER; + VNCOUNT2 PLS_INTEGER; + BEGIN + -- In this example I check that the procedure does + -- not insert anything when passing it a NULL parameter + SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; + PKG_TEST_ME.PR_TEST_ME(NULL); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; + UT.EXPECT(VNCOUNT1).TO_EQUAL(VNCOUNT2); + END; + + PROCEDURE TEST_PR_TEST_ME_NOT_NULL IS + VNCOUNT1 PLS_INTEGER; + VNCOUNT2 PLS_INTEGER; + VSNAME TO_TEST_ME.SNAME%TYPE; + BEGIN + -- In this test I will check that I do insert a value + -- when the parameter is not null. I futher check that + -- the procedure has inserted the value I specified. + SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; + VSNAME := TO_CHAR(VNCOUNT1); + PKG_TEST_ME.PR_TEST_ME(VSNAME); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; + + -- Check that I have inserted the value + UT.EXPECT(VNCOUNT1 + 1).TO_EQUAL(VNCOUNT2); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; + + -- Check that I inserted the one I said I would insert + UT.EXPECT(VNCOUNT2).TO_EQUAL(1); + DELETE FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; + COMMIT; + END; + + PROCEDURE TEST_PR_TEST_ME_EXISTS IS + BEGIN + -- In case the value exists the procedure should fail with an exception. + BEGIN + PKG_TEST_ME.PR_TEST_ME('EXISTS'); + PKG_TEST_ME.PR_TEST_ME('EXISTS'); + EXCEPTION + WHEN OTHERS THEN + UT.FAIL('Unexpected exception raised'); + END; + END; + + PROCEDURE TEST_PR_TEST_ME_CURSOR IS + TYPE REF_CURSOR IS REF CURSOR; + VEXPECTED REF_CURSOR; + VACTUAL REF_CURSOR; + BEGIN + EXECUTE IMMEDIATE 'TRUNCATE TABLE TO_TEST_ME'; + OPEN VEXPECTED FOR + SELECT T.SNAME FROM TO_TEST_ME T; + OPEN VACTUAL FOR + SELECT T.SNAME FROM TO_TEST_ME T; + UT.EXPECT(VEXPECTED).TO_(EQUAL(VACTUAL)); + END; + +END; +/ diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc similarity index 96% rename from utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc rename to utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc index 86ae400..e2c82fa 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc @@ -1,86 +1,86 @@ -CREATE OR REPLACE PACKAGE TEST_PKG_TEST_ME AS - -- %suite(TEST_PKG_TEST_ME) - -- %suitepath(plsql.examples) - -- - -- This package shows all the possibilities to unit test - -- your PL/SQL package. NOTE that it is not limited to - -- testing your package. You can do that on all your - -- procedure/functions... - -- - - /** - * This two parameters are used by the test framework in - * order to identify the test suite to run - */ - - /* - * This method is invoked once before any other method. - * It should contain all the setup code that is relevant - * for all your test. It might be inserting a register, - * creating a type, etc... - */ - -- %beforeall - PROCEDURE SETUP_GLOBAL; - - /* - * This method is invoked once after all other method. - * It can be used to clean up all the resources that - * you created in your script - */ - -- %afterall - PROCEDURE TEARDOWN_GLOBAL; - - /* - * This method is called once before each test. - */ - -- %beforeeach - PROCEDURE SETUP_TEST; - - /* - * This method is called once after each test. - */ - -- %aftereach - PROCEDURE TEARDOWN_TEST; - - /** - * This is a real test. The main test can declare a setup - * and teardown method in order to setup and cleanup things - * for that specific test. - */ - -- %test - -- %displayname(Checking if function ('1') returns 1) - -- %beforetest(SETUP_TEST_FC_INPUT_1) - -- %aftertest(TEARDOWN_TEST_FC_INPUT_1) - PROCEDURE TEST_FC_INPUT_1; - PROCEDURE SETUP_TEST_FC_INPUT_1; - PROCEDURE TEARDOWN_TEST_FC_INPUT_1; - - -- %test - -- %displayname(Checking if function ('0') returns 0) - PROCEDURE TEST_FC_INPUT_0; - - -- %test - -- %displayname(Checking if function (NULL) returns NULL) - PROCEDURE TEST_FC_INPUT_NULL; - - -- %test - -- %displayname(Checking if procedure (NULL) insert) - PROCEDURE TEST_PR_TEST_ME_NULL; - - -- %test - -- %displayname(Checking if procedure (NOT NULL) insert) - -- %rollback(manual) - PROCEDURE TEST_PR_TEST_ME_NOT_NULL; - - -- %test - -- %displayname(Checking if procedure (NOT NULL) insert while existing) - -- %rollback(manual) - PROCEDURE TEST_PR_TEST_ME_EXISTS; - - -- %test - -- %displayname(Demonstrating the use of cursor) - -- %rollback(manual) - PROCEDURE TEST_PR_TEST_ME_CURSOR; - -END; -/ +CREATE OR REPLACE PACKAGE TEST_PKG_TEST_ME AS + -- %suite(TEST_PKG_TEST_ME) + -- %suitepath(plsql.examples) + -- + -- This package shows all the possibilities to unit test + -- your PL/SQL package. NOTE that it is not limited to + -- testing your package. You can do that on all your + -- procedure/functions... + -- + + /** + * This two parameters are used by the test framework in + * order to identify the test suite to run + */ + + /* + * This method is invoked once before any other method. + * It should contain all the setup code that is relevant + * for all your test. It might be inserting a register, + * creating a type, etc... + */ + -- %beforeall + PROCEDURE SETUP_GLOBAL; + + /* + * This method is invoked once after all other method. + * It can be used to clean up all the resources that + * you created in your script + */ + -- %afterall + PROCEDURE TEARDOWN_GLOBAL; + + /* + * This method is called once before each test. + */ + -- %beforeeach + PROCEDURE SETUP_TEST; + + /* + * This method is called once after each test. + */ + -- %aftereach + PROCEDURE TEARDOWN_TEST; + + /** + * This is a real test. The main test can declare a setup + * and teardown method in order to setup and cleanup things + * for that specific test. + */ + -- %test + -- %displayname(Checking if function ('1') returns 1) + -- %beforetest(SETUP_TEST_FC_INPUT_1) + -- %aftertest(TEARDOWN_TEST_FC_INPUT_1) + PROCEDURE TEST_FC_INPUT_1; + PROCEDURE SETUP_TEST_FC_INPUT_1; + PROCEDURE TEARDOWN_TEST_FC_INPUT_1; + + -- %test + -- %displayname(Checking if function ('0') returns 0) + PROCEDURE TEST_FC_INPUT_0; + + -- %test + -- %displayname(Checking if function (NULL) returns NULL) + PROCEDURE TEST_FC_INPUT_NULL; + + -- %test + -- %displayname(Checking if procedure (NULL) insert) + PROCEDURE TEST_PR_TEST_ME_NULL; + + -- %test + -- %displayname(Checking if procedure (NOT NULL) insert) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_NOT_NULL; + + -- %test + -- %displayname(Checking if procedure (NOT NULL) insert while existing) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml similarity index 79% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml index 65ddd2b..f046682 100644 --- a/utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml similarity index 82% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml index 84e9996..cd174ad 100644 --- a/utplsql-maven-plugin/src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml @@ -1,5 +1,5 @@ - + diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml new file mode 100644 index 0000000..92f4819 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml @@ -0,0 +1,92 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-type-mapping-test + 1.0.0 + + pom + + utplsql-maven-plugin IT Type Mapping + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*sql + + + + .*/(\w+)/(\w+)/(\w+)\.\w{3} + 1 + 3 + 2 + + + package body + package_bodies + + + + + + scripts/test + + **/*sql + + + + .*/(\w+)/(\w+)/(\w+)\.\w{3} + 1 + 3 + 2 + + + package body + package_bodies + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql similarity index 100% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql similarity index 100% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab similarity index 93% rename from utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab index 1cd6f12..b2e90d9 100644 --- a/utplsql-maven-plugin/src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab @@ -1,8 +1,8 @@ --- --- This is a table used to demonstrate the UNIT test framework. --- -CREATE TABLE TO_TEST_ME -( - SNAME VARCHAR2(10) -) -/ +-- +-- This is a table used to demonstrate the UNIT test framework. +-- +CREATE TABLE TO_TEST_ME +( + SNAME VARCHAR2(10) +) +/ diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql similarity index 100% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql similarity index 100% rename from utplsql-maven-plugin/src/test/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql rename to utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql diff --git a/utplsql-maven-plugin/pom.xml b/utplsql-maven-plugin/pom.xml index c0628df..5dbbf0c 100644 --- a/utplsql-maven-plugin/pom.xml +++ b/utplsql-maven-plugin/pom.xml @@ -1,12 +1,16 @@ - 4.0.0 + + org.utplsql + utplsql-maven-plugin-parent + 3.1.0-SNAPSHOT + - org.utplsql utplsql-maven-plugin maven-plugin - 3.1.0-SNAPSHOT utplsql-maven-plugin Maven Plugin @@ -50,6 +54,8 @@ + + org.apache.maven.plugin-testing diff --git a/utplsql-maven-plugin/src/test/java/org/utpsql/maven/plugin/test/UtPLSQLMojoTest.java b/utplsql-maven-plugin/src/test/java/org/utpsql/maven/plugin/test/UtPLSQLMojoTest.java deleted file mode 100644 index 7695c8b..0000000 --- a/utplsql-maven-plugin/src/test/java/org/utpsql/maven/plugin/test/UtPLSQLMojoTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.utpsql.maven.plugin.test; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.testing.MojoRule; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.utplsql.maven.plugin.UtPLSQLMojo; - -public class UtPLSQLMojoTest -{ - public static final String TARGET_DIRECTORY = "target/test-classes"; - - @Rule - public MojoRule rule = new MojoRule(); - - @Test - public void testDefinition() throws Exception - { - - try - { - final String PROJECT_NAME = "simple-project"; - UtPLSQLMojo myMojo = (UtPLSQLMojo) rule.lookupConfiguredMojo(new File(TARGET_DIRECTORY+"/"+PROJECT_NAME), "test"); - - Assert.assertNotNull(myMojo); - myMojo.execute(); - - checkReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml"); - } - catch (Exception e) - { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition"); - } - } - - @Test - public void testRegexDefinition() throws Exception - { - try - { - final String PROJECT_NAME = "regex-project"; - UtPLSQLMojo myMojo = (UtPLSQLMojo) rule.lookupConfiguredMojo(new File(TARGET_DIRECTORY+"/"+PROJECT_NAME), "test"); - - Assert.assertNotNull(myMojo); - myMojo.execute(); - - checkReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml"); - } - catch (Exception e) - { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition"); - } - } - - @Test - public void testTypeMappingDefinition() throws Exception - { - try - { - final String PROJECT_NAME = "type-mapping-project"; - UtPLSQLMojo myMojo = (UtPLSQLMojo) rule.lookupConfiguredMojo(new File(TARGET_DIRECTORY+"/"+PROJECT_NAME), "test"); - - Assert.assertNotNull(myMojo); - myMojo.execute(); - - checkReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml"); - } - catch (Exception e) - { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition"); - } - } - - /** - * - * @param files - */ - private void checkReportsGenerated(String projectName, String... files) - { - for (String filename : files) - { - File outputFile = new File(TARGET_DIRECTORY+"/"+projectName+"/target/", filename); - File expectedOutputFile = new File(TARGET_DIRECTORY+"/"+projectName+"/expected-output/", filename); - - Assert.assertTrue("The reporter for " + filename + " was not generated", outputFile.exists()); - try { - // Duration is set to 1 before comparing contents as it is always different. - // Path separator is set to "/" to ensure windows / linux / mac compatibility - Stream stream = Files.lines(Paths.get(TARGET_DIRECTORY,projectName,"target",filename)); - String outputContent = stream.map(line -> line.replaceAll("(duration=\"[0-9\\.]*\")", "duration=\"1\"")) - .map(line -> line.replaceAll("\\\\", "/")) - .map(line -> line.replaceAll("\r", "").replaceAll("\n", "")) - .collect(Collectors.joining("\n")); - - stream.close(); - Assert.assertEquals("The files differ!", - outputContent, - FileUtils.readFileToString(expectedOutputFile, "utf-8").replace("\r","")); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition"); - } - } - } -} diff --git a/utplsql-maven-plugin/src/test/resources/regex-project/pom.xml b/utplsql-maven-plugin/src/test/resources/regex-project/pom.xml deleted file mode 100644 index cbf04a8..0000000 --- a/utplsql-maven-plugin/src/test/resources/regex-project/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - 4.0.0 - - org.utplsql - utplsql-maven-plugin-test - 1.0.0-SNAPSHOT - maven-plugin - - utplsql-maven-plugin Maven Plugin Test - - - - jdbc:oracle:thin:@127.0.0.1:1521:xe - - - - - - - - ${pom.groupId} - utplsql-maven-plugin - ${pom.version} - - test - - - - - false - - - app - - - - - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml - true - - - UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml - true - - - - - - src/test/resources/regex-project/scripts/sources - - **/*bdy - **/*spc - - - - .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) - 2 - 6 - 7 - - - - src/test/resources/regex-project/scripts/test - - **/*bdy - **/*spc - - - - .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) - 2 - 6 - 7 - - - - - - \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/simple-project/pom.xml b/utplsql-maven-plugin/src/test/resources/simple-project/pom.xml deleted file mode 100644 index 3cbd422..0000000 --- a/utplsql-maven-plugin/src/test/resources/simple-project/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - 4.0.0 - - org.utplsql - utplsql-maven-plugin-test - 1.0.0-SNAPSHOT - maven-plugin - - utplsql-maven-plugin Maven Plugin Test - - - - jdbc:oracle:thin:@127.0.0.1:1521:xe - - - - - - - ${pom.groupId} - utplsql-maven-plugin - ${pom.version} - - test - - - - - false - - - app - - - - - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml - true - - - UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml - true - - - - - - src/test/resources/simple-project/scripts/sources - - **/*bdy - **/*spc - - - - - - - src/test/resources/simple-project/scripts/tests - - **/*bdy - **/*spc - - - - - - - - - \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/type-mapping-project/pom.xml b/utplsql-maven-plugin/src/test/resources/type-mapping-project/pom.xml deleted file mode 100644 index 42312f9..0000000 --- a/utplsql-maven-plugin/src/test/resources/type-mapping-project/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - 4.0.0 - - org.utplsql - utplsql-maven-plugin-test - 1.0.0-SNAPSHOT - maven-plugin - - utplsql-maven-plugin Maven Plugin Test - - - - jdbc:oracle:thin:@127.0.0.1:1521:xe - - - - - - - - ${pom.groupId} - utplsql-maven-plugin - ${pom.version} - - test - - - - - false - - - app - - - - - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml - true - - - UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml - true - - - - - - src/test/resources/type-mapping-project/scripts/sources - - **/*sql - - - - .*/(\w+)/(\w+)/(\w+)\.\w{3} - 1 - 3 - 2 - - - package body - package_bodies - - - - - - src/test/resources/type-mapping-project/scripts/test - - **/*sql - - - - .*/(\w+)/(\w+)/(\w+)\.\w{3} - 1 - 3 - 2 - - - package body - package_bodies - - - - - - - \ No newline at end of file