Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362495 - Incorrect null checks after Model.getResource()
Summary: Incorrect null checks after Model.getResource()
Status: CLOSED FIXED
Alias: None
Product: Lyo
Classification: Technology
Component: TestSuite (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Samuel Padgett CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-31 10:43 EDT by Samuel Padgett CLA
Modified: 2013-05-23 09:13 EDT (History)
3 users (show)

See Also:


Attachments
Use Model.contains() instead of Model.getResource() to see if a subject is in the model (15.60 KB, patch)
2011-11-02 15:19 EDT, Samuel Padgett CLA
samuel.padgett: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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...