Skip to content

Commit

Permalink
gziped expected builds
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Apr 3, 2024
1 parent f3299f8 commit 2c142a0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2,966 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.github.clagomess.pirilampo.core;

import java.io.File;
import java.io.*;
import java.util.Objects;
import java.util.zip.GZIPInputStream;

public abstract class Common {
protected final File featureFolder = new File(Objects.requireNonNull(getClass()
Expand All @@ -18,4 +19,23 @@ public abstract class Common {

protected final File featureErrorFile = new File(Objects.requireNonNull(getClass()
.getResource("../feature_error/yyy.feature")).getFile());

protected File decompressResource(File target, String resource) throws IOException {
File outfile = new File(target, resource.replace("/", ""));

try(
InputStream is = getClass().getResourceAsStream(resource);
BufferedInputStream bis = new BufferedInputStream(new GZIPInputStream(is));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outfile));
){
byte[] buffer = new byte[1024 * 4];
int n;

while ((n = bis.read(buffer)) != -1) {
bos.write(buffer, 0, n);
}
}

return outfile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void build() throws Exception {
;

Assertions.assertThat(htmlFile)
.hasSameTextualContentAs(new File(getClass()
.getResource("FeatureToHTMLCompilerTest/expected-build.html")
.getFile()
.hasSameTextualContentAs(decompressResource(
targetFile,
"FeatureToHTMLCompilerTest/expected-build.html.gz"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public void build() throws Exception {
;

Assertions.assertThat(htmlFile)
.hasSameTextualContentAs(new File(getClass()
.getResource("FolderToHTMLCompilerTest/expected-build.html")
.getFile()
.hasSameTextualContentAs(decompressResource(
targetFile,
"FolderToHTMLCompilerTest/expected-build.html.gz"
));
}

Expand All @@ -75,9 +75,9 @@ public void build_master() throws Exception {
.contains("YYY_MASTER_YYY");

Assertions.assertThat(htmlFile)
.hasSameTextualContentAs(new File(getClass()
.getResource("FolderToHTMLCompilerTest/expected-build-master.html")
.getFile()
.hasSameTextualContentAs(decompressResource(
targetFile,
"FolderToHTMLCompilerTest/expected-build-master.html.gz"
));
}

Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

0 comments on commit 2c142a0

Please sign in to comment.