Skip to content

Commit d484647

Browse files
committed
Fix unit tests on Windows
1 parent 4da8c87 commit d484647

File tree

11 files changed

+84
-17
lines changed

11 files changed

+84
-17
lines changed

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v2/applications/ReactorApplicationsV2Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,10 @@ public void upload() throws IOException {
10021002
"{\"sha1\":\"ff84f89760317996b9dd180ab996b079f418396f\",\"fn\":\"path/to/code.jar\",\"size\":123}]" +
10031003
"\r\n" + "--" + boundary + "\r\n" +
10041004
"content-disposition: form-data; name=\"application\"; filename=\"application.zip\"\r\n" +
1005-
"content-length: 13\r\n" +
1005+
"content-length: 12\r\n" +
10061006
"content-type: application/zip\r\n" +
10071007
"\r\n" +
1008-
"test-content\n" +
1008+
"test-content" +
10091009
"\r\n" +
10101010
"--" + boundary + "--");
10111011
}))
@@ -1058,9 +1058,9 @@ public void uploadDroplet() throws IOException {
10581058
assertThat(body.readString(Charset.defaultCharset()))
10591059
.isEqualTo("\r\n" + "--" + boundary + "\r\n" +
10601060
"content-disposition: form-data; name=\"droplet\"; filename=\"test-droplet.tgz\"\r\n" +
1061-
"content-length: 13\r\n" +
1061+
"content-length: 12\r\n" +
10621062
"\r\n" +
1063-
"test-content\n" +
1063+
"test-content" +
10641064
"\r\n" +
10651065
"--" + boundary + "--");
10661066
}))

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v2/buildpacks/ReactorBuildpacksTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ public void upload() throws IOException {
280280
assertThat(body.readString(Charset.defaultCharset()))
281281
.isEqualTo("\r\n--" + boundary + "\r\n" +
282282
"content-disposition: form-data; name=\"buildpack\"; filename=\"test-filename\"\r\n" +
283-
"content-length: 13\r\n" +
283+
"content-length: 12\r\n" +
284284
"content-type: application/zip\r\n" +
285285
"\r\n" +
286-
"test-content\n" +
286+
"test-content" +
287287
"\r\n" +
288288
"--" + boundary + "--");
289289
}))

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackagesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ public void upload() throws IOException {
471471
assertThat(body.readString(Charset.defaultCharset()))
472472
.isEqualTo("\r\n--" + boundary + "\r\n" +
473473
"content-disposition: form-data; name=\"bits\"; filename=\"application.zip\"\r\n" +
474-
"content-length: 13\r\n" +
474+
"content-length: 12\r\n" +
475475
"content-type: application/zip\r\n" +
476476
"\r\n" +
477-
"test-content\n" +
477+
"test-content" +
478478
"\r\n" +
479479
"--" + boundary + "--");
480480
}))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test-content
1+
test-content
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test-content
1+
test-content
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test-content
1+
test-content
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
test-content
1+
test-content

cloudfoundry-operations/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
<groupId>org.yaml</groupId>
9292
<artifactId>snakeyaml</artifactId>
9393
</dependency>
94+
<dependency>
95+
<groupId>org.apache.commons</groupId>
96+
<artifactId>commons-lang3</artifactId>
97+
<scope>test</scope>
98+
</dependency>
9499
</dependencies>
95100

96101
<build>

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsTest.java

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

1717
package org.cloudfoundry.operations.applications;
1818

19+
import org.apache.commons.lang3.SystemUtils;
1920
import org.junit.Test;
2021
import org.springframework.core.io.ClassPathResource;
2122

@@ -30,6 +31,7 @@
3031
import static org.assertj.core.api.Assertions.assertThat;
3132
import static org.cloudfoundry.operations.applications.ApplicationHealthCheck.NONE;
3233
import static org.cloudfoundry.operations.applications.ApplicationHealthCheck.PORT;
34+
import static org.junit.Assume.assumeTrue;
3335

3436
public final class ApplicationManifestUtilsTest {
3537

@@ -512,7 +514,18 @@ public void testDiskQuotaAndMemoryParsing() throws Exception {
512514
}
513515

514516
@Test
515-
public void write() throws IOException {
517+
public void windowsWrite() throws IOException {
518+
assumeTrue(SystemUtils.IS_OS_WINDOWS);
519+
write("c:\\alpha-path", "fixtures/manifest-echo-windows.yml");
520+
}
521+
522+
@Test
523+
public void unixWrite() throws IOException {
524+
assumeTrue(SystemUtils.IS_OS_UNIX);
525+
write("/alpha-path", "fixtures/manifest-echo-unix.yml");
526+
}
527+
528+
private void write(String path, String expectedManifest) throws IOException {
516529
Path out = Files.createTempFile("test-manifest-", ".yml");
517530

518531
ApplicationManifestUtils.write(out, Arrays.asList(
@@ -525,7 +538,7 @@ public void write() throws IOException {
525538
.instances(-1)
526539
.memory(512)
527540
.noRoute(true)
528-
.path(Paths.get("/alpha-path"))
541+
.path(Paths.get(path))
529542
.randomRoute(true)
530543
.route(Route.builder()
531544
.route("alpha-route-1")
@@ -555,7 +568,7 @@ public void write() throws IOException {
555568
.instances(-1)
556569
.noHostname(true)
557570
.noRoute(true)
558-
.path(Paths.get("c:\\alpha-path"))
571+
.path(Paths.get(path))
559572
.randomRoute(true)
560573
.stack("alpha-stack")
561574
.timeout(-1)
@@ -565,7 +578,7 @@ public void write() throws IOException {
565578
.service("alpha-instance-2")
566579
.build()));
567580

568-
List<String> expected = Files.readAllLines(new ClassPathResource("fixtures/manifest-echo.yml").getFile().toPath());
581+
List<String> expected = Files.readAllLines(new ClassPathResource(expectedManifest).getFile().toPath());
569582
List<String> actual = Files.readAllLines(out);
570583

571584
assertThat(actual).isEqualTo(expected);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
applications:
3+
- buildpack: alpha-buildpack
4+
command: alpha-command
5+
disk_quota: 512M
6+
env:
7+
ALPHA_KEY_1: alpha-value-1
8+
ALPHA_KEY_2: alpha-value-2
9+
health-check-http-endpoint: alpha-health-check-http-endpoint
10+
instances: -1
11+
memory: 512M
12+
name: alpha-application-1
13+
no-route: true
14+
path: /alpha-path
15+
random-route: true
16+
routes:
17+
- route: alpha-route-1
18+
- route: alpha-route-2
19+
services:
20+
- alpha-instance-1
21+
- alpha-instance-2
22+
stack: alpha-stack
23+
timeout: -1
24+
- buildpack: alpha-buildpack
25+
command: alpha-command
26+
domains:
27+
- alpha-domain
28+
- alpha-domains-1
29+
- alpha-domains-2
30+
env:
31+
ALPHA_KEY_1: alpha-value-1
32+
ALPHA_KEY_2: alpha-value-2
33+
health-check-http-endpoint: alpha-health-check-http-endpoint
34+
health-check-type: port
35+
hosts:
36+
- alpha-host
37+
- alpha-hosts-1
38+
- alpha-hosts-2
39+
instances: -1
40+
name: alpha-application-2
41+
no-hostname: true
42+
no-route: true
43+
path: /alpha-path
44+
random-route: true
45+
services:
46+
- alpha-instance-1
47+
- alpha-instance-2
48+
stack: alpha-stack
49+
timeout: -1

0 commit comments

Comments
 (0)