Skip to content

Commit

Permalink
Merge pull request #1605 from ngocnhan-tran1996
Browse files Browse the repository at this point in the history
* pr/1605:
  Use OS agnostic newline comparison

Closes gh-1605
  • Loading branch information
mhalbritter committed Oct 7, 2024
2 parents 1ed078d + ad12311 commit 964c0b1
Showing 1 changed file with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @author Eddú Meléndez
* @author Chris Bono
* @author Moritz Halbritter
* @author Ngoc Nhan
*/
class TestcontainersProjectGenerationConfigurationTests extends AbstractExtensionTests {

Expand Down Expand Up @@ -191,7 +192,7 @@ void testApplicationWithGroovyAndGenericContainerIsContributed() {
request.setLanguage("groovy");
assertThat(generateProject(request))
.textFile("src/test/groovy/com/example/demo/TestcontainersConfiguration.groovy")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.test.context.TestConfiguration
Expand Down Expand Up @@ -219,7 +220,7 @@ void testApplicationWithJavaAndGenericContainerIsContributed() {
request.setBootVersion(SPRING_BOOT_VERSION_3_3);
request.setLanguage("java");
assertThat(generateProject(request)).textFile("src/test/java/com/example/demo/TestcontainersConfiguration.java")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo;
import org.springframework.boot.test.context.TestConfiguration;
Expand Down Expand Up @@ -247,7 +248,7 @@ void testApplicationWithKotlinAndGenericContainerIsContributed() {
request.setBootVersion(SPRING_BOOT_VERSION_3_3);
request.setLanguage("kotlin");
assertThat(generateProject(request)).textFile("src/test/kotlin/com/example/demo/TestcontainersConfiguration.kt")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.test.context.TestConfiguration
Expand Down Expand Up @@ -276,7 +277,7 @@ void testApplicationWithGroovyAndSpecificContainerIsContributed() {
request.setLanguage("groovy");
ProjectStructure projectStructure = generateProject(request);
assertThat(projectStructure).textFile("src/test/groovy/com/example/demo/TestDemoApplication.groovy")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.SpringApplication
Expand All @@ -290,7 +291,7 @@ static void main(String[] args) {
}
""");
assertThat(projectStructure).textFile("src/test/groovy/com/example/demo/TestcontainersConfiguration.groovy")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.test.context.TestConfiguration
Expand All @@ -311,7 +312,7 @@ CassandraContainer cassandraContainer() {
}
""");
assertThat(projectStructure).textFile("src/test/groovy/com/example/demo/DemoApplicationTests.groovy")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.junit.jupiter.api.Test
Expand All @@ -336,21 +337,23 @@ void testApplicationWithJavaAndSpecificContainerIsContributed() {
request.setBootVersion(SPRING_BOOT_VERSION_3_3);
request.setLanguage("java");
ProjectStructure projectStructure = generateProject(request);
assertThat(projectStructure).textFile("src/test/java/com/example/demo/TestDemoApplication.java").isEqualTo("""
package com.example.demo;
assertThat(projectStructure).textFile("src/test/java/com/example/demo/TestDemoApplication.java")
.isEqualToNormalizingNewlines(
"""
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplication;
public class TestDemoApplication {
public class TestDemoApplication {
public static void main(String[] args) {
SpringApplication.from(DemoApplication::main).with(TestcontainersConfiguration.class).run(args);
}
public static void main(String[] args) {
SpringApplication.from(DemoApplication::main).with(TestcontainersConfiguration.class).run(args);
}
}
""");
}
""");
assertThat(projectStructure).textFile("src/test/java/com/example/demo/TestcontainersConfiguration.java")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo;
import org.springframework.boot.test.context.TestConfiguration;
Expand All @@ -370,23 +373,24 @@ CassandraContainer<?> cassandraContainer() {
}
""");
assertThat(projectStructure).textFile("src/test/java/com/example/demo/DemoApplicationTests.java").isEqualTo("""
package com.example.demo;
assertThat(projectStructure).textFile("src/test/java/com/example/demo/DemoApplicationTests.java")
.isEqualToNormalizingNewlines("""
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
@Import(TestcontainersConfiguration.class)
@SpringBootTest
class DemoApplicationTests {
@Import(TestcontainersConfiguration.class)
@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() {
}
@Test
void contextLoads() {
}
}
""");
}
""");
}

@Test
Expand All @@ -395,19 +399,20 @@ void testApplicationWithKotlinAndSpecificContainerIsContributed() {
request.setBootVersion(SPRING_BOOT_VERSION_3_3);
request.setLanguage("kotlin");
ProjectStructure projectStructure = generateProject(request);
assertThat(projectStructure).textFile("src/test/kotlin/com/example/demo/TestDemoApplication.kt").isEqualTo("""
package com.example.demo
assertThat(projectStructure).textFile("src/test/kotlin/com/example/demo/TestDemoApplication.kt")
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.fromApplication
import org.springframework.boot.with
import org.springframework.boot.fromApplication
import org.springframework.boot.with
fun main(args: Array<String>) {
fromApplication<DemoApplication>().with(TestcontainersConfiguration::class).run(*args)
}
""");
fun main(args: Array<String>) {
fromApplication<DemoApplication>().with(TestcontainersConfiguration::class).run(*args)
}
""");
assertThat(projectStructure).textFile("src/test/kotlin/com/example/demo/TestcontainersConfiguration.kt")
.isEqualTo("""
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.springframework.boot.test.context.TestConfiguration
Expand All @@ -427,23 +432,24 @@ fun cassandraContainer(): CassandraContainer<*> {
}
""");
assertThat(projectStructure).textFile("src/test/kotlin/com/example/demo/DemoApplicationTests.kt").isEqualTo("""
package com.example.demo
assertThat(projectStructure).textFile("src/test/kotlin/com/example/demo/DemoApplicationTests.kt")
.isEqualToNormalizingNewlines("""
package com.example.demo
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Import
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Import
@Import(TestcontainersConfiguration::class)
@SpringBootTest
class DemoApplicationTests {
@Import(TestcontainersConfiguration::class)
@SpringBootTest
class DemoApplicationTests {
@Test
fun contextLoads() {
}
@Test
fun contextLoads() {
}
}
""");
""");
}

@Test
Expand Down

0 comments on commit 964c0b1

Please sign in to comment.