use of won.protocol.validation.WonMessageValidator in project webofneeds by researchstudio-sat.
the class WonMessageValidatorTest method testValidHintMessage.
@Test
public void testValidHintMessage() throws IOException {
WonMessageValidator validator = new WonMessageValidator();
StringBuilder message = new StringBuilder();
boolean valid = validator.validate(Utils.createTestDataset("/validation/valid/hint_msg.trig"), message);
Assert.assertTrue("validation is expected not to fail at " + message, valid);
}
use of won.protocol.validation.WonMessageValidator in project webofneeds by researchstudio-sat.
the class WonMessageValidatorTest method testGraphUris.
@Test
public void testGraphUris() throws IOException {
// create a dataset with invalid content uris - i.e. replace valid content graph
// name with
// the one that does not start with the corresponding event uri: replace the uri
// in the
// respective envelope content and content signature reference, as well as in
// the content signature
Dataset invalidDataset = WonRdfUtils.MessageUtils.copyByDatasetSerialization(WonMessage.of(createMessageDataset)).getCompleteDataset();
Model contModel = invalidDataset.getNamedModel(CREATE_CONTENT_NAME);
invalidDataset.removeNamedModel(CREATE_CONTENT_NAME);
String dummyName = "test:graph:uri";
invalidDataset.addNamedModel(dummyName, contModel);
Model env1Model = invalidDataset.getNamedModel(CREATE_ENV_NAME);
StmtIterator iter = env1Model.listStatements(null, WONMSG.content, RdfUtils.EMPTY_RDF_NODE);
Statement stmtOld = iter.removeNext();
Statement stmtNew = env1Model.createStatement(stmtOld.getSubject(), stmtOld.getPredicate(), ResourceFactory.createResource(dummyName));
env1Model.add(stmtNew);
iter = env1Model.listStatements(null, WONMSG.signedGraph, ResourceFactory.createResource(CREATE_CONTENT_NAME));
Statement stmtOld2 = iter.removeNext();
Statement stmtNew2 = env1Model.createStatement(stmtOld2.getSubject(), stmtOld2.getPredicate(), ResourceFactory.createResource(dummyName));
env1Model.add(stmtNew2);
Model sigModel = invalidDataset.getNamedModel(CREATE_SIG_NAME);
iter = sigModel.listStatements(null, WONMSG.signedGraph, RdfUtils.EMPTY_RDF_NODE);
Statement stmtOld3 = iter.removeNext();
Statement stmtNew3 = sigModel.createStatement(stmtOld3.getSubject(), stmtOld3.getPredicate(), ResourceFactory.createResource(dummyName));
sigModel.add(stmtNew3);
// String test = RdfUtils.writeDatasetToString(invalidDataset, Lang.TRIG);
// System.out.println("OUT:\n" + test);
WonMessageValidator validator = new WonMessageValidator();
StringBuilder message = new StringBuilder();
// validate this invalid dataset
boolean valid = validator.validate(invalidDataset, message);
Assert.assertFalse(valid);
// actually
Assert.assertTrue(message.toString().contains("graph_uris"));
// reset for further testing:
// env2sigModel.add(stmtOld);
// env2sigModel.remove(stmtNew);
}
use of won.protocol.validation.WonMessageValidator in project webofneeds by researchstudio-sat.
the class WonMessageValidatorTest method testValidResponseLocalMessage.
@Test
@Ignore
public void testValidResponseLocalMessage() throws IOException {
WonMessageValidator validator = new WonMessageValidator();
StringBuilder message = new StringBuilder();
boolean valid = validator.validate(responseMessageDataset, message);
Assert.assertTrue("validation is expected not to fail at " + message, valid);
}
use of won.protocol.validation.WonMessageValidator in project webofneeds by researchstudio-sat.
the class WonMessageValidatorTest method testValidMessageWithMisleadingContent.
@Test
@Ignore
public void testValidMessageWithMisleadingContent() throws IOException {
WonMessageValidator validator = new WonMessageValidator();
StringBuilder message = new StringBuilder();
boolean valid = validator.validate(misleadingMessageDataset, message);
Assert.assertTrue("validation is not expected to fail at " + message, valid);
}
use of won.protocol.validation.WonMessageValidator in project webofneeds by researchstudio-sat.
the class WonMessageValidatorTest method testValidTextRemoteMessage.
@Test
@Ignore
public void testValidTextRemoteMessage() throws IOException {
WonMessageValidator validator = new WonMessageValidator();
StringBuilder message = new StringBuilder();
boolean valid = validator.validate(textMessageDataset, message);
Assert.assertTrue("validation is expected not to fail at " + message, valid);
}
Aggregations