Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365422

Summary: Add RDF model validation to the OSLC JUnits.
Product: [Technology] Lyo Reporter: Paul Slauenwhite <paulslau>
Component: TestSuiteAssignee: Michael Fiedler <fiedler.mf>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: fiedler.mf, sspeiche
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Paul Slauenwhite CLA 2011-12-02 07:59:39 EST
Validate the model after reading (GET) and before creating/updating (PUT/POST).  For example:

protected void validateModel(Model model) throws Exception {

		InfModel infmodel = ModelFactory.createRDFSModel(model);
		ValidityReport validityReport = infmodel.validate();

		if (!validityReport.isClean()) {

			StringBuffer errorMessage = new StringBuffer();
			errorMessage.append("Invalid model:"); //$NON-NLS-1$

			Iterator<ValidityReport.Report> reports = validityReport.getReports();

			while(reports.hasNext()){

				errorMessage.append('\n');
				errorMessage.append(reports.next().toString());
			}

			Assert.fail(errorMessage.toString());
		}
	}
Comment 2 Paul Slauenwhite CLA 2011-12-10 08:42:30 EST
Thanks Mike.

Closing.