Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 2a16758

Browse files
committed
Fix tests on windows
- Fix some tests so that build on windows is possible. - This is mostly around spaces, line breaks and file/dir separators. - Relates #182
1 parent 698b336 commit 2a16758

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/test/java/org/springframework/cli/runtime/engine/actions/handlers/GenerateHandlerTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cli.runtime.engine.actions.handlers;
1818

19+
import java.io.File;
1920
import java.nio.file.Path;
2021

2122
import org.junit.jupiter.api.Test;
@@ -49,8 +50,8 @@ void generateFileUsingModelPopulators(@TempDir(cleanup = CleanupMode.ON_SUCCESS)
4950
Path helloPath = workingDir.resolve("hello.txt");
5051
assertThat(helloPath).exists();
5152
String tempDir = System.getProperty("java.io.tmpdir");
52-
String expectedContents = "Hello World with Java 8 Root package com/example/restservice Temp dir "
53-
+ tempDir;
53+
String expectedContents = "Hello World with Java 8 Root package " + "com" + File.separatorChar + "example"
54+
+ File.separatorChar + "restservice Temp dir " + tempDir;
5455
assertThat(helloPath.toFile()).hasContent(expectedContents);
5556

5657
});

src/test/java/org/springframework/cli/util/MavenDependencyReaderTests.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 the original author or authors.
2+
* Copyright 2021-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,13 +34,16 @@ void read() {
3434
MavenDependencyReader mavenDependencyReader = new MavenDependencyReader();
3535
String[] mavenDependencies = mavenDependencyReader.parseMavenSection(dependencyText);
3636
assertThat(mavenDependencies).hasSize(3);
37-
assertThat(mavenDependencies[0]).isEqualTo("<dependency>\n" + " <groupId>org.springframework.boot</groupId>\n"
38-
+ " <artifactId>spring-boot-starter-data-jpa</artifactId>\n" + "</dependency>");
39-
assertThat(mavenDependencies[1]).isEqualTo("<dependency>\n" + " <groupId>org.springframework.boot</groupId>\n"
40-
+ " <artifactId>spring-boot-starter-test</artifactId>\n" + " <scope>test</scope>\n"
41-
+ "</dependency>");
42-
assertThat(mavenDependencies[2]).isEqualTo("<dependency>\n" + " <groupId>com.h2database</groupId>\n"
43-
+ " <artifactId>h2</artifactId>\n" + " <scope>runtime</scope>\n" + "</dependency>");
37+
assertThat(mavenDependencies[0])
38+
.isEqualToIgnoringWhitespace("<dependency>\n" + " <groupId>org.springframework.boot</groupId>\n"
39+
+ " <artifactId>spring-boot-starter-data-jpa</artifactId>\n" + "</dependency>");
40+
assertThat(mavenDependencies[1])
41+
.isEqualToIgnoringWhitespace("<dependency>\n" + " <groupId>org.springframework.boot</groupId>\n"
42+
+ " <artifactId>spring-boot-starter-test</artifactId>\n" + " <scope>test</scope>\n"
43+
+ "</dependency>");
44+
assertThat(mavenDependencies[2])
45+
.isEqualToIgnoringWhitespace("<dependency>\n" + " <groupId>com.h2database</groupId>\n"
46+
+ " <artifactId>h2</artifactId>\n" + " <scope>runtime</scope>\n" + "</dependency>");
4447
}
4548

4649
}

0 commit comments

Comments
 (0)