Added tests for ros2

parent d636e8c1
......@@ -338,19 +338,4 @@ public class GenerationTest extends AbstractSymtabTest {
assertFalse(filenames.stream().anyMatch(fn -> fn.endsWith("rosMsg/CMakeLists.txt")));
}
@Test
public void testRos2Generation() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.aRos2.addComp", EMAComponentInstanceSymbol.KIND).orElse(null);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath("./target/generated-sources-ros2/addComp/src");
distributedTargetGenerator.add(new CPPGenImpl(),"cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
}
package de.monticore.lang.monticar.generator.middleware;
public class Ros2GenerationTest {
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RclCppGenImpl;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertNotNull;
public class Ros2GenerationTest extends AbstractSymtabTest {
private static final String TEST_PATH = "src/test/resources/";
private static final String OUT_BASE = "./target/generated-sources-ros2/";
@Test
public void testRos2Generation() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.aRos2.addComp", EMAComponentInstanceSymbol.KIND).orElse(null);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "addComp/src");
distributedTargetGenerator.add(new CPPGenImpl(),"cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testBaSystem() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("ba.system", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
String generationTargetPath = OUT_BASE + "system/src/";
distributedTargetGenerator.setGenerationTargetPath(generationTargetPath);
//distributedTargetGenerator.setGenDebug(true);
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testDistributedTargetGenerator() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.distComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "distributed/src/");
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testDistributedStructTargetGenerator() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.distWithStructComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "distributedStruct/src/");
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
}
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