From f4a9810cc1e71af1bddc2c66a73c9bcd702e39b9 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Wed, 5 Apr 2017 18:55:10 -0300 Subject: [PATCH 01/19] Initial travis configuration --- .travis.yml | 25 +++++++++++++++++++++++++ .travis/install_utplsql.sh | 27 +++++++++++++++++++++++++++ .travis/start_db.sh | 14 ++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .travis.yml create mode 100644 .travis/install_utplsql.sh create mode 100644 .travis/start_db.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8e1e8a5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: java + +services: + - docker + +jdk: + - oraclejdk8 + - oraclejdk7 + +env: + global: + - DOCKER_CFG=$HOME/.docker/config.json + - DOCKER_REPO="viniciusam/oracledb" + - UTPLSQL_VERSION="v3.0.0-beta" + - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" + matrix: + - ORACLE_VERSION="11g-xe-r2" CONNECTION_STR="127.0.0.1:1521/XE" DOCKER_OPTIONS="--shm-size=1g" + +cache: + directories: + - $DOCKER_CFG + +install: + - bash .travis/start_db.sh + - bash .travis/install_utplsql.sh diff --git a/.travis/install_utplsql.sh b/.travis/install_utplsql.sh new file mode 100644 index 0000000..0791f0e --- /dev/null +++ b/.travis/install_utplsql.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +# Download the specified version of utPLSQL. +curl -L -O "https://github.com/utPLSQL/utPLSQL/releases/download/$UTPLSQL_VERSION/$UTPLSQL_FILE.tar.gz" + +# Create a temporary install script. +cat > install.sh.tmp < Date: Wed, 5 Apr 2017 19:05:30 -0300 Subject: [PATCH 02/19] Fix docker cfg cache dir --- .travis.yml | 2 +- .travis/start_db.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e1e8a5..ac0345d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jdk: env: global: - - DOCKER_CFG=$HOME/.docker/config.json + - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" diff --git a/.travis/start_db.sh b/.travis/start_db.sh index 1644921..07b558d 100644 --- a/.travis/start_db.sh +++ b/.travis/start_db.sh @@ -2,7 +2,7 @@ set -e # If docker credentials are not cached, do the login. -if [ ! -f $DOCKER_CFG ]; then +if [ ! -f $DOCKER_CFG/config.json ]; then docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" else echo "Using docker login from cache..." From a67dcf53230ad152eb76adff14cf0d8708b1f804 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Wed, 5 Apr 2017 19:28:47 -0300 Subject: [PATCH 03/19] Fix install script --- .travis/install_utplsql.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis/install_utplsql.sh b/.travis/install_utplsql.sh index 0791f0e..933733a 100644 --- a/.travis/install_utplsql.sh +++ b/.travis/install_utplsql.sh @@ -8,11 +8,8 @@ curl -L -O "https://github.com/utPLSQL/utPLSQL/releases/download/$UTPLSQL_VERSIO cat > install.sh.tmp < Date: Thu, 6 Apr 2017 08:41:31 -0300 Subject: [PATCH 04/19] Overriding default test parameters --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index ac0345d..3e91bac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,3 +23,6 @@ cache: install: - bash .travis/start_db.sh - bash .travis/install_utplsql.sh + +script: + - test true From b0d21d77602565d0a19b26d2ecbb64239b3238c8 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Thu, 6 Apr 2017 15:34:03 -0300 Subject: [PATCH 05/19] Initial maven project config --- .gitignore | 18 +++++++ .idea/compiler.xml | 16 ++++++ .idea/encodings.xml | 6 +++ .idea/kotlinc.xml | 7 +++ .idea/misc.xml | 13 +++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ README.md | 6 +++ pom.xml | 52 ++++++++++++++++++++ src/main/java/io/github/utplsql/App.java | 13 +++++ src/test/java/io/github/utplsql/AppTest.java | 35 +++++++++++++ 11 files changed, 180 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/io/github/utplsql/App.java create mode 100644 src/test/java/io/github/utplsql/AppTest.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd7987b --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# IntelliJ +*.iml +.idea/workspace.xml +.idea/libraries/ + +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..aa058d8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b26911b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0cb3555 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5f7558b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4792c5b --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ + +##### Configuring the Oracle Maven Repository ##### +http://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9010 + +##### IntelliJ IDEA Maven Module ##### +https://www.jetbrains.com/help/idea/2017.1/maven.html diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..467edae --- /dev/null +++ b/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + io.github.utplsql + java-api + 1.0 + jar + + java-api + http://maven.apache.org + + + UTF-8 + + + + + com.oracle.jdbc + ojdbc7 + 12.1.0.2 + + + junit + junit + 4.12 + test + + + + + + maven.oracle.com + + true + + + false + + https://maven.oracle.com + default + + + + + + maven.oracle.com + https://maven.oracle.com + + + + diff --git a/src/main/java/io/github/utplsql/App.java b/src/main/java/io/github/utplsql/App.java new file mode 100644 index 0000000..0172f74 --- /dev/null +++ b/src/main/java/io/github/utplsql/App.java @@ -0,0 +1,13 @@ +package io.github.utplsql; + +/** + * Hello world! + * + */ +public class App { + + public static void main( String[] args ) { + System.out.println( "Hello World!" ); + } + +} diff --git a/src/test/java/io/github/utplsql/AppTest.java b/src/test/java/io/github/utplsql/AppTest.java new file mode 100644 index 0000000..5c989da --- /dev/null +++ b/src/test/java/io/github/utplsql/AppTest.java @@ -0,0 +1,35 @@ +package io.github.utplsql; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest extends TestCase { + + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() { + assertTrue( true ); + } + +} From d86079ede62e4ce773e33909c061cd74fb8a9d86 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Thu, 6 Apr 2017 15:37:39 -0300 Subject: [PATCH 06/19] Using default test cmd --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e91bac..898f8c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,4 @@ install: - bash .travis/install_utplsql.sh script: - - test true + - mvn test -B From 0d4837acef7ba6ea0c92c88138a39baff9f2292b Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Thu, 6 Apr 2017 16:25:57 -0300 Subject: [PATCH 07/19] Added oracle maven server config --- .travis.yml | 1 + .travis/maven_cfg.sh | 14 ++++++++++ .travis/settings.tmpl.xml | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 .travis/maven_cfg.sh create mode 100644 .travis/settings.tmpl.xml diff --git a/.travis.yml b/.travis.yml index 898f8c1..fbd1686 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ cache: - $DOCKER_CFG install: + - bash .travis/maven_cfg.sh - bash .travis/start_db.sh - bash .travis/install_utplsql.sh diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh new file mode 100644 index 0000000..3df83c7 --- /dev/null +++ b/.travis/maven_cfg.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e +cd $(dirname $(readlink -f $0)) + +if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then + echo "Oracle OTN username/password not specified." +fi + +MAVEN_SETTINGS=$HOME/.m2/settings.xml + +# Copy the maven settings file to the right place, and set the username/password for oracle maven server. +cp settings.tmpl.xml $MAVEN_SETTINGS +sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS +sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $MAVEN_SETTINGS diff --git a/.travis/settings.tmpl.xml b/.travis/settings.tmpl.xml new file mode 100644 index 0000000..14e04fe --- /dev/null +++ b/.travis/settings.tmpl.xml @@ -0,0 +1,56 @@ + + + + + + + + + maven.oracle.com + ###USERNAME### + ###PASSWORD### + + + ANY + ANY + OAM 11g + + + + + + http.protocol.allow-circular-redirects + %b,true + + + + + + + + + + + + + + From 7676addf7fa7450e6a1de16bd40875f6fda20d1d Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Thu, 6 Apr 2017 17:01:46 -0300 Subject: [PATCH 08/19] Fix maven settings placeholder and added verbosity --- .travis/install_utplsql.sh | 2 +- .travis/maven_cfg.sh | 3 ++- .travis/settings.tmpl.xml | 4 ++-- .travis/start_db.sh | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis/install_utplsql.sh b/.travis/install_utplsql.sh index 933733a..6e7b5f3 100644 --- a/.travis/install_utplsql.sh +++ b/.travis/install_utplsql.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ev # Download the specified version of utPLSQL. curl -L -O "https://github.com/utPLSQL/utPLSQL/releases/download/$UTPLSQL_VERSION/$UTPLSQL_FILE.tar.gz" diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index 3df83c7..92d8cf0 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -1,9 +1,10 @@ #!/bin/bash -set -e +set -ev cd $(dirname $(readlink -f $0)) if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then echo "Oracle OTN username/password not specified." + exit 1 fi MAVEN_SETTINGS=$HOME/.m2/settings.xml diff --git a/.travis/settings.tmpl.xml b/.travis/settings.tmpl.xml index 14e04fe..a6f3060 100644 --- a/.travis/settings.tmpl.xml +++ b/.travis/settings.tmpl.xml @@ -26,8 +26,8 @@ under the License. maven.oracle.com - ###USERNAME### - ###PASSWORD### + ###ORACLE_OTN_USER### + ###ORACLE_OTN_PASSWORD### ANY diff --git a/.travis/start_db.sh b/.travis/start_db.sh index 07b558d..2367d64 100644 --- a/.travis/start_db.sh +++ b/.travis/start_db.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ev # If docker credentials are not cached, do the login. if [ ! -f $DOCKER_CFG/config.json ]; then From c0d27666b0ab51bc19de83b9a2161d72e22a0b3e Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 6 Apr 2017 19:51:55 -0300 Subject: [PATCH 09/19] Making test cmd use custom settings.xml --- .travis.yml | 3 ++- .travis/maven_cfg.sh | 2 -- .travis/settings.tmpl.xml | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fbd1686..8827526 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: global: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" + - MAVEN_SETTINGS=$HOME/.m2/settings.xml # TODO: Cache? - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" matrix: @@ -26,4 +27,4 @@ install: - bash .travis/install_utplsql.sh script: - - mvn test -B + - mvn --settings $MAVEN_SETTINGS test -B # TODO: Why is not working with settings on user folder? diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index 92d8cf0..e4d62f8 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -7,8 +7,6 @@ if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then exit 1 fi -MAVEN_SETTINGS=$HOME/.m2/settings.xml - # Copy the maven settings file to the right place, and set the username/password for oracle maven server. cp settings.tmpl.xml $MAVEN_SETTINGS sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS diff --git a/.travis/settings.tmpl.xml b/.travis/settings.tmpl.xml index a6f3060..14e04fe 100644 --- a/.travis/settings.tmpl.xml +++ b/.travis/settings.tmpl.xml @@ -26,8 +26,8 @@ under the License. maven.oracle.com - ###ORACLE_OTN_USER### - ###ORACLE_OTN_PASSWORD### + ###USERNAME### + ###PASSWORD### ANY From c31c681f140d1dc2c1e9665e57fe9123153344c1 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 6 Apr 2017 20:59:12 -0300 Subject: [PATCH 10/19] Trying to setup oracle maven credentials --- .gitignore | 1 - .idea/compiler.xml | 2 +- .travis.yml | 8 +++++--- pom.xml | 4 ++-- utPLSQL-java-api.iml | 23 +++++++++++++++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 utPLSQL-java-api.iml diff --git a/.gitignore b/.gitignore index cd7987b..bec7522 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # IntelliJ -*.iml .idea/workspace.xml .idea/libraries/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml index aa058d8..d16de85 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -10,7 +10,7 @@ - + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8827526..c1c24d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,15 @@ services: - docker jdk: - - oraclejdk8 - oraclejdk7 + # - oraclejdk8 env: global: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - - MAVEN_SETTINGS=$HOME/.m2/settings.xml # TODO: Cache? + - MAVEN_HOME=$HOME/.m2 + - MAVEN_SETTINGS=$HOME/settings.xml - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" matrix: @@ -20,6 +21,7 @@ env: cache: directories: - $DOCKER_CFG + - $MAVEN_HOME install: - bash .travis/maven_cfg.sh @@ -27,4 +29,4 @@ install: - bash .travis/install_utplsql.sh script: - - mvn --settings $MAVEN_SETTINGS test -B # TODO: Why is not working with settings on user folder? + - mvn --settings $MAVEN_SETTINGS test -B \ No newline at end of file diff --git a/pom.xml b/pom.xml index 467edae..ca96787 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,8 @@ 1.0 jar - java-api - http://maven.apache.org + utPLSQL-java-api + https://github.com/utPLSQL/utPLSQL-java-api UTF-8 diff --git a/utPLSQL-java-api.iml b/utPLSQL-java-api.iml new file mode 100644 index 0000000..ca51068 --- /dev/null +++ b/utPLSQL-java-api.iml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From e10900996423310c70f6f193a66df7efd24d6e42 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 6 Apr 2017 22:37:17 -0300 Subject: [PATCH 11/19] Trying settings.xml with env vars --- .travis.yml | 2 +- .travis/maven_cfg.sh | 6 ++--- .travis/settings.xml | 56 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .travis/settings.xml diff --git a/.travis.yml b/.travis.yml index c1c24d2..a083a1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - MAVEN_HOME=$HOME/.m2 - - MAVEN_SETTINGS=$HOME/settings.xml + - MAVEN_SETTINGS=.travis/settings.xml - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" matrix: diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index e4d62f8..29882a6 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -8,6 +8,6 @@ if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then fi # Copy the maven settings file to the right place, and set the username/password for oracle maven server. -cp settings.tmpl.xml $MAVEN_SETTINGS -sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS -sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $MAVEN_SETTINGS +# cp settings.tmpl.xml $MAVEN_SETTINGS +# sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS +# sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $MAVEN_SETTINGS diff --git a/.travis/settings.xml b/.travis/settings.xml new file mode 100644 index 0000000..98573db --- /dev/null +++ b/.travis/settings.xml @@ -0,0 +1,56 @@ + + + + + + + + + maven.oracle.com + ${env.ORACLE_OTN_USER} + ${env.ORACLE_OTN_PASSWORD} + + + ANY + ANY + OAM 11g + + + + + + http.protocol.allow-circular-redirects + %b,true + + + + + + + + + + + + + + From 228d3dc52787748aaf76a551623bce19be89784c Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 6 Apr 2017 23:00:04 -0300 Subject: [PATCH 12/19] Adding some debug --- .travis.yml | 5 +++-- .travis/maven_cfg.sh | 7 +++++++ .travis/settings.tmpl.xml | 5 ----- .travis/settings.xml | 5 ----- README.md | 1 + 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index a083a1d..facc76b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: required language: java services: @@ -25,8 +26,8 @@ cache: install: - bash .travis/maven_cfg.sh - - bash .travis/start_db.sh - - bash .travis/install_utplsql.sh + # - bash .travis/start_db.sh + # - bash .travis/install_utplsql.sh script: - mvn --settings $MAVEN_SETTINGS test -B \ No newline at end of file diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index 29882a6..d28ea28 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -11,3 +11,10 @@ fi # cp settings.tmpl.xml $MAVEN_SETTINGS # sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS # sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $MAVEN_SETTINGS + +echo $M2_HOME +echo $JAVA_HOME +ls -la $M2_HOME +ls -la $MAVEN_HOME + +sudo find / -type d -iname "maven" diff --git a/.travis/settings.tmpl.xml b/.travis/settings.tmpl.xml index 14e04fe..89204b6 100644 --- a/.travis/settings.tmpl.xml +++ b/.travis/settings.tmpl.xml @@ -48,9 +48,4 @@ under the License. - - - - - diff --git a/.travis/settings.xml b/.travis/settings.xml index 98573db..731ef52 100644 --- a/.travis/settings.xml +++ b/.travis/settings.xml @@ -48,9 +48,4 @@ under the License. - - - - - diff --git a/README.md b/README.md index 4792c5b..f288b78 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ##### Configuring the Oracle Maven Repository ##### http://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9010 +https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbc#pom ##### IntelliJ IDEA Maven Module ##### https://www.jetbrains.com/help/idea/2017.1/maven.html From 45c88d061b13d358bae5624aab0e4256c1f2f118 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Fri, 7 Apr 2017 14:22:43 -0300 Subject: [PATCH 13/19] Trying to use downloaded maven version --- .travis.yml | 5 ++--- .travis/maven_cfg.sh | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index facc76b..b0f6262 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,7 @@ env: global: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - - MAVEN_HOME=$HOME/.m2 - - MAVEN_SETTINGS=.travis/settings.xml + - MAVEN_HOME=$HOME/apache-maven - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" matrix: @@ -30,4 +29,4 @@ install: # - bash .travis/install_utplsql.sh script: - - mvn --settings $MAVEN_SETTINGS test -B \ No newline at end of file + - $MAVEN_HOME/bin/mvn test -B \ No newline at end of file diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index d28ea28..49c4507 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -2,19 +2,27 @@ set -ev cd $(dirname $(readlink -f $0)) +if [ -d $MAVEN_HOME ]; then + echo "Using cached maven install..." + $MAVEN_HOME/bin/mvn -v + exit 0 +fi + if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then echo "Oracle OTN username/password not specified." exit 1 fi -# Copy the maven settings file to the right place, and set the username/password for oracle maven server. -# cp settings.tmpl.xml $MAVEN_SETTINGS -# sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $MAVEN_SETTINGS -# sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $MAVEN_SETTINGS +# If not cached, download and install maven. +# Then create the settings file, with username/password for oracle server. +curl -L -O "http://mirror.nbtelecom.com.br/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" +tar -xzf apache-maven-3.3.9-bin.tar.gz +mv apache-maven-3.3.9 $MAVEN_HOME +rm apache-maven-3.3.9-bin.tar.gz -echo $M2_HOME -echo $JAVA_HOME -ls -la $M2_HOME -ls -la $MAVEN_HOME +settingsFile=$MAVEN_HOME/conf/settings.xml +cp settings.tmpl.xml $settingsFile +sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $settingsFile +sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $settingsFile -sudo find / -type d -iname "maven" +$MAVEN_HOME/bin/mvn -v From 9162ffac9bfc09ea4d5aff6aef9b6ba38a246c37 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Fri, 7 Apr 2017 14:49:48 -0300 Subject: [PATCH 14/19] Using http-wagon recommended by oracle --- .travis.yml | 8 +++++--- .travis/maven_cfg.sh | 28 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0f6262..6e1e18e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,8 @@ env: global: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - - MAVEN_HOME=$HOME/apache-maven + # - MAVEN_HOME=$HOME/apache-maven + - MAVEN_HOME=/usr/local/maven - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" matrix: @@ -21,7 +22,8 @@ env: cache: directories: - $DOCKER_CFG - - $MAVEN_HOME + - $HOME/.m2 + - $MAVEN_HOME/lib/ext install: - bash .travis/maven_cfg.sh @@ -29,4 +31,4 @@ install: # - bash .travis/install_utplsql.sh script: - - $MAVEN_HOME/bin/mvn test -B \ No newline at end of file + - mvn test -B \ No newline at end of file diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index 49c4507..bab265e 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -2,9 +2,10 @@ set -ev cd $(dirname $(readlink -f $0)) -if [ -d $MAVEN_HOME ]; then - echo "Using cached maven install..." - $MAVEN_HOME/bin/mvn -v +mavenSettings=$HOME/.m2/settings.xml + +if [ -d $mavenSettings ]; then + echo "Using cached maven user config..." exit 0 fi @@ -15,14 +16,17 @@ fi # If not cached, download and install maven. # Then create the settings file, with username/password for oracle server. -curl -L -O "http://mirror.nbtelecom.com.br/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" -tar -xzf apache-maven-3.3.9-bin.tar.gz -mv apache-maven-3.3.9 $MAVEN_HOME -rm apache-maven-3.3.9-bin.tar.gz +# curl -L -O "http://mirror.nbtelecom.com.br/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" +# tar -xzf apache-maven-3.3.9-bin.tar.gz +# mv apache-maven-3.3.9 $MAVEN_HOME +# rm apache-maven-3.3.9-bin.tar.gz + +curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar" +sudo mv wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ -settingsFile=$MAVEN_HOME/conf/settings.xml -cp settings.tmpl.xml $settingsFile -sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $settingsFile -sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $settingsFile +# MAVEN_CFG=$MAVEN_HOME/conf/settings.xml +cp settings.tmpl.xml $mavenSettings +sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $mavenSettings +sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $mavenSettings -$MAVEN_HOME/bin/mvn -v +# $MAVEN_HOME/bin/mvn -v From 6d3a9f88807d28db752660577c98e85d81cac52f Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Moreira Date: Fri, 7 Apr 2017 16:12:43 -0300 Subject: [PATCH 15/19] Code cleanup --- .travis.yml | 11 +++++------ .travis/maven_cfg.sh | 16 ++++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e1e18e..4267be6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,12 @@ services: jdk: - oraclejdk7 - # - oraclejdk8 + - oraclejdk8 env: global: - DOCKER_CFG=$HOME/.docker - DOCKER_REPO="viniciusam/oracledb" - # - MAVEN_HOME=$HOME/apache-maven - MAVEN_HOME=/usr/local/maven - UTPLSQL_VERSION="v3.0.0-beta" - UTPLSQL_FILE="utPLSQLv3.0.0.562-beta" @@ -23,12 +22,12 @@ cache: directories: - $DOCKER_CFG - $HOME/.m2 - - $MAVEN_HOME/lib/ext + - $MAVEN_HOME/lib/ext # Used to cache wagon-http lib. install: - bash .travis/maven_cfg.sh - # - bash .travis/start_db.sh - # - bash .travis/install_utplsql.sh + - bash .travis/start_db.sh + - bash .travis/install_utplsql.sh script: - - mvn test -B \ No newline at end of file + - mvn test -B diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh index bab265e..b4f7757 100644 --- a/.travis/maven_cfg.sh +++ b/.travis/maven_cfg.sh @@ -3,8 +3,9 @@ set -ev cd $(dirname $(readlink -f $0)) mavenSettings=$HOME/.m2/settings.xml +mavenCached=$HOME/.m2/.cached -if [ -d $mavenSettings ]; then +if [ -f $mavenCached ]; then echo "Using cached maven user config..." exit 0 fi @@ -14,19 +15,14 @@ if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then exit 1 fi -# If not cached, download and install maven. -# Then create the settings file, with username/password for oracle server. -# curl -L -O "http://mirror.nbtelecom.com.br/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" -# tar -xzf apache-maven-3.3.9-bin.tar.gz -# mv apache-maven-3.3.9 $MAVEN_HOME -# rm apache-maven-3.3.9-bin.tar.gz - +# Download wagon-http recommended by Oracle. +# On maven latest version this is not needed, but travis doesn't have it. curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar" sudo mv wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ -# MAVEN_CFG=$MAVEN_HOME/conf/settings.xml +# Create the settings file with oracle server config. cp settings.tmpl.xml $mavenSettings sed -i -e "s|###USERNAME###|$ORACLE_OTN_USER|g" $mavenSettings sed -i -e "s|###PASSWORD###|$ORACLE_OTN_PASSWORD|g" $mavenSettings -# $MAVEN_HOME/bin/mvn -v +touch $mavenCached From 1e25bc525e1339cb947ff6608f646ad6d8a6d534 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Sat, 8 Apr 2017 15:22:06 -0300 Subject: [PATCH 16/19] Removing IDE files --- .gitignore | 4 ++-- .idea/compiler.xml | 16 ---------------- .idea/encodings.xml | 6 ------ .idea/kotlinc.xml | 7 ------- .idea/misc.xml | 13 ------------- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ utPLSQL-java-api.iml | 23 ----------------------- 8 files changed, 2 insertions(+), 81 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/kotlinc.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 utPLSQL-java-api.iml diff --git a/.gitignore b/.gitignore index bec7522..2d0c11c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # IntelliJ -.idea/workspace.xml -.idea/libraries/ +*.iml +.idea/ # Maven target/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index d16de85..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index b26911b..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 1c24f9a..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0cb3555..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5f7558b..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/utPLSQL-java-api.iml b/utPLSQL-java-api.iml deleted file mode 100644 index ca51068..0000000 --- a/utPLSQL-java-api.iml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8ca4248650aba9a08ece6785519a7352104be553 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 13 Apr 2017 18:01:32 -0300 Subject: [PATCH 17/19] Api development startup --- pom.xml | 20 +++++++ src/main/java/io/github/utplsql/App.java | 13 ---- .../java/io/github/utplsql/OutputBuffer.java | 44 ++++++++++++++ .../java/io/github/utplsql/TestRunner.java | 45 ++++++++++++++ src/main/java/io/github/utplsql/UTPLSQL.java | 59 ++++++++++++++++++ .../io/github/utplsql/types/BaseReporter.java | 60 +++++++++++++++++++ .../io/github/utplsql/types/CustomTypes.java | 22 +++++++ .../utplsql/types/DocumentationReporter.java | 15 +++++ src/test/java/io/github/utplsql/AppTest.java | 35 ----------- .../io/github/utplsql/OutputBufferTest.java | 43 +++++++++++++ .../io/github/utplsql/TestRunnerTest.java | 40 +++++++++++++ .../io/github/utplsql/rules/DatabaseRule.java | 21 +++++++ 12 files changed, 369 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/io/github/utplsql/App.java create mode 100644 src/main/java/io/github/utplsql/OutputBuffer.java create mode 100644 src/main/java/io/github/utplsql/TestRunner.java create mode 100644 src/main/java/io/github/utplsql/UTPLSQL.java create mode 100644 src/main/java/io/github/utplsql/types/BaseReporter.java create mode 100644 src/main/java/io/github/utplsql/types/CustomTypes.java create mode 100644 src/main/java/io/github/utplsql/types/DocumentationReporter.java delete mode 100644 src/test/java/io/github/utplsql/AppTest.java create mode 100644 src/test/java/io/github/utplsql/OutputBufferTest.java create mode 100644 src/test/java/io/github/utplsql/TestRunnerTest.java create mode 100644 src/test/java/io/github/utplsql/rules/DatabaseRule.java diff --git a/pom.xml b/pom.xml index ca96787..b61d95e 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,8 @@ UTF-8 + 1.8 + 1.8 @@ -28,6 +30,24 @@ + + + + net.orfjackal.retrolambda + retrolambda-maven-plugin + 2.5.1 + + + + process-main + process-test + + + + + + + maven.oracle.com diff --git a/src/main/java/io/github/utplsql/App.java b/src/main/java/io/github/utplsql/App.java deleted file mode 100644 index 0172f74..0000000 --- a/src/main/java/io/github/utplsql/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.utplsql; - -/** - * Hello world! - * - */ -public class App { - - public static void main( String[] args ) { - System.out.println( "Hello World!" ); - } - -} diff --git a/src/main/java/io/github/utplsql/OutputBuffer.java b/src/main/java/io/github/utplsql/OutputBuffer.java new file mode 100644 index 0000000..817ba69 --- /dev/null +++ b/src/main/java/io/github/utplsql/OutputBuffer.java @@ -0,0 +1,44 @@ +package io.github.utplsql; + +import oracle.jdbc.OracleTypes; + +import java.sql.CallableStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Vinicius on 13/04/2017. + */ +public final class OutputBuffer { + + private OutputBuffer() {} + + public static List getAllLines(String reporterId) throws SQLException { + CallableStatement callableStatement = null; + ResultSet resultSet = null; + try { + callableStatement = UTPLSQL.getConnection() + .prepareCall("BEGIN :lines := ut_output_buffer.get_lines_cursor(:reporter_id); END;"); + + callableStatement.registerOutParameter(":lines", OracleTypes.CURSOR); + callableStatement.setString(":reporter_id", reporterId); + callableStatement.execute(); + + resultSet = (ResultSet) callableStatement.getObject(":lines"); + + List outputLines = new ArrayList<>(); + while (resultSet.next()) { + outputLines.add(resultSet.getString(0)); + } + return outputLines; + } finally { + if (resultSet != null) + resultSet.close(); + if (callableStatement != null) + callableStatement.close(); + } + } + +} diff --git a/src/main/java/io/github/utplsql/TestRunner.java b/src/main/java/io/github/utplsql/TestRunner.java new file mode 100644 index 0000000..c908379 --- /dev/null +++ b/src/main/java/io/github/utplsql/TestRunner.java @@ -0,0 +1,45 @@ +package io.github.utplsql; + +import io.github.utplsql.types.BaseReporter; + +import java.sql.CallableStatement; +import java.sql.SQLException; + +/** + * Created by Vinicius Avellar on 12/04/2017. + */ +public final class TestRunner { + + private TestRunner() {} + + public static void run() throws SQLException { + CallableStatement callableStatement = null; + try { + callableStatement = UTPLSQL.getConnection() + .prepareCall("BEGIN ut.run(); END;"); + callableStatement.execute(); + } finally { + if (callableStatement != null) + callableStatement.close(); + } + } + + public static void run(String path, BaseReporter reporter) throws SQLException { + if (reporter.getReporterId() == null || reporter.getReporterId().isEmpty()) { + reporter.setReporterId(UTPLSQL.newSysGuid()); + } + + CallableStatement callableStatement = null; + try { + callableStatement = UTPLSQL.getConnection() + .prepareCall("BEGIN ut.run(:path, :reporter); END;"); + callableStatement.setString(":path", path); + callableStatement.setObject(":reporter", reporter); + callableStatement.execute(); + } finally { + if (callableStatement != null) + callableStatement.close(); + } + } + +} diff --git a/src/main/java/io/github/utplsql/UTPLSQL.java b/src/main/java/io/github/utplsql/UTPLSQL.java new file mode 100644 index 0000000..89a8155 --- /dev/null +++ b/src/main/java/io/github/utplsql/UTPLSQL.java @@ -0,0 +1,59 @@ +package io.github.utplsql; + +import io.github.utplsql.types.DocumentationReporter; +import io.github.utplsql.types.CustomTypes; +import oracle.jdbc.OracleTypes; + +import java.sql.*; +import java.util.Map; + +/** + * Created by Vinicius Avellar on 12/04/2017. + */ +public final class UTPLSQL { + + private static Connection sConnection; + + private UTPLSQL() {} + + public static void init(String url, String user, String password) throws SQLException { + UTPLSQL.init(DriverManager.getConnection(url, user, password)); + } + + public static void init(Connection conn) throws SQLException { + sConnection = conn; + createTypeMap(); + } + + public static void close() { + if (sConnection != null) + try { sConnection.close(); } catch (SQLException ignored) {} + } + + protected static Connection getConnection() { + if (sConnection == null) + throw new RuntimeException("Connection not initialized."); + + return sConnection; + } + + public static String newSysGuid() throws SQLException { + CallableStatement callableStatement = null; + try { + callableStatement = sConnection.prepareCall("BEGIN :id := sys_guid(); END;"); + callableStatement.registerOutParameter(":id", OracleTypes.RAW); + callableStatement.executeUpdate(); + return callableStatement.getString(":id"); + } finally { + if (callableStatement != null) + callableStatement.close(); + } + } + + private static void createTypeMap() throws SQLException { + Map typeMap = sConnection.getTypeMap(); + typeMap.put(CustomTypes.UT_DOCUMENTATION_REPORTER.getName(), DocumentationReporter.class); + sConnection.setTypeMap(typeMap); + } + +} diff --git a/src/main/java/io/github/utplsql/types/BaseReporter.java b/src/main/java/io/github/utplsql/types/BaseReporter.java new file mode 100644 index 0000000..d2c1265 --- /dev/null +++ b/src/main/java/io/github/utplsql/types/BaseReporter.java @@ -0,0 +1,60 @@ +package io.github.utplsql.types; + +import java.sql.SQLData; +import java.sql.SQLException; +import java.sql.SQLInput; +import java.sql.SQLOutput; +import java.util.Calendar; + +/** + * Created by Vinicius on 13/04/2017. + */ +public abstract class BaseReporter implements SQLData { + + private String selfType; + private String reporterId; + private java.sql.Date startDate; + + public BaseReporter() { + startDate = new java.sql.Date(Calendar.getInstance().getTimeInMillis()); + } + + public String getSelfType() { + return this.selfType; + } + + public void setSelfType(String selfType) { + this.selfType = selfType; + } + + public String getReporterId() { + return this.reporterId; + } + + public void setReporterId(String reporterId) { + this.reporterId = reporterId; + } + + public java.sql.Date getStartDate() { + return this.startDate; + } + + public void setStartDate(java.sql.Date startDate) { + this.startDate = startDate; + } + + @Override + public void readSQL(SQLInput stream, String typeName) throws SQLException { + setSelfType(stream.readString()); + setReporterId(stream.readString()); + setStartDate(stream.readDate()); + } + + @Override + public void writeSQL(SQLOutput stream) throws SQLException { + stream.writeString(getSelfType()); + stream.writeString(getReporterId()); + stream.writeDate(getStartDate()); + } + +} diff --git a/src/main/java/io/github/utplsql/types/CustomTypes.java b/src/main/java/io/github/utplsql/types/CustomTypes.java new file mode 100644 index 0000000..787c92c --- /dev/null +++ b/src/main/java/io/github/utplsql/types/CustomTypes.java @@ -0,0 +1,22 @@ +package io.github.utplsql.types; + +/** + * Created by Vinicius on 13/04/2017. + * utPLSQL custom data types. + */ +public enum CustomTypes { + // Object names must be upper case. + UT_DOCUMENTATION_REPORTER("UT_DOCUMENTATION_REPORTER"), + UT_VARCHAF2_LIST("UT_VARCHAF2_LIST"); + + private String typeName; + + CustomTypes(String typeName) { + this.typeName = typeName; + } + + public String getName() { + return this.typeName; + } + +} diff --git a/src/main/java/io/github/utplsql/types/DocumentationReporter.java b/src/main/java/io/github/utplsql/types/DocumentationReporter.java new file mode 100644 index 0000000..72e1873 --- /dev/null +++ b/src/main/java/io/github/utplsql/types/DocumentationReporter.java @@ -0,0 +1,15 @@ +package io.github.utplsql.types; + +import java.sql.SQLException; + +/** + * Created by Vinicius on 13/04/2017. + */ +public class DocumentationReporter extends BaseReporter { + + @Override + public String getSQLTypeName() throws SQLException { + return CustomTypes.UT_DOCUMENTATION_REPORTER.getName(); + } + +} diff --git a/src/test/java/io/github/utplsql/AppTest.java b/src/test/java/io/github/utplsql/AppTest.java deleted file mode 100644 index 5c989da..0000000 --- a/src/test/java/io/github/utplsql/AppTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.utplsql; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest extends TestCase { - - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() { - assertTrue( true ); - } - -} diff --git a/src/test/java/io/github/utplsql/OutputBufferTest.java b/src/test/java/io/github/utplsql/OutputBufferTest.java new file mode 100644 index 0000000..f98a456 --- /dev/null +++ b/src/test/java/io/github/utplsql/OutputBufferTest.java @@ -0,0 +1,43 @@ +package io.github.utplsql; + +import io.github.utplsql.rules.DatabaseRule; +import io.github.utplsql.types.BaseReporter; +import io.github.utplsql.types.DocumentationReporter; +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + +/** + * Created by Vinicius on 13/04/2017. + */ +public class OutputBufferTest { + + @ClassRule + public static final DatabaseRule sInitialization = new DatabaseRule(); + + @Test + public void getLinesFromOutputBuffer() { + try { + Connection conn = UTPLSQL.getConnection(); + conn.setAutoCommit(false); + + BaseReporter reporter = new DocumentationReporter(); + reporter.setReporterId(UTPLSQL.newSysGuid()); + TestRunner.run("", reporter); + + List outputLines = OutputBuffer.getAllLines(reporter.getReporterId()); + for (int i = 0; i < outputLines.size(); i++) { + System.out.println(outputLines.get(0)); + } + + conn.commit(); + } catch (SQLException e) { + Assert.fail(e.getMessage()); + } + } + +} diff --git a/src/test/java/io/github/utplsql/TestRunnerTest.java b/src/test/java/io/github/utplsql/TestRunnerTest.java new file mode 100644 index 0000000..f507543 --- /dev/null +++ b/src/test/java/io/github/utplsql/TestRunnerTest.java @@ -0,0 +1,40 @@ +package io.github.utplsql; + +import io.github.utplsql.rules.DatabaseRule; +import io.github.utplsql.types.BaseReporter; +import io.github.utplsql.types.DocumentationReporter; +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Test; + +import java.sql.SQLException; + +/** + * Created by Vinicius on 13/04/2017. + */ +public class TestRunnerTest { + + @ClassRule + public static final DatabaseRule sInitialization = new DatabaseRule(); + + @Test + public void runWithoutParams() { + try { + TestRunner.run(); + } catch (SQLException e) { + Assert.fail(e.getMessage()); + } + } + + @Test + public void runWithDocumentationReporter() { + try { + BaseReporter reporter = new DocumentationReporter(); + TestRunner.run("", reporter); + Assert.assertNotNull(reporter.getReporterId()); + } catch (SQLException e) { + Assert.fail(e.getMessage()); + } + } + +} diff --git a/src/test/java/io/github/utplsql/rules/DatabaseRule.java b/src/test/java/io/github/utplsql/rules/DatabaseRule.java new file mode 100644 index 0000000..5476543 --- /dev/null +++ b/src/test/java/io/github/utplsql/rules/DatabaseRule.java @@ -0,0 +1,21 @@ +package io.github.utplsql.rules; + +import io.github.utplsql.UTPLSQL; +import org.junit.rules.ExternalResource; + +/** + * Created by Vinicius on 13/04/2017. + */ +public class DatabaseRule extends ExternalResource { + + @Override + protected void before() throws Throwable { + UTPLSQL.init("jdbc:oracle:thin:@docker:1521:xe", "app", "app"); + } + + @Override + protected void after() { + UTPLSQL.close(); + } + +} From b04f4be60d373e6e344292cdb882e88b16a0a17a Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Thu, 13 Apr 2017 22:07:27 -0300 Subject: [PATCH 18/19] Calling right function to run tests and typo fix --- src/main/java/io/github/utplsql/OutputBuffer.java | 10 +++++----- src/main/java/io/github/utplsql/TestRunner.java | 4 ++-- .../java/io/github/utplsql/types/CustomTypes.java | 2 +- src/test/java/io/github/utplsql/OutputBufferTest.java | 11 ++++------- .../java/io/github/utplsql/rules/DatabaseRule.java | 3 ++- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/github/utplsql/OutputBuffer.java b/src/main/java/io/github/utplsql/OutputBuffer.java index 817ba69..7345b4b 100644 --- a/src/main/java/io/github/utplsql/OutputBuffer.java +++ b/src/main/java/io/github/utplsql/OutputBuffer.java @@ -20,17 +20,17 @@ public static List getAllLines(String reporterId) throws SQLException { ResultSet resultSet = null; try { callableStatement = UTPLSQL.getConnection() - .prepareCall("BEGIN :lines := ut_output_buffer.get_lines_cursor(:reporter_id); END;"); + .prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;"); - callableStatement.registerOutParameter(":lines", OracleTypes.CURSOR); - callableStatement.setString(":reporter_id", reporterId); + callableStatement.registerOutParameter(1, OracleTypes.CURSOR); + callableStatement.setString(2, reporterId); callableStatement.execute(); - resultSet = (ResultSet) callableStatement.getObject(":lines"); + resultSet = (ResultSet) callableStatement.getObject(1); List outputLines = new ArrayList<>(); while (resultSet.next()) { - outputLines.add(resultSet.getString(0)); + outputLines.add(resultSet.getString("text")); } return outputLines; } finally { diff --git a/src/main/java/io/github/utplsql/TestRunner.java b/src/main/java/io/github/utplsql/TestRunner.java index c908379..d720e45 100644 --- a/src/main/java/io/github/utplsql/TestRunner.java +++ b/src/main/java/io/github/utplsql/TestRunner.java @@ -16,7 +16,7 @@ public static void run() throws SQLException { CallableStatement callableStatement = null; try { callableStatement = UTPLSQL.getConnection() - .prepareCall("BEGIN ut.run(); END;"); + .prepareCall("BEGIN ut_runner.run(); END;"); callableStatement.execute(); } finally { if (callableStatement != null) @@ -32,7 +32,7 @@ public static void run(String path, BaseReporter reporter) throws SQLException { CallableStatement callableStatement = null; try { callableStatement = UTPLSQL.getConnection() - .prepareCall("BEGIN ut.run(:path, :reporter); END;"); + .prepareCall("BEGIN ut_runner.run(:path, :reporter); END;"); callableStatement.setString(":path", path); callableStatement.setObject(":reporter", reporter); callableStatement.execute(); diff --git a/src/main/java/io/github/utplsql/types/CustomTypes.java b/src/main/java/io/github/utplsql/types/CustomTypes.java index 787c92c..22398dd 100644 --- a/src/main/java/io/github/utplsql/types/CustomTypes.java +++ b/src/main/java/io/github/utplsql/types/CustomTypes.java @@ -7,7 +7,7 @@ public enum CustomTypes { // Object names must be upper case. UT_DOCUMENTATION_REPORTER("UT_DOCUMENTATION_REPORTER"), - UT_VARCHAF2_LIST("UT_VARCHAF2_LIST"); + UT_VARCHAF2_LIST("UT_VARCHAR2_LIST"); private String typeName; diff --git a/src/test/java/io/github/utplsql/OutputBufferTest.java b/src/test/java/io/github/utplsql/OutputBufferTest.java index f98a456..0c09c06 100644 --- a/src/test/java/io/github/utplsql/OutputBufferTest.java +++ b/src/test/java/io/github/utplsql/OutputBufferTest.java @@ -7,7 +7,6 @@ import org.junit.ClassRule; import org.junit.Test; -import java.sql.Connection; import java.sql.SQLException; import java.util.List; @@ -22,19 +21,17 @@ public class OutputBufferTest { @Test public void getLinesFromOutputBuffer() { try { - Connection conn = UTPLSQL.getConnection(); - conn.setAutoCommit(false); - BaseReporter reporter = new DocumentationReporter(); reporter.setReporterId(UTPLSQL.newSysGuid()); TestRunner.run("", reporter); List outputLines = OutputBuffer.getAllLines(reporter.getReporterId()); + + // Debug + System.out.println("Reporter ID: " + reporter.getReporterId()); for (int i = 0; i < outputLines.size(); i++) { - System.out.println(outputLines.get(0)); + System.out.println(outputLines.get(i)); } - - conn.commit(); } catch (SQLException e) { Assert.fail(e.getMessage()); } diff --git a/src/test/java/io/github/utplsql/rules/DatabaseRule.java b/src/test/java/io/github/utplsql/rules/DatabaseRule.java index 5476543..71863a8 100644 --- a/src/test/java/io/github/utplsql/rules/DatabaseRule.java +++ b/src/test/java/io/github/utplsql/rules/DatabaseRule.java @@ -10,7 +10,8 @@ public class DatabaseRule extends ExternalResource { @Override protected void before() throws Throwable { - UTPLSQL.init("jdbc:oracle:thin:@docker:1521:xe", "app", "app"); + // TODO: Options file. + UTPLSQL.init("jdbc:oracle:thin:@127.0.0.1:1521:xe", "ut3", "ut3"); } @Override From 9811c23c8e384ec83de47595cebd0fc4dd015b13 Mon Sep 17 00:00:00 2001 From: Vinicius Avellar Date: Wed, 19 Apr 2017 20:16:34 -0300 Subject: [PATCH 19/19] Small api changes --- .travis.yml | 2 +- pom.xml | 34 +++++++------- .../java/io/github/utplsql/OutputBuffer.java | 44 +++++++++++++++++-- .../java/io/github/utplsql/TestRunner.java | 8 ++-- .../io/github/utplsql/OutputBufferTest.java | 43 +++++++++++++++--- .../io/github/utplsql/TestRunnerTest.java | 4 +- 6 files changed, 101 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4267be6..661f6b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: - docker jdk: - - oraclejdk7 +# - oraclejdk7 - oraclejdk8 env: diff --git a/pom.xml b/pom.xml index b61d95e..a300d87 100644 --- a/pom.xml +++ b/pom.xml @@ -30,23 +30,23 @@ - - - - net.orfjackal.retrolambda - retrolambda-maven-plugin - 2.5.1 - - - - process-main - process-test - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/main/java/io/github/utplsql/OutputBuffer.java b/src/main/java/io/github/utplsql/OutputBuffer.java index 7345b4b..1a2878b 100644 --- a/src/main/java/io/github/utplsql/OutputBuffer.java +++ b/src/main/java/io/github/utplsql/OutputBuffer.java @@ -3,6 +3,7 @@ import oracle.jdbc.OracleTypes; import java.sql.CallableStatement; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -11,11 +12,46 @@ /** * Created by Vinicius on 13/04/2017. */ -public final class OutputBuffer { +public class OutputBuffer { - private OutputBuffer() {} + private String reporterId; - public static List getAllLines(String reporterId) throws SQLException { + public OutputBuffer(String reporterId) { + this.reporterId = reporterId; + } + + public String getReporterId() { + return reporterId; + } + + public void setReporterId(String reporterId) { + this.reporterId = reporterId; + } + + public List getLines() throws SQLException { + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + try { + preparedStatement = UTPLSQL.getConnection() + .prepareStatement("SELECT * FROM TABLE(ut_output_buffer.get_lines(?, 1))"); + + preparedStatement.setString(1, getReporterId()); + resultSet = preparedStatement.executeQuery(); + + List outputLines = new ArrayList<>(); + while (resultSet.next()) { + outputLines.add(resultSet.getString(1)); + } + return outputLines; + } finally { + if (resultSet != null) + resultSet.close(); + if (preparedStatement != null) + preparedStatement.close(); + } + } + + public List getAllLines() throws SQLException { CallableStatement callableStatement = null; ResultSet resultSet = null; try { @@ -23,7 +59,7 @@ public static List getAllLines(String reporterId) throws SQLException { .prepareCall("BEGIN ? := ut_output_buffer.get_lines_cursor(?); END;"); callableStatement.registerOutParameter(1, OracleTypes.CURSOR); - callableStatement.setString(2, reporterId); + callableStatement.setString(2, getReporterId()); callableStatement.execute(); resultSet = (ResultSet) callableStatement.getObject(1); diff --git a/src/main/java/io/github/utplsql/TestRunner.java b/src/main/java/io/github/utplsql/TestRunner.java index d720e45..21d1601 100644 --- a/src/main/java/io/github/utplsql/TestRunner.java +++ b/src/main/java/io/github/utplsql/TestRunner.java @@ -8,11 +8,11 @@ /** * Created by Vinicius Avellar on 12/04/2017. */ -public final class TestRunner { +public class TestRunner { - private TestRunner() {} + public TestRunner() {} - public static void run() throws SQLException { + public void run() throws SQLException { CallableStatement callableStatement = null; try { callableStatement = UTPLSQL.getConnection() @@ -24,7 +24,7 @@ public static void run() throws SQLException { } } - public static void run(String path, BaseReporter reporter) throws SQLException { + public void run(String path, BaseReporter reporter) throws SQLException { if (reporter.getReporterId() == null || reporter.getReporterId().isEmpty()) { reporter.setReporterId(UTPLSQL.newSysGuid()); } diff --git a/src/test/java/io/github/utplsql/OutputBufferTest.java b/src/test/java/io/github/utplsql/OutputBufferTest.java index 0c09c06..1343f0e 100644 --- a/src/test/java/io/github/utplsql/OutputBufferTest.java +++ b/src/test/java/io/github/utplsql/OutputBufferTest.java @@ -18,17 +18,48 @@ public class OutputBufferTest { @ClassRule public static final DatabaseRule sInitialization = new DatabaseRule(); + private BaseReporter currentReporter = null; + + public BaseReporter createReporter() throws SQLException { + BaseReporter reporter = new DocumentationReporter(); + reporter.setReporterId(UTPLSQL.newSysGuid()); + System.out.println("Reporter ID: " + reporter.getReporterId()); + return reporter; + } + @Test public void getLinesFromOutputBuffer() { try { - BaseReporter reporter = new DocumentationReporter(); - reporter.setReporterId(UTPLSQL.newSysGuid()); - TestRunner.run("", reporter); + final BaseReporter reporter = createReporter(); +// new TestRunner().run("", reporter); + new Thread(() -> { + try { + new TestRunner().run("", reporter); + } catch (SQLException e) { + e.printStackTrace(); + } + }).start(); + + List outputLines = new OutputBuffer(reporter.getReporterId()) + .getLines(); + + for (int i = 0; i < outputLines.size(); i++) { + System.out.println(outputLines.get(i)); + } + } catch (SQLException e) { + Assert.fail(e.getMessage()); + } + } + + @Test + public void getAllLinesFromOutputBuffer() { + try { + final BaseReporter reporter = createReporter(); + new TestRunner().run("", reporter); - List outputLines = OutputBuffer.getAllLines(reporter.getReporterId()); + List outputLines = new OutputBuffer(reporter.getReporterId()) + .getAllLines(); - // Debug - System.out.println("Reporter ID: " + reporter.getReporterId()); for (int i = 0; i < outputLines.size(); i++) { System.out.println(outputLines.get(i)); } diff --git a/src/test/java/io/github/utplsql/TestRunnerTest.java b/src/test/java/io/github/utplsql/TestRunnerTest.java index f507543..fc63229 100644 --- a/src/test/java/io/github/utplsql/TestRunnerTest.java +++ b/src/test/java/io/github/utplsql/TestRunnerTest.java @@ -20,7 +20,7 @@ public class TestRunnerTest { @Test public void runWithoutParams() { try { - TestRunner.run(); + new TestRunner().run(); } catch (SQLException e) { Assert.fail(e.getMessage()); } @@ -30,7 +30,7 @@ public void runWithoutParams() { public void runWithDocumentationReporter() { try { BaseReporter reporter = new DocumentationReporter(); - TestRunner.run("", reporter); + new TestRunner().run("", reporter); Assert.assertNotNull(reporter.getReporterId()); } catch (SQLException e) { Assert.fail(e.getMessage());