pull/11971/head
Phillip Webb 7 years ago
parent a0f4071390
commit 5de46c3186

@ -40,6 +40,7 @@ import org.springframework.kafka.core.KafkaAdmin;
* {@link EnableAutoConfiguration Auto-configuration} for {@link KafkaHealthIndicator}. * {@link EnableAutoConfiguration Auto-configuration} for {@link KafkaHealthIndicator}.
* *
* @author Juan Rada * @author Juan Rada
* @since 2.0.0
*/ */
@Configuration @Configuration
@ConditionalOnClass(KafkaAdmin.class) @ConditionalOnClass(KafkaAdmin.class)
@ -55,7 +56,7 @@ public class KafkaHealthIndicatorAutoConfiguration
private final KafkaHealthIndicatorProperties properties; private final KafkaHealthIndicatorProperties properties;
KafkaHealthIndicatorAutoConfiguration(Map<String, KafkaAdmin> admins, public KafkaHealthIndicatorAutoConfiguration(Map<String, KafkaAdmin> admins,
KafkaHealthIndicatorProperties properties) { KafkaHealthIndicatorProperties properties) {
this.admins = admins; this.admins = admins;
this.properties = properties; this.properties = properties;

@ -62,8 +62,8 @@ class MeterRegistryConfigurer {
if (registry instanceof CompositeMeterRegistry) { if (registry instanceof CompositeMeterRegistry) {
return; return;
} }
// Customizers must be applied before binders, as they may add custom tags or // Customizers must be applied before binders, as they may add custom
// alter timer or summary configuration. // tags or alter timer or summary configuration.
customize(registry); customize(registry);
addFilters(registry); addFilters(registry);
addBinders(registry); addBinders(registry);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -53,4 +53,5 @@ public class KafkaHealthIndicatorAutoConfigurationTests {
.doesNotHaveBean(KafkaHealthIndicator.class) .doesNotHaveBean(KafkaHealthIndicator.class)
.hasSingleBean(ApplicationHealthIndicator.class)); .hasSingleBean(ApplicationHealthIndicator.class));
} }
} }

@ -38,6 +38,7 @@ import org.springframework.util.Assert;
* {@link HealthIndicator} for Kafka cluster. * {@link HealthIndicator} for Kafka cluster.
* *
* @author Juan Rada * @author Juan Rada
* @since 2.0.0
*/ */
public class KafkaHealthIndicator extends AbstractHealthIndicator { public class KafkaHealthIndicator extends AbstractHealthIndicator {

@ -128,11 +128,10 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
private Object getHandler(HttpServletRequest request) throws Exception { private Object getHandler(HttpServletRequest request) throws Exception {
HttpServletRequest wrapper = new UnmodifiableAttributesRequestWrapper(request); HttpServletRequest wrapper = new UnmodifiableAttributesRequestWrapper(request);
for (HandlerMapping handlerMapping : getMappingIntrospector() for (HandlerMapping mapping : getMappingIntrospector().getHandlerMappings()) {
.getHandlerMappings()) { HandlerExecutionChain chain = mapping.getHandler(wrapper);
HandlerExecutionChain chain = handlerMapping.getHandler(wrapper);
if (chain != null) { if (chain != null) {
if (handlerMapping instanceof MatchableHandlerMapping) { if (mapping instanceof MatchableHandlerMapping) {
return chain.getHandler(); return chain.getHandler();
} }
return null; return null;
@ -294,8 +293,8 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
@Override @Override
public void setAttribute(String name, Object value) { public void setAttribute(String name, Object value) {
} }
} }
} }

@ -132,27 +132,32 @@ public class JerseyWebEndpointIntegrationTests extends
protected void doFilterInternal(HttpServletRequest request, protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain) HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException { throws ServletException, IOException {
filterChain.doFilter(new HttpServletRequestWrapper(request) { filterChain.doFilter(new MockPrincipalWrapper(request), response);
}
@Override };
public Principal getUserPrincipal() { }
return new Principal() { }
@Override private static class MockPrincipalWrapper extends HttpServletRequestWrapper {
public String getName() {
return "Alice";
}
}; public MockPrincipalWrapper(HttpServletRequest request) {
super(request);
}
} @Override
public Principal getUserPrincipal() {
return new MockPrincipal();
}
}, response); }
}
}; private static class MockPrincipal implements Principal {
@Override
public String getName() {
return "Alice";
} }
} }

@ -152,24 +152,34 @@ public class WebFluxEndpointIntegrationTests
@Override @Override
public Mono<Void> filter(ServerWebExchange exchange, public Mono<Void> filter(ServerWebExchange exchange,
WebFilterChain chain) { WebFilterChain chain) {
return chain.filter(new ServerWebExchangeDecorator(exchange) { return chain.filter(
new MockPrincipalServerWebExchangeDecorator(exchange));
}
@Override };
public Mono<Principal> getPrincipal() { }
return Mono.just(new Principal() {
@Override }
public String getName() {
return "Alice";
}
}); private static class MockPrincipalServerWebExchangeDecorator
} extends ServerWebExchangeDecorator {
}); protected MockPrincipalServerWebExchangeDecorator(ServerWebExchange delegate) {
} super(delegate);
}
}; @Override
public Mono<Principal> getPrincipal() {
return Mono.just(new MockPrincipal());
}
}
private static class MockPrincipal implements Principal {
@Override
public String getName() {
return "Alice";
} }
} }

@ -146,27 +146,32 @@ public class MvcWebEndpointIntegrationTests extends
protected void doFilterInternal(HttpServletRequest request, protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain) HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException { throws ServletException, IOException {
filterChain.doFilter(new HttpServletRequestWrapper(request) { filterChain.doFilter(new MockPrincipalWrapper(request), response);
}
@Override };
public Principal getUserPrincipal() { }
return new Principal() { }
@Override private static class MockPrincipalWrapper extends HttpServletRequestWrapper {
public String getName() {
return "Alice";
}
}; public MockPrincipalWrapper(HttpServletRequest request) {
super(request);
}
} @Override
public Principal getUserPrincipal() {
return new MockPrincipal();
}
}, response); }
}
}; private static class MockPrincipal implements Principal {
@Override
public String getName() {
return "Alice";
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -6152,6 +6152,8 @@ NOTE: While Spring's test framework caches application contexts between tests an
a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean` a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean`
influences the cache key, which will most likely increase the number of contexts. influences the cache key, which will most likely increase the number of contexts.
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]] [[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]]
==== Auto-configured Tests ==== Auto-configured Tests
Spring Boot's auto-configuration system works well for applications but can sometimes be Spring Boot's auto-configuration system works well for applications but can sometimes be

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -127,27 +127,25 @@ class JavaBeanBinder implements BeanBinder {
int parameterCount = method.getParameterCount(); int parameterCount = method.getParameterCount();
if (name.startsWith("get") && parameterCount == 0) { if (name.startsWith("get") && parameterCount == 0) {
name = Introspector.decapitalize(name.substring(3)); name = Introspector.decapitalize(name.substring(3));
this.properties this.properties.computeIfAbsent(name, this::getBeanProperty)
.computeIfAbsent(name,
(n) -> new BeanProperty(n, this.resolvableType))
.addGetter(method); .addGetter(method);
} }
else if (name.startsWith("is") && parameterCount == 0) { else if (name.startsWith("is") && parameterCount == 0) {
name = Introspector.decapitalize(name.substring(2)); name = Introspector.decapitalize(name.substring(2));
this.properties this.properties.computeIfAbsent(name, this::getBeanProperty)
.computeIfAbsent(name,
(n) -> new BeanProperty(n, this.resolvableType))
.addGetter(method); .addGetter(method);
} }
else if (name.startsWith("set") && parameterCount == 1) { else if (name.startsWith("set") && parameterCount == 1) {
name = Introspector.decapitalize(name.substring(3)); name = Introspector.decapitalize(name.substring(3));
this.properties this.properties.computeIfAbsent(name, this::getBeanProperty)
.computeIfAbsent(name,
(n) -> new BeanProperty(n, this.resolvableType))
.addSetter(method); .addSetter(method);
} }
} }
private BeanProperty getBeanProperty(String name) {
return new BeanProperty(name, this.resolvableType);
}
private void addField(Field field) { private void addField(Field field) {
BeanProperty property = this.properties.get(field.getName()); BeanProperty property = this.properties.get(field.getName());
if (property != null) { if (property != null) {

@ -107,8 +107,7 @@ public class ApplicationHome {
try { try {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (int i = stackTrace.length - 1; i >= 0; i--) { for (int i = stackTrace.length - 1; i >= 0; i--) {
StackTraceElement element = stackTrace[i]; if (stackTrace[i].getClassName().startsWith("org.junit.")) {
if (element.getClassName().startsWith("org.junit.")) {
return true; return true;
} }
} }

@ -370,6 +370,7 @@ public class BinderTests {
public void setBar(T bar) { public void setBar(T bar) {
this.bar = bar; this.bar = bar;
} }
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<!-- Your own application should inherit from spring-boot-starter-parent --> <!-- Your own application should inherit from spring-boot-starter-parent -->
@ -11,11 +11,9 @@
<artifactId>spring-boot-sample-kafka</artifactId> <artifactId>spring-boot-sample-kafka</artifactId>
<name>Spring Boot Kafka Sample</name> <name>Spring Boot Kafka Sample</name>
<description>Spring Boot Kafka Sample</description> <description>Spring Boot Kafka Sample</description>
<properties> <properties>
<main.basedir>${basedir}/../..</main.basedir> <main.basedir>${basedir}/../..</main.basedir>
</properties> </properties>
<dependencies> <dependencies>
<!-- Compile --> <!-- Compile -->
<dependency> <dependency>
@ -38,7 +36,6 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package sample.kafka; package sample.kafka;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
@ -26,4 +27,4 @@ class Consumer {
System.out.println("Received sample message [" + message + "]"); System.out.println("Received sample message [" + message + "]");
} }
} }

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package sample.kafka; package sample.kafka;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
@ -32,4 +33,4 @@ public class Producer {
System.out.println("Sent sample message [" + message + "]"); System.out.println("Sent sample message [" + message + "]");
} }
} }

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package sample.kafka; package sample.kafka;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication

@ -41,11 +41,7 @@ public class SampleMessage {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("SampleMessage{"); return "SampleMessage{id=" + this.id + ", message='" + this.message + "'}";
sb.append("id=").append(this.id);
sb.append(", message='").append(this.message).append('\'');
sb.append('}');
return sb.toString();
} }
} }

@ -22,7 +22,6 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.rule.OutputCapture;
@ -64,11 +63,13 @@ public class SampleKafkaApplicationTests {
@Bean @Bean
public Consumer consumer() { public Consumer consumer() {
return new Consumer() { return new Consumer() {
@Override @Override
public void processMessage(SampleMessage message) { public void processMessage(SampleMessage message) {
super.processMessage(message); super.processMessage(message);
latch.countDown(); latch.countDown();
} }
}; };
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

Loading…
Cancel
Save