Skip to content

Switch remaining JUnit 4 tests to JUnit Jupiter #4011 #4425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 4.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions spring-cloud-netflix-eureka-client-tls-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions spring-cloud-netflix-eureka-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-test-support</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2024 the original author or authors.
* Copyright 2013-2025 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.
Expand All @@ -25,23 +25,22 @@
import com.netflix.discovery.shared.transport.EurekaHttpClient;
import com.netflix.discovery.shared.transport.EurekaHttpResponse;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.cloud.config.client.ConfigServerInstanceProvider;
import org.springframework.cloud.netflix.eureka.CloudEurekaClient;
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient;
import org.springframework.cloud.test.ClassPathExclusions;
import org.springframework.cloud.test.ModifiedClassPathRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -52,103 +51,101 @@
/**
* @author Spencer Gibb
* @author Tang Xiong
* @author David Vana
*/
@RunWith(ModifiedClassPathRunner.class)
@ExtendWith(OutputCaptureExtension.class)
@ClassPathExclusions("spring-webflux-*")
public class EurekaConfigServerBootstrapConfigurationTests {

@Rule
public OutputCaptureRule output = new OutputCaptureRule();
class EurekaConfigServerBootstrapConfigurationTests {

@Test
public void offByDefault() {
void offByDefault() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void properBeansCreatedWhenDiscoveryEnabled() {
void properBeansCreatedWhenDiscoveryEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true")
.run(this::assertEurekaBeansPresent);
}

@Test
public void beansNotCreatedWhenDiscoveryNotEnabled() {
void beansNotCreatedWhenDiscoveryNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenDiscoveryDisabled() {
void beansNotCreatedWhenDiscoveryDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.disabled")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenEurekaClientEnabled() {
void beansNotCreatedWhenEurekaClientEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=true")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenEurekaClientNotEnabled() {
void beansNotCreatedWhenEurekaClientNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenEurekaClientDisabled() {
void beansNotCreatedWhenEurekaClientDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.disabled")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void properBeansCreatedWhenDiscoveryEnabled_EurekaEnabled() {
void properBeansCreatedWhenDiscoveryEnabled_EurekaEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true")
.run(this::assertEurekaBeansPresent);
}

@Test
public void beansNotCreatedWhenDiscoveryEnabled_EurekaNotEnabled() {
void beansNotCreatedWhenDiscoveryEnabled_EurekaNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaEnabled() {
void beansNotCreatedWhenDiscoveryNotEnabled_EurekaEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=true")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaNotEnabled() {
void beansNotCreatedWhenDiscoveryNotEnabled_EurekaNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}

@Test
public void eurekaDnsConfigurationWorks() {
void eurekaDnsConfigurationWorks(CapturedOutput output) {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true",
Expand All @@ -160,7 +157,7 @@ public void eurekaDnsConfigurationWorks() {
}

@Test
public void eurekaConfigServerInstanceProviderCalled() {
void eurekaConfigServerInstanceProviderCalled(CapturedOutput output) {
// FIXME: why do I need to do this? (fails in maven build without it.
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
Expand All @@ -175,7 +172,7 @@ public void eurekaConfigServerInstanceProviderCalled() {
}

@Test
public void eurekaConfigServerInstanceProviderCalledWithRemoteRegions() {
void eurekaConfigServerInstanceProviderCalledWithRemoteRegions(CapturedOutput output) {
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
Expand All @@ -189,7 +186,7 @@ public void eurekaConfigServerInstanceProviderCalledWithRemoteRegions() {
}

@Test
public void eurekaConfigServerInstanceProviderCalledWithVipAddress() {
void eurekaConfigServerInstanceProviderCalledWithVipAddress(CapturedOutput output) {
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 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.
Expand All @@ -17,30 +17,25 @@
package org.springframework.cloud.netflix.eureka.config;

import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication;
import org.springframework.cloud.test.ClassPathExclusions;
import org.springframework.cloud.test.ModifiedClassPathRunner;
import org.springframework.context.ConfigurableApplicationContext;

import static org.assertj.core.api.AssertionsForClassTypes.fail;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

/**
* @author Daniel Lavoie
* @author David Vana
*/
@RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions({ "jersey-client-*", "jersey-core-*", "jersey-apache-client4-*", "spring-webflux-*" })
@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class EurekaHttpClientsOptionalArgsConfigurationNoWebFluxTests {
class EurekaHttpClientsOptionalArgsConfigurationNoWebFluxTests {

@Test
public void contextFailsWithoutWebClient() {
void contextFailsWithoutWebClient() {

ConfigurableApplicationContext ctx = null;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 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.
Expand All @@ -16,30 +16,25 @@

package org.springframework.cloud.netflix.eureka.config;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs;
import org.springframework.cloud.netflix.eureka.http.WebClientDiscoveryClientOptionalArgs;
import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication;
import org.springframework.cloud.test.ClassPathExclusions;
import org.springframework.cloud.test.ModifiedClassPathRunner;

import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

/**
* @author Daniel Lavoie
* @author David Vana
*/
@RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions({ "jersey-client-*", "jersey-core-*", "jersey-apache-client4-*" })
@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class EurekaHttpClientsOptionalArgsConfigurationTests {
class EurekaHttpClientsOptionalArgsConfigurationTests {

@Test
public void contextLoadsWithRestTemplate() {
void contextLoadsWithRestTemplate() {
new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class)
.withPropertyValues("eureka.client.webclient.enabled=false")
.run(context -> {
Expand All @@ -49,7 +44,7 @@ public void contextLoadsWithRestTemplate() {
}

@Test
public void contextLoadsWithWebClient() {
void contextLoadsWithWebClient() {
new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class)
.withPropertyValues("eureka.client.webclient.enabled=true")
.run(context -> {
Expand All @@ -59,7 +54,7 @@ public void contextLoadsWithWebClient() {
}

@Test
public void contextLoadsWithRestTemplateAsDefault() {
void contextLoadsWithRestTemplateAsDefault() {
new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class).run(context -> {
assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class);
Expand Down
Loading