Skip to content
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

JUnit 4 -> 5 #5899

Closed
wants to merge 9 commits into from
Closed
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
14 changes: 2 additions & 12 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ jobs:
with:
java-version: '17'
distribution: 'liberica'
- uses: jvalkeal/setup-maven@v1
with:
maven-version: 3.8.8
maven-mirror: 'https://dlcdn.apache.org/maven/maven-3/'
# secrets not available to PR.
# - name: Login dockerhub
# if: ${{ secrets.DOCKERHUB_USERNAME != null && secrets.DOCKERHUB_USERNAME != '' }}
# uses: docker/login-action@v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this commented out code?

Expand All @@ -39,14 +36,7 @@ jobs:
# build
- name: Build
run: |
mvn -B -s .github/settings.xml clean install
- name: Capture Test Results
if: failure()
uses: actions/upload-artifact@v3
with:
name: Unit Tests
path: '**/surefire-reports/*.xml'
retention-days: 3
./mvnw -B -s .github/settings.xml -Pasciidoctordocs,restdocs clean install
# clean m2 cache
- name: Clean cache
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AppResourceCommonTests {
private AppResourceCommon appResourceCommon = new AppResourceCommon(new MavenProperties(), resourceLoader);

@Test

void badNamedJars() throws Exception {
UrlResource urlResource = new UrlResource("https://repo.maven.apache.org/maven2/org/springframework/cloud/stream/app/file-sink-rabbit/5.0.0/file-sink-rabbit.jar");
assertThatIllegalArgumentException().isThrownBy( () -> appResourceCommon.getUrlResourceVersion(urlResource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ void pagination() throws Exception {
}

@Test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an artifact. But we can probably remove these blank lines between the @test and the function.

void listApplicationsByVersion() throws Exception {
mockMvc.perform(get("/apps?version=5.0.0").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.springframework.cloud.dataflow.shell.command;

import javax.sql.DataSource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;

import javax.sql.DataSource;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -38,7 +38,6 @@
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRepository;
Expand All @@ -51,8 +50,6 @@
import org.springframework.shell.table.Table;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Glenn Renfro
Expand Down Expand Up @@ -159,9 +156,7 @@ void viewExecution() {
logger.info("Retrieve Job Execution Detail by Id");
Table table = getTable(job().executionDisplay(getFirstJobExecutionIdFromTable()));
verifyColumnNumber(table, 2);
assertEquals(19,
table.getModel().getRowCount(),
"Number of expected rows returned from the table is incorrect");
assertThat(table.getModel().getRowCount()).as("Number of expected rows returned from the table is incorrect").isEqualTo(19);
int rowNumber = 0;
checkCell(table, rowNumber++, 0, "Key ");
checkCell(table, rowNumber++, 0, "Job Execution Id ");
Expand All @@ -181,14 +176,11 @@ void viewExecution() {
checkCell(table, rowNumber++, 0, "Job Parameters ");
int paramRowOne = rowNumber;

assertTrue(checkModelColumn(paramRowOne, table, "-foo(java.lang.String) "),
"the table did not contain the correct job parameters for job parameter value foo");
assertThat(checkModelColumn(paramRowOne, table, "-foo(java.lang.String) ")).as("the table did not contain the correct job parameters for job parameter value foo").isTrue();

assertTrue(checkModelColumn(paramRowOne, table, "bar(java.lang.String) "),
"the table did not contain the correct job parameters for job parameter value bar");
assertThat(checkModelColumn(paramRowOne, table, "bar(java.lang.String) ")).as("the table did not contain the correct job parameters for job parameter value bar").isTrue();

assertTrue(checkModelColumn(paramRowOne, table, "baz(java.lang.Long) "),
"the table did not contain the correct job parameters for job parameter value baz");
assertThat(checkModelColumn(paramRowOne, table, "baz(java.lang.Long) ")).as("the table did not contain the correct job parameters for job parameter value baz").isTrue();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.util.TestSocketUtils;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

/**
* Tests for {@link LocalTestDataFlowServer}.
Expand Down Expand Up @@ -73,10 +70,10 @@ void config() {
int randomPort = TestSocketUtils.findAvailableTcpPort();
String dataSourceUrl = String.format("jdbc:h2:tcp://localhost:%s/mem:dataflow;DATABASE_TO_UPPER=FALSE", randomPort);
context = app.run(new String[] { "--debug","--spring.cloud.kubernetes.enabled=false", "--server.port=0", "--spring.datasource.url=" + dataSourceUrl });
assertNotNull(context.getBean(AppRegistryService.class));
assertNotNull(context.getBean(TaskExecutionController.class));
assertThat(context.getBean(AppRegistryService.class)).isNotNull();
assertThat(context.getBean(TaskExecutionController.class)).isNotNull();
// From DataFlowControllerAutoConfiguration
assertNotNull(context.getBean(AboutController.class));
assertThat(context.getBean(AboutController.class)).isNotNull();
}

@Test
Expand All @@ -86,19 +83,19 @@ void localAutoConfigApplied() throws Exception {
// LocalDataFlowServerAutoConfiguration also adds docker and maven resource loaders.
DelegatingResourceLoader delegatingResourceLoader = context.getBean(DelegatingResourceLoader.class);
Map<String, ResourceLoader> loaders = TestUtils.readField("loaders", delegatingResourceLoader);
assertThat(loaders.size(), is(2));
assertThat(loaders.get("maven"), notNullValue());
assertThat(loaders.get("docker"), notNullValue());
assertThat(loaders).hasSize(2);
assertThat(loaders.get("maven")).isNotNull();
assertThat(loaders.get("docker")).isNotNull();
}

@Test
void configWithStreamsDisabled() {
SpringApplication app = new SpringApplication(LocalTestDataFlowServer.class);
context = app.run(new String[] { "--spring.cloud.kubernetes.enabled=false", "--server.port=0",
"--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.STREAMS_ENABLED + "=false" });
assertNotNull(context.getBean(TaskDefinitionRepository.class));
assertThat(context.getBean(TaskDefinitionRepository.class)).isNotNull();
// The StreamDefinition repository is expected to exist.
assertNotNull(context.getBean(StreamDefinitionRepository.class));
assertThat(context.getBean(StreamDefinitionRepository.class)).isNotNull();
try {
context.getBean(StreamService.class);
fail("Stream features should have been disabled.");
Expand All @@ -112,9 +109,9 @@ void configWithTasksDisabled() {
SpringApplication app = new SpringApplication(LocalTestDataFlowServer.class);
context = app.run(new String[] { "--spring.cloud.kubernetes.enabled=false", "--server.port=0",
"--" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.TASKS_ENABLED + "=false" });
assertNotNull(context.getBean(StreamDefinitionRepository.class));
assertThat(context.getBean(StreamDefinitionRepository.class)).isNotNull();
// The TaskDefinition repository is expected to exist.
assertNotNull(context.getBean(TaskDefinitionRepository.class));
assertThat(context.getBean(TaskDefinitionRepository.class)).isNotNull();
try {
context.getBean(TaskExecutionService.class);
fail("Task features should have been disabled.");
Expand All @@ -127,6 +124,6 @@ void configWithTasksDisabled() {
void noDataflowConfig() {
SpringApplication app = new SpringApplication(LocalTestNoDataFlowServer.class);
context = app.run(new String[] { "--spring.cloud.kubernetes.enabled=false", "--server.port=0", "--spring.jpa.database=H2", "--spring.flyway.enabled=false" });
assertThat(context.containsBean("appRegistry"), is(false));
assertThat(context.containsBean("appRegistry")).isEqualTo(false);
}
}
Loading