From 99f2d9a92ef2c371547b691ffe9528f18bd36a5f Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 14 Apr 2016 17:43:49 -0400 Subject: [PATCH 01/46] add test that uses stub message producer --- pom.xml | 7 +++++++ .../github/AnalyticsApplicationTests.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 48b6267..02301f0 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,13 @@ spring-boot-starter-test test + + + org.springframework.github + github-webhook-stub + 0.0.1-SNAPSHOT + test + diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 927fe60..54dcefd 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -2,9 +2,11 @@ import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.messaging.Sink; +import org.springframework.cloud.stream.test.stub.StubMessageProducer; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.MessageBuilder; @@ -21,10 +23,11 @@ public class AnalyticsApplicationTests { @Autowired private Sink sink; + @Autowired + private StubMessageProducer messageProducer; @Test - public void contextLoads() throws JsonProcessingException { - + public void testWithMarshalledPojo() throws JsonProcessingException { GithubData data = new GithubData(); data.setRepository("spring-framework"); data.setUsername("rossen"); @@ -32,9 +35,11 @@ public void contextLoads() throws JsonProcessingException { Message message = MessageBuilder.withPayload(json).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build(); this.sink.input().send(message); - } - + @Test + public void testWithStubData() { + messageProducer.produce("issue-created.json", MimeTypeUtils.APPLICATION_JSON); + } } From 13fdd1dbb1ce89183a36be8e86c05c2c36ffff34 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 20 Apr 2016 17:56:15 +0100 Subject: [PATCH 02/46] Test incoming v2 messages --- .../springframework/github/GithubData.java | 47 +++++++++++++------ .../github/AnalyticsApplicationTests.java | 10 ++-- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubData.java b/src/main/java/org/springframework/github/GithubData.java index c0e4ce6..e379032 100644 --- a/src/main/java/org/springframework/github/GithubData.java +++ b/src/main/java/org/springframework/github/GithubData.java @@ -17,24 +17,43 @@ public class GithubData { + private String username; - private String username; + private String repository; - private String repository; + private String type = "unknown"; - public String getUsername() { - return username; - } + private String action = "unknown"; - public void setUsername(String username) { - this.username = username; - } + public String getUsername() { + return this.username; + } - public String getRepository() { - return repository; - } + public void setUsername(String username) { + this.username = username; + } - public void setRepository(String repository) { - this.repository = repository; - } + public String getRepository() { + return this.repository; + } + + public void setRepository(String repository) { + this.repository = repository; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } } diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 54dcefd..59166b4 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -2,7 +2,6 @@ import org.junit.Test; import org.junit.runner.RunWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.messaging.Sink; @@ -38,8 +37,13 @@ public void testWithMarshalledPojo() throws JsonProcessingException { } @Test - public void testWithStubData() { - messageProducer.produce("issue-created.json", MimeTypeUtils.APPLICATION_JSON); + public void testWithV1StubData() { + this.messageProducer.produce("v1/issue-created.json", MimeTypeUtils.APPLICATION_JSON); + } + + @Test + public void testWithV2StubData() { + this.messageProducer.produce("v2/issue-created.json", MimeTypeUtils.APPLICATION_JSON); } } From 26a46e4086b0a91a7455a648164a89536152eb15 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 21 Apr 2016 09:31:29 +0100 Subject: [PATCH 03/46] Add new fields to metric store --- .../github/GithubDataListener.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index c69ba85..413bea5 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -28,30 +28,29 @@ @Component public class GithubDataListener { - - - @Autowired - private FieldValueCounterWriter fieldValueCounterWriter; - - @StreamListener(Sink.INPUT) - public void listen(GithubData data) { - processValue("repository", data.getRepository()); - processValue("username", data.getUsername()); - - } - - - protected void processValue(String counterName, Object value) { - if ((value instanceof Collection) || ObjectUtils.isArray(value)) { - Collection c = (value instanceof Collection) ? (Collection) value - : Arrays.asList(ObjectUtils.toObjectArray(value)); - for (Object val : c) { - this.fieldValueCounterWriter.increment(counterName, val.toString(), 1.0); - } - } - else if (value!=null) { - this.fieldValueCounterWriter.increment(counterName, value.toString(), 1.0); - } - } + @Autowired + private FieldValueCounterWriter fieldValueCounterWriter; + + @StreamListener(Sink.INPUT) + public void listen(GithubData data) { + processValue("repository", data.getRepository()); + processValue("username", data.getUsername()); + processValue("type", data.getType()); + processValue("action", data.getAction()); + + } + + protected void processValue(String counterName, Object value) { + if ((value instanceof Collection) || ObjectUtils.isArray(value)) { + Collection c = (value instanceof Collection) ? (Collection) value + : Arrays.asList(ObjectUtils.toObjectArray(value)); + for (Object val : c) { + this.fieldValueCounterWriter.increment(counterName, val.toString(), 1.0); + } + } + else if (value != null) { + this.fieldValueCounterWriter.increment(counterName, value.toString(), 1.0); + } + } } From 8cf6f987cb084c04cbfaf225d014ca846c3c9628 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 21 Apr 2016 10:35:55 +0100 Subject: [PATCH 04/46] Add spring.application.name --- src/main/resources/application.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f2dd8c7..5611408 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,5 @@ +spring.application.name: github-analytics server.port=8081 +# Not used at runtime but needed to validate the counter properties bean: fieldName=test spring.cloud.stream.bindings.input.destination=messages From 5df3ee7624bdda26cb377d65ed1fe33272ae3c62 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 27 Apr 2016 17:21:56 +0200 Subject: [PATCH 05/46] Added Accurest --- pom.xml | 15 ++++++----- .../github/AnalyticsApplication.java | 5 +++- .../github/GithubDataListener.java | 14 +++++++--- .../github/AnalyticsApplicationTests.java | 26 ++++++++++++++----- src/test/resources/application.yml | 2 ++ 5 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 src/test/resources/application.yml diff --git a/pom.xml b/pom.xml index 02301f0..2488d6e 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ org.springframework.cloud spring-cloud-starter-stream-rabbit - + org.springframework.cloud spring-cloud-stream-test-support @@ -50,13 +50,14 @@ - org.springframework.github - github-webhook-stub - 0.0.1-SNAPSHOT + io.codearte.accurest + stub-runner-messaging-stream test + 1.1.0-M1 + - + @@ -68,7 +69,7 @@ - + @@ -81,7 +82,7 @@ - + spring-snapshots diff --git a/src/main/java/org/springframework/github/AnalyticsApplication.java b/src/main/java/org/springframework/github/AnalyticsApplication.java index 4f8e157..05bacc4 100644 --- a/src/main/java/org/springframework/github/AnalyticsApplication.java +++ b/src/main/java/org/springframework/github/AnalyticsApplication.java @@ -2,11 +2,14 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.app.fieldvaluecounter.sink.FieldValueCounterSinkStoreConfiguration; +import org.springframework.cloud.stream.annotation.EnableBinding; +import org.springframework.cloud.stream.app.field.value.counter.sink.FieldValueCounterSinkStoreConfiguration; +import org.springframework.cloud.stream.messaging.Sink; import org.springframework.context.annotation.Import; @SpringBootApplication @Import(FieldValueCounterSinkStoreConfiguration.class) +@EnableBinding(Sink.class) public class AnalyticsApplication { public static void main(String[] args) { diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index 413bea5..7ca5088 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -15,9 +15,6 @@ */ package org.springframework.github; -import java.util.Arrays; -import java.util.Collection; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.app.metrics.FieldValueCounterWriter; @@ -25,11 +22,18 @@ import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + @Component public class GithubDataListener { @Autowired private FieldValueCounterWriter fieldValueCounterWriter; + Map counter = new HashMap<>(); + @StreamListener(Sink.INPUT) public void listen(GithubData data) { @@ -37,7 +41,10 @@ public void listen(GithubData data) { processValue("username", data.getUsername()); processValue("type", data.getType()); processValue("action", data.getAction()); + } + void clear() { + counter.clear(); } protected void processValue(String counterName, Object value) { @@ -51,6 +58,7 @@ protected void processValue(String counterName, Object value) { else if (value != null) { this.fieldValueCounterWriter.increment(counterName, value.toString(), 1.0); } + counter.put(counterName, value); } } diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 59166b4..89d79d1 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -1,19 +1,22 @@ package org.springframework.github; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.codearte.accurest.stubrunner.StubTrigger; +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.cloud.stream.test.stub.StubMessageProducer; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.MessageBuilder; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MimeTypeUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.hamcrest.Matchers.is; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = AnalyticsApplication.class) @@ -22,8 +25,13 @@ public class AnalyticsApplicationTests { @Autowired private Sink sink; - @Autowired - private StubMessageProducer messageProducer; + @Autowired StubTrigger stubTriggerer; + @Autowired GithubDataListener githubDataListener; + + @Before + public void setup() { + this.githubDataListener.clear(); + } @Test public void testWithMarshalledPojo() throws JsonProcessingException { @@ -38,12 +46,16 @@ public void testWithMarshalledPojo() throws JsonProcessingException { @Test public void testWithV1StubData() { - this.messageProducer.produce("v1/issue-created.json", MimeTypeUtils.APPLICATION_JSON); + this.stubTriggerer.trigger("issue_created_v1"); + + Assert.assertThat(this.githubDataListener.counter.isEmpty(), is(false)); } @Test public void testWithV2StubData() { - this.messageProducer.produce("v2/issue-created.json", MimeTypeUtils.APPLICATION_JSON); + this.stubTriggerer.trigger("issue_created_v2"); + + Assert.assertThat(this.githubDataListener.counter.isEmpty(), is(false)); } } diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 0000000..90146df --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,2 @@ +stubrunner.stubs.repository.root: https://repo.spring.io/snapshot +stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file From 87e5bfb1024f8a2186e5ab7944b826247f6cbf7f Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 27 Apr 2016 17:37:09 +0200 Subject: [PATCH 06/46] Added Distribution management --- pom.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pom.xml b/pom.xml index 2488d6e..fe3aa03 100644 --- a/pom.xml +++ b/pom.xml @@ -83,6 +83,26 @@ + + + + static.springframework.org + scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-security/rsa + + + + + + + + + repo.spring.io + Spring Snapshot Repository + https://repo.spring.io/libs-snapshot-local + + + + spring-snapshots From c3f071fc59ebff385906ac71e590d011bc5a34c6 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 22:35:09 +0200 Subject: [PATCH 07/46] Updating repository root --- src/test/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 90146df..7936d3b 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,2 +1,2 @@ -stubrunner.stubs.repository.root: https://repo.spring.io/snapshot +stubrunner.stubs.repository.root: https://repo.spring.io/libs-snapshot-local/ stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file From 5aad244ac22c913b49fa6f02175da818968ea4e9 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 22:38:17 +0200 Subject: [PATCH 08/46] Updating repository root --- src/test/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 7936d3b..52e20fc 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,2 +1,2 @@ -stubrunner.stubs.repository.root: https://repo.spring.io/libs-snapshot-local/ +stubrunner.stubs.repository.root: https://repo.spring.io/libs-snapshot-local stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file From 417e7f4cc075e0f9ff9dc3a0d7a9a503ed4b260c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 22:39:34 +0200 Subject: [PATCH 09/46] Updated accurest to M2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe3aa03..5a6f121 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ io.codearte.accurest stub-runner-messaging-stream test - 1.1.0-M1 + 1.1.0-M2 From 018b56a1b238d78b102c2be80afc443777dc5bf7 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 23:31:32 +0200 Subject: [PATCH 10/46] Updating repository root --- src/test/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 52e20fc..90146df 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,2 +1,2 @@ -stubrunner.stubs.repository.root: https://repo.spring.io/libs-snapshot-local +stubrunner.stubs.repository.root: https://repo.spring.io/snapshot stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file From 2a1424435b5db77e562db95f305c1ee852626976 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 23:33:50 +0200 Subject: [PATCH 11/46] Updating repository root --- src/test/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 90146df..b1792f1 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,2 +1,2 @@ -stubrunner.stubs.repository.root: https://repo.spring.io/snapshot +stubrunner.stubs.repository.root: https://repo.spring.io/snapshot/ stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file From 31a4aa2cc57620a606ce3a05c523c5aa42f9e425 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 28 Apr 2016 23:49:16 +0200 Subject: [PATCH 12/46] Updating repositories --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 5a6f121..12066e5 100644 --- a/pom.xml +++ b/pom.xml @@ -120,6 +120,14 @@ false + + spring-releases + Spring Releases + http://repo.spring.io/release + + false + + From 68d6bf18b3aa4e2a5fdd6b978fba3062e3a6e372 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 29 Apr 2016 09:50:43 +0200 Subject: [PATCH 13/46] Added Accurest Maven Plugin --- pom.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pom.xml b/pom.xml index 12066e5..0384f10 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ UTF-8 1.8 + 0.5.10 @@ -80,6 +81,37 @@ pl.project13.maven git-commit-id-plugin + + io.codearte.accurest + accurest-maven-plugin + ${accurest-plugin.version} + + + + run + + + org.springframework.github:github-webhook:stubs + + + + + + io.codearte.accurest + accurest-core + 1.1.0-M2 + + + com.toomuchcoding.jsonassert + jsonassert + 0.4.1 + + + + accurest + com.example.accurest.BaseClass + + From ba3d587fa4bba0ddf2ac29226515e01f5c24a7a7 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 29 Apr 2016 13:44:31 +0200 Subject: [PATCH 14/46] Bumped accurest to 1.1.0-M3 --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0384f10..f19ab6b 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,7 @@ UTF-8 1.8 0.5.10 + 1.1.0-M3 @@ -54,7 +55,7 @@ io.codearte.accurest stub-runner-messaging-stream test - 1.1.0-M2 + ${accurest.version} @@ -99,7 +100,7 @@ io.codearte.accurest accurest-core - 1.1.0-M2 + ${accurest.version} com.toomuchcoding.jsonassert From e1cf804b9ec1f682e95528424e9f8781a0f9c42d Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 17 May 2016 17:14:18 +0200 Subject: [PATCH 15/46] Bumping accurest to M6 --- pom.xml | 7 ++++--- src/test/resources/application.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index f19ab6b..16025c7 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.4.BUILD-SNAPSHOT + 1.3.5.RELEASE @@ -22,7 +22,7 @@ UTF-8 1.8 0.5.10 - 1.1.0-M3 + 1.1.0-M6 @@ -65,7 +65,7 @@ org.springframework.cloud spring-cloud-dependencies - Brixton.BUILD-SNAPSHOT + Brixton.RELEASE pom import @@ -109,6 +109,7 @@ + src/test/resources/accurest accurest com.example.accurest.BaseClass diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index b1792f1..48db9cb 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,2 +1,2 @@ stubrunner.stubs.repository.root: https://repo.spring.io/snapshot/ -stubrunner.stubs.ids: org.springframework.github:github-webhook:stubs \ No newline at end of file +stubrunner.stubs.ids: org.springframework.github:github-webhook:+:stubs \ No newline at end of file From 8c4685be2cfaad442d86028da3d975e53b7c8d6b Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 15 Jun 2016 17:03:38 +0200 Subject: [PATCH 16/46] Updated the props --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5611408..2ea5760 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ spring.application.name: github-analytics server.port=8081 # Not used at runtime but needed to validate the counter properties bean: -fieldName=test +field-value-counter.fieldName=test spring.cloud.stream.bindings.input.destination=messages From 6a9f7a129062b9a16283a69e7ecdfaa8ce519731 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 20 Jun 2016 11:10:41 +0200 Subject: [PATCH 17/46] Fixed wrong import --- .../springframework/github/GithubDataListener.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index 7ca5088..feddf18 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -15,18 +15,18 @@ */ package org.springframework.github; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.springframework.analytics.metrics.FieldValueCounterWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; -import org.springframework.cloud.stream.app.metrics.FieldValueCounterWriter; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - @Component public class GithubDataListener { From 8906a506be1c1a07b529ec8b5e469b1e2242002c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 1 Sep 2016 13:05:06 +0200 Subject: [PATCH 18/46] Upgraded boot to 1.4, BOM to Camden.SNAPSHOT --- pom.xml | 92 ++++++------------- .../github/AnalyticsApplication.java | 9 +- .../github/AnalyticsApplicationTests.java | 26 +++--- src/test/resources/application.yml | 2 - 4 files changed, 49 insertions(+), 80 deletions(-) delete mode 100644 src/test/resources/application.yml diff --git a/pom.xml b/pom.xml index 16025c7..a7a035d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,58 +14,58 @@ org.springframework.boot spring-boot-starter-parent - 1.3.5.RELEASE + 1.4.0.RELEASE UTF-8 1.8 - 0.5.10 - 1.1.0-M6 + 1.0.0.BUILD-SNAPSHOT + Camden.BUILD-SNAPSHOT - - org.springframework.cloud.stream.app - spring-cloud-starter-stream-sink-field-value-counter - 1.0.0.BUILD-SNAPSHOT + org.springframework.analytics + spring-analytics + 1.0.1.BUILD-SNAPSHOT - - org.springframework.cloud spring-cloud-starter-stream-rabbit - org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-starter-contract-stub-runner test - - org.springframework.boot - spring-boot-starter-test + org.springframework.cloud + spring-cloud-contract-wiremock test - - io.codearte.accurest - stub-runner-messaging-stream + org.springframework.cloud + spring-cloud-stream-test-support test - ${accurest.version} + + org.springframework.cloud + spring-cloud-contract-dependencies + ${spring-cloud-contract.version} + pom + import + org.springframework.cloud spring-cloud-dependencies - Brixton.RELEASE + ${spring-cloud-bom.version} pom import @@ -82,59 +82,15 @@ pl.project13.maven git-commit-id-plugin - - io.codearte.accurest - accurest-maven-plugin - ${accurest-plugin.version} - - - - run - - - org.springframework.github:github-webhook:stubs - - - - - - io.codearte.accurest - accurest-core - ${accurest.version} - - - com.toomuchcoding.jsonassert - jsonassert - 0.4.1 - - - - src/test/resources/accurest - accurest - com.example.accurest.BaseClass - - - - - static.springframework.org - scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-security/rsa - - - - - - - repo.spring.io Spring Snapshot Repository https://repo.spring.io/libs-snapshot-local - @@ -157,7 +113,7 @@ spring-releases Spring Releases - http://repo.spring.io/release + https://repo.spring.io/release false @@ -180,6 +136,14 @@ false + + spring-releases + Spring Releases + https://repo.spring.io/release + + false + + diff --git a/src/main/java/org/springframework/github/AnalyticsApplication.java b/src/main/java/org/springframework/github/AnalyticsApplication.java index 05bacc4..525a6ed 100644 --- a/src/main/java/org/springframework/github/AnalyticsApplication.java +++ b/src/main/java/org/springframework/github/AnalyticsApplication.java @@ -1,18 +1,21 @@ package org.springframework.github; +import org.springframework.analytics.metrics.memory.InMemoryFieldValueCounterRepository; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.app.field.value.counter.sink.FieldValueCounterSinkStoreConfiguration; import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Bean; @SpringBootApplication -@Import(FieldValueCounterSinkStoreConfiguration.class) @EnableBinding(Sink.class) public class AnalyticsApplication { public static void main(String[] args) { SpringApplication.run(AnalyticsApplication.class, args); } + + @Bean InMemoryFieldValueCounterRepository repository() { + return new InMemoryFieldValueCounterRepository(); + } } diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 89d79d1..d43ff10 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -1,14 +1,12 @@ package org.springframework.github; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.codearte.accurest.stubrunner.StubTrigger; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.contract.stubrunner.StubTrigger; +import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; @@ -16,16 +14,22 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MimeTypeUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = AnalyticsApplication.class) +@SpringBootTest(classes = AnalyticsApplication.class) +@AutoConfigureStubRunner(repositoryRoot = "https://repo.spring.io/snapshot/", + ids = {"org.springframework.github:github-webhook"}) public class AnalyticsApplicationTests { @Autowired private Sink sink; - @Autowired StubTrigger stubTriggerer; + @Autowired StubTrigger stubTrigger; @Autowired GithubDataListener githubDataListener; @Before @@ -46,16 +50,16 @@ public void testWithMarshalledPojo() throws JsonProcessingException { @Test public void testWithV1StubData() { - this.stubTriggerer.trigger("issue_created_v1"); + this.stubTrigger.trigger("issue_created_v1"); - Assert.assertThat(this.githubDataListener.counter.isEmpty(), is(false)); + assertThat(this.githubDataListener.counter.isEmpty(), is(false)); } @Test public void testWithV2StubData() { - this.stubTriggerer.trigger("issue_created_v2"); + this.stubTrigger.trigger("issue_created_v2"); - Assert.assertThat(this.githubDataListener.counter.isEmpty(), is(false)); + assertThat(this.githubDataListener.counter.isEmpty(), is(false)); } } diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml deleted file mode 100644 index 48db9cb..0000000 --- a/src/test/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -stubrunner.stubs.repository.root: https://repo.spring.io/snapshot/ -stubrunner.stubs.ids: org.springframework.github:github-webhook:+:stubs \ No newline at end of file From 4f59fac2cb1870ab854bd060b51fd6012d783ac8 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 12:26:47 +0200 Subject: [PATCH 19/46] Simplified the project / added cloud profile --- pom.xml | 16 +++------------- src/main/resources/application-cloud.yaml | 2 ++ 2 files changed, 5 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/application-cloud.yaml diff --git a/pom.xml b/pom.xml index a7a035d..e2edaca 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.github github-analytics - 0.0.1-SNAPSHOT + ${version} jar analytics @@ -23,6 +23,8 @@ 1.8 1.0.0.BUILD-SNAPSHOT Camden.BUILD-SNAPSHOT + org.springframework.github:github-webhook + 0.0.1-SNAPSHOT @@ -40,11 +42,6 @@ spring-cloud-starter-contract-stub-runner test - - org.springframework.cloud - spring-cloud-contract-wiremock - test - org.springframework.cloud spring-cloud-stream-test-support @@ -55,13 +52,6 @@ - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - org.springframework.cloud spring-cloud-dependencies diff --git a/src/main/resources/application-cloud.yaml b/src/main/resources/application-cloud.yaml new file mode 100644 index 0000000..35a24a0 --- /dev/null +++ b/src/main/resources/application-cloud.yaml @@ -0,0 +1,2 @@ +# From command line +spring.rabbitmq.addresses: ${vcap.services.rabbitmq.credentials.uri} \ No newline at end of file From fb0fe3129e126dff5090d77eaad45fecd8da85b7 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 14:14:23 +0200 Subject: [PATCH 20/46] Added missing manifest --- manifest.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 manifest.yml diff --git a/manifest.yml b/manifest.yml new file mode 100644 index 0000000..0a78fa1 --- /dev/null +++ b/manifest.yml @@ -0,0 +1,9 @@ +--- +applications: +- name: github-analytics + services: + - rabbitmq + - eureka + env: + SPRING_PROFILES_ACTIVE: cloud + DEBUG: "true" \ No newline at end of file From 6ba341e4ef8c104c484d072b13d522c282c11c29 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 14:16:42 +0200 Subject: [PATCH 21/46] Added rest endpoint to count entries --- .../org/springframework/github/GithubDataListener.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index feddf18..c6a7680 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -24,10 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -@Component +@RestController public class GithubDataListener { @Autowired @@ -43,6 +44,11 @@ public void listen(GithubData data) { processValue("action", data.getAction()); } + @RequestMapping("/count") + public int count() { + return this.counter.size(); + } + void clear() { counter.clear(); } From e22ddc70a7700236005e5efc9226952723849842 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 14:34:36 +0200 Subject: [PATCH 22/46] Added contracts for rest endpoints --- pom.xml | 15 +++++++- .../github/GithubDataListener.java | 9 +++-- .../github/contract/BaseClass.java | 36 +++++++++++++++++++ .../contracts/rest/countIssues.groovy | 12 +++++++ .../contracts/rest/createIssue.groovy | 17 +++++++++ 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/springframework/github/contract/BaseClass.java create mode 100644 src/test/resources/contracts/rest/countIssues.groovy create mode 100644 src/test/resources/contracts/rest/createIssue.groovy diff --git a/pom.xml b/pom.xml index e2edaca..8ea65ea 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,11 @@ spring-cloud-stream-test-support test - + + org.springframework.cloud + spring-cloud-starter-contract-verifier + test + @@ -72,6 +76,15 @@ pl.project13.maven git-commit-id-plugin + + org.springframework.cloud + spring-cloud-contract-maven-plugin + ${spring-cloud-contract.version} + true + + org.springframework.github.contract.BaseClass + + diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index c6a7680..c4144c9 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -26,6 +26,7 @@ import org.springframework.cloud.stream.messaging.Sink; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @@ -35,7 +36,6 @@ public class GithubDataListener { private FieldValueCounterWriter fieldValueCounterWriter; Map counter = new HashMap<>(); - @StreamListener(Sink.INPUT) public void listen(GithubData data) { processValue("repository", data.getRepository()); @@ -44,6 +44,11 @@ public void listen(GithubData data) { processValue("action", data.getAction()); } + @RequestMapping(value = "/data", method = RequestMethod.POST) + public void data(GithubData data) { + listen(data); + } + @RequestMapping("/count") public int count() { return this.counter.size(); @@ -53,7 +58,7 @@ void clear() { counter.clear(); } - protected void processValue(String counterName, Object value) { + public void processValue(String counterName, Object value) { if ((value instanceof Collection) || ObjectUtils.isArray(value)) { Collection c = (value instanceof Collection) ? (Collection) value : Arrays.asList(ObjectUtils.toObjectArray(value)); diff --git a/src/test/java/org/springframework/github/contract/BaseClass.java b/src/test/java/org/springframework/github/contract/BaseClass.java new file mode 100644 index 0000000..9d29aec --- /dev/null +++ b/src/test/java/org/springframework/github/contract/BaseClass.java @@ -0,0 +1,36 @@ +package org.springframework.github.contract; + +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier; +import org.springframework.github.AnalyticsApplication; +import org.springframework.github.GithubDataListener; +import org.springframework.test.context.junit4.SpringRunner; + +import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc; + +/** + * @author Marcin Grzejszczak + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = AnalyticsApplication.class) +@AutoConfigureMessageVerifier +public class BaseClass { + + @Autowired GithubDataListener githubDataListener; + + @Before + public void setup() { + RestAssuredMockMvc.standaloneSetup(githubDataListener); + if (this.githubDataListener.count() < 5) { + githubDataListener.processValue("foo1", 1); + githubDataListener.processValue("foo2", 2); + githubDataListener.processValue("foo3", 3); + githubDataListener.processValue("foo4", 4); + githubDataListener.processValue("foo5", 5); + } + } + +} diff --git a/src/test/resources/contracts/rest/countIssues.groovy b/src/test/resources/contracts/rest/countIssues.groovy new file mode 100644 index 0000000..09737e5 --- /dev/null +++ b/src/test/resources/contracts/rest/countIssues.groovy @@ -0,0 +1,12 @@ +package rest + +org.springframework.cloud.contract.spec.Contract.make { + request { + method 'GET' + url '/count' + } + response { + status 200 + body 5 + } +} \ No newline at end of file diff --git a/src/test/resources/contracts/rest/createIssue.groovy b/src/test/resources/contracts/rest/createIssue.groovy new file mode 100644 index 0000000..a97859f --- /dev/null +++ b/src/test/resources/contracts/rest/createIssue.groovy @@ -0,0 +1,17 @@ +package rest + +org.springframework.cloud.contract.spec.Contract.make { + request { + method 'POST' + url '/data' + body([ + username: 'smithapitla', + repository: 'spring-cloud/spring-cloud-netflix', + type: 'issue', + action: 'created' + ]) + } + response { + status 200 + } +} \ No newline at end of file From c127021fe81e3f297517b7a9a324d979b1b8f9a1 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 14:48:49 +0200 Subject: [PATCH 23/46] Prearing for cloud deployment --- src/main/resources/application.properties | 5 ----- src/main/resources/application.yml | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 2ea5760..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -spring.application.name: github-analytics -server.port=8081 -# Not used at runtime but needed to validate the counter properties bean: -field-value-counter.fieldName=test -spring.cloud.stream.bindings.input.destination=messages diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..ac2158e --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,6 @@ +spring: + application.name: github-analytics + cloud.stream.bindings.input.destination: messages +server.port: ${PORT:8081} +# Not used at runtime but needed to validate the counter properties bean: +field-value-counter.fieldName: test From 3a54af004d5543cc2d6270d4333fd920fe4d35fc Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Sep 2016 18:11:44 +0200 Subject: [PATCH 24/46] Added integratoin tests --- pom.xml | 51 +++++++++++++++++++ .../java/integration/IntegrationTests.java | 48 +++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/test/java/integration/IntegrationTests.java diff --git a/pom.xml b/pom.xml index 8ea65ea..f97ec47 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,12 @@ spring-cloud-starter-contract-verifier test + + org.awaitility + awaitility + 2.0.0 + test + @@ -88,6 +94,51 @@ + + + default + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + org/**/*Tests.java + org/**/*Test.java + + + + + + + + integration + + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + integration/**/*Tests.java + integration/**/*Test.java + + + + + + + + repo.spring.io diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java new file mode 100644 index 0000000..56ddcf9 --- /dev/null +++ b/src/test/java/integration/IntegrationTests.java @@ -0,0 +1,48 @@ +package integration; + +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.BDDAssertions.then; +import static org.awaitility.Awaitility.await; + +/** + * @author Marcin Grzejszczak + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = IntegrationTests.class, + webEnvironment = SpringBootTest.WebEnvironment.NONE) +@EnableAutoConfiguration +public class IntegrationTests { + + @Value("${stubrunner.url}") String stubRunnerUrl; + @Value("${application.url}") String applicationUrl; + + TestRestTemplate testRestTemplate = new TestRestTemplate(); + + @Test + public void shouldStoreAMessageWhenGithubDataWasReceived() { + final Integer countOfEntries = countGithubData(); + Map response = triggerMessage(); + then(response).isNotEmpty(); + + await().until(() -> countGithubData() > countOfEntries); + } + + private Map triggerMessage() { + return this.testRestTemplate.getForObject( + this.stubRunnerUrl + "/triggers/hook_created_v2", Map.class); + } + + private Integer countGithubData() { + return this.testRestTemplate + .getForObject(this.applicationUrl + "/count", Integer.class); + } +} From b1110d9e39be7b7c75a89b36d1b239e478da8b27 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sat, 3 Sep 2016 12:52:12 +0200 Subject: [PATCH 25/46] Changed Group id --- pom.xml | 7 ++++++- .../springframework/github/AnalyticsApplicationTests.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f97ec47..1e5ce57 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.github + com.example.github github-analytics ${version} jar @@ -140,6 +140,11 @@ + + repo.spring.io + Spring Milestone Repository + https://repo.spring.io/libs-milestone-local + repo.spring.io Spring Snapshot Repository diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index d43ff10..12ce061 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -23,7 +23,7 @@ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = AnalyticsApplication.class) @AutoConfigureStubRunner(repositoryRoot = "https://repo.spring.io/snapshot/", - ids = {"org.springframework.github:github-webhook"}) + ids = {"com.example.github:github-webhook"}) public class AnalyticsApplicationTests { @Autowired From 8eff4516b79ef93d61b5343c6e8d274d4af9bd3f Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sat, 3 Sep 2016 23:35:22 +0200 Subject: [PATCH 26/46] Updated props --- manifest.yml | 4 ++-- src/main/resources/application-cloud.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.yml b/manifest.yml index 0a78fa1..723a228 100644 --- a/manifest.yml +++ b/manifest.yml @@ -2,8 +2,8 @@ applications: - name: github-analytics services: - - rabbitmq - - eureka + - github-rabbitmq + - github-eureka env: SPRING_PROFILES_ACTIVE: cloud DEBUG: "true" \ No newline at end of file diff --git a/src/main/resources/application-cloud.yaml b/src/main/resources/application-cloud.yaml index 35a24a0..74ef714 100644 --- a/src/main/resources/application-cloud.yaml +++ b/src/main/resources/application-cloud.yaml @@ -1,2 +1,2 @@ # From command line -spring.rabbitmq.addresses: ${vcap.services.rabbitmq.credentials.uri} \ No newline at end of file +spring.rabbitmq.addresses: ${vcap.services.github-rabbitmq.credentials.uri} \ No newline at end of file From 2f35cb170d13a3864783fa21f7572a577511e19a Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 00:06:04 +0200 Subject: [PATCH 27/46] Updated stubrunner props --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1e5ce57..377f86d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 1.8 1.0.0.BUILD-SNAPSHOT Camden.BUILD-SNAPSHOT - org.springframework.github:github-webhook + com.example.github:github-webhook 0.0.1-SNAPSHOT From 60730f1032182602472c8c2a1d2ac34189a3ae15 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 00:50:14 +0200 Subject: [PATCH 28/46] Added http to the url --- src/test/java/integration/IntegrationTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index 56ddcf9..cc71e54 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -37,12 +37,12 @@ public void shouldStoreAMessageWhenGithubDataWasReceived() { } private Map triggerMessage() { - return this.testRestTemplate.getForObject( + return this.testRestTemplate.getForObject("http://" + this.stubRunnerUrl + "/triggers/hook_created_v2", Map.class); } private Integer countGithubData() { return this.testRestTemplate - .getForObject(this.applicationUrl + "/count", Integer.class); + .getForObject("http://" + this.applicationUrl + "/count", Integer.class); } } From 8822c4f71b90422ec2030493698f96e701100b9b Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 01:01:48 +0200 Subject: [PATCH 29/46] Fixed tests --- .../java/org/springframework/github/GithubDataListener.java | 2 +- src/test/java/integration/IntegrationTests.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index c4144c9..221c509 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -49,7 +49,7 @@ public void data(GithubData data) { listen(data); } - @RequestMapping("/count") + @RequestMapping(value = "/count", method = RequestMethod.GET) public int count() { return this.counter.size(); } diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index cc71e54..d399c39 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -37,8 +37,8 @@ public void shouldStoreAMessageWhenGithubDataWasReceived() { } private Map triggerMessage() { - return this.testRestTemplate.getForObject("http://" + - this.stubRunnerUrl + "/triggers/hook_created_v2", Map.class); + return this.testRestTemplate.postForObject("http://" + + this.stubRunnerUrl + "/triggers/hook_created_v2", "", Map.class); } private Integer countGithubData() { From da0b0c5aaf3d9bc5e3fd5b694d3b33400849330b Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 01:09:09 +0200 Subject: [PATCH 30/46] Fixed tests --- src/test/java/integration/IntegrationTests.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index d399c39..c3f374a 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -1,13 +1,17 @@ package integration; +import java.lang.invoke.MethodHandles; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -22,6 +26,8 @@ @EnableAutoConfiguration public class IntegrationTests { + private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); + @Value("${stubrunner.url}") String stubRunnerUrl; @Value("${application.url}") String applicationUrl; @@ -30,14 +36,16 @@ public class IntegrationTests { @Test public void shouldStoreAMessageWhenGithubDataWasReceived() { final Integer countOfEntries = countGithubData(); - Map response = triggerMessage(); - then(response).isNotEmpty(); + log.info("Initial count is [" + countOfEntries + "]"); + ResponseEntity response = triggerMessage(); + then(response.getStatusCode().is2xxSuccessful()).isTrue(); + log.info("Awaiting proper count of github data"); await().until(() -> countGithubData() > countOfEntries); } - private Map triggerMessage() { - return this.testRestTemplate.postForObject("http://" + + private ResponseEntity triggerMessage() { + return this.testRestTemplate.postForEntity("http://" + this.stubRunnerUrl + "/triggers/hook_created_v2", "", Map.class); } From 5d3c62fb5ab50f7787437472c8c10e7469bbfe73 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 01:13:30 +0200 Subject: [PATCH 31/46] Added logging --- .../org/springframework/github/GithubDataListener.java | 8 ++++++++ src/test/java/integration/IntegrationTests.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index 221c509..e8b41e4 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -15,11 +15,14 @@ */ package org.springframework.github; +import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.analytics.metrics.FieldValueCounterWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; @@ -32,12 +35,15 @@ @RestController public class GithubDataListener { + private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); + @Autowired private FieldValueCounterWriter fieldValueCounterWriter; Map counter = new HashMap<>(); @StreamListener(Sink.INPUT) public void listen(GithubData data) { + log.info("Received a new message [" + data + "]"); processValue("repository", data.getRepository()); processValue("username", data.getUsername()); processValue("type", data.getType()); @@ -46,11 +52,13 @@ public void listen(GithubData data) { @RequestMapping(value = "/data", method = RequestMethod.POST) public void data(GithubData data) { + log.info("Received a new request [" + data + "]"); listen(data); } @RequestMapping(value = "/count", method = RequestMethod.GET) public int count() { + log.info("Received a new request for size"); return this.counter.size(); } diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index c3f374a..19efa28 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -39,6 +39,7 @@ public void shouldStoreAMessageWhenGithubDataWasReceived() { log.info("Initial count is [" + countOfEntries + "]"); ResponseEntity response = triggerMessage(); then(response.getStatusCode().is2xxSuccessful()).isTrue(); + log.info("Triggered additional message"); log.info("Awaiting proper count of github data"); await().until(() -> countGithubData() > countOfEntries); @@ -50,7 +51,9 @@ private ResponseEntity triggerMessage() { } private Integer countGithubData() { - return this.testRestTemplate + Integer response = this.testRestTemplate .getForObject("http://" + this.applicationUrl + "/count", Integer.class); + log.info("Received response [" + response + "]"); + return response; } } From 1404e2667f26bd15bc095f0c8a62ad29113187de Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Sun, 4 Sep 2016 08:48:11 +0200 Subject: [PATCH 32/46] Fixed impl --- .../github/GithubDataListener.java | 17 ++++++++++------- .../github/AnalyticsApplicationTests.java | 13 ++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index e8b41e4..e84951a 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -20,10 +20,11 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.analytics.metrics.FieldValueCounterWriter; +import org.springframework.analytics.metrics.FieldValueCounterRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.messaging.Sink; @@ -37,9 +38,9 @@ public class GithubDataListener { private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); - @Autowired - private FieldValueCounterWriter fieldValueCounterWriter; + @Autowired private FieldValueCounterRepository fieldValueCounterRepository; Map counter = new HashMap<>(); + AtomicInteger stats = new AtomicInteger(); @StreamListener(Sink.INPUT) public void listen(GithubData data) { @@ -48,6 +49,7 @@ public void listen(GithubData data) { processValue("username", data.getUsername()); processValue("type", data.getType()); processValue("action", data.getAction()); + stats.incrementAndGet(); } @RequestMapping(value = "/data", method = RequestMethod.POST) @@ -58,8 +60,9 @@ public void data(GithubData data) { @RequestMapping(value = "/count", method = RequestMethod.GET) public int count() { - log.info("Received a new request for size"); - return this.counter.size(); + int size = this.stats.get(); + log.info("Size of counters equals [" + size + "]"); + return size; } void clear() { @@ -71,11 +74,11 @@ public void processValue(String counterName, Object value) { Collection c = (value instanceof Collection) ? (Collection) value : Arrays.asList(ObjectUtils.toObjectArray(value)); for (Object val : c) { - this.fieldValueCounterWriter.increment(counterName, val.toString(), 1.0); + this.fieldValueCounterRepository.increment(counterName, val.toString(), 1.0); } } else if (value != null) { - this.fieldValueCounterWriter.increment(counterName, value.toString(), 1.0); + this.fieldValueCounterRepository.increment(counterName, value.toString(), 1.0); } counter.put(counterName, value); } diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 12ce061..e884821 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -1,5 +1,8 @@ package org.springframework.github; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,9 +17,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MimeTypeUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; @@ -50,16 +51,22 @@ public void testWithMarshalledPojo() throws JsonProcessingException { @Test public void testWithV1StubData() { + int initialSize = this.githubDataListener.stats.get(); + this.stubTrigger.trigger("issue_created_v1"); assertThat(this.githubDataListener.counter.isEmpty(), is(false)); + assertThat(this.githubDataListener.stats.get(), is(greaterThan(initialSize))); } @Test public void testWithV2StubData() { + int initialSize = this.githubDataListener.stats.get(); + this.stubTrigger.trigger("issue_created_v2"); assertThat(this.githubDataListener.counter.isEmpty(), is(false)); + assertThat(this.githubDataListener.stats.get(), is(greaterThan(initialSize))); } } From ae544b745ec425447b88850c169b2b607d239787 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 9 Sep 2016 16:23:24 +0200 Subject: [PATCH 33/46] Updated mvnw --- mvnw | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mvnw b/mvnw index a1ba1bf..fe1957e 100755 --- a/mvnw +++ b/mvnw @@ -226,8 +226,23 @@ export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +VERSION=$(exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + -Dexec.executable="echo" -Dexec.args='${project.version}' ${WRAPPER_LAUNCHER} -q --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec ) + +if echo $VERSION | egrep -q 'M|RC'; then + echo Activating \"milestone\" profile for version=\"$VERSION\" + echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" +else + echo Deactivating \"milestone\" profile for version=\"$VERSION\" + echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') +fi + + exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} "$@" + ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" From 1dcc7188da880e6ad810e7ef3d47ccfdb948ca03 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 9 Sep 2016 16:28:00 +0200 Subject: [PATCH 34/46] Revert "Updated mvnw" This reverts commit ae544b745ec425447b88850c169b2b607d239787. --- mvnw | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mvnw b/mvnw index fe1957e..a1ba1bf 100755 --- a/mvnw +++ b/mvnw @@ -226,23 +226,8 @@ export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -VERSION=$(exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - -Dexec.executable="echo" -Dexec.args='${project.version}' ${WRAPPER_LAUNCHER} -q --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec ) - -if echo $VERSION | egrep -q 'M|RC'; then - echo Activating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" -else - echo Deactivating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') -fi - - exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" + ${WRAPPER_LAUNCHER} "$@" From 99d7a6c42779301df9cec771e9bc211a6a2ae204 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 13 Sep 2016 11:10:58 +0200 Subject: [PATCH 35/46] Parametrized distribution management --- pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 377f86d..0a68f99 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,8 @@ Camden.BUILD-SNAPSHOT com.example.github:github-webhook 0.0.1-SNAPSHOT + repo.spring.io + https://repo.spring.io/libs-milestone-local @@ -141,9 +143,9 @@ - repo.spring.io + ${distribution.management.release.id} Spring Milestone Repository - https://repo.spring.io/libs-milestone-local + ${distribution.management.release.url} repo.spring.io From f81b5b13eface5143055930c20bcdf2002b7b68f Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 16 Sep 2016 13:28:52 +0200 Subject: [PATCH 36/46] Added service discovery feature --- pom.xml | 9 +++ .../github/AnalyticsApplication.java | 14 +++++ .../springframework/github/GithubData.java | 42 +++---------- .../github/GithubDataListener.java | 25 +++++--- .../springframework/github/GithubDatum.java | 59 +++++++++++++++++++ .../java/integration/IntegrationTests.java | 21 ++++++- .../github/AnalyticsApplicationTests.java | 32 ++++++---- 7 files changed, 147 insertions(+), 55 deletions(-) create mode 100644 src/main/java/org/springframework/github/GithubDatum.java diff --git a/pom.xml b/pom.xml index 0a68f99..1460c98 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,15 @@ spring-analytics 1.0.1.BUILD-SNAPSHOT + + org.springframework.cloud + spring-cloud-starter-eureka + + + + org.hibernate + hibernate-validator + org.springframework.cloud spring-cloud-starter-stream-rabbit diff --git a/src/main/java/org/springframework/github/AnalyticsApplication.java b/src/main/java/org/springframework/github/AnalyticsApplication.java index 525a6ed..7faadc0 100644 --- a/src/main/java/org/springframework/github/AnalyticsApplication.java +++ b/src/main/java/org/springframework/github/AnalyticsApplication.java @@ -1,11 +1,14 @@ package org.springframework.github; +import org.springframework.analytics.metrics.FieldValueCounterRepository; import org.springframework.analytics.metrics.memory.InMemoryFieldValueCounterRepository; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; @SpringBootApplication @EnableBinding(Sink.class) @@ -18,4 +21,15 @@ public static void main(String[] args) { @Bean InMemoryFieldValueCounterRepository repository() { return new InMemoryFieldValueCounterRepository(); } + + @Bean GithubDataListener githubDataListener(FieldValueCounterRepository fieldValueCounterRepository, + @LoadBalanced RestTemplate restTemplate) { + return new GithubDataListener(fieldValueCounterRepository, restTemplate); + } + + @Bean + @LoadBalanced + RestTemplate restTemplate() { + return new RestTemplate(); + } } diff --git a/src/main/java/org/springframework/github/GithubData.java b/src/main/java/org/springframework/github/GithubData.java index e379032..6db5d21 100644 --- a/src/main/java/org/springframework/github/GithubData.java +++ b/src/main/java/org/springframework/github/GithubData.java @@ -15,45 +15,17 @@ */ package org.springframework.github; -public class GithubData { - - private String username; - - private String repository; - - private String type = "unknown"; - - private String action = "unknown"; - - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getRepository() { - return this.repository; - } - - public void setRepository(String repository) { - this.repository = repository; - } +import java.util.List; - public String getType() { - return this.type; - } +public class GithubData { - public void setType(String type) { - this.type = type; - } + private List data; - public String getAction() { - return this.action; + public List getData() { + return data; } - public void setAction(String action) { - this.action = action; + public void setData(List data) { + this.data = data; } } diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index e84951a..242bad3 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -25,25 +25,34 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.analytics.metrics.FieldValueCounterRepository; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; @RestController public class GithubDataListener { private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); - @Autowired private FieldValueCounterRepository fieldValueCounterRepository; + private final FieldValueCounterRepository fieldValueCounterRepository; + private final RestTemplate restTemplate; + Map counter = new HashMap<>(); AtomicInteger stats = new AtomicInteger(); + public GithubDataListener(FieldValueCounterRepository fieldValueCounterRepository, + RestTemplate restTemplate) { + this.fieldValueCounterRepository = fieldValueCounterRepository; + this.restTemplate = restTemplate; + } + @StreamListener(Sink.INPUT) - public void listen(GithubData data) { + public void listen(GithubDatum data) { log.info("Received a new message [" + data + "]"); processValue("repository", data.getRepository()); processValue("username", data.getUsername()); @@ -52,10 +61,12 @@ public void listen(GithubData data) { stats.incrementAndGet(); } - @RequestMapping(value = "/data", method = RequestMethod.POST) - public void data(GithubData data) { - log.info("Received a new request [" + data + "]"); - listen(data); + @GetMapping(value = "/data") + public GithubData data() { + log.info("Sending request to github-webook"); + GithubData data = restTemplate.getForObject("http://github-webhook/", GithubData.class); + data.getData().forEach(this::listen); + return data; } @RequestMapping(value = "/count", method = RequestMethod.GET) diff --git a/src/main/java/org/springframework/github/GithubDatum.java b/src/main/java/org/springframework/github/GithubDatum.java new file mode 100644 index 0000000..d51e880 --- /dev/null +++ b/src/main/java/org/springframework/github/GithubDatum.java @@ -0,0 +1,59 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.github; + +public class GithubDatum { + + private String username; + + private String repository; + + private String type = "unknown"; + + private String action = "unknown"; + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getRepository() { + return this.repository; + } + + public void setRepository(String repository) { + this.repository = repository; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } +} diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index 19efa28..88eedb1 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.github.GithubData; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; @@ -34,7 +35,7 @@ public class IntegrationTests { TestRestTemplate testRestTemplate = new TestRestTemplate(); @Test - public void shouldStoreAMessageWhenGithubDataWasReceived() { + public void shouldStoreAMessageWhenGithubDataWasReceivedViaMessaging() { final Integer countOfEntries = countGithubData(); log.info("Initial count is [" + countOfEntries + "]"); ResponseEntity response = triggerMessage(); @@ -45,11 +46,29 @@ public void shouldStoreAMessageWhenGithubDataWasReceived() { await().until(() -> countGithubData() > countOfEntries); } + @Test + public void shouldStoreAMessageWhenGithubDataWasReceivedFromServiceDiscovery() { + final Integer countOfEntries = countGithubData(); + log.info("Initial count is [" + countOfEntries + "]"); + + ResponseEntity response = callData(); + then(response.getStatusCode().is2xxSuccessful()).isTrue(); + then(response.getBody()).isNotNull(); + + log.info("Awaiting proper count of github data"); + await().until(() -> countGithubData() > countOfEntries); + } + private ResponseEntity triggerMessage() { return this.testRestTemplate.postForEntity("http://" + this.stubRunnerUrl + "/triggers/hook_created_v2", "", Map.class); } + private ResponseEntity callData() { + return this.testRestTemplate.postForEntity("http://" + + this.applicationUrl + "/data", "", GithubData.class); + } + private Integer countGithubData() { Integer response = this.testRestTemplate .getForObject("http://" + this.applicationUrl + "/count", Integer.class); diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index e884821..2d2ac4a 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -1,8 +1,5 @@ package org.springframework.github; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -17,13 +14,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MimeTypeUtils; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import static org.assertj.core.api.BDDAssertions.then; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = AnalyticsApplication.class) -@AutoConfigureStubRunner(repositoryRoot = "https://repo.spring.io/snapshot/", +@AutoConfigureStubRunner(repositoryRoot = "https://repo.spring.io/milestone/", ids = {"com.example.github:github-webhook"}) public class AnalyticsApplicationTests { @@ -40,7 +38,7 @@ public void setup() { @Test public void testWithMarshalledPojo() throws JsonProcessingException { - GithubData data = new GithubData(); + GithubDatum data = new GithubDatum(); data.setRepository("spring-framework"); data.setUsername("rossen"); String json = new ObjectMapper().writeValueAsString(data); @@ -55,8 +53,8 @@ public void testWithV1StubData() { this.stubTrigger.trigger("issue_created_v1"); - assertThat(this.githubDataListener.counter.isEmpty(), is(false)); - assertThat(this.githubDataListener.stats.get(), is(greaterThan(initialSize))); + then(this.githubDataListener.counter).isNotEmpty(); + then(this.githubDataListener.stats.get()).isGreaterThan(initialSize); } @Test @@ -65,8 +63,18 @@ public void testWithV2StubData() { this.stubTrigger.trigger("issue_created_v2"); - assertThat(this.githubDataListener.counter.isEmpty(), is(false)); - assertThat(this.githubDataListener.stats.get(), is(greaterThan(initialSize))); + then(this.githubDataListener.counter).isNotEmpty(); + then(this.githubDataListener.stats.get()).isGreaterThan(initialSize); + } + + @Test + public void testWithInMemoryServiceDiscovery() { + int initialSize = this.githubDataListener.stats.get(); + + GithubData data = this.githubDataListener.data(); + + then(this.githubDataListener.counter).isNotEmpty(); + then(this.githubDataListener.stats.get()).isGreaterThan(initialSize); } } From 9d2b9d46660334c5a2fec58d8e045917bc33fe69 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 16 Sep 2016 13:46:30 +0200 Subject: [PATCH 37/46] Updated tests to pass contract tests --- .../github/AnalyticsApplication.java | 8 +++-- .../github/GithubDataListener.java | 12 ++++---- .../springframework/github/GithubDatum.java | 10 +++++++ .../github/contract/BaseClass.java | 21 +++++++++++++- .../contracts/rest/createIssue.groovy | 29 ++++++++++++++----- 5 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/springframework/github/AnalyticsApplication.java b/src/main/java/org/springframework/github/AnalyticsApplication.java index 7faadc0..ece9eec 100644 --- a/src/main/java/org/springframework/github/AnalyticsApplication.java +++ b/src/main/java/org/springframework/github/AnalyticsApplication.java @@ -23,8 +23,12 @@ public static void main(String[] args) { } @Bean GithubDataListener githubDataListener(FieldValueCounterRepository fieldValueCounterRepository, - @LoadBalanced RestTemplate restTemplate) { - return new GithubDataListener(fieldValueCounterRepository, restTemplate); + GithubDataListener.WebhookService webhookService) { + return new GithubDataListener(fieldValueCounterRepository, webhookService); + } + + @Bean GithubDataListener.WebhookService webhookService(final @LoadBalanced RestTemplate restTemplate) { + return () -> restTemplate.getForObject("http://github-webhook/", GithubData.class); } @Bean diff --git a/src/main/java/org/springframework/github/GithubDataListener.java b/src/main/java/org/springframework/github/GithubDataListener.java index 242bad3..02cd6d4 100644 --- a/src/main/java/org/springframework/github/GithubDataListener.java +++ b/src/main/java/org/springframework/github/GithubDataListener.java @@ -32,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; @RestController public class GithubDataListener { @@ -40,15 +39,15 @@ public class GithubDataListener { private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); private final FieldValueCounterRepository fieldValueCounterRepository; - private final RestTemplate restTemplate; + private final GithubDataListener.WebhookService webhookService; Map counter = new HashMap<>(); AtomicInteger stats = new AtomicInteger(); public GithubDataListener(FieldValueCounterRepository fieldValueCounterRepository, - RestTemplate restTemplate) { + GithubDataListener.WebhookService webhookService) { this.fieldValueCounterRepository = fieldValueCounterRepository; - this.restTemplate = restTemplate; + this.webhookService = webhookService; } @StreamListener(Sink.INPUT) @@ -64,7 +63,7 @@ public void listen(GithubDatum data) { @GetMapping(value = "/data") public GithubData data() { log.info("Sending request to github-webook"); - GithubData data = restTemplate.getForObject("http://github-webhook/", GithubData.class); + GithubData data = webhookService.data(); data.getData().forEach(this::listen); return data; } @@ -94,4 +93,7 @@ else if (value != null) { counter.put(counterName, value); } + public interface WebhookService { + GithubData data(); + } } diff --git a/src/main/java/org/springframework/github/GithubDatum.java b/src/main/java/org/springframework/github/GithubDatum.java index d51e880..5a28da5 100644 --- a/src/main/java/org/springframework/github/GithubDatum.java +++ b/src/main/java/org/springframework/github/GithubDatum.java @@ -25,6 +25,16 @@ public class GithubDatum { private String action = "unknown"; + public GithubDatum(String username, String repository, String type, String action) { + this.username = username; + this.repository = repository; + this.type = type; + this.action = action; + } + + public GithubDatum() { + } + public String getUsername() { return this.username; } diff --git a/src/test/java/org/springframework/github/contract/BaseClass.java b/src/test/java/org/springframework/github/contract/BaseClass.java index 9d29aec..6954462 100644 --- a/src/test/java/org/springframework/github/contract/BaseClass.java +++ b/src/test/java/org/springframework/github/contract/BaseClass.java @@ -1,12 +1,19 @@ package org.springframework.github.contract; +import java.util.Arrays; + import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.github.AnalyticsApplication; +import org.springframework.github.GithubData; import org.springframework.github.GithubDataListener; +import org.springframework.github.GithubDatum; import org.springframework.test.context.junit4.SpringRunner; import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc; @@ -15,7 +22,7 @@ * @author Marcin Grzejszczak */ @RunWith(SpringRunner.class) -@SpringBootTest(classes = AnalyticsApplication.class) +@SpringBootTest(classes = { BaseClass.Config.class, AnalyticsApplication.class }) @AutoConfigureMessageVerifier public class BaseClass { @@ -33,4 +40,16 @@ public void setup() { } } + @Configuration + static class Config { + @Bean @Primary GithubDataListener.WebhookService testWebhook() { + return () -> { + GithubData githubData = new GithubData(); + githubData.setData(Arrays.asList( + new GithubDatum("dsyer", "spring-cloud-samples", "hook", "updated"), + new GithubDatum("smithapitla", "spring-cloud/spring-cloud-netflix", "issue", "created"))); + return githubData; + }; + } + } } diff --git a/src/test/resources/contracts/rest/createIssue.groovy b/src/test/resources/contracts/rest/createIssue.groovy index a97859f..3d836c0 100644 --- a/src/test/resources/contracts/rest/createIssue.groovy +++ b/src/test/resources/contracts/rest/createIssue.groovy @@ -2,16 +2,31 @@ package rest org.springframework.cloud.contract.spec.Contract.make { request { - method 'POST' + method 'GET' url '/data' - body([ - username: 'smithapitla', - repository: 'spring-cloud/spring-cloud-netflix', - type: 'issue', - action: 'created' - ]) } response { status 200 + body([ data: [ + [ + username:"dsyer", + repository:"spring-cloud-samples", + type:"hook", + action:"updated" + ], + [ + username:"smithapitla", + repository:"spring-cloud/spring-cloud-netflix", + type:"issue", + action:"created" + ] + ] + ]) + headers { + header('Content-Type': value( + producer(regex('application/json.*')), + consumer('application/json')) + ) + } } } \ No newline at end of file From 091136f39fcebbd8413b74a4af534f4054564aa4 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 16 Sep 2016 13:52:43 +0200 Subject: [PATCH 38/46] Updated tests to pass integration tests --- src/test/java/integration/IntegrationTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index 88eedb1..10524e0 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -65,8 +65,8 @@ private ResponseEntity triggerMessage() { } private ResponseEntity callData() { - return this.testRestTemplate.postForEntity("http://" + - this.applicationUrl + "/data", "", GithubData.class); + return this.testRestTemplate.getForEntity("http://" + + this.applicationUrl + "/data", GithubData.class); } private Integer countGithubData() { From a5ca3f20f740828da09d7f0490f49947b2db5039 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 19 Sep 2016 18:26:48 +0200 Subject: [PATCH 39/46] Added dependency to stubrunner at runtime --- pom.xml | 7 +++++++ src/test/java/integration/IntegrationTests.java | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1460c98..6d396ff 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,13 @@ false + + + org.springframework.cloud + spring-cloud-starter-contract-stub-runner + compile + + diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/integration/IntegrationTests.java index 10524e0..8e7b0d7 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/integration/IntegrationTests.java @@ -10,10 +10,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.github.GithubData; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.BDDAssertions.then; import static org.awaitility.Awaitility.await; @@ -32,7 +32,7 @@ public class IntegrationTests { @Value("${stubrunner.url}") String stubRunnerUrl; @Value("${application.url}") String applicationUrl; - TestRestTemplate testRestTemplate = new TestRestTemplate(); + RestTemplate restTemplate = new RestTemplate(); @Test public void shouldStoreAMessageWhenGithubDataWasReceivedViaMessaging() { @@ -60,17 +60,17 @@ public void shouldStoreAMessageWhenGithubDataWasReceivedFromServiceDiscovery() { } private ResponseEntity triggerMessage() { - return this.testRestTemplate.postForEntity("http://" + + return this.restTemplate.postForEntity("http://" + this.stubRunnerUrl + "/triggers/hook_created_v2", "", Map.class); } private ResponseEntity callData() { - return this.testRestTemplate.getForEntity("http://" + + return this.restTemplate.getForEntity("http://" + this.applicationUrl + "/data", GithubData.class); } private Integer countGithubData() { - Integer response = this.testRestTemplate + Integer response = this.restTemplate .getForObject("http://" + this.applicationUrl + "/count", Integer.class); log.info("Received response [" + response + "]"); return response; From e1e7827acb03f88e4e124c8fae30ca8161ba5077 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 20 Sep 2016 16:21:45 +0200 Subject: [PATCH 40/46] Added beans on smoke profile --- pom.xml | 13 +++------- .../github/AnalyticsApplication.java | 25 ++++++++++++++++++- .../IntegrationTests.java | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) rename src/test/java/{integration => smoke}/IntegrationTests.java (99%) diff --git a/pom.xml b/pom.xml index 6d396ff..0d60340 100644 --- a/pom.xml +++ b/pom.xml @@ -128,17 +128,10 @@ - integration + smoke false - - - org.springframework.cloud - spring-cloud-starter-contract-stub-runner - compile - - @@ -147,8 +140,8 @@ 2.18.1 - integration/**/*Tests.java - integration/**/*Test.java + smoke/**/*Tests.java + smoke/**/*Test.java diff --git a/src/main/java/org/springframework/github/AnalyticsApplication.java b/src/main/java/org/springframework/github/AnalyticsApplication.java index ece9eec..cd42adf 100644 --- a/src/main/java/org/springframework/github/AnalyticsApplication.java +++ b/src/main/java/org/springframework/github/AnalyticsApplication.java @@ -1,5 +1,7 @@ package org.springframework.github; +import java.util.Arrays; + import org.springframework.analytics.metrics.FieldValueCounterRepository; import org.springframework.analytics.metrics.memory.InMemoryFieldValueCounterRepository; import org.springframework.boot.SpringApplication; @@ -8,6 +10,8 @@ import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.cloud.stream.messaging.Sink; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; import org.springframework.web.client.RestTemplate; @SpringBootApplication @@ -27,10 +31,29 @@ public static void main(String[] args) { return new GithubDataListener(fieldValueCounterRepository, webhookService); } - @Bean GithubDataListener.WebhookService webhookService(final @LoadBalanced RestTemplate restTemplate) { + @Bean + GithubDataListener.WebhookService webhookService(final @LoadBalanced RestTemplate restTemplate) { return () -> restTemplate.getForObject("http://github-webhook/", GithubData.class); } + /** + * Since an app in Cloud Foundry can't run on multiple ports, for HTTP we need to do + * a poor man's version and stub out any communication if we want to just check if the + * application is properly packaged + */ + @Bean + @Profile("smoke") + @Primary + GithubDataListener.WebhookService integrationWebhookService() { + return () -> { + GithubData githubData = new GithubData(); + githubData.setData(Arrays.asList( + new GithubDatum("dsyer", "spring-cloud-samples", "hook", "updated"), + new GithubDatum("smithapitla", "spring-cloud/spring-cloud-netflix", "issue", "created"))); + return githubData; + }; + } + @Bean @LoadBalanced RestTemplate restTemplate() { diff --git a/src/test/java/integration/IntegrationTests.java b/src/test/java/smoke/IntegrationTests.java similarity index 99% rename from src/test/java/integration/IntegrationTests.java rename to src/test/java/smoke/IntegrationTests.java index 8e7b0d7..99181c6 100644 --- a/src/test/java/integration/IntegrationTests.java +++ b/src/test/java/smoke/IntegrationTests.java @@ -1,4 +1,4 @@ -package integration; +package smoke; import java.lang.invoke.MethodHandles; import java.util.Map; From 1f1a2d9af121ac79a156b7f3baacccbd5ee377ae Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 20 Sep 2016 17:26:10 +0200 Subject: [PATCH 41/46] Added e2e profile --- pom.xml | 21 ++++++++++++ src/test/java/e2e/E2eTests.java | 60 +++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/test/java/e2e/E2eTests.java diff --git a/pom.xml b/pom.xml index 0d60340..25b369a 100644 --- a/pom.xml +++ b/pom.xml @@ -148,6 +148,27 @@ + + e2e + + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + e2e/**/*Tests.java + e2e/**/*Test.java + + + + + + diff --git a/src/test/java/e2e/E2eTests.java b/src/test/java/e2e/E2eTests.java new file mode 100644 index 0000000..6e71afe --- /dev/null +++ b/src/test/java/e2e/E2eTests.java @@ -0,0 +1,60 @@ +package e2e; + +import java.lang.invoke.MethodHandles; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.github.GithubData; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +import static org.assertj.core.api.BDDAssertions.then; +import static org.awaitility.Awaitility.await; + +/** + * @author Marcin Grzejszczak + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = E2eTests.class, + webEnvironment = SpringBootTest.WebEnvironment.NONE) +@EnableAutoConfiguration +public class E2eTests { + + private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); + + @Value("${application.url}") String applicationUrl; + + RestTemplate restTemplate = new RestTemplate(); + + @Test + @SuppressWarnings("Duplicates") + public void shouldStoreAMessageWhenGithubDataWasReceivedFromServiceDiscovery() { + final Integer countOfEntries = countGithubData(); + log.info("Initial count is [" + countOfEntries + "]"); + + ResponseEntity response = callData(); + then(response.getStatusCode().is2xxSuccessful()).isTrue(); + then(response.getBody()).isNotNull(); + + log.info("Awaiting proper count of github data"); + await().until(() -> countGithubData() > countOfEntries); + } + + private ResponseEntity callData() { + return this.restTemplate.getForEntity("http://" + + this.applicationUrl + "/data", GithubData.class); + } + + private Integer countGithubData() { + Integer response = this.restTemplate + .getForObject("http://" + this.applicationUrl + "/count", Integer.class); + log.info("Received response [" + response + "]"); + return response; + } +} From 9ee212581fd39eef6d4ab182376dbe19e5d342c6 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 6 Oct 2016 11:01:09 +0200 Subject: [PATCH 42/46] Pointing by default to local artifactory --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 25b369a..a1350f1 100644 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,8 @@ Camden.BUILD-SNAPSHOT com.example.github:github-webhook 0.0.1-SNAPSHOT - repo.spring.io - https://repo.spring.io/libs-milestone-local + artifactory-local + https://localhost:8081/libs-release-local From 22b8aadf4930c1b3fba502d58e960c0e234d932e Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 6 Oct 2016 11:06:51 +0200 Subject: [PATCH 43/46] Changing versions with Maven Versions plugin --- .gitignore | 1 + pom.xml | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 42bdaef..5955b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ _site/ dump.rdb .apt_generated artifacts +*.versionsBackup diff --git a/pom.xml b/pom.xml index a1350f1..7e83584 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.example.github github-analytics - ${version} + 0.0.1-SNAPSHOT jar analytics @@ -24,7 +24,6 @@ 1.0.0.BUILD-SNAPSHOT Camden.BUILD-SNAPSHOT com.example.github:github-webhook - 0.0.1-SNAPSHOT artifactory-local https://localhost:8081/libs-release-local From ba715662480b87fb01547d61079cbd1319eb2626 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 6 Oct 2016 11:49:08 +0200 Subject: [PATCH 44/46] Fixed deploy url --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7e83584..4fc4e14 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ Camden.BUILD-SNAPSHOT com.example.github:github-webhook artifactory-local - https://localhost:8081/libs-release-local + https://localhost:8081/artifactory/libs-release-local From 956c9f3463bec7729bc7e5484f516b5c51bfd81f Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 6 Oct 2016 11:49:35 +0200 Subject: [PATCH 45/46] Fixed deploy url --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc4e14..262062b 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ Camden.BUILD-SNAPSHOT com.example.github:github-webhook artifactory-local - https://localhost:8081/artifactory/libs-release-local + http://localhost:8081/artifactory/libs-release-local From 388f4205dd8f1e4ad051c97719ef5503158cd0eb Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 12 Oct 2016 10:24:57 +0200 Subject: [PATCH 46/46] Updated repository root --- src/test/application-test.yml | 1 + .../springframework/github/AnalyticsApplicationTests.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/test/application-test.yml diff --git a/src/test/application-test.yml b/src/test/application-test.yml new file mode 100644 index 0000000..09db631 --- /dev/null +++ b/src/test/application-test.yml @@ -0,0 +1 @@ +stubrunner.repositoryRoot: ${REPO_WITH_JARS:https://repo.spring.io/milestone/} \ No newline at end of file diff --git a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java index 2d2ac4a..80804db 100644 --- a/src/test/java/org/springframework/github/AnalyticsApplicationTests.java +++ b/src/test/java/org/springframework/github/AnalyticsApplicationTests.java @@ -11,6 +11,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.MessageBuilder; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MimeTypeUtils; @@ -21,8 +22,8 @@ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = AnalyticsApplication.class) -@AutoConfigureStubRunner(repositoryRoot = "https://repo.spring.io/milestone/", - ids = {"com.example.github:github-webhook"}) +@AutoConfigureStubRunner(ids = {"com.example.github:github-webhook"}) +@ActiveProfiles("test") public class AnalyticsApplicationTests { @Autowired