parent
5c06970a8c
commit
055ab1a536
@ -1,24 +1,5 @@ |
||||
package de.kreth.property2java.config; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import freemarker.template.Configuration; |
||||
import freemarker.template.Template; |
||||
|
||||
public enum FreemarkerConfig { |
||||
|
||||
INSTANCE; |
||||
|
||||
private final Configuration cfg; |
||||
|
||||
public Template getTemplate() throws IOException { |
||||
return cfg.getTemplate("enum_template.tpl"); |
||||
} |
||||
|
||||
private FreemarkerConfig() { |
||||
cfg = new Configuration(Configuration.VERSION_2_3_28); |
||||
cfg.setClassForTemplateLoading(this.getClass(), "/template/"); |
||||
cfg.setDefaultEncoding("UTF-8"); |
||||
} |
||||
public interface FreemarkerConfig { |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,24 @@ |
||||
package de.kreth.property2java.config; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import freemarker.template.Configuration; |
||||
import freemarker.template.Template; |
||||
|
||||
public enum FreemarkerConfigImpl implements FreemarkerConfig { |
||||
|
||||
INSTANCE; |
||||
|
||||
private final Configuration cfg; |
||||
|
||||
public Template getTemplate() throws IOException { |
||||
return cfg.getTemplate("enum_template.tpl"); |
||||
} |
||||
|
||||
private FreemarkerConfigImpl() { |
||||
cfg = new Configuration(Configuration.VERSION_2_3_28); |
||||
cfg.setClassForTemplateLoading(this.getClass(), "/template/"); |
||||
cfg.setDefaultEncoding("UTF-8"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,55 @@ |
||||
package de.kreth.property2java.cli; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.io.Reader; |
||||
import java.util.Map; |
||||
|
||||
import org.junit.jupiter.api.AfterAll; |
||||
import org.junit.jupiter.api.BeforeAll; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import de.kreth.property2java.Configuration; |
||||
|
||||
class ArgumentConfigurationTest { |
||||
|
||||
private static File target; |
||||
|
||||
private static File input; |
||||
|
||||
private static File input2; |
||||
|
||||
@BeforeAll |
||||
static void createTargetDir() throws IOException { |
||||
target = new File("testTargetDir"); |
||||
target.mkdir(); |
||||
input = new File(target, "application.properties"); |
||||
input.createNewFile(); |
||||
input2 = new File(target, "application2.properties"); |
||||
input2.createNewFile(); |
||||
} |
||||
|
||||
@AfterAll |
||||
static void deleteTestfiles() { |
||||
target.delete(); |
||||
input.delete(); |
||||
input2.delete(); |
||||
} |
||||
|
||||
@Test |
||||
void testArgumentParser() throws IOException { |
||||
|
||||
String[] args = { "-t", target.getAbsolutePath(), |
||||
"-f", |
||||
input.getAbsolutePath() + "," + input2.getAbsolutePath(), |
||||
"-p", "de.kreth.clubinvoice" }; |
||||
Configuration config = ArgumentConfiguration.parse(args); |
||||
assertEquals("de.kreth.clubinvoice", config.getPackage()); |
||||
assertEquals(target.getAbsolutePath(), config.getRootPath().toFile().getAbsolutePath()); |
||||
Map<String, Reader> inputMap = config.getInput(); |
||||
assertEquals(2, inputMap.size()); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue