Commit 81058872 authored by René Schöne's avatar René Schöne
Browse files

add checks for scheme, host and path after processing an uri for connection

parent a0e389e2
Pipeline #9910 passed with stages
in 10 minutes and 49 seconds
String scheme,host, path;
String scheme, host, path;
java.net.URI uri;
try {
uri = new java.net.URI({{connectParameterName}});
......@@ -9,3 +9,15 @@ try {
System.err.println(e.getMessage()); // Maybe re-throw error?
return false;
}
if (scheme == null || scheme.isBlank()) {
System.err.println("Missing or empty scheme in " + uri);
return false;
}
if (host == null || host.isBlank()) {
System.err.println("Missing or empty host in " + uri);
return false;
}
if (path == null || path.isBlank()) {
System.err.println("Missing or empty path in " + uri);
return false;
}
......@@ -12,6 +12,7 @@ import java.util.concurrent.TimeUnit;
import static org.jastadd.ragconnect.tests.TestUtils.mqttUri;
import static org.jastadd.ragconnect.tests.TestUtils.testJaddContainReferenceToJackson;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case "defaultOnlyRead".
......@@ -67,39 +68,39 @@ public class DefaultOnlyReadTest extends AbstractMqttTest {
protected void setupReceiverAndConnect(boolean writeCurrentValue) throws IOException {
model.ragconnectSetupMqttWaitUntilReady(2, TimeUnit.SECONDS);
integers.connectBooleanValue(mqttUri(TOPIC_NATIVE_BOOLEAN));
integers.connectIntValue(mqttUri(TOPIC_NATIVE_INT));
integers.connectShortValue(mqttUri(TOPIC_NATIVE_SHORT));
integers.connectLongValue(mqttUri(TOPIC_NATIVE_LONG));
floats.connectFloatValue(mqttUri(TOPIC_NATIVE_FLOAT));
floats.connectDoubleValue(mqttUri(TOPIC_NATIVE_DOUBLE));
chars.connectCharValue(mqttUri(TOPIC_NATIVE_CHAR));
chars.connectStringValue(mqttUri(TOPIC_NATIVE_STRING));
integers.connectBooleanValueTransformed(mqttUri(TOPIC_NATIVE_BOOLEAN));
integers.connectIntValueTransformed(mqttUri(TOPIC_NATIVE_INT));
integers.connectShortValueTransformed(mqttUri(TOPIC_NATIVE_SHORT));
integers.connectLongValueTransformed(mqttUri(TOPIC_NATIVE_LONG));
floats.connectFloatValueTransformed(mqttUri(TOPIC_NATIVE_FLOAT));
floats.connectDoubleValueTransformed(mqttUri(TOPIC_NATIVE_DOUBLE));
chars.connectCharValueTransformed(mqttUri(TOPIC_NATIVE_CHAR));
chars.connectStringValueTransformed(mqttUri(TOPIC_NATIVE_STRING));
allBoxed.connectBooleanValue(mqttUri(TOPIC_BOXED_BOOLEAN));
allBoxed.connectIntValue(mqttUri(TOPIC_BOXED_INTEGER));
allBoxed.connectShortValue(mqttUri(TOPIC_BOXED_SHORT));
allBoxed.connectLongValue(mqttUri(TOPIC_BOXED_LONG));
allBoxed.connectFloatValue(mqttUri(TOPIC_BOXED_FLOAT));
allBoxed.connectDoubleValue(mqttUri(TOPIC_BOXED_DOUBLE));
allBoxed.connectCharValue(mqttUri(TOPIC_BOXED_CHARACTER));
allBoxed.connectBooleanValueTransformed(mqttUri(TOPIC_BOXED_BOOLEAN));
allBoxed.connectIntValueTransformed(mqttUri(TOPIC_BOXED_INTEGER));
allBoxed.connectShortValueTransformed(mqttUri(TOPIC_BOXED_SHORT));
allBoxed.connectLongValueTransformed(mqttUri(TOPIC_BOXED_LONG));
allBoxed.connectFloatValueTransformed(mqttUri(TOPIC_BOXED_FLOAT));
allBoxed.connectDoubleValueTransformed(mqttUri(TOPIC_BOXED_DOUBLE));
allBoxed.connectCharValueTransformed(mqttUri(TOPIC_BOXED_CHARACTER));
assertTrue(integers.connectBooleanValue(mqttUri(TOPIC_NATIVE_BOOLEAN)));
assertTrue(integers.connectIntValue(mqttUri(TOPIC_NATIVE_INT)));
assertTrue(integers.connectShortValue(mqttUri(TOPIC_NATIVE_SHORT)));
assertTrue(integers.connectLongValue(mqttUri(TOPIC_NATIVE_LONG)));
assertTrue(floats.connectFloatValue(mqttUri(TOPIC_NATIVE_FLOAT)));
assertTrue(floats.connectDoubleValue(mqttUri(TOPIC_NATIVE_DOUBLE)));
assertTrue(chars.connectCharValue(mqttUri(TOPIC_NATIVE_CHAR)));
assertTrue(chars.connectStringValue(mqttUri(TOPIC_NATIVE_STRING)));
assertTrue(integers.connectBooleanValueTransformed(mqttUri(TOPIC_NATIVE_BOOLEAN)));
assertTrue(integers.connectIntValueTransformed(mqttUri(TOPIC_NATIVE_INT)));
assertTrue(integers.connectShortValueTransformed(mqttUri(TOPIC_NATIVE_SHORT)));
assertTrue(integers.connectLongValueTransformed(mqttUri(TOPIC_NATIVE_LONG)));
assertTrue(floats.connectFloatValueTransformed(mqttUri(TOPIC_NATIVE_FLOAT)));
assertTrue(floats.connectDoubleValueTransformed(mqttUri(TOPIC_NATIVE_DOUBLE)));
assertTrue(chars.connectCharValueTransformed(mqttUri(TOPIC_NATIVE_CHAR)));
assertTrue(chars.connectStringValueTransformed(mqttUri(TOPIC_NATIVE_STRING)));
assertTrue(allBoxed.connectBooleanValue(mqttUri(TOPIC_BOXED_BOOLEAN)));
assertTrue(allBoxed.connectIntValue(mqttUri(TOPIC_BOXED_INTEGER)));
assertTrue(allBoxed.connectShortValue(mqttUri(TOPIC_BOXED_SHORT)));
assertTrue(allBoxed.connectLongValue(mqttUri(TOPIC_BOXED_LONG)));
assertTrue(allBoxed.connectFloatValue(mqttUri(TOPIC_BOXED_FLOAT)));
assertTrue(allBoxed.connectDoubleValue(mqttUri(TOPIC_BOXED_DOUBLE)));
assertTrue(allBoxed.connectCharValue(mqttUri(TOPIC_BOXED_CHARACTER)));
assertTrue(allBoxed.connectBooleanValueTransformed(mqttUri(TOPIC_BOXED_BOOLEAN)));
assertTrue(allBoxed.connectIntValueTransformed(mqttUri(TOPIC_BOXED_INTEGER)));
assertTrue(allBoxed.connectShortValueTransformed(mqttUri(TOPIC_BOXED_SHORT)));
assertTrue(allBoxed.connectLongValueTransformed(mqttUri(TOPIC_BOXED_LONG)));
assertTrue(allBoxed.connectFloatValueTransformed(mqttUri(TOPIC_BOXED_FLOAT)));
assertTrue(allBoxed.connectDoubleValueTransformed(mqttUri(TOPIC_BOXED_DOUBLE)));
assertTrue(allBoxed.connectCharValueTransformed(mqttUri(TOPIC_BOXED_CHARACTER)));
}
@Override
......
......@@ -137,39 +137,39 @@ public class DefaultOnlyWriteTest extends AbstractMqttTest {
dataNormal = createReceiver(false);
dataTransformed = createReceiver(true);
nativeIntegers.connectBooleanValue(mqttUri(TOPIC_NATIVE_BOOLEAN), writeCurrentValue);
nativeIntegers.connectIntValue(mqttUri(TOPIC_NATIVE_INT), writeCurrentValue);
nativeIntegers.connectShortValue(mqttUri(TOPIC_NATIVE_SHORT), writeCurrentValue);
nativeIntegers.connectLongValue(mqttUri(TOPIC_NATIVE_LONG), writeCurrentValue);
nativeFloats.connectFloatValue(mqttUri(TOPIC_NATIVE_FLOAT), writeCurrentValue);
nativeFloats.connectDoubleValue(mqttUri(TOPIC_NATIVE_DOUBLE), writeCurrentValue);
nativeChars.connectCharValue(mqttUri(TOPIC_NATIVE_CHAR), writeCurrentValue);
nativeChars.connectStringValue(mqttUri(TOPIC_NATIVE_STRING), writeCurrentValue);
nativeIntegers.connectBooleanValueTransformed(mqttUri(TOPIC_NATIVE_BOOLEAN_TRANSFORMED), writeCurrentValue);
nativeIntegers.connectIntValueTransformed(mqttUri(TOPIC_NATIVE_INT_TRANSFORMED), writeCurrentValue);
nativeIntegers.connectShortValueTransformed(mqttUri(TOPIC_NATIVE_SHORT_TRANSFORMED), writeCurrentValue);
nativeIntegers.connectLongValueTransformed(mqttUri(TOPIC_NATIVE_LONG_TRANSFORMED), writeCurrentValue);
nativeFloats.connectFloatValueTransformed(mqttUri(TOPIC_NATIVE_FLOAT_TRANSFORMED), writeCurrentValue);
nativeFloats.connectDoubleValueTransformed(mqttUri(TOPIC_NATIVE_DOUBLE_TRANSFORMED), writeCurrentValue);
nativeChars.connectCharValueTransformed(mqttUri(TOPIC_NATIVE_CHAR_TRANSFORMED), writeCurrentValue);
nativeChars.connectStringValueTransformed(mqttUri(TOPIC_NATIVE_STRING_TRANSFORMED), writeCurrentValue);
boxedIntegers.connectBooleanValue(mqttUri(TOPIC_BOXED_BOOLEAN), writeCurrentValue);
boxedIntegers.connectIntValue(mqttUri(TOPIC_BOXED_INTEGER), writeCurrentValue);
boxedIntegers.connectShortValue(mqttUri(TOPIC_BOXED_SHORT), writeCurrentValue);
boxedIntegers.connectLongValue(mqttUri(TOPIC_BOXED_LONG), writeCurrentValue);
boxedFloats.connectFloatValue(mqttUri(TOPIC_BOXED_FLOAT), writeCurrentValue);
boxedFloats.connectDoubleValue(mqttUri(TOPIC_BOXED_DOUBLE), writeCurrentValue);
boxedChars.connectCharValue(mqttUri(TOPIC_BOXED_CHARACTER), writeCurrentValue);
boxedIntegers.connectBooleanValueTransformed(mqttUri(TOPIC_BOXED_BOOLEAN_TRANSFORMED), writeCurrentValue);
boxedIntegers.connectIntValueTransformed(mqttUri(TOPIC_BOXED_INTEGER_TRANSFORMED), writeCurrentValue);
boxedIntegers.connectShortValueTransformed(mqttUri(TOPIC_BOXED_SHORT_TRANSFORMED), writeCurrentValue);
boxedIntegers.connectLongValueTransformed(mqttUri(TOPIC_BOXED_LONG_TRANSFORMED), writeCurrentValue);
boxedFloats.connectFloatValueTransformed(mqttUri(TOPIC_BOXED_FLOAT_TRANSFORMED), writeCurrentValue);
boxedFloats.connectDoubleValueTransformed(mqttUri(TOPIC_BOXED_DOUBLE_TRANSFORMED), writeCurrentValue);
boxedChars.connectCharValueTransformed(mqttUri(TOPIC_BOXED_CHARACTER_TRANSFORMED), writeCurrentValue);
assertTrue(nativeIntegers.connectBooleanValue(mqttUri(TOPIC_NATIVE_BOOLEAN), writeCurrentValue));
assertTrue(nativeIntegers.connectIntValue(mqttUri(TOPIC_NATIVE_INT), writeCurrentValue));
assertTrue(nativeIntegers.connectShortValue(mqttUri(TOPIC_NATIVE_SHORT), writeCurrentValue));
assertTrue(nativeIntegers.connectLongValue(mqttUri(TOPIC_NATIVE_LONG), writeCurrentValue));
assertTrue(nativeFloats.connectFloatValue(mqttUri(TOPIC_NATIVE_FLOAT), writeCurrentValue));
assertTrue(nativeFloats.connectDoubleValue(mqttUri(TOPIC_NATIVE_DOUBLE), writeCurrentValue));
assertTrue(nativeChars.connectCharValue(mqttUri(TOPIC_NATIVE_CHAR), writeCurrentValue));
assertTrue(nativeChars.connectStringValue(mqttUri(TOPIC_NATIVE_STRING), writeCurrentValue));
assertTrue(nativeIntegers.connectBooleanValueTransformed(mqttUri(TOPIC_NATIVE_BOOLEAN_TRANSFORMED), writeCurrentValue));
assertTrue(nativeIntegers.connectIntValueTransformed(mqttUri(TOPIC_NATIVE_INT_TRANSFORMED), writeCurrentValue));
assertTrue(nativeIntegers.connectShortValueTransformed(mqttUri(TOPIC_NATIVE_SHORT_TRANSFORMED), writeCurrentValue));
assertTrue(nativeIntegers.connectLongValueTransformed(mqttUri(TOPIC_NATIVE_LONG_TRANSFORMED), writeCurrentValue));
assertTrue(nativeFloats.connectFloatValueTransformed(mqttUri(TOPIC_NATIVE_FLOAT_TRANSFORMED), writeCurrentValue));
assertTrue(nativeFloats.connectDoubleValueTransformed(mqttUri(TOPIC_NATIVE_DOUBLE_TRANSFORMED), writeCurrentValue));
assertTrue(nativeChars.connectCharValueTransformed(mqttUri(TOPIC_NATIVE_CHAR_TRANSFORMED), writeCurrentValue));
assertTrue(nativeChars.connectStringValueTransformed(mqttUri(TOPIC_NATIVE_STRING_TRANSFORMED), writeCurrentValue));
assertTrue(boxedIntegers.connectBooleanValue(mqttUri(TOPIC_BOXED_BOOLEAN), writeCurrentValue));
assertTrue(boxedIntegers.connectIntValue(mqttUri(TOPIC_BOXED_INTEGER), writeCurrentValue));
assertTrue(boxedIntegers.connectShortValue(mqttUri(TOPIC_BOXED_SHORT), writeCurrentValue));
assertTrue(boxedIntegers.connectLongValue(mqttUri(TOPIC_BOXED_LONG), writeCurrentValue));
assertTrue(boxedFloats.connectFloatValue(mqttUri(TOPIC_BOXED_FLOAT), writeCurrentValue));
assertTrue(boxedFloats.connectDoubleValue(mqttUri(TOPIC_BOXED_DOUBLE), writeCurrentValue));
assertTrue(boxedChars.connectCharValue(mqttUri(TOPIC_BOXED_CHARACTER), writeCurrentValue));
assertTrue(boxedIntegers.connectBooleanValueTransformed(mqttUri(TOPIC_BOXED_BOOLEAN_TRANSFORMED), writeCurrentValue));
assertTrue(boxedIntegers.connectIntValueTransformed(mqttUri(TOPIC_BOXED_INTEGER_TRANSFORMED), writeCurrentValue));
assertTrue(boxedIntegers.connectShortValueTransformed(mqttUri(TOPIC_BOXED_SHORT_TRANSFORMED), writeCurrentValue));
assertTrue(boxedIntegers.connectLongValueTransformed(mqttUri(TOPIC_BOXED_LONG_TRANSFORMED), writeCurrentValue));
assertTrue(boxedFloats.connectFloatValueTransformed(mqttUri(TOPIC_BOXED_FLOAT_TRANSFORMED), writeCurrentValue));
assertTrue(boxedFloats.connectDoubleValueTransformed(mqttUri(TOPIC_BOXED_DOUBLE_TRANSFORMED), writeCurrentValue));
assertTrue(boxedChars.connectCharValueTransformed(mqttUri(TOPIC_BOXED_CHARACTER_TRANSFORMED), writeCurrentValue));
}
private ReceiverData createReceiver(boolean transformed) {
......
......@@ -97,9 +97,9 @@ public class ExampleTest extends AbstractMqttTest {
}
});
robotArm.connectAppropriateSpeed(mqttUri(TOPIC_CONFIG), writeCurrentValue);
link1.connectCurrentPosition(mqttUri(TOPIC_JOINT1));
link2.connectCurrentPosition(mqttUri(TOPIC_JOINT2));
assertTrue(robotArm.connectAppropriateSpeed(mqttUri(TOPIC_CONFIG), writeCurrentValue));
assertTrue(link1.connectCurrentPosition(mqttUri(TOPIC_JOINT1)));
assertTrue(link2.connectCurrentPosition(mqttUri(TOPIC_JOINT2)));
}
@Override
......
......@@ -73,10 +73,10 @@ public class IncrementalDependencyTest extends AbstractMqttTest {
dataB2.lastStringValue = TestUtils.DefaultMappings.BytesToString(bytes);
});
model.connectInput(mqttUri(TOPIC_IN));
model.connectOutputOnA(mqttUri(TOPIC_OUT_A), writeCurrentValue);
b1.connectOutputOnB(mqttUri(TOPIC_OUT_B1), writeCurrentValue);
b2.connectOutputOnB(mqttUri(TOPIC_OUT_B2), writeCurrentValue);
assertTrue(model.connectInput(mqttUri(TOPIC_IN)));
assertTrue(model.connectOutputOnA(mqttUri(TOPIC_OUT_A), writeCurrentValue));
assertTrue(b1.connectOutputOnB(mqttUri(TOPIC_OUT_B1), writeCurrentValue));
assertTrue(b2.connectOutputOnB(mqttUri(TOPIC_OUT_B2), writeCurrentValue));
}
@Override
......
......@@ -89,29 +89,29 @@ public class MappingTest extends AbstractMqttTest {
data.lastNativeBooleanValue = TestUtils.DefaultMappings.BytesToBool(bytes);
});
natives.connectWriteIntValue(mqttUri(TOPIC_WRITE_NATIVE_INT), writeCurrentValue);
natives.connectWriteShortValue(mqttUri(TOPIC_WRITE_NATIVE_SHORT), writeCurrentValue);
natives.connectWriteLongValue(mqttUri(TOPIC_WRITE_NATIVE_LONG), writeCurrentValue);
natives.connectWriteFloatValue(mqttUri(TOPIC_WRITE_NATIVE_FLOAT), writeCurrentValue);
natives.connectWriteDoubleValue(mqttUri(TOPIC_WRITE_NATIVE_DOUBLE), writeCurrentValue);
natives.connectWriteCharValue(mqttUri(TOPIC_WRITE_NATIVE_CHAR), writeCurrentValue);
natives.connectWriteBooleanValue(mqttUri(TOPIC_WRITE_NATIVE_BOOLEAN), writeCurrentValue);
natives.connectIntValue(mqttUri(TOPIC_INPUT));
natives.connectShortValue(mqttUri(TOPIC_INPUT));
natives.connectLongValue(mqttUri(TOPIC_INPUT));
natives.connectFloatValue(mqttUri(TOPIC_INPUT));
natives.connectDoubleValue(mqttUri(TOPIC_INPUT));
natives.connectCharValue(mqttUri(TOPIC_INPUT));
natives.connectBooleanValue(mqttUri(TOPIC_INPUT));
boxes.connectIntValue(mqttUri(TOPIC_INPUT));
boxes.connectShortValue(mqttUri(TOPIC_INPUT));
boxes.connectLongValue(mqttUri(TOPIC_INPUT));
boxes.connectFloatValue(mqttUri(TOPIC_INPUT));
boxes.connectDoubleValue(mqttUri(TOPIC_INPUT));
boxes.connectCharValue(mqttUri(TOPIC_INPUT));
boxes.connectBooleanValue(mqttUri(TOPIC_INPUT));
assertTrue(natives.connectWriteIntValue(mqttUri(TOPIC_WRITE_NATIVE_INT), writeCurrentValue));
assertTrue(natives.connectWriteShortValue(mqttUri(TOPIC_WRITE_NATIVE_SHORT), writeCurrentValue));
assertTrue(natives.connectWriteLongValue(mqttUri(TOPIC_WRITE_NATIVE_LONG), writeCurrentValue));
assertTrue(natives.connectWriteFloatValue(mqttUri(TOPIC_WRITE_NATIVE_FLOAT), writeCurrentValue));
assertTrue(natives.connectWriteDoubleValue(mqttUri(TOPIC_WRITE_NATIVE_DOUBLE), writeCurrentValue));
assertTrue(natives.connectWriteCharValue(mqttUri(TOPIC_WRITE_NATIVE_CHAR), writeCurrentValue));
assertTrue(natives.connectWriteBooleanValue(mqttUri(TOPIC_WRITE_NATIVE_BOOLEAN), writeCurrentValue));
assertTrue(natives.connectIntValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectShortValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectLongValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectFloatValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectDoubleValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectCharValue(mqttUri(TOPIC_INPUT)));
assertTrue(natives.connectBooleanValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectIntValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectShortValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectLongValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectFloatValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectDoubleValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectCharValue(mqttUri(TOPIC_INPUT)));
assertTrue(boxes.connectBooleanValue(mqttUri(TOPIC_INPUT)));
}
@Override
......
......@@ -100,15 +100,15 @@ public class Read1Write2Test extends AbstractMqttTest {
dataOther2.lastStringValue = TestUtils.DefaultMappings.BytesToString(bytes);
});
onSameNonterminal.connectInput(mqttUri(TOPIC_SAME_READ));
onSameNonterminal.connectOutInteger(mqttUri(TOPIC_SAME_WRITE_INT), writeCurrentValue);
onSameNonterminal.connectOutString(mqttUri(TOPIC_SAME_WRITE_STRING), writeCurrentValue);
onDifferentNonterminal.connectInput(mqttUri(TOPIC_DIFFERENT_READ));
other1.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE1_INT), writeCurrentValue);
other1.connectOutString(mqttUri(TOPIC_DIFFERENT_WRITE1_STRING), writeCurrentValue);
other2.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE2_INT), writeCurrentValue);
other2.connectOutString(mqttUri(TOPIC_DIFFERENT_WRITE2_STRING), writeCurrentValue);
assertTrue(onSameNonterminal.connectInput(mqttUri(TOPIC_SAME_READ)));
assertTrue(onSameNonterminal.connectOutInteger(mqttUri(TOPIC_SAME_WRITE_INT), writeCurrentValue));
assertTrue(onSameNonterminal.connectOutString(mqttUri(TOPIC_SAME_WRITE_STRING), writeCurrentValue));
assertTrue(onDifferentNonterminal.connectInput(mqttUri(TOPIC_DIFFERENT_READ)));
assertTrue(other1.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE1_INT), writeCurrentValue));
assertTrue(other1.connectOutString(mqttUri(TOPIC_DIFFERENT_WRITE1_STRING), writeCurrentValue));
assertTrue(other2.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE2_INT), writeCurrentValue));
assertTrue(other2.connectOutString(mqttUri(TOPIC_DIFFERENT_WRITE2_STRING), writeCurrentValue));
}
@Override
......
......@@ -89,14 +89,14 @@ public class Read2Write1Test extends AbstractMqttTest {
dataOther2.lastIntValue = TestUtils.DefaultMappings.BytesToInt(bytes);
});
onSameNonterminal.connectInput1(mqttUri(TOPIC_SAME_READ1));
onSameNonterminal.connectInput2(mqttUri(TOPIC_SAME_READ2));
onSameNonterminal.connectOutInteger(mqttUri(TOPIC_SAME_WRITE_INT), writeCurrentValue);
onDifferentNonterminal.connectInput1(mqttUri(TOPIC_DIFFERENT_READ1));
onDifferentNonterminal.connectInput2(mqttUri(TOPIC_DIFFERENT_READ2));
other1.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE1_INT), writeCurrentValue);
other2.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE2_INT), writeCurrentValue);
assertTrue(onSameNonterminal.connectInput1(mqttUri(TOPIC_SAME_READ1)));
assertTrue(onSameNonterminal.connectInput2(mqttUri(TOPIC_SAME_READ2)));
assertTrue(onSameNonterminal.connectOutInteger(mqttUri(TOPIC_SAME_WRITE_INT), writeCurrentValue));
assertTrue(onDifferentNonterminal.connectInput1(mqttUri(TOPIC_DIFFERENT_READ1)));
assertTrue(onDifferentNonterminal.connectInput2(mqttUri(TOPIC_DIFFERENT_READ2)));
assertTrue(other1.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE1_INT), writeCurrentValue));
assertTrue(other2.connectOutInteger(mqttUri(TOPIC_DIFFERENT_WRITE2_INT), writeCurrentValue));
}
@Override
......
package org.jastadd.ragconnect.tests;
import org.junit.jupiter.api.Test;
import via.ast.A;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Collections;
import static org.junit.jupiter.api.Assertions.*;
/**
* Regression tests for fixed issues.
*
......@@ -15,6 +21,27 @@ public class RegressionTests {
private static final String REGRESSION_TEST_OUTPUT_DIRECTORY = "regression-test/";
@Test
public void issue22() {
// use model of "via" test case as it uses both mqtt and rest as protocols
A a = new A();
try {
// should fail because of missing scheme
assertFalse(a.connectBoth2BothInput("missing/scheme"));
// should fail because of missing host
assertFalse(a.connectBoth2BothInput("mqtt://"));
// should fail because of missing part
assertFalse(a.connectBoth2BothInput("mqtt://localhost"));
// should fail because of unknown scheme
assertFalse(a.connectBoth2BothInput("badScheme://host/some/topic"));
} catch (IOException e) {
fail(e);
}
}
@Test
public void issue27() throws IOException {
String grammarFile = "regression-tests/issue27/Test.relast";
......
......@@ -87,12 +87,12 @@ public class TokenValueSendTest extends AbstractMqttTest {
dataThreeOther.lastStringValue = TestUtils.DefaultMappings.BytesToString(bytes);
});
one.connectValue(mqttUri(TOPIC_SEND_ONE), writeCurrentValue);
two.connectValue(mqttUri(TOPIC_RECEIVE_TWO));
two.connectValue(mqttUri(TOPIC_SEND_TWO), writeCurrentValue);
three.connectValue(mqttUri(TOPIC_RECEIVE_THREE_VALUE));
three.connectValue(mqttUri(TOPIC_SEND_THREE_VALUE), writeCurrentValue);
three.connectOtherOutput(mqttUri(TOPIC_SEND_THREE_OTHER), writeCurrentValue);
assertTrue(one.connectValue(mqttUri(TOPIC_SEND_ONE), writeCurrentValue));
assertTrue(two.connectValue(mqttUri(TOPIC_RECEIVE_TWO)));
assertTrue(two.connectValue(mqttUri(TOPIC_SEND_TWO), writeCurrentValue));
assertTrue(three.connectValue(mqttUri(TOPIC_RECEIVE_THREE_VALUE)));
assertTrue(three.connectValue(mqttUri(TOPIC_SEND_THREE_VALUE), writeCurrentValue));
assertTrue(three.connectOtherOutput(mqttUri(TOPIC_SEND_THREE_OTHER), writeCurrentValue));
}
@Override
......
......@@ -61,14 +61,14 @@ public class TreeAllowedTokensIncrementalTest extends AbstractTreeAllowedTokensT
handler.newConnection(TOPIC_ALFA_PRIMITIVE, bytes -> data.numberOfPrimitiveTrees += 1);
// connect. important: first receiver, then sender. to not miss initial value.
senderRoot.connectInput1WhenFlagIsFalse(mqttUri(TOPIC_INPUT1FALSE));
senderRoot.connectInput1WhenFlagIsTrue(mqttUri(TOPIC_INPUT1TRUE));
senderRoot.connectInput2(mqttUri(TOPIC_INPUT2));
senderRoot.connectInput3(mqttUri(TOPIC_INPUT3));
receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA));
receiverRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE));
senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue);
senderRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE), writeCurrentValue);
assertTrue(senderRoot.connectInput1WhenFlagIsFalse(mqttUri(TOPIC_INPUT1FALSE)));
assertTrue(senderRoot.connectInput1WhenFlagIsTrue(mqttUri(TOPIC_INPUT1TRUE)));
assertTrue(senderRoot.connectInput2(mqttUri(TOPIC_INPUT2)));
assertTrue(senderRoot.connectInput3(mqttUri(TOPIC_INPUT3)));
assertTrue(receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA)));
assertTrue(receiverRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE)));
assertTrue(senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue));
assertTrue(senderRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE), writeCurrentValue));
}
@Override
......
......@@ -65,14 +65,14 @@ public class TreeAllowedTokensManualTest extends AbstractTreeAllowedTokensTest {
handler.newConnection(TOPIC_ALFA_PRIMITIVE, bytes -> data.numberOfPrimitiveTrees += 1);
// connect. important: first receiver, then sender. to not miss initial value.
senderRoot.connectInput1WhenFlagIsFalse(mqttUri(TOPIC_INPUT1FALSE));
senderRoot.connectInput1WhenFlagIsTrue(mqttUri(TOPIC_INPUT1TRUE));
senderRoot.connectInput2(mqttUri(TOPIC_INPUT2));
senderRoot.connectInput3(mqttUri(TOPIC_INPUT3));
receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA));
receiverRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE));
senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue);
senderRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE), writeCurrentValue);
assertTrue(senderRoot.connectInput1WhenFlagIsFalse(mqttUri(TOPIC_INPUT1FALSE)));
assertTrue(senderRoot.connectInput1WhenFlagIsTrue(mqttUri(TOPIC_INPUT1TRUE)));
assertTrue(senderRoot.connectInput2(mqttUri(TOPIC_INPUT2)));
assertTrue(senderRoot.connectInput3(mqttUri(TOPIC_INPUT3)));
assertTrue(receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA)));
assertTrue(receiverRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE)));
assertTrue(senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue));
assertTrue(senderRoot.connectAlfaPrimitive(mqttUri(TOPIC_ALFA_PRIMITIVE), writeCurrentValue));
}
@Override
......
......@@ -56,8 +56,8 @@ public class TreeIncrementalTest extends AbstractTreeTest {
handler.newConnection(TOPIC_ALFA, bytes -> data.numberOfTrees += 1);
// connect. important: first receiver, then sender. to not miss initial value.
receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA));
senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue);
assertTrue(receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA)));
assertTrue(senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue));
}
@Override
......
......@@ -58,8 +58,8 @@ public class TreeManualTest extends AbstractTreeTest {
handler.newConnection(TOPIC_ALFA, bytes -> data.numberOfTrees += 1);
// connect. important: first receiver, then sender. to not miss initial value.
receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA));
senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue);
assertTrue(receiverRoot.connectAlfa(mqttUri(TOPIC_ALFA)));
assertTrue(senderRoot.connectAlfa(mqttUri(TOPIC_ALFA), writeCurrentValue));
}
@Override
......
......@@ -6,6 +6,7 @@ import tutorial.ast.B;
import java.io.IOException;
import static org.jastadd.ragconnect.tests.TestUtils.mqttUri;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Testcase "Tutorial".
......@@ -38,10 +39,10 @@ public class TutorialTest extends AbstractMqttTest {
// b2.OutputOnB -> a.Input
b2.addDependencyB(a);
a.connectInput(mqttUri("topic/for/input"));
a.connectOutputOnA(mqttUri("a/out"), true);
b1.connectOutputOnB(mqttUri("b1/out"), true);
b2.connectOutputOnB(mqttUri("b2/out"), false);
assertTrue(a.connectInput(mqttUri("topic/for/input")));
assertTrue(a.connectOutputOnA(mqttUri("a/out"), true));
assertTrue(b1.connectOutputOnB(mqttUri("b1/out"), true));
assertTrue(b2.connectOutputOnB(mqttUri("b2/out"), false));
}
@Override
......
......@@ -106,18 +106,18 @@ public class ViaTest extends AbstractMqttTest {
senderRest2Mqtt = client.target(REST_SERVER_BASE_URL + PATH_REST_2_MQTT_RECEIVE);
senderBoth2Rest = client.target(REST_SERVER_BASE_URL + PATH_BOTH_REST_RECEIVE);
model.connectMqtt2MqttInput(mqttUri(TOPIC_MQTT_2_MQTT_RECEIVE));
model.connectMqtt2MqttOutput(mqttUri(TOPIC_MQTT_2_MQTT_SEND), writeCurrentValue);
model.connectMqtt2RestInput(mqttUri(TOPIC_MQTT_2_REST_RECEIVE));
model.connectMqtt2RestOutput(restUri(PATH_MQTT_2_REST_SEND, REST_PORT), writeCurrentValue);
model.connectRest2MqttInput(restUri(PATH_REST_2_MQTT_RECEIVE, REST_PORT));
model.connectRest2MqttOutput(mqttUri(TOPIC_REST_2_MQTT_SEND), writeCurrentValue);
model.connectRest2RestInput(restUri(PATH_REST_2_REST_RECEIVE, REST_PORT));
model.connectRest2RestOutput(restUri(PATH_REST_2_REST_SEND, REST_PORT), writeCurrentValue);
model.connectBoth2BothInput(mqttUri(TOPIC_BOTH_MQTT_RECEIVE));
model.connectBoth2BothInput(restUri(PATH_BOTH_REST_RECEIVE, REST_PORT));
model.connectBoth2MqttOutput(mqttUri(TOPIC_BOTH_2_MQTT_SEND), writeCurrentValue);
model.connectBoth2RestOutput(restUri(PATH_BOTH_2_REST_SEND, REST_PORT), writeCurrentValue);
assertTrue(model.connectMqtt2MqttInput(mqttUri(TOPIC_MQTT_2_MQTT_RECEIVE)));
assertTrue(model.connectMqtt2MqttOutput(mqttUri(TOPIC_MQTT_2_MQTT_SEND), writeCurrentValue));
assertTrue(model.connectMqtt2RestInput(mqttUri(TOPIC_MQTT_2_REST_RECEIVE)));
assertTrue(model.connectMqtt2RestOutput(restUri(PATH_MQTT_2_REST_SEND, REST_PORT), writeCurrentValue));
assertTrue(model.connectRest2MqttInput(restUri(PATH_REST_2_MQTT_RECEIVE, REST_PORT)));
assertTrue(model.connectRest2MqttOutput(mqttUri(TOPIC_REST_2_MQTT_SEND), writeCurrentValue));
assertTrue(model.connectRest2RestInput(restUri(PATH_REST_2_REST_RECEIVE, REST_PORT)));
assertTrue(model.connectRest2RestOutput(restUri(PATH_REST_2_REST_SEND, REST_PORT), writeCurrentValue));
assertTrue(model.connectBoth2BothInput(mqttUri(TOPIC_BOTH_MQTT_RECEIVE)));
assertTrue(model.connectBoth2BothInput(restUri(PATH_BOTH_REST_RECEIVE, REST_PORT)));
assertTrue(model.connectBoth2MqttOutput(mqttUri(TOPIC_BOTH_2_MQTT_SEND), writeCurrentValue));
assertTrue(model.connectBoth2RestOutput(restUri(PATH_BOTH_2_REST_SEND, REST_PORT), writeCurrentValue));
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment