use of org.omg.dmn.tck.marshaller._20160719.TestCases in project tck by dmn-tck.
the class Reporter method loadTestCases.
private static Map<String, TestCasesData> loadTestCases(Parameters params) {
logger.info("Loading test case definitions");
Map<String, TestCasesData> tests = new TreeMap<>();
List<URL> testCaseURLs = getTestCaseURLs(params);
int testCount = 0;
for (URL url : testCaseURLs) {
File tcFolder = null;
try {
tcFolder = new File(url.toURI());
} catch (URISyntaxException e) {
logger.error("Error loading test case " + url, e);
System.exit(1);
}
final String tcName = tcFolder.getName();
File[] tcfiles = tcFolder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.matches(tcName + "-test-\\d\\d.xml");
}
});
for (File tcfile : tcfiles) {
try {
TestCases tcd = TckMarshallingHelper.load(new FileInputStream(tcfile));
testCount += tcd.getTestCase().size();
String parent = tcfile.getParent();
String folder = parent != null ? parent.substring(parent.lastIndexOf('/', parent.lastIndexOf('/') - 1) + 1) : "<unknown>";
String tcdname = tcfile.getName();
tcdname = tcdname.substring(0, tcdname.lastIndexOf('.')).replaceAll("\\.", "/");
TestCasesData tcdd = new TestCasesData(folder, tcdname, tcd);
tests.put(createTestCaseKey(folder, tcdname), tcdd);
} catch (FileNotFoundException e) {
logger.error("Error loading test case " + tcfile, e);
System.exit(1);
} catch (JAXBException e) {
logger.error("Error loading test case " + tcfile, e);
System.exit(1);
}
}
}
logger.info(tests.size() + " test suites loaded, with " + testCount + " unit tests");
return tests;
}
use of org.omg.dmn.tck.marshaller._20160719.TestCases in project tck by dmn-tck.
the class TestCasesFiles method data.
@Parameters(name = "TestCase {0}")
public static Iterable<Object[]> data() {
List<Object[]> testCases = new ArrayList<>();
File cl2parent = new File("../../TestCases/compliance-level-2");
FileFilter filenameFilter = pathname -> pathname.isDirectory();
for (File file : cl2parent.listFiles(filenameFilter)) {
testCases.add(new Object[] { file.getName(), file });
}
File cl3parent = new File("../../TestCases/compliance-level-3");
for (File file : cl3parent.listFiles(filenameFilter)) {
testCases.add(new Object[] { file.getName(), file });
}
return testCases;
}
use of org.omg.dmn.tck.marshaller._20160719.TestCases in project tck by dmn-tck.
the class JDMNTckTest method createContext.
@Override
public TestSuiteContext createContext() {
DMNReader dmnReader = new DMNReader(LOGGER, false);
DMNWriter dmnWriter = new DMNWriter(LOGGER);
DMNTransformer<TestCases> dmnTransformer = new ToQuotedNameTransformer(LOGGER);
StandardDMNDialectDefinition dialectDefinition = new StandardDMNDialectDefinition();
return new JDMNTestContext<>(dmnReader, dmnWriter, dmnTransformer, dialectDefinition);
}
use of org.omg.dmn.tck.marshaller._20160719.TestCases in project tck by dmn-tck.
the class TckMarshallingHelper method load.
@SuppressWarnings({ "unchecked" })
public static final TestCases load(InputStream inputStream) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(TestCases.class);
Unmarshaller um = context.createUnmarshaller();
Object obj = um.unmarshal(inputStream);
if (obj instanceof JAXBElement<?>) {
return ((JAXBElement<TestCases>) obj).getValue();
} else {
return (TestCases) obj;
}
}
use of org.omg.dmn.tck.marshaller._20160719.TestCases in project tck by dmn-tck.
the class TestCasesFiles method testCaseFileIsValid.
@Test
public void testCaseFileIsValid() throws Exception {
for (File dmnFile : basedir.listFiles((dir, name) -> name.matches(".*\\.xml$"))) {
Validator validator = testCasesSchema.newValidator();
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
validator.validate(new StreamSource(dmnFile));
TestCases testCases = TckMarshallingHelper.load(new FileInputStream(dmnFile));
Map<String, Long> idCounting = testCases.getTestCase().stream().map(TestCases.TestCase::getId).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
for (Entry<String, Long> kv : idCounting.entrySet()) {
assertThat("The id '" + kv.getKey() + "' is occuring more than one time in the file " + dmnFile, kv.getValue(), is(1L));
}
}
}
Aggregations