LwM2MImporter { public ValidationReport validate(InputStream fileInput) { try { LWM2M lwm2m = parse(fileInput); if (lwm2m.getObject().isEmpty()) { return ValidationReport.invalid("File does not contain any object definitions."); } else { return ValidationReport.valid("File is a valid LwM2M description"); } } catch (Exception ex) { return ValidationReport.invalid(ex.getMessage()); } }  ValidationReport validate(InputStream fileInput); byte[] convert(InputStream fileInput);  }
@Test public void testValidation() { final String filename = "3328_1_1.xml"; InputStream lwm2mXml = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename); LwM2MImporter importer = new LwM2MImporter(); ValidationReport report = importer.validate(lwm2mXml); assertTrue(report.isValid()); assertNotNull(report.getMessage()); }