From fa1d6fd36fb633be03777ea1d2cf8b4ec11c26d9 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Mon, 31 Oct 2016 12:50:43 -0700 Subject: [PATCH 01/28] updatign to remove jfrog --- pom.xml | 4 ++-- shippable.yml | 28 ---------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index 30ef6e5..4046c2f 100644 --- a/pom.xml +++ b/pom.xml @@ -13,13 +13,13 @@ ttrahan - + diff --git a/shippable.yml b/shippable.yml index 0a0d251..9a10231 100644 --- a/shippable.yml +++ b/shippable.yml @@ -3,35 +3,7 @@ language: java jdk: - oraclejdk8 -branches: - only: - - github-beta - -env: - global: - - secure: pTctULZoZ0Ejip41hbaQq9HpfHE/TAIrcWZlZ2yDSQ4FDK4TllXTAZe/A6nWf+0mZ4JKMxYQcNaum52xtFUAmfyg+mpqJksedfZPcLmyev8AqWunUS1DSDi2MZ0po+ou4uUUYE/7ewT42HXyVSi/Rvx6MWsNqzv5k/sTQEq79FGXgnJ91JzWi/Mp1YzA5jm/yvd02OepLcqBXSyYr9QFqlI0xUuLj6Asenp2rT8Yq4wLQOIyQbBCdxaBKbni+tM4QdbfJrCEClK/MB/X0rVymO9eOA1TzoqxszldDbaPXzsum0cbLpPwPP4Ix3R+jLQxvjQ3fC7OM/QgpS0bfLXfoQ== - build: ci: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - sed -i "s/{PASSWORD}/$PASSWORD/" .m2/settings.xml - mvn -q -B -s .m2/settings.xml -U clean cobertura:cobertura deploy - - docker build -t ttrahan/javahelloworld:$BRANCH.$BUILD_NUMBER . - - docker push ttrahan/javahelloworld:$BRANCH.$BUILD_NUMBER - -integrations: - hub: - - integrationName: ttrahan-dh - type: docker - - notifications: - - integrationName: trigger-javahello-pipeline - type: webhook - payload: - - versionName=$BRANCH.$BUILD_NUMBER - branches: - only: - - github-beta - on_success: always - on_failure: never - on_start: never From 9fb38705c48f29d9875dc292ed45cc5efd1b23ec Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 15:20:12 -0800 Subject: [PATCH 02/28] resetting jf --- pom.xml | 54 --------------------------------------------------- shippable.yml | 2 +- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/pom.xml b/pom.xml index 4046c2f..f641514 100644 --- a/pom.xml +++ b/pom.xml @@ -13,14 +13,6 @@ ttrahan - - junit @@ -55,12 +47,6 @@ org.springframework.boot spring-boot-starter-web 1.4.0.RELEASE - org.springframework.boot @@ -74,29 +60,6 @@ 1.4.0.RELEASE provided - - - @@ -127,23 +90,6 @@ - diff --git a/shippable.yml b/shippable.yml index 9a10231..8dc9f74 100644 --- a/shippable.yml +++ b/shippable.yml @@ -6,4 +6,4 @@ jdk: build: ci: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - mvn -q -B -s .m2/settings.xml -U clean cobertura:cobertura deploy + - mvn -B clean cobertura:cobertura deploy From a0ea1ed754e855d266050154521c42fb131f9a16 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 15:29:24 -0800 Subject: [PATCH 03/28] resetting jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 8dc9f74..ce859a6 100644 --- a/shippable.yml +++ b/shippable.yml @@ -6,4 +6,4 @@ jdk: build: ci: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - mvn -B clean cobertura:cobertura deploy + - mvn -B clean cobertura:cobertura install From 7ce5e3e8a7eec8b8fe259b0cdabe1bc060e86c28 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 15:30:52 -0800 Subject: [PATCH 04/28] resetting jf --- shippable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/shippable.yml b/shippable.yml index ce859a6..8278048 100644 --- a/shippable.yml +++ b/shippable.yml @@ -7,3 +7,4 @@ build: ci: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install + - ls -al $SHIPPABLE_BUILD_DIR/target From 4c48359edbe3e76efbda704f59b1e0d1958a49b1 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 16:20:56 -0800 Subject: [PATCH 05/28] pushing to jf --- .m2/settings.xml | 56 ------------------------------------------------ shippable.yml | 12 +++++++++++ 2 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 .m2/settings.xml diff --git a/.m2/settings.xml b/.m2/settings.xml deleted file mode 100644 index 051016a..0000000 --- a/.m2/settings.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - admin - {PASSWORD} - central - - - admin - {PASSWORD} - snapshots - - - - - - - - false - - central - libs-release - https://shipdemo.jfrog.io/shipdemo/libs-release - - - - snapshots - libs-snapshot - https://shipdemo.jfrog.io/shipdemo/libs-snapshot - - - - - - false - - central - plugins-release - https://shipdemo.jfrog.io/shipdemo/plugins-release - - - - snapshots - plugins-snapshot - https://shipdemo.jfrog.io/shipdemo/plugins-snapshot - - - artifactory - - - - artifactory - - diff --git a/shippable.yml b/shippable.yml index 8278048..8ea7953 100644 --- a/shippable.yml +++ b/shippable.yml @@ -4,7 +4,19 @@ jdk: - oraclejdk8 build: + pre_ci_boot: + image_name: drydock/u14 + image_tag: tip + pull: false + options: '--privileged=true --net=bridge' + ci: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target + - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war + +integrations: + hub: + - integrationName: avinci-jf + type: artifactory \ No newline at end of file From ee7cfeec62f43d61b9cafebc449faec24ff9b405 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 16:30:08 -0800 Subject: [PATCH 06/28] pushing to jf --- shippable.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/shippable.yml b/shippable.yml index 8ea7953..b8ec1b7 100644 --- a/shippable.yml +++ b/shippable.yml @@ -4,13 +4,8 @@ jdk: - oraclejdk8 build: - pre_ci_boot: - image_name: drydock/u14 - image_tag: tip - pull: false - options: '--privileged=true --net=bridge' - ci: + - curl -fL https://getcli.jfrog.io | sh - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target From 120eb002f7ae6da7f807199e3a98e07935e9c9d0 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 16:39:14 -0800 Subject: [PATCH 07/28] pushing to jf --- shippable.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index b8ec1b7..630232b 100644 --- a/shippable.yml +++ b/shippable.yml @@ -5,7 +5,9 @@ jdk: build: ci: - - curl -fL https://getcli.jfrog.io | sh + - wget -v https://api.bintray.com/content/jfrog/jfrog-cli-go/1.4.1/jfrog-cli-linux-amd64/jfrog?bt_package=jfrog-cli-linux-amd64 -O jfrog + - sudo chmod +x jfrog + - mv jfrog /usr/bin/jfrog - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target From c9eb06c16c1f06713b0ee84fa78829ff3905a53e Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 17:24:38 -0800 Subject: [PATCH 08/28] pushing to jf --- shippable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/shippable.yml b/shippable.yml index 630232b..724ad6f 100644 --- a/shippable.yml +++ b/shippable.yml @@ -8,6 +8,7 @@ build: - wget -v https://api.bintray.com/content/jfrog/jfrog-cli-go/1.4.1/jfrog-cli-linux-amd64/jfrog?bt_package=jfrog-cli-linux-amd64 -O jfrog - sudo chmod +x jfrog - mv jfrog /usr/bin/jfrog + - jfrog rt dl pages/data.json - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target From a9cda4a15020305b926bd6ed3894a93b5ee9670c Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 17:30:07 -0800 Subject: [PATCH 09/28] pushing to jf --- shippable.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shippable.yml b/shippable.yml index 724ad6f..6d7c6ca 100644 --- a/shippable.yml +++ b/shippable.yml @@ -4,10 +4,13 @@ jdk: - oraclejdk8 build: + pre_ci_boot: + image_name: drydock/u14 + image_tag: tip + pull: false + options: '--privileged=true --net=bridge' + ci: - - wget -v https://api.bintray.com/content/jfrog/jfrog-cli-go/1.4.1/jfrog-cli-linux-amd64/jfrog?bt_package=jfrog-cli-linux-amd64 -O jfrog - - sudo chmod +x jfrog - - mv jfrog /usr/bin/jfrog - jfrog rt dl pages/data.json - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install From 9a833d10387bc1157871c8004d592dfc4c185989 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 17:30:21 -0800 Subject: [PATCH 10/28] pushing to jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 6d7c6ca..47f3ab4 100644 --- a/shippable.yml +++ b/shippable.yml @@ -5,7 +5,7 @@ jdk: build: pre_ci_boot: - image_name: drydock/u14 + image_name: drydock/u14jav image_tag: tip pull: false options: '--privileged=true --net=bridge' From 23e30887084822687b8d08fcc5c9f2cad55d630b Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:02:48 -0800 Subject: [PATCH 11/28] pushing to jf --- shippable.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shippable.yml b/shippable.yml index 47f3ab4..508eacb 100644 --- a/shippable.yml +++ b/shippable.yml @@ -5,12 +5,16 @@ jdk: build: pre_ci_boot: - image_name: drydock/u14jav + image_name: drydock/u14 image_tag: tip pull: false options: '--privileged=true --net=bridge' ci: + - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3.3.9/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz + - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz + - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin + - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - jfrog rt dl pages/data.json - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - mvn -B clean cobertura:cobertura install @@ -20,4 +24,5 @@ build: integrations: hub: - integrationName: avinci-jf - type: artifactory \ No newline at end of file + type: artifactory + \ No newline at end of file From 3f299acd2257839ec0f95fd9931303801477737d Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:15:16 -0800 Subject: [PATCH 12/28] pushing to jf --- shippable.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shippable.yml b/shippable.yml index 508eacb..8268a4f 100644 --- a/shippable.yml +++ b/shippable.yml @@ -11,7 +11,7 @@ build: options: '--privileged=true --net=bridge' ci: - - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3.3.9/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz + - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3.3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc @@ -25,4 +25,3 @@ integrations: hub: - integrationName: avinci-jf type: artifactory - \ No newline at end of file From d0072ace5ad92089add2d019f46c410e2956b561 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:24:18 -0800 Subject: [PATCH 13/28] pushing to jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 8268a4f..b6e049e 100644 --- a/shippable.yml +++ b/shippable.yml @@ -11,7 +11,7 @@ build: options: '--privileged=true --net=bridge' ci: - - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3.3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz + - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc From 775b1181b1ced9677d557d1d382aba383deb2c5d Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:26:01 -0800 Subject: [PATCH 14/28] pushing to jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index b6e049e..63b5706 100644 --- a/shippable.yml +++ b/shippable.yml @@ -17,7 +17,7 @@ build: - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - jfrog rt dl pages/data.json - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - mvn -B clean cobertura:cobertura install + - /usr/bin/mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war From 71d5e54bd18032ba00ca896ddc0c4678178e5952 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:27:33 -0800 Subject: [PATCH 15/28] pushing to jf --- shippable.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shippable.yml b/shippable.yml index 63b5706..4979f84 100644 --- a/shippable.yml +++ b/shippable.yml @@ -15,9 +15,9 @@ build: - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - - jfrog rt dl pages/data.json - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - /usr/bin/mvn -B clean cobertura:cobertura install + - . .bashrc + - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war From 9d8498ab38909a8bf8eb5aa8888792f25b47ea7b Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:48:56 -0800 Subject: [PATCH 16/28] pushing to jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 4979f84..dcecb2f 100644 --- a/shippable.yml +++ b/shippable.yml @@ -16,7 +16,7 @@ build: - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - . .bashrc + - . $HOME/.bashrc - mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war From ab6987dee84f047e230a98dec133378dac82e540 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:50:44 -0800 Subject: [PATCH 17/28] pushing to jf --- shippable.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shippable.yml b/shippable.yml index dcecb2f..4cffa85 100644 --- a/shippable.yml +++ b/shippable.yml @@ -16,8 +16,7 @@ build: - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - . $HOME/.bashrc - - mvn -B clean cobertura:cobertura install + - /usr/local/apache-maven-$3.3.9/bin/mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war From 8546ea95f7edcc60d88c541edce606cd9bef7806 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 18:52:07 -0800 Subject: [PATCH 18/28] pushing to jf --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 4cffa85..684f6cb 100644 --- a/shippable.yml +++ b/shippable.yml @@ -16,7 +16,7 @@ build: - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - /usr/local/apache-maven-$3.3.9/bin/mvn -B clean cobertura:cobertura install + - /usr/local/apache-maven-3.3.9/bin/mvn -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war From 2fc123a7eb3896ce25512e5cc8d91982c22d9765 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 19:01:47 -0800 Subject: [PATCH 19/28] adding trigger --- shippable.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 684f6cb..85e6d90 100644 --- a/shippable.yml +++ b/shippable.yml @@ -16,7 +16,7 @@ build: - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - - /usr/local/apache-maven-3.3.9/bin/mvn -B clean cobertura:cobertura install + - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war @@ -24,3 +24,10 @@ integrations: hub: - integrationName: avinci-jf type: artifactory + + notifications: + - integrationName: demo-jar-trg + type: webhook + payload: + - versionName=$BUILD_NUMBER + on_success: always From 22e89008f0f9fa469feb933221ea51ff578c5bbf Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Wed, 21 Dec 2016 19:38:54 -0800 Subject: [PATCH 20/28] adding sample --- shippable.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 85e6d90..9e2d07e 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,13 +12,14 @@ build: ci: - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz + - wget http://138.197.80.53:8080/docs/appdev/sample/sample.war - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war + - jfrog rt u $SHIPPABLE_BUILD_DIR/sample.war builds/sample.war integrations: hub: From e4a600324b261157102ceacf2598725d2dd92587 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Thu, 22 Dec 2016 05:01:38 -0800 Subject: [PATCH 21/28] resetting yml --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 9e2d07e..edcad37 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,10 +12,10 @@ build: ci: - sudo wget http://mirrors.ibiblio.org/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz - - wget http://138.197.80.53:8080/docs/appdev/sample/sample.war - sudo tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local && rm -f apache-maven-3.3.9-bin.tar.gz - ln -fs /usr/local/apache-maven-$3.3.9/bin/mvn /usr/bin - echo "export PATH=$PATH:/usr/local/apache-maven-3.3.9/bin" >> $HOME/.bashrc + - wget http://138.197.80.53:8080/docs/appdev/sample/sample.war - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target From 6dca208d78d8d6ed6917a4e23feaf8aefdfcd4ff Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Thu, 22 Dec 2016 06:47:20 -0800 Subject: [PATCH 22/28] removing docker refs --- Dockerfile | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 58808f4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM tomcat:8.0.20-jre8 - -RUN rm -rf /usr/local/tomcat/webapps/* - -COPY $SHIPPABLE_BUILD_DIR/target/HelloWorld.war /usr/local/tomcat/webapps/HelloWorld.war - -# COPY $SHIPPABLE_BUILD_DIR/target/sample.war /usr/local/tomcat/webapps/sample.war From fb484b0d1f46e472cf5bb1f7b2966191fd4efb81 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Thu, 22 Dec 2016 08:32:50 -0800 Subject: [PATCH 23/28] initial trigger --- shippable.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shippable.yml b/shippable.yml index edcad37..c03c0e5 100644 --- a/shippable.yml +++ b/shippable.yml @@ -32,3 +32,6 @@ integrations: payload: - versionName=$BUILD_NUMBER on_success: always + + + From ec7df3f5009c426ee4d765874629dc8436ad3cf5 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Tue, 3 Jan 2017 13:19:26 -0800 Subject: [PATCH 24/28] trying out main war --- shippable.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shippable.yml b/shippable.yml index c03c0e5..1b68478 100644 --- a/shippable.yml +++ b/shippable.yml @@ -20,6 +20,7 @@ build: - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - jfrog rt u $SHIPPABLE_BUILD_DIR/sample.war builds/sample.war + - ls $SHIPPABLE_BUILD_DIR/target integrations: hub: @@ -32,6 +33,3 @@ integrations: payload: - versionName=$BUILD_NUMBER on_success: always - - - From e0e68aa8538ebfa0f7845b445b142dc23fe4b866 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Thu, 5 Jan 2017 15:44:09 -0800 Subject: [PATCH 25/28] adding HelloWorld --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 1b68478..2433b8f 100644 --- a/shippable.yml +++ b/shippable.yml @@ -19,7 +19,7 @@ build: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - - jfrog rt u $SHIPPABLE_BUILD_DIR/sample.war builds/sample.war + - jfrog rt u $SHIPPABLE_BUILD_DIR/HelloWorld.war builds/HelloWorld.war - ls $SHIPPABLE_BUILD_DIR/target integrations: From f5e49588215627060b721ff3a03ec80fc2357b91 Mon Sep 17 00:00:00 2001 From: Avi Cavale Date: Thu, 5 Jan 2017 15:53:33 -0800 Subject: [PATCH 26/28] adding HelloWorld --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 2433b8f..442ae21 100644 --- a/shippable.yml +++ b/shippable.yml @@ -19,7 +19,7 @@ build: - mkdir -p shippable/testresults && mkdir -p shippable/codecoverage - /usr/local/apache-maven-3.3.9/bin/mvn -q -B clean cobertura:cobertura install - ls -al $SHIPPABLE_BUILD_DIR/target - - jfrog rt u $SHIPPABLE_BUILD_DIR/HelloWorld.war builds/HelloWorld.war + - jfrog rt u $SHIPPABLE_BUILD_DIR/target/HelloWorld.war builds/HelloWorld.war - ls $SHIPPABLE_BUILD_DIR/target integrations: From 84af2ce9c09bbedd7aa9b09f0d158a1d180acb8c Mon Sep 17 00:00:00 2001 From: Richard Meserve Date: Fri, 27 Jan 2017 10:51:42 -0500 Subject: [PATCH 27/28] Created an API that can GET, PUT, and POST user defined properties. Created an index view that displays a greeting and a first and last name. Wrote unit tests for code coverage. --- .gitignore | 2 +- pom.xml | 108 +++++++++----- .../controller/HelloWorldController.java | 30 ---- .../controller/PropertiesController.java | 137 ++++++++++++++++++ .../model/PropertiesSerializer.java | 22 +++ .../properties/model/PropertiesVessel.java | 68 +++++++++ .../properties/model/PropertySerializer.java | 18 +++ .../webapp/WEB-INF/dispatcher-servlet.xml | 31 +++- src/main/webapp/WEB-INF/views/helloworld.jsp | 15 -- src/main/webapp/WEB-INF/views/index.jsp | 27 ++++ src/main/webapp/WEB-INF/web.xml | 49 +++---- src/main/webapp/index.jsp | 28 ++-- src/test/java/ControllerTest.java | 84 ----------- src/test/java/PropertiesControllerTest.java | 137 ++++++++++++++++++ ...l => PropertiesControllerTest-context.xml} | 2 +- 15 files changed, 547 insertions(+), 211 deletions(-) delete mode 100644 src/main/java/com/shipfmrsamplejava/helloworld/controller/HelloWorldController.java create mode 100644 src/main/java/com/shippable/properties/controller/PropertiesController.java create mode 100644 src/main/java/com/shippable/properties/model/PropertiesSerializer.java create mode 100644 src/main/java/com/shippable/properties/model/PropertiesVessel.java create mode 100644 src/main/java/com/shippable/properties/model/PropertySerializer.java delete mode 100644 src/main/webapp/WEB-INF/views/helloworld.jsp create mode 100644 src/main/webapp/WEB-INF/views/index.jsp delete mode 100644 src/test/java/ControllerTest.java create mode 100644 src/test/java/PropertiesControllerTest.java rename src/test/resources/{ControllerTest-context.xml => PropertiesControllerTest-context.xml} (72%) diff --git a/.gitignore b/.gitignore index 11ea0a7..9640be3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ target/ # misc local-test.sh mvncolor.sh -shippable/ +/shippable/ diff --git a/pom.xml b/pom.xml index f641514..6372acc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,11 @@ 4.0.0 - com.shipfmrsamplejava - helloworld + com.shippable + properties war 0.0.1-SNAPSHOT - HelloWorld Maven Webapp + Shippable Properties Maven Webapp http://maven.apache.org @@ -39,32 +39,72 @@ ${spring.version} - org.springframework - spring-test - 4.0.5.RELEASE + org.springframework + spring-test + 4.0.5.RELEASE + + + org.springframework.boot + spring-boot-starter-web + 1.4.0.RELEASE - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-test - 1.4.0.RELEASE - + org.springframework.boot + spring-boot-starter-test + 1.4.0.RELEASE + - org.springframework.boot - spring-boot-starter-tomcat - 1.4.0.RELEASE - provided + com.fasterxml.jackson.core + jackson-core + 2.8.6 + + + com.fasterxml.jackson.core + jackson-databind + 2.8.6 + + + com.fasterxml.jackson.core + jackson-annotations + 2.8.6 + + + org.springframework.boot + spring-boot-starter-tomcat + 1.4.0.RELEASE + provided + - HelloWorld + Shippable-Properties + + org.jacoco + jacoco-maven-plugin + 0.7.8 + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + package + + report + + + + org.apache.maven.plugins maven-compiler-plugin @@ -75,21 +115,21 @@ - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 - true - shippable/testresults - - - - org.apache.maven.surefire - surefire-junit47 - 2.19.1 - - - + true + shippable/testresults + + + + org.apache.maven.surefire + surefire-junit47 + 2.19.1 + + + diff --git a/src/main/java/com/shipfmrsamplejava/helloworld/controller/HelloWorldController.java b/src/main/java/com/shipfmrsamplejava/helloworld/controller/HelloWorldController.java deleted file mode 100644 index b42df53..0000000 --- a/src/main/java/com/shipfmrsamplejava/helloworld/controller/HelloWorldController.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.shipfmrsamplejava.helloworld.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; - -@Controller -public class HelloWorldController { - String message = "Welcome to Spring MVC, "; - - @RequestMapping("/hello") - public ModelAndView showMessage( - @RequestParam(value = "name", required = false, defaultValue = "World") String name) { - System.out.println("in controller"); - - String environment = System.getenv("ENVIRONMENT"); - - ModelAndView mv = new ModelAndView("helloworld"); - mv.addObject("message", message); - mv.addObject("environment", environment); - if (name == "") { - mv.addObject("name", "World"); - } else { - mv.addObject("name", name); - } - return mv; - } -} diff --git a/src/main/java/com/shippable/properties/controller/PropertiesController.java b/src/main/java/com/shippable/properties/controller/PropertiesController.java new file mode 100644 index 0000000..55b1c4e --- /dev/null +++ b/src/main/java/com/shippable/properties/controller/PropertiesController.java @@ -0,0 +1,137 @@ +package com.shippable.properties.controller; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +import com.shippable.properties.model.PropertiesVessel; + +//@EnableWebMvc +@Controller +public class PropertiesController { + Map propertiesMap = new HashMap<>(); + Map namesMap = new HashMap<>(); + + @RequestMapping(value = "/", method = RequestMethod.GET) + public ModelAndView showRoot(HttpServletRequest request) { + return showIndex(request); + } + + private PropertiesVessel getNamesMapProperties(String remoteAddr) { + PropertiesVessel properties = namesMap.get(remoteAddr); + if(properties == null) { + System.out.println("Creating new names properties map for " + remoteAddr); + properties = new PropertiesVessel(); + namesMap.put(remoteAddr, properties); + } + return properties; + } + + private PropertiesVessel getPropertiesMapProperties(String remoteAddr) { + PropertiesVessel properties = propertiesMap.get(remoteAddr); + if(properties == null) { + System.out.println("Creating new properties map for " + remoteAddr); + properties = new PropertiesVessel(); + propertiesMap.put(remoteAddr, properties); + } + return properties; + } + + @RequestMapping(value = "/index", method = RequestMethod.GET) + public ModelAndView showIndex(HttpServletRequest request) { + + PropertiesVessel properties = getNamesMapProperties(request.getRemoteAddr()); + + PropertiesVessel.Property firstNameProperty = properties.getProperty("firstName"); + if(firstNameProperty.getValue() == null) { + properties.setProperty("firstName", "Unknown"); + } + + PropertiesVessel.Property lastNameProperty = properties.getProperty("lastName"); + if(lastNameProperty.getValue() == null) { + properties.setProperty("lastName", "Unknown"); + } + + ModelAndView mv = new ModelAndView("index"); + mv.addObject("firstName", properties.getProperty("firstName").getValue()); + mv.addObject("lastName", properties.getProperty("lastName").getValue()); + return mv; + } + + @RequestMapping(value ="/index", method = RequestMethod.POST) + public ModelAndView postIndex( + @RequestParam(required = false) String firstName, + @RequestParam(required = false) String lastName, + HttpServletRequest request) { + + PropertiesVessel properties = getNamesMapProperties(request.getRemoteAddr()); + + PropertiesVessel.Property firstNameProperty = properties.getProperty("firstName"); + if(firstNameProperty.getValue() == null) { + properties.setProperty("firstName", "Unknown"); + } + if(firstName != null) { + properties.setProperty("firstName", firstName); + } + + PropertiesVessel.Property lastNameProperty = properties.getProperty("lastName"); + if(lastNameProperty.getValue() == null) { + properties.setProperty("lastName", "Unknown"); + } + if(lastName != null) { + properties.setProperty("lastName", lastName); + } + + ModelAndView mv = new ModelAndView("index"); + mv.addObject("firstName", properties.getProperty("firstName").getValue()); + mv.addObject("lastName", properties.getProperty("lastName").getValue()); + return mv; + } + + @RequestMapping(value = "/properties.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody PropertiesVessel getProperties(HttpServletRequest request) { + PropertiesVessel properties = getPropertiesMapProperties(request.getRemoteAddr()); + + return properties; + } + + @RequestMapping(value = "/property", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody PropertiesVessel putProperty(@RequestParam("name") String propertyName, @RequestParam("value") String propertyValue, HttpServletRequest request) { + return setProperty(request.getRemoteAddr(), propertyName, propertyValue); + } + + @RequestMapping(value = "/property", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody PropertiesVessel postProperty(@RequestParam("name") String propertyName, @RequestParam("value") String propertyValue, HttpServletRequest request) { + return setProperty(request.getRemoteAddr(), propertyName, propertyValue); + } + + @RequestMapping(value = "/property", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody PropertiesVessel.Property getPropertyResponse(@RequestParam("name") String propertyName, HttpServletRequest request) { + return getProperty(request.getRemoteAddr(), propertyName); + } + + private PropertiesVessel.Property getProperty(String remoteAddr, String propertyName) { + PropertiesVessel properties = getPropertiesMapProperties(remoteAddr); + + return properties.getProperty(propertyName); + } + + private PropertiesVessel setProperty(String remoteAddr, String propertyName, String propertyValue) { + PropertiesVessel properties = getPropertiesMapProperties(remoteAddr); + + properties.setProperty("hostDateTime", LocalDateTime.now().toString()); + properties.setProperty(propertyName, propertyValue); + return properties; + } + +} diff --git a/src/main/java/com/shippable/properties/model/PropertiesSerializer.java b/src/main/java/com/shippable/properties/model/PropertiesSerializer.java new file mode 100644 index 0000000..e6a2784 --- /dev/null +++ b/src/main/java/com/shippable/properties/model/PropertiesSerializer.java @@ -0,0 +1,22 @@ +package com.shippable.properties.model; + +import java.io.IOException; +import java.util.Set; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.shippable.properties.model.PropertiesVessel.Property; + +public class PropertiesSerializer extends JsonSerializer> { + public void serialize(Set properties, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeStartObject(); + //jgen.writeObjectField("size", properties.size()); + for(Property property : properties) { + jgen.writeObjectField(property.getName(), property.getValue()); + } + jgen.writeEndObject(); + } +} diff --git a/src/main/java/com/shippable/properties/model/PropertiesVessel.java b/src/main/java/com/shippable/properties/model/PropertiesVessel.java new file mode 100644 index 0000000..06b5a5f --- /dev/null +++ b/src/main/java/com/shippable/properties/model/PropertiesVessel.java @@ -0,0 +1,68 @@ +package com.shippable.properties.model; + +import java.util.HashSet; +import java.util.Set; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +public class PropertiesVessel { + @JsonSerialize(using = PropertiesSerializer.class) + private Set properties = new HashSet<>(); + + public Set getProperties() { + return properties; + } + + public Property getProperty(String propertyToFind) { + for (Property property : properties) { + if (property.getName().equals(propertyToFind)) { + return property; + } + } + return new Property(propertyToFind, null); + } + + @JsonSerialize(using = PropertySerializer.class) + public static class Property implements Comparable { + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + private String name; + private String value; + + public Property(String name, String value) { + this.name = name; + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Property)) { + return false; + } + + return this.name.equals(((Property) o).getName()); + } + + @Override + public int compareTo(Property arg0) { + return this.name.compareTo(arg0.getName()); + } + + @Override + public int hashCode() { + return this.name.hashCode(); + } + } + + public void setProperty(String name, String value) { + Property property = new Property(name, value); + properties.remove(property); + properties.add(property); + } +} diff --git a/src/main/java/com/shippable/properties/model/PropertySerializer.java b/src/main/java/com/shippable/properties/model/PropertySerializer.java new file mode 100644 index 0000000..df23b24 --- /dev/null +++ b/src/main/java/com/shippable/properties/model/PropertySerializer.java @@ -0,0 +1,18 @@ +package com.shippable.properties.model; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.shippable.properties.model.PropertiesVessel.Property; + +public class PropertySerializer extends JsonSerializer { + public void serialize(Property property, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeObjectField(property.getName(), property.getValue()); + jgen.writeEndObject(); + } +} diff --git a/src/main/webapp/WEB-INF/dispatcher-servlet.xml b/src/main/webapp/WEB-INF/dispatcher-servlet.xml index 58abbbf..24b9b3c 100644 --- a/src/main/webapp/WEB-INF/dispatcher-servlet.xml +++ b/src/main/webapp/WEB-INF/dispatcher-servlet.xml @@ -1,14 +1,21 @@ - - +http://www.springframework.org/schema/context/spring-context-3.0.xsd +http://www.springframework.org/schema/mvc +http://www.springframework.org/schema/mvc/spring-mvc.xsd"> + + + + + + @@ -18,4 +25,20 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> .jsp + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/views/helloworld.jsp b/src/main/webapp/WEB-INF/views/helloworld.jsp deleted file mode 100644 index 0bb94fc..0000000 --- a/src/main/webapp/WEB-INF/views/helloworld.jsp +++ /dev/null @@ -1,15 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -Java - Spring 4 MVC -HelloWorld - - -
-

Hello World - ${environment}

-

${message}${name}!

-
- - diff --git a/src/main/webapp/WEB-INF/views/index.jsp b/src/main/webapp/WEB-INF/views/index.jsp new file mode 100644 index 0000000..a49336f --- /dev/null +++ b/src/main/webapp/WEB-INF/views/index.jsp @@ -0,0 +1,27 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Hello! + + +
+ +
+

Hello there ${firstName} ${lastName}!

+

+ +

+ <%-- submit --%> + +

+
+
+ + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index d65faee..257c44d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,29 +1,20 @@ - - - - - Archetype Created Web Application - - - dispatcher - org.springframework.web.servlet.DispatcherServlet - 1 - - - - dispatcher - / - - - - contextConfigLocation - /WEB-INF/dispatcher-servlet.xml - - - - org.springframework.web.context.ContextLoaderListener - - + + + Archetype Created Web Application + + dispatcher + org.springframework.web.servlet.DispatcherServlet + 1 + + + dispatcher + / + + + contextConfigLocation + /WEB-INF/dispatcher-servlet.xml + + + org.springframework.web.context.ContextLoaderListener + + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index ec09725..4e4aa0d 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -4,22 +4,24 @@ -Spring 4 MVC - HelloWorld Index Page +Hello! -
-

Hello World

-

- - -

- <%-- submit --%> -
- -
-

-
+
+
+

Hello there ${firstName} ${lastName}!

+

+ +

+ <%-- submit --%> + +

+
+
diff --git a/src/test/java/ControllerTest.java b/src/test/java/ControllerTest.java deleted file mode 100644 index 516f6f0..0000000 --- a/src/test/java/ControllerTest.java +++ /dev/null @@ -1,84 +0,0 @@ -import org.junit.Assert; -import org.junit.Test; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.http.MediaType; -import org.springframework.test.util.ReflectionTestUtils; -import com.shipfmrsamplejava.helloworld.controller.HelloWorldController; -import com.shipfmrsamplejava.helloworld.controller.HelloWorldController.*; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; - -// -// public class SimpleTestNameInput { -// -// @Test -// public void testNameInput() { -// HelloWorldController hello = new HelloWorldController(); -// ModelAndView result = hello.showMessage("Test Name"); -// Assert.assertEquals("Test Name", result.name); -// } -// -// @Test -// public void testNoNameInput() { -// HelloWorldController hello = new HelloWorldController(); -// ModelAndView result = hello.showMessage(""); -// Assert.assertEquals("World", result.name); -// } -// } - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -// @WebAppConfiguration -@SpringBootTest -public class ControllerTest { - - @Autowired - private HelloWorldController helloWorldController; - - @InjectMocks - HelloWorldController controller; - - MockMvc mockMvc; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mockMvc = MockMvcBuilders.standaloneSetup(controller) - .build(); - } - - @Test - public void testNameInput() throws Exception { - this.mockMvc.perform(get("/hello") - .param("name", "Tee") - .accept(MediaType.TEXT_HTML) - ) .andExpect(status().isOk()) - .andExpect(view().name("helloworld")) - .andExpect(model().attribute("name", "Tee")); - } - @Test - public void testNullNameInput() throws Exception { - this.mockMvc.perform(get("/hello") - .param("name", "") - .accept(MediaType.TEXT_HTML) - ) .andExpect(status().isOk()) - .andExpect(view().name("helloworld")) - .andExpect(model().attribute("name", "World")); - } -} diff --git a/src/test/java/PropertiesControllerTest.java b/src/test/java/PropertiesControllerTest.java new file mode 100644 index 0000000..1312a0f --- /dev/null +++ b/src/test/java/PropertiesControllerTest.java @@ -0,0 +1,137 @@ +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.servlet.view.InternalResourceViewResolver; + +import com.shippable.properties.controller.PropertiesController; +import com.shippable.properties.model.PropertiesVessel; + +import junit.framework.Assert; + +// +// public class SimpleTestNameInput { +// +// @Test +// public void testNameInput() { +// HelloWorldController hello = new HelloWorldController(); +// ModelAndView result = hello.showMessage("Test Name"); +// Assert.assertEquals("Test Name", result.name); +// } +// +// @Test +// public void testNoNameInput() { +// HelloWorldController hello = new HelloWorldController(); +// ModelAndView result = hello.showMessage(""); +// Assert.assertEquals("World", result.name); +// } +// } + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +// @WebAppConfiguration +@SpringBootTest +public class PropertiesControllerTest { + + @Autowired + private PropertiesController propertiesController; + + @InjectMocks + PropertiesController controller; + + MockMvc mockMvc; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); + viewResolver.setPrefix("/WEB-INF/jsp/view/"); + viewResolver.setSuffix(".jsp"); + + mockMvc = MockMvcBuilders.standaloneSetup(controller).setViewResolvers(viewResolver).build(); + } + + @Test + public void testRoot() throws Exception { + this.mockMvc.perform(get("/").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()) + .andExpect(view().name("index")); + } + + @Test + public void testGetIndex() throws Exception { + this.mockMvc.perform(get("/index").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()); + } + + @Test + public void testPropertiesMapSet() throws Exception { + this.mockMvc.perform(get("/index").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()); + this.mockMvc.perform(get("/index").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()); + } + + @Test + public void testPostIndex() throws Exception { + this.mockMvc.perform(post("/index").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()) + .andExpect(model().attribute("firstName", "Unknown")).andExpect(model().attribute("lastName", "Unknown")); + this.mockMvc.perform(post("/index").param("firstName", "testFirst").param("lastName", "testLast").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()) + .andExpect(model().attribute("firstName", "testFirst")).andExpect(model().attribute("lastName", "testLast")); + this.mockMvc.perform(post("/index").accept(MediaType.TEXT_HTML)).andExpect(status().isOk()) + .andExpect(model().attribute("firstName", "testFirst")).andExpect(model().attribute("lastName", "testLast")); + } + + @Test + public void testPutProperty() throws Exception { + this.mockMvc.perform(put("/property").param("name", "testProperty").param("value", "testValue").accept(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk());; + } + + @Test + public void testGetProperties() throws Exception { + this.mockMvc.perform(get("/properties.json").accept(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()); + } + + @Test + public void testSetProperty() throws Exception { + this.mockMvc.perform(post("/property").param("name", "testProperty").param("value", "testValue").accept(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()); + this.mockMvc.perform(get("/property").param("name", "testProperty").param("value", "testValue").accept(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()); + } + + @Test + public void testPropertyVessel() throws Exception { + PropertiesVessel pv = new PropertiesVessel(); + pv.setProperty("testName", "testValue"); + PropertiesVessel.Property p = pv.getProperty("testName"); + Assert.assertSame("testValue", p.getValue()); + } + + @Test + public void testPropertyVesselProperty() throws Exception { + PropertiesVessel.Property p1 = new PropertiesVessel.Property("testName", "testValue"); + PropertiesVessel.Property p2 = new PropertiesVessel.Property("testName", "testValue"); + PropertiesVessel.Property p3 = new PropertiesVessel.Property("testName2", "testValue"); + PropertiesVessel.Property p4 = new PropertiesVessel.Property("testName", "testValue2"); + + Assert.assertEquals(p1, p2); + Assert.assertNotSame(p1, p3); + Assert.assertNotSame(p1, p4); + Assert.assertEquals(p1.equals("string"), false); + Assert.assertEquals(p1.compareTo(p2), 0); + Assert.assertEquals(p1.compareTo(p3), -1); + Assert.assertEquals(p3.compareTo(p1), 1); + + } +} diff --git a/src/test/resources/ControllerTest-context.xml b/src/test/resources/PropertiesControllerTest-context.xml similarity index 72% rename from src/test/resources/ControllerTest-context.xml rename to src/test/resources/PropertiesControllerTest-context.xml index c33b942..d13abab 100644 --- a/src/test/resources/ControllerTest-context.xml +++ b/src/test/resources/PropertiesControllerTest-context.xml @@ -4,6 +4,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + From ccaedf1fba1eef46dd4d6d8ac2345c6920e20a75 Mon Sep 17 00:00:00 2001 From: Richard Meserve Date: Fri, 27 Jan 2017 10:53:15 -0500 Subject: [PATCH 28/28] no message --- src/main/webapp/WEB-INF/views/index.jsp | 2 +- src/main/webapp/index.jsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/index.jsp b/src/main/webapp/WEB-INF/views/index.jsp index a49336f..89bbbce 100644 --- a/src/main/webapp/WEB-INF/views/index.jsp +++ b/src/main/webapp/WEB-INF/views/index.jsp @@ -10,7 +10,7 @@
-

Hello there ${firstName} ${lastName}!

+

Hello, ${firstName} ${lastName}!

-

Hello there ${firstName} ${lastName}!

+

Hello, ${firstName} ${lastName}!