Skip to content
Snippets Groups Projects
Commit 6902e32e authored by René Schöne's avatar René Schöne
Browse files

working on slf4j debug messages

- fixed docu spelling typo
- updated preprocessor-testing to not require handler-jadds as input anymore
- grammar: removed obsolete DefinitionFileName from Handler
- Compiler: revert to standard-out/-err instead of JUL for logging (slf4j did not work here)
- Compiler: remove temporary code to create empty handler files
- Compiler: add some documentation snippets
- use slf4j loggers in tests instead of log4j ones
- always use slf4j as logTarget in tests
- update log4j impl to 2.17.1 in tests
parent 8c125c74
No related branches found
No related tags found
1 merge request!26Resolve "Refactor debug messages from System.out to SLF4J"
Pipeline #12576 failed
...@@ -12,7 +12,7 @@ Additional options are as follows. ...@@ -12,7 +12,7 @@ Additional options are as follows.
| `--logReads` | No (false) | Enable logging for every received message. | | `--logReads` | No (false) | Enable logging for every received message. |
| `--logWrites` | No (false) | Enable logging for every sent message. | | `--logWrites` | No (false) | Enable logging for every sent message. |
| `--logIncremental` | No (false) | Enable logging for observer in incremental dependency tracking. | | `--logIncremental` | No (false) | Enable logging for observer in incremental dependency tracking. |
| `--loggingTarget` | No (`console`) | Logging target to use, currently available: `console, slf4j`. | | `--logTarget` | No (`console`) | Logging target to use, currently available: `console, slf4j`. |
| `--experimental-jastadd-329` | No (false) | Use trace events `INC_FLUSH_START` and `INC_FLUSH_END` ([JastAdd issue #329][jastadd-issue-329]), see [section about automatic dependency tracking](/using#dependency-tracking-automatically-derived). | | `--experimental-jastadd-329` | No (false) | Use trace events `INC_FLUSH_START` and `INC_FLUSH_END` ([JastAdd issue #329][jastadd-issue-329]), see [section about automatic dependency tracking](/using#dependency-tracking-automatically-derived). |
| `--incremental` | No (false) | Enables incremental dependency tracking (if `trace` is also set appropriately). | | `--incremental` | No (false) | Enables incremental dependency tracking (if `trace` is also set appropriately). |
| `--trace[=flush]` | No (false) | Enables incremental dependency tracking (if `incremental` is also set appropriately). | | `--trace[=flush]` | No (false) | Enables incremental dependency tracking (if `incremental` is also set appropriately). |
......
...@@ -30,7 +30,7 @@ JavaMappingDefinitionType : MappingDefinitionType ::= Type:JavaTypeUse; ...@@ -30,7 +30,7 @@ JavaMappingDefinitionType : MappingDefinitionType ::= Type:JavaTypeUse;
JavaArrayMappingDefinitionType : MappingDefinitionType ::= Type:JavaTypeUse; JavaArrayMappingDefinitionType : MappingDefinitionType ::= Type:JavaTypeUse;
DefaultMappingDefinition : MappingDefinition; DefaultMappingDefinition : MappingDefinition;
Handler ::= <DefinitionFileName> <ClassName> <UniqueName> <InUse:boolean>; Handler ::= <ClassName> <UniqueName> <InUse:boolean>;
Configuration ::= Configuration ::=
<LoggingEnabledForReads:boolean> <LoggingEnabledForReads:boolean>
......
...@@ -9,19 +9,19 @@ import org.jastadd.ragconnect.scanner.RagConnectScanner; ...@@ -9,19 +9,19 @@ import org.jastadd.ragconnect.scanner.RagConnectScanner;
import org.jastadd.relast.compiler.AbstractCompiler; import org.jastadd.relast.compiler.AbstractCompiler;
import org.jastadd.relast.compiler.CompilerException; import org.jastadd.relast.compiler.CompilerException;
import java.io.*; import java.io.BufferedReader;
import java.nio.charset.StandardCharsets; import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardCopyOption; import java.util.Collection;
import java.util.*; import java.util.MissingResourceException;
import java.util.logging.Level; import java.util.ResourceBundle;
import java.util.logging.Logger;
public class Compiler extends AbstractCompiler { public class Compiler extends AbstractCompiler {
// private ValueOption optionOutputDir;
private ValueOption optionRootNode; private ValueOption optionRootNode;
private ValueOption optionProtocols; private ValueOption optionProtocols;
private BooleanOption optionPrintYaml; private BooleanOption optionPrintYaml;
...@@ -38,8 +38,6 @@ public class Compiler extends AbstractCompiler { ...@@ -38,8 +38,6 @@ public class Compiler extends AbstractCompiler {
private static final String OPTION_PROTOCOL_MQTT = "mqtt"; private static final String OPTION_PROTOCOL_MQTT = "mqtt";
private static final String OPTION_PROTOCOL_REST = "rest"; private static final String OPTION_PROTOCOL_REST = "rest";
private final static Logger LOGGER = Logger.getLogger(Compiler.class.getName());
public Compiler() { public Compiler() {
super("ragconnect", true); super("ragconnect", true);
} }
...@@ -63,11 +61,8 @@ public class Compiler extends AbstractCompiler { ...@@ -63,11 +61,8 @@ public class Compiler extends AbstractCompiler {
getConfiguration().printHelp(System.out); getConfiguration().printHelp(System.out);
return; return;
} }
if (optionVerbose.value()) {
LOGGER.setLevel(Level.FINE);
}
LOGGER.info(() -> "Running RagConnect " + readVersion()); System.out.println("Running RagConnect " + readVersion());
if (!getConfiguration().outputDir().exists()) { if (!getConfiguration().outputDir().exists()) {
try { try {
...@@ -93,35 +88,21 @@ public class Compiler extends AbstractCompiler { ...@@ -93,35 +88,21 @@ public class Compiler extends AbstractCompiler {
for (ErrorMessage e : ragConnect.errors()) { for (ErrorMessage e : ragConnect.errors()) {
sb.append(e).append("\n"); sb.append(e).append("\n");
} }
LOGGER.severe(sb::toString); System.err.println(sb);
System.exit(1); System.exit(1);
} }
if (optionPrintYaml.value()) { if (optionPrintYaml.value()) {
String yamlContent = ragConnect.toYAML().prettyPrint(); String yamlContent = ragConnect.toYAML().prettyPrint();
LOGGER.fine(yamlContent); if (isVerbose()) {
System.out.println(yamlContent);
}
writeToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.yml"), yamlContent); writeToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.yml"), yamlContent);
return; return;
} }
LOGGER.fine("Writing output files"); if (isVerbose()) {
// copy handlers into outputDir System.out.println("Writing output files");
for (Handler handler : ragConnect.getHandlerList()) {
if (!handler.getInUse()) {
continue;
}
String handlerFileName = handler.getDefinitionFileName();
try {
InputStream inputStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
// if (inputStream == null) {
// throw new CompilerException("Could not open " + handlerFileName);
// }
Files.copy(inputStream,
getConfiguration().outputDir().toPath().resolve(handlerFileName),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new CompilerException("Could not copy " + handlerFileName, e);
}
} }
for (GrammarFile grammarFile : ragConnect.getProgram().getGrammarFileList()) { for (GrammarFile grammarFile : ragConnect.getProgram().getGrammarFileList()) {
Path outputFile = getConfiguration().outputDir().toPath().resolve(grammarFile.getFileName()); Path outputFile = getConfiguration().outputDir().toPath().resolve(grammarFile.getFileName());
...@@ -138,14 +119,22 @@ public class Compiler extends AbstractCompiler { ...@@ -138,14 +119,22 @@ public class Compiler extends AbstractCompiler {
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("mustache.debug", "true"); System.setProperty("mustache.debug", "true");
Compiler compiler = new Compiler();
try { try {
new Compiler().run(args); compiler.run(args);
} catch (CompilerException e) { } catch (CompilerException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e); System.err.println(e.getMessage());
if (compiler.isVerbose()) {
e.printStackTrace();
}
System.exit(1); System.exit(1);
} }
} }
private boolean isVerbose() {
return optionVerbose != null && optionVerbose.value();
}
/** /**
* Reads the version string. * Reads the version string.
* <p> * <p>
...@@ -228,13 +217,13 @@ public class Compiler extends AbstractCompiler { ...@@ -228,13 +217,13 @@ public class Compiler extends AbstractCompiler {
switch (extension) { switch (extension) {
case "ast": case "ast":
case "relast": case "relast":
// processGrammar // process grammar
program.addGrammarFile(parseGrammar(filename)); program.addGrammarFile(parseGrammar(filename));
atLeastOneGrammar = true; atLeastOneGrammar = true;
break; break;
case "connect": case "connect":
case "ragconnect": case "ragconnect":
// process ragConnect // process RagConnect specification
ragConnect.addConnectSpecificationFile(parseConnectSpec(filename)); ragConnect.addConnectSpecificationFile(parseConnectSpec(filename));
atLeastOneRagConnect = true; atLeastOneRagConnect = true;
break; break;
...@@ -242,13 +231,13 @@ public class Compiler extends AbstractCompiler { ...@@ -242,13 +231,13 @@ public class Compiler extends AbstractCompiler {
throw new CompilerException("Unknown file extension " + extension + " in " + filename); throw new CompilerException("Unknown file extension " + extension + " in " + filename);
} }
} }
if (!atLeastOneGrammar) {
LOGGER.severe(() -> "No grammar file specified! (*.ast, *.relast)");
}
if (!atLeastOneRagConnect) { if (!atLeastOneRagConnect) {
LOGGER.severe(() -> "No ragconnect file specified! (*.connect, *.ragconnect)"); System.err.println("No RagConnect specification file (*.connect, *.ragconnect) specified!");
} }
if (!atLeastOneGrammar && !atLeastOneRagConnect) { if (!atLeastOneGrammar) {
// without a grammar, RagConnect can not operate
System.err.println("No grammar file (*.ast, *.relast) specified! Exiting!");
System.exit(1); System.exit(1);
} }
...@@ -256,6 +245,7 @@ public class Compiler extends AbstractCompiler { ...@@ -256,6 +245,7 @@ public class Compiler extends AbstractCompiler {
ragConnect.flushTreeCache(); ragConnect.flushTreeCache();
ragConnect.treeResolveAll(); ragConnect.treeResolveAll();
// add new parts to production rule, and new relations
ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration); ragConnect.additionalRelations().forEach(ragConnectGrammarPart::addDeclaration);
ragConnect.additionalTokens().forEach(TypeDecl::addComponent); ragConnect.additionalTokens().forEach(TypeDecl::addComponent);
...@@ -267,8 +257,8 @@ public class Compiler extends AbstractCompiler { ...@@ -267,8 +257,8 @@ public class Compiler extends AbstractCompiler {
RagConnectScanner scanner = new RagConnectScanner(reader); RagConnectScanner scanner = new RagConnectScanner(reader);
RagConnectParser parser = new RagConnectParser(); RagConnectParser parser = new RagConnectParser();
GrammarFile grammarFile = (GrammarFile) parser.parse(scanner); GrammarFile grammarFile = (GrammarFile) parser.parse(scanner);
if (optionVerbose.value()) { if (isVerbose()) {
LOGGER.fine(grammarFile::dumpTree); System.out.println(grammarFile.dumpTree());
} }
grammarFile.setFileName(toBaseName(filename)); grammarFile.setFileName(toBaseName(filename));
return grammarFile; return grammarFile;
...@@ -314,7 +304,9 @@ public class Compiler extends AbstractCompiler { ...@@ -314,7 +304,9 @@ public class Compiler extends AbstractCompiler {
// reuse "--incremental" and "--trace=flush" options of JastAdd // reuse "--incremental" and "--trace=flush" options of JastAdd
boolean incrementalOptionActive = this.getConfiguration().incremental() && this.getConfiguration().traceFlush(); boolean incrementalOptionActive = this.getConfiguration().incremental() && this.getConfiguration().traceFlush();
ragConnect.getConfiguration().setIncrementalOptionActive(incrementalOptionActive); ragConnect.getConfiguration().setIncrementalOptionActive(incrementalOptionActive);
LOGGER.fine(() -> "ragConnect.getConfiguration().IncrementalOptionActive = " + incrementalOptionActive); if (isVerbose()) {
System.out.println("ragConnect.getConfiguration().IncrementalOptionActive = " + incrementalOptionActive);
}
// reuse "--List" and "--Opt" options of JastAdd // reuse "--List" and "--Opt" options of JastAdd
ragConnect.getConfiguration().setJastAddList(this.getConfiguration().listType()); ragConnect.getConfiguration().setJastAddList(this.getConfiguration().listType());
...@@ -330,12 +322,13 @@ public class Compiler extends AbstractCompiler { ...@@ -330,12 +322,13 @@ public class Compiler extends AbstractCompiler {
ragConnect.getConfiguration().setRootNode(rootNode); ragConnect.getConfiguration().setRootNode(rootNode);
// Handler ::= <ClassName> <UniqueName> <InUse:boolean>; // Handler ::= <ClassName> <UniqueName> <InUse:boolean>;
ragConnect.addHandler(new Handler("MqttHandler.jadd", "MqttServerHandler", "mqtt", optionProtocols.hasValue(OPTION_PROTOCOL_MQTT))); ragConnect.addHandler(new Handler("MqttServerHandler", "mqtt", optionProtocols.hasValue(OPTION_PROTOCOL_MQTT)));
ragConnect.addHandler(new Handler("RestHandler.jadd", "RestServerHandler", "rest", optionProtocols.hasValue(OPTION_PROTOCOL_REST))); ragConnect.addHandler(new Handler("RestServerHandler", "rest", optionProtocols.hasValue(OPTION_PROTOCOL_REST)));
} }
public String generateAspect(RagConnect ragConnect) { public String generateAspect(RagConnect ragConnect) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// add handler to get error message when template expansion did not find some part
com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() { com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() {
@Override @Override
public com.github.mustachejava.Binding createBinding(String name, final com.github.mustachejava.TemplateContext tc, com.github.mustachejava.Code code) { public com.github.mustachejava.Binding createBinding(String name, final com.github.mustachejava.TemplateContext tc, com.github.mustachejava.Code code) {
...@@ -360,7 +353,7 @@ public class Compiler extends AbstractCompiler { ...@@ -360,7 +353,7 @@ public class Compiler extends AbstractCompiler {
@Override @Override
protected int error(String message) { protected int error(String message) {
LOGGER.log(Level.SEVERE, message); System.err.println(message);
return 1; return 1;
} }
......
...@@ -9,7 +9,7 @@ buildscript { ...@@ -9,7 +9,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'org.jastadd:jastaddgradle:1.13.3' classpath 'org.jastadd:jastaddgradle:1.13.3'
classpath 'org.jastadd.preprocessor:testing:0.2.11' classpath 'org.jastadd.preprocessor:testing:0.2.12'
} }
} }
...@@ -60,7 +60,7 @@ dependencies { ...@@ -60,7 +60,7 @@ dependencies {
// rest and client // rest and client
testImplementation group: 'com.sparkjava', name: 'spark-core', version: '2.9.3' testImplementation group: 'com.sparkjava', name: 'spark-core', version: '2.9.3'
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.2' testImplementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.17.1'
testImplementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.31' testImplementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.31'
testImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.31' testImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.31'
testImplementation group: 'javax.activation', name: 'activation', version: '1.1.1' testImplementation group: 'javax.activation', name: 'activation', version: '1.1.1'
...@@ -158,6 +158,7 @@ task compileExampleTest(type: RagConnectTest) { ...@@ -158,6 +158,7 @@ task compileExampleTest(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/example/Test.relast'), inputFiles = [file('src/test/01-input/example/Test.relast'),
file('src/test/01-input/example/Test.connect')] file('src/test/01-input/example/Test.connect')]
rootNode = 'Model' rootNode = 'Model'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -177,6 +178,7 @@ task compileDefaultOnlyRead(type: RagConnectTest) { ...@@ -177,6 +178,7 @@ task compileDefaultOnlyRead(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/defaultOnlyRead/Test.relast'), inputFiles = [file('src/test/01-input/defaultOnlyRead/Test.relast'),
file('src/test/01-input/defaultOnlyRead/Test.connect')] file('src/test/01-input/defaultOnlyRead/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -195,6 +197,7 @@ task compileDefaultOnlyWrite(type: RagConnectTest) { ...@@ -195,6 +197,7 @@ task compileDefaultOnlyWrite(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/defaultOnlyWrite/Test.relast'), inputFiles = [file('src/test/01-input/defaultOnlyWrite/Test.relast'),
file('src/test/01-input/defaultOnlyWrite/Test.connect')] file('src/test/01-input/defaultOnlyWrite/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -214,6 +217,7 @@ task compileRead1write2(type: RagConnectTest) { ...@@ -214,6 +217,7 @@ task compileRead1write2(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/read1write2/Test.relast'), inputFiles = [file('src/test/01-input/read1write2/Test.relast'),
file('src/test/01-input/read1write2/Test.connect')] file('src/test/01-input/read1write2/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -233,6 +237,7 @@ task compileRead2write1(type: RagConnectTest) { ...@@ -233,6 +237,7 @@ task compileRead2write1(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/read2write1/Test.relast'), inputFiles = [file('src/test/01-input/read2write1/Test.relast'),
file('src/test/01-input/read2write1/Test.connect')] file('src/test/01-input/read2write1/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -253,6 +258,7 @@ task compileVia(type: RagConnectTest) { ...@@ -253,6 +258,7 @@ task compileVia(type: RagConnectTest) {
file('src/test/01-input/via/Test.connect')] file('src/test/01-input/via/Test.connect')]
rootNode = 'A' rootNode = 'A'
protocols = ['mqtt', 'rest'] protocols = ['mqtt', 'rest']
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -272,6 +278,7 @@ task compileTokenValueSend(type: RagConnectTest) { ...@@ -272,6 +278,7 @@ task compileTokenValueSend(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/tokenValueSend/Test.relast'), inputFiles = [file('src/test/01-input/tokenValueSend/Test.relast'),
file('src/test/01-input/tokenValueSend/Test.connect')] file('src/test/01-input/tokenValueSend/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -291,6 +298,7 @@ task compileTutorial(type: RagConnectTest) { ...@@ -291,6 +298,7 @@ task compileTutorial(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/tutorial/Test.relast'), inputFiles = [file('src/test/01-input/tutorial/Test.relast'),
file('src/test/01-input/tutorial/Test.connect')] file('src/test/01-input/tutorial/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -310,6 +318,7 @@ task compileIncremental(type: RagConnectTest) { ...@@ -310,6 +318,7 @@ task compileIncremental(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/incremental/Test.relast'), inputFiles = [file('src/test/01-input/incremental/Test.relast'),
file('src/test/01-input/incremental/Test.connect')] file('src/test/01-input/incremental/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -330,6 +339,7 @@ task compileMapping(type: RagConnectTest) { ...@@ -330,6 +339,7 @@ task compileMapping(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/mapping/Test.relast'), inputFiles = [file('src/test/01-input/mapping/Test.relast'),
file('src/test/01-input/mapping/Test.connect')] file('src/test/01-input/mapping/Test.connect')]
rootNode = 'A' rootNode = 'A'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -350,6 +360,7 @@ task compileTreeManual(type: RagConnectTest, dependsOn: ':ragconnect.base:compil ...@@ -350,6 +360,7 @@ task compileTreeManual(type: RagConnectTest, dependsOn: ':ragconnect.base:compil
file('src/test/01-input/tree/Test.connect'), file('src/test/01-input/tree/Test.connect'),
file('src/test/01-input/tree/TestDependencies.connect')] file('src/test/01-input/tree/TestDependencies.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -370,6 +381,7 @@ task compileTreeIncremental(type: RagConnectTest) { ...@@ -370,6 +381,7 @@ task compileTreeIncremental(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/tree/Test.relast'), inputFiles = [file('src/test/01-input/tree/Test.relast'),
file('src/test/01-input/tree/Test.connect')] file('src/test/01-input/tree/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -392,6 +404,7 @@ task compileTreeAllowedTokens(type: RagConnectTest) { ...@@ -392,6 +404,7 @@ task compileTreeAllowedTokens(type: RagConnectTest) {
file('src/test/01-input/treeAllowedTokens/Test.connect'), file('src/test/01-input/treeAllowedTokens/Test.connect'),
file('src/test/01-input/treeAllowedTokens/TestDependencies.connect')] file('src/test/01-input/treeAllowedTokens/TestDependencies.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -412,6 +425,7 @@ task compileTreeAllowedTokensIncremental(type: RagConnectTest) { ...@@ -412,6 +425,7 @@ task compileTreeAllowedTokensIncremental(type: RagConnectTest) {
inputFiles = [file('src/test/01-input/treeAllowedTokens/Test.relast'), inputFiles = [file('src/test/01-input/treeAllowedTokens/Test.relast'),
file('src/test/01-input/treeAllowedTokens/Test.connect')] file('src/test/01-input/treeAllowedTokens/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -427,13 +441,14 @@ task compileTreeAllowedTokensIncremental(type: RagConnectTest) { ...@@ -427,13 +441,14 @@ task compileTreeAllowedTokensIncremental(type: RagConnectTest) {
} }
// --- Test: list-manual --- // --- Test: list-manual ---
task compileListManual(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileListManual(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/list') outputDir = file('src/test/02-after-ragconnect/list')
inputFiles = [file('src/test/01-input/list/Test.relast'), inputFiles = [file('src/test/01-input/list/Test.relast'),
file('src/test/01-input/list/Test.connect'), file('src/test/01-input/list/Test.connect'),
file('src/test/01-input/list/TestDependencies.connect')] file('src/test/01-input/list/TestDependencies.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -448,12 +463,13 @@ task compileListManual(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') ...@@ -448,12 +463,13 @@ task compileListManual(type: RagConnectTest, dependsOn: ':ragconnect.base:jar')
} }
// --- Test: list-incremental --- // --- Test: list-incremental ---
task compileListIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileListIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/listInc') outputDir = file('src/test/02-after-ragconnect/listInc')
inputFiles = [file('src/test/01-input/list/Test.relast'), inputFiles = [file('src/test/01-input/list/Test.relast'),
file('src/test/01-input/list/Test.connect')] file('src/test/01-input/list/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -469,13 +485,14 @@ task compileListIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:j ...@@ -469,13 +485,14 @@ task compileListIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:j
} }
// --- Test: singleList-manual --- // --- Test: singleList-manual ---
task compileSingleListManual(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileSingleListManual(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/singleList') outputDir = file('src/test/02-after-ragconnect/singleList')
inputFiles = [file('src/test/01-input/singleList/Test.relast'), inputFiles = [file('src/test/01-input/singleList/Test.relast'),
file('src/test/01-input/singleList/Test.connect'), file('src/test/01-input/singleList/Test.connect'),
file('src/test/01-input/singleList/TestDependencies.connect')] file('src/test/01-input/singleList/TestDependencies.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -490,12 +507,13 @@ task compileSingleListManual(type: RagConnectTest, dependsOn: ':ragconnect.base: ...@@ -490,12 +507,13 @@ task compileSingleListManual(type: RagConnectTest, dependsOn: ':ragconnect.base:
} }
// --- Test: singleList-incremental --- // --- Test: singleList-incremental ---
task compileSingleListIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileSingleListIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/singleListInc') outputDir = file('src/test/02-after-ragconnect/singleListInc')
inputFiles = [file('src/test/01-input/singleList/Test.relast'), inputFiles = [file('src/test/01-input/singleList/Test.relast'),
file('src/test/01-input/singleList/Test.connect')] file('src/test/01-input/singleList/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -511,13 +529,14 @@ task compileSingleListIncremental(type: RagConnectTest, dependsOn: ':ragconnect. ...@@ -511,13 +529,14 @@ task compileSingleListIncremental(type: RagConnectTest, dependsOn: ':ragconnect.
} }
// --- Test: singleListVariant-manual --- // --- Test: singleListVariant-manual ---
task compileSingleListVariantManual(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileSingleListVariantManual(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/singleListVariant') outputDir = file('src/test/02-after-ragconnect/singleListVariant')
inputFiles = [file('src/test/01-input/singleListVariant/Test.relast'), inputFiles = [file('src/test/01-input/singleListVariant/Test.relast'),
file('src/test/01-input/singleListVariant/Test.connect'), file('src/test/01-input/singleListVariant/Test.connect'),
file('src/test/01-input/singleListVariant/TestDependencies.connect')] file('src/test/01-input/singleListVariant/TestDependencies.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = defaultRagConnectOptionsAnd()
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -532,13 +551,13 @@ task compileSingleListVariantManual(type: RagConnectTest, dependsOn: ':ragconnec ...@@ -532,13 +551,13 @@ task compileSingleListVariantManual(type: RagConnectTest, dependsOn: ':ragconnec
} }
// --- Test: singleListVariant-incremental --- // --- Test: singleListVariant-incremental ---
task compileSingleListVariantIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileSingleListVariantIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/singleListVariantInc') outputDir = file('src/test/02-after-ragconnect/singleListVariantInc')
inputFiles = [file('src/test/01-input/singleListVariant/Test.relast'), inputFiles = [file('src/test/01-input/singleListVariant/Test.relast'),
file('src/test/01-input/singleListVariant/Test.connect')] file('src/test/01-input/singleListVariant/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = ['--experimental-jastadd-329'] extraOptions = defaultRagConnectOptionsAnd(['--experimental-jastadd-329'])
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -554,13 +573,13 @@ task compileSingleListVariantIncremental(type: RagConnectTest, dependsOn: ':ragc ...@@ -554,13 +573,13 @@ task compileSingleListVariantIncremental(type: RagConnectTest, dependsOn: ':ragc
} }
// --- Test: contextFreeSimple-incremental --- // --- Test: contextFreeSimple-incremental ---
task compileContextFreeSimpleIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileContextFreeSimpleIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/contextFreeSimpleInc') outputDir = file('src/test/02-after-ragconnect/contextFreeSimpleInc')
inputFiles = [file('src/test/01-input/contextFreeSimple/Test.relast'), inputFiles = [file('src/test/01-input/contextFreeSimple/Test.relast'),
file('src/test/01-input/contextFreeSimple/Test.connect')] file('src/test/01-input/contextFreeSimple/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = ['--experimental-jastadd-329'] extraOptions = defaultRagConnectOptionsAnd(['--experimental-jastadd-329'])
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -575,13 +594,13 @@ task compileContextFreeSimpleIncremental(type: RagConnectTest, dependsOn: ':ragc ...@@ -575,13 +594,13 @@ task compileContextFreeSimpleIncremental(type: RagConnectTest, dependsOn: ':ragc
} }
// --- Test: forwarding-incremental --- // --- Test: forwarding-incremental ---
task compileForwardingIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileForwardingIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/forwardingInc') outputDir = file('src/test/02-after-ragconnect/forwardingInc')
inputFiles = [file('src/test/01-input/forwarding/Test.relast'), inputFiles = [file('src/test/01-input/forwarding/Test.relast'),
file('src/test/01-input/forwarding/Test.connect')] file('src/test/01-input/forwarding/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = ['--experimental-jastadd-329'] extraOptions = defaultRagConnectOptionsAnd(['--experimental-jastadd-329'])
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -596,13 +615,13 @@ task compileForwardingIncremental(type: RagConnectTest, dependsOn: ':ragconnect. ...@@ -596,13 +615,13 @@ task compileForwardingIncremental(type: RagConnectTest, dependsOn: ':ragconnect.
} }
// --- Test: indexed-send-incremental --- // --- Test: indexed-send-incremental ---
task compileIndexedSendIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileIndexedSendIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/indexedSendInc') outputDir = file('src/test/02-after-ragconnect/indexedSendInc')
inputFiles = [file('src/test/01-input/indexedSend/Test.relast'), inputFiles = [file('src/test/01-input/indexedSend/Test.relast'),
file('src/test/01-input/indexedSend/Test.connect')] file('src/test/01-input/indexedSend/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = ['--experimental-jastadd-329'] extraOptions = defaultRagConnectOptionsAnd(['--experimental-jastadd-329'])
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -618,13 +637,13 @@ task compileIndexedSendIncremental(type: RagConnectTest, dependsOn: ':ragconnect ...@@ -618,13 +637,13 @@ task compileIndexedSendIncremental(type: RagConnectTest, dependsOn: ':ragconnect
} }
// --- Test: attribute-incremental --- // --- Test: attribute-incremental ---
task compileAttributeIncremental(type: RagConnectTest, dependsOn: ':ragconnect.base:jar') { task compileAttributeIncremental(type: RagConnectTest) {
ragconnect { ragconnect {
outputDir = file('src/test/02-after-ragconnect/attributeInc') outputDir = file('src/test/02-after-ragconnect/attributeInc')
inputFiles = [file('src/test/01-input/attribute/Test.relast'), inputFiles = [file('src/test/01-input/attribute/Test.relast'),
file('src/test/01-input/attribute/Test.connect')] file('src/test/01-input/attribute/Test.connect')]
rootNode = 'Root' rootNode = 'Root'
extraOptions = ['--experimental-jastadd-329'] extraOptions = defaultRagConnectOptionsAnd(['--experimental-jastadd-329'])
} }
relast { relast {
useJastAddNames = true useJastAddNames = true
...@@ -638,3 +657,11 @@ task compileAttributeIncremental(type: RagConnectTest, dependsOn: ':ragconnect.b ...@@ -638,3 +657,11 @@ task compileAttributeIncremental(type: RagConnectTest, dependsOn: ':ragconnect.b
extraOptions = JASTADD_INCREMENTAL_OPTIONS_TRACING_FULL extraOptions = JASTADD_INCREMENTAL_OPTIONS_TRACING_FULL
} }
} }
compileAttributeIncremental.outputs.upToDateWhen { false }
static ArrayList<String> defaultRagConnectOptionsAnd(ArrayList<String> options = []) {
if (!options.contains('--logTarget=slf4j')) {
options.add('--logTarget=slf4j')
}
return options
}
package org.jastadd.ragconnect.tests; package org.jastadd.ragconnect.tests;
import defaultOnlyRead.ast.MqttHandler; import defaultOnlyRead.ast.MqttHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -20,7 +20,7 @@ public abstract class AbstractMqttTest { ...@@ -20,7 +20,7 @@ public abstract class AbstractMqttTest {
protected static MqttHandler publisher; protected static MqttHandler publisher;
protected Logger logger = LogManager.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
/** /**
* if the initial/current value shall be sent upon connecting * if the initial/current value shall be sent upon connecting
...@@ -65,7 +65,7 @@ public abstract class AbstractMqttTest { ...@@ -65,7 +65,7 @@ public abstract class AbstractMqttTest {
createModel(); createModel();
setupReceiverAndConnect(); setupReceiverAndConnect();
logger.debug("Calling communicateSendInitialValue"); logger.info("Calling communicateSendInitialValue");
communicateSendInitialValue(); communicateSendInitialValue();
} }
...@@ -84,7 +84,7 @@ public abstract class AbstractMqttTest { ...@@ -84,7 +84,7 @@ public abstract class AbstractMqttTest {
createModel(); createModel();
setupReceiverAndConnect(); setupReceiverAndConnect();
logger.debug("Calling communicateOnlyUpdatedValue"); logger.info("Calling communicateOnlyUpdatedValue");
communicateOnlyUpdatedValue(); communicateOnlyUpdatedValue();
} }
......
package org.jastadd.ragconnect.tests; package org.jastadd.ragconnect.tests;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; ...@@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class Errors { public class Errors {
private static final Logger logger = LogManager.getLogger(Errors.class); private static final Logger logger = LoggerFactory.getLogger(Errors.class);
private static final String FILENAME_PATTERN = "$FILENAME"; private static final String FILENAME_PATTERN = "$FILENAME";
private static final String ERROR_DIRECTORY = "errors/"; private static final String ERROR_DIRECTORY = "errors/";
private static final String OUTPUT_DIRECTORY = TestUtils.OUTPUT_DIRECTORY_PREFIX + ERROR_DIRECTORY; private static final String OUTPUT_DIRECTORY = TestUtils.OUTPUT_DIRECTORY_PREFIX + ERROR_DIRECTORY;
......
...@@ -3,12 +3,12 @@ package org.jastadd.ragconnect.tests; ...@@ -3,12 +3,12 @@ package org.jastadd.ragconnect.tests;
import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory; import org.awaitility.core.ConditionFactory;
import org.jastadd.ragconnect.compiler.Compiler; import org.jastadd.ragconnect.compiler.Compiler;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
...@@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.fail; ...@@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.fail;
*/ */
public class TestUtils { public class TestUtils {
private static final Logger logger = LogManager.getLogger(TestUtils.class); private static final Logger logger = LoggerFactory.getLogger(TestUtils.class);
public static final double DELTA = 0.001d; public static final double DELTA = 0.001d;
public static final String INPUT_DIRECTORY_PREFIX = "./src/test/01-input/"; public static final String INPUT_DIRECTORY_PREFIX = "./src/test/01-input/";
public static final String OUTPUT_DIRECTORY_PREFIX = "./src/test/02-after-ragconnect/"; public static final String OUTPUT_DIRECTORY_PREFIX = "./src/test/02-after-ragconnect/";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment