Fixed the samples

This commit is contained in:
Marcin Grzejszczak
2019-08-28 16:05:52 +02:00
parent 2098e81ece
commit edf463d715
8 changed files with 11 additions and 51 deletions

View File

@@ -36,7 +36,9 @@ dependencyManagement {
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.cloud:spring-cloud-starter-stream-rabbit")
testCompile("org.springframework.cloud:spring-cloud-stream-test-support")
testCompile "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
testCompile "org.springframework.cloud:spring-cloud-starter-contract-verifier"
}

View File

@@ -18,8 +18,11 @@ package com.example.loan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink;
@SpringBootApplication
@EnableBinding(Sink.class)
public class Application {
public static void main(String[] args) {

View File

@@ -14,25 +14,12 @@
* limitations under the License.
*/
package com.example.sink;
package com.example.loan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Component;
@SpringBootApplication
@EnableBinding(Sink.class)
public class ContractVerifierSampleStreamSinkApplication {
public static void main(String[] args) {
SpringApplication.run(ContractVerifierSampleStreamSinkApplication.class, args);
}
}
@Component
class Listener {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.example.sink;
package com.example.loan;
/**
* @author Marius Bogoevici

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.example.sink;
package com.example.loan;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = "spring.cloud.stream.bindings.input.destination=sensor-data")
@AutoConfigureStubRunner(stubsMode = StubRunnerProperties.StubsMode.LOCAL)
@AutoConfigureStubRunner(ids = "com.example:http-server-dsl", stubsMode = StubRunnerProperties.StubsMode.LOCAL)
public class MessageConsumedTests {
@Autowired

View File

@@ -1,33 +0,0 @@
/*
* Copyright 2013-2019 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
*
* https://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 com.example.sink;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ContractVerifierSampleStreamSinkApplicationTests {
@Test
public void contextLoads() {
}
}

View File

@@ -45,7 +45,7 @@ dependencyManagement {
contracts {
packageWithBaseClasses = 'com.example.fraud'
convertToYaml = true
// convertToYaml = true
}
dependencies {

View File

@@ -62,6 +62,7 @@ class MyProcessorListener {
void listen(byte[] payload) {
log.info("Got the message!");
if (!Arrays.equals(payload, this.expectedInput)) {
log.error("Input payload size is [" + payload.length + "] and the expected one is [" + this.expectedInput.length + "]");
throw new IllegalStateException("Wrong input");
}
this.processor.output()