Skip to content
Snippets Groups Projects
Commit f75d4145 authored by Christian Wulf's avatar Christian Wulf
Browse files

fixed isBinaryFile

parent 47971bc8
Branches
Tags
No related merge requests found
......@@ -16,7 +16,7 @@ public class ProductLineTemplateEngine {
// patterns for predicate and corresponding generate methods
private static final String BINARY_FILENAME_PATTERN = "_template_default\\.(\\w+)\\z";
private String chosenProduct;
private final String chosenProduct;
public ProductLineTemplateEngine(String chosenProduct) {
this.chosenProduct = chosenProduct;
......@@ -31,7 +31,7 @@ public class ProductLineTemplateEngine {
}
public boolean isBinaryFile(File file) {
return file.getName().matches(BINARY_FILENAME_PATTERN);
return file.getName().matches(".*" + BINARY_FILENAME_PATTERN);
}
public void generateBinaryFile(File file) throws IOException {
......
package de.chw.css.script;
import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
......@@ -9,11 +11,11 @@ import org.junit.Test;
public class ProductLineTemplateEngineTest {
private void testGenerateBinaryFile(String filenameToSearchFor, String generatedFilename) throws IOException {
private void testGenerateBinaryFile(String filenameToSearchFor, String expectedGeneratedFilename) throws IOException {
ProductLineTemplateEngine engine = new ProductLineTemplateEngine("fm");
engine.generateBinaryFile(new File(filenameToSearchFor));
File generatedFile = new File(generatedFilename);
File generatedFile = new File(expectedGeneratedFilename);
assertTrue(generatedFile.exists());
// clean up
generatedFile.delete();
......@@ -24,6 +26,13 @@ public class ProductLineTemplateEngineTest {
testGenerateBinaryFile("resource/logo_template_default.png", "resource/logo.png");
}
@Test
public void testIsBinaryFile() throws IOException {
ProductLineTemplateEngine engine = new ProductLineTemplateEngine("fm");
assertTrue(engine.isBinaryFile(new File("resource/logo_template_default.png")));
assertFalse(engine.isBinaryFile(new File("resource/DataSource.groovy")));
}
@Test
public void testGenerateBuildConfig() throws IOException {
testGenerateBinaryFile("resource/BootStrap_template_default.groovy", "resource/BootStrap.groovy");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment