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

Bug 362495

Summary: Incorrect null checks after Model.getResource()
Product: [Technology] Lyo Reporter: Samuel Padgett <samuel.padgett>
Component: TestSuiteAssignee: Samuel Padgett <samuel.padgett>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: fiedler.mf, samuel.padgett, sspeiche
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Use Model.contains() instead of Model.getResource() to see if a subject is in the model samuel.padgett: review?

Description Samuel Padgett CLA 2011-10-31 10:43:24 EDT
Build Identifier: 

The test suite contains several null tests like this,

  catalog = (Resource) rdfModel.getResource(currentUrl);
  assertNotNull("Failed to read Catalog resource at URI: "+currentUrl, catalog);

According to the Jena Javadoc, Model.getResource() never returns null, however.

http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/rdf/model/Model.html#getResource%28java.lang.String%29

"Return a Resource instance with the given URI in this model. This method behaves identically to createResource(String) and exists as legacy: createResource is now capable of, and allowed to, reuse existing objects."

If the resource isn't in the model, it gets created, so the tests are not really checking if the resource is there.

Reproducible: Always
Comment 1 Samuel Padgett CLA 2011-11-02 15:19:20 EDT
Created attachment 206369 [details]
Use Model.contains() instead of Model.getResource() to see if a subject is in the model

I updated the tests to match the original intent (checking if the resources are really in the model), and removed the null checks for objects that will never be null.
Comment 3 Samuel Padgett CLA 2013-05-23 09:13:15 EDT
Closing...