Skip to content

Commit

Permalink
Bumping versions
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-builds committed Jul 23, 2024
1 parent 8445b04 commit c4f557d
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void before() {
"spring.rabbitmq.port=" + rabbitMQContainer.getAmqpPort(),
"management.endpoints.web.exposure.include=*", "spring.cloud.bus.id=app:2",
"spring.autoconfigure.exclude=org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration")
.run();
.run();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public void testCustomEventSerializes() {
assertThat(this.converter.isMapperCreated()).isFalse();

// set by configuration
assertThat(this.converter.getMapper().getSerializationConfig()
.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)).isTrue();
assertThat(this.converter.getMapper()
.getSerializationConfig()
.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)).isTrue();

Map map = this.rest.getForObject("http://localhost:" + this.port + "/date", Map.class);
assertThat(map).containsOnlyKeys("date");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class BusEnvironmentPostProcessor implements EnvironmentPostProcessor {
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
if (environment.containsProperty(ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED)) {
if (Boolean.FALSE.toString()
.equalsIgnoreCase(environment.getProperty(ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED))) {
.equalsIgnoreCase(environment.getProperty(ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED))) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ public void setContentType(MimeType contentType) {

@Override
public String toString() {
return new ToStringCreator(this).append("ack", ack).append("trace", trace).append("destination", destination)
.append("id", id).append("contentType", contentType).append("enabled", enabled).toString();
return new ToStringCreator(this).append("ack", ack)
.append("trace", trace)
.append("destination", destination)
.append("id", id)
.append("contentType", contentType)
.append("enabled", enabled)
.toString();

}

Expand Down Expand Up @@ -143,8 +148,9 @@ public void setDestinationService(String destinationService) {

@Override
public String toString() {
return new ToStringCreator(this).append("enabled", enabled).append("destinationService", destinationService)
.toString();
return new ToStringCreator(this).append("enabled", enabled)
.append("destinationService", destinationService)
.toString();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ else if (!this.values.equals(other.values)) {

@Override
public String toString() {
return new ToStringCreator(this).append("id", getId()).append("originService", getOriginService())
.append("destinationService", getDestinationService()).append("values", values).toString();
return new ToStringCreator(this).append("id", getId())
.append("originService", getOriginService())
.append("destinationService", getDestinationService())
.append("values", values)
.toString();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ else if (!this.originService.equals(other.originService)) {

@Override
public String toString() {
return new ToStringCreator(this).append("id", id).append("originService", originService)
.append("destinationService", destinationService).toString();
return new ToStringCreator(this).append("id", id)
.append("originService", originService)
.append("destinationService", destinationService)
.toString();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public String getPayloadAsString() {

@Override
public String toString() {
return new ToStringCreator(this).append("id", getId()).append("originService", getOriginService())
.append("destinationService", getDestinationService()).append("typeInfo", typeInfo)
.append("payload", getPayloadAsString()).toString();
return new ToStringCreator(this).append("id", getId())
.append("originService", getOriginService())
.append("destinationService", getDestinationService())
.append("typeInfo", typeInfo)
.append("payload", getPayloadAsString())
.toString();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void registerBeanDefinitions(final AnnotationMetadata importingClassMetad
final BeanDefinitionRegistry registry) {

Map<String, Object> componentScan = importingClassMetadata
.getAnnotationAttributes(RemoteApplicationEventScan.class.getName(), false);
.getAnnotationAttributes(RemoteApplicationEventScan.class.getName(), false);

Set<String> basePackages = new HashSet<>();
for (String pkg : (String[]) componentScan.get("value")) {
Expand All @@ -70,7 +70,7 @@ public void registerBeanDefinitions(final AnnotationMetadata importingClassMetad

if (!registry.containsBeanDefinition(BUS_JSON_CONVERTER)) {
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder
.genericBeanDefinition(BusJacksonMessageConverter.class);
.genericBeanDefinition(BusJacksonMessageConverter.class);
beanDefinitionBuilder.addPropertyValue(PACKAGES_TO_SCAN,
basePackages.toArray(new String[basePackages.size()]));
AbstractBeanDefinition beanDefinition = beanDefinitionBuilder.getBeanDefinition();
Expand All @@ -80,16 +80,18 @@ public void registerBeanDefinitions(final AnnotationMetadata importingClassMetad
}
else {
basePackages.addAll(getEarlierPackagesToScan(registry));
registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues().addPropertyValue(PACKAGES_TO_SCAN,
basePackages.toArray(new String[basePackages.size()]));
registry.getBeanDefinition(BUS_JSON_CONVERTER)
.getPropertyValues()
.addPropertyValue(PACKAGES_TO_SCAN, basePackages.toArray(new String[basePackages.size()]));
}
}

private Set<String> getEarlierPackagesToScan(final BeanDefinitionRegistry registry) {
if (registry.containsBeanDefinition(BUS_JSON_CONVERTER)
&& registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues().get(PACKAGES_TO_SCAN) != null) {
String[] earlierValues = (String[]) registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues()
.get(PACKAGES_TO_SCAN);
String[] earlierValues = (String[]) registry.getBeanDefinition(BUS_JSON_CONVERTER)
.getPropertyValues()
.get(PACKAGES_TO_SCAN);
return new HashSet<>(Arrays.asList(earlierValues));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class BusAutoConfigurationClassPathTests {
@Test
public void refreshListenerCreatedWithoutActuator() {
new ApplicationContextRunner().withClassLoader(new FilteredClassLoader("org.springframework.boot.actuate"))
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class,
PathServiceMatcherAutoConfiguration.class, BusRefreshAutoConfiguration.class))
.run(context -> assertThat(context).hasSingleBean(RefreshListener.class)
.doesNotHaveBean(RefreshBusEndpoint.class));
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class,
PathServiceMatcherAutoConfiguration.class, BusRefreshAutoConfiguration.class))
.run(context -> assertThat(context).hasSingleBean(RefreshListener.class)
.doesNotHaveBean(RefreshBusEndpoint.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ public void close() {
public void defaultId() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--server.port=0");
assertThat(this.context.getBean(BusProperties.class).getId().startsWith("application:0:"))
.as("Wrong ID: " + this.context.getBean(BusProperties.class).getId()).isTrue();
.as("Wrong ID: " + this.context.getBean(BusProperties.class).getId())
.isTrue();
}

@Test
public void inboundNotForSelf() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=foo",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "bar", "bar")));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "bar", "bar")));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNull();
}

Expand All @@ -82,7 +83,7 @@ public void inboundFromSelf() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=foo",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNull();
}

Expand All @@ -91,7 +92,7 @@ public void inboundNotFromSelf() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull();
}

Expand All @@ -103,7 +104,7 @@ public void inboundNotFromSelfWithAck() throws Exception {
new String[] { "--spring.cloud.bus.id=bar", "--server.port=0",
"--spring.main.allow-bean-definition-overriding=true" });
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null)));
RefreshRemoteApplicationEvent refresh = this.context.getBean(InboundMessageHandlerConfiguration.class).refresh;
assertThat(refresh).isNotNull();
TestStreamBusBridge busBridge = this.context.getBean(TestStreamBusBridge.class);
Expand Down Expand Up @@ -135,8 +136,9 @@ public void inboundAckWithTrace() throws InterruptedException {
AckMessageConfiguration.class },
new String[] { "--spring.cloud.bus.trace.enabled=true", "--spring.cloud.bus.id=bar",
"--server.port=0" });
this.context.getBean(BusConsumer.class).accept(new AckRemoteApplicationEvent(this, "foo",
new PathDestinationFactory().getDestination(null), "ID", "bar", RefreshRemoteApplicationEvent.class));
this.context.getBean(BusConsumer.class)
.accept(new AckRemoteApplicationEvent(this, "foo", new PathDestinationFactory().getDestination(null), "ID",
"bar", RefreshRemoteApplicationEvent.class));
AckMessageConfiguration ack = this.context.getBean(AckMessageConfiguration.class);
assertThat(ack.latch.await(5, TimeUnit.SECONDS)).isTrue();
assertThat(ack.event).isNotNull();
Expand Down Expand Up @@ -166,7 +168,7 @@ public void inboundNotFromSelfPathPattern() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar:1000",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:*")));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:*")));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull();
}

Expand All @@ -175,7 +177,7 @@ public void inboundNotFromSelfDeepPathPattern() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class,
"--spring.cloud.bus.id=bar:test:1000", "--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:**")));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:**")));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull();
}

Expand All @@ -184,7 +186,7 @@ public void inboundNotFromSelfFlatPattern() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar*")));
.send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar*")));
assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull();
}

Expand All @@ -194,7 +196,7 @@ public void inboundNotFromSelfUnknown() {
this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar",
"--server.port=0");
this.context.getBean(BusConstants.INPUT, MessageChannel.class)
.send(new GenericMessage<>(new UnknownRemoteApplicationEvent(this, "UnknownEvent", "yada".getBytes())));
.send(new GenericMessage<>(new UnknownRemoteApplicationEvent(this, "UnknownEvent", "yada".getBytes())));
// No Exception expected
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void testDefaults() {
@Test
void testWithActiveProfile() {
MockEnvironment env = new MockEnvironment().withProperty("cachedrandom.application.value", "123")
.withProperty("spring.profiles.active", "dev");
.withProperty("spring.profiles.active", "dev");
new BusEnvironmentPostProcessor().postProcessEnvironment(env, mock(SpringApplication.class));
assertThat(env.getProperty(FunctionProperties.PREFIX + ".definition")).isEqualTo(BUS_CONSUMER);
assertThat(env.getProperty("spring.cloud.stream.function.bindings." + BUS_CONSUMER + "-in-0")).isEqualTo(INPUT);
Expand All @@ -65,15 +65,16 @@ void testOverrides() {
String fnDefKey = FunctionProperties.PREFIX + ".definition";
String idKey = BusProperties.PREFIX + ".id";
MockEnvironment env = new MockEnvironment().withProperty("cachedrandom.application.value", "123")
.withProperty(BusProperties.PREFIX + ".destination", "mydestination").withProperty(idKey, "app:1")
.withProperty(fnDefKey, "uppercase");
.withProperty(BusProperties.PREFIX + ".destination", "mydestination")
.withProperty(idKey, "app:1")
.withProperty(fnDefKey, "uppercase");
new BusEnvironmentPostProcessor().postProcessEnvironment(env, mock(SpringApplication.class));
assertThat(env.getProperty(fnDefKey)).isEqualTo("uppercase;" + BUS_CONSUMER);
assertThat(env.getProperty("spring.cloud.stream.function.bindings." + BUS_CONSUMER + "-in-0")).isEqualTo(INPUT);
assertThat(env.getProperty("spring.cloud.stream.bindings." + INPUT + ".destination"))
.isEqualTo("mydestination");
.isEqualTo("mydestination");
assertThat(env.getProperty("spring.cloud.stream.bindings." + OUTPUT + ".destination"))
.isEqualTo("mydestination");
.isEqualTo("mydestination");
assertThat(env.getProperty(idKey)).isEqualTo("app:1");
assertThat(env.getPropertySources().contains(OVERRIDES_PROPERTY_SOURCE_NAME));
assertThat(env.getPropertySources().contains(DEFAULTS_PROPERTY_SOURCE_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void busEnabledMissing() {
public void busDisabled() {
load(MyBusEnabledConfig.class, ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED + ":false");
assertThat(this.context.containsBean("foo")).as("bean exists from disabled @ConditionalOnBusEnabled config")
.isFalse();
.isFalse();
}

private void load(Class<?> config, String... environment) {
Expand Down
Loading

0 comments on commit c4f557d

Please sign in to comment.