Package com.epimorphics.util
Class TestUtil
- java.lang.Object
-
- com.epimorphics.util.TestUtil
-
public class TestUtil extends Object
Support for testing iterator/list values against and expected set of answers.- Author:
- Dave Reynolds
-
-
Constructor Summary
Constructors Constructor Description TestUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbaseURIFixture()Return a base URI that is guaranteed not to resolve.static booleanisOnlyValue(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object)Test that the given resource/property has the given object value and ONLY the given object value.static org.apache.jena.rdf.model.ModelmodelFixture(String content)Create aModelas a text fixturestatic org.apache.jena.rdf.model.PropertypropertyFixture(org.apache.jena.rdf.model.Model m, String uri)Return a property with the given URI.static org.apache.jena.rdf.model.ResourceresourceFixture(String src)Return a resource which is the (assumed sole) root subject of the model given by the turtle source.static org.apache.jena.rdf.model.ResourceresourceFixture(org.apache.jena.rdf.model.Model m, String uri)Return a resource with the given URI.static <E> voidtestArray(E[] actual, E[] expected)static <E> voidtestArray(Collection<E> actual, E[] expected)static <E> voidtestArray(Iterator<E> actual, E[] expected)static voidtestResourcesMatch(org.apache.jena.rdf.model.Resource expected, org.apache.jena.rdf.model.Resource actual, org.apache.jena.rdf.model.Property... omit)Compare the properties of two resources, omitting any of the list of blocked properties.
-
-
-
Method Detail
-
testArray
public static <E> void testArray(E[] actual, E[] expected)
-
testArray
public static <E> void testArray(Collection<E> actual, E[] expected)
-
testArray
public static <E> void testArray(Iterator<E> actual, E[] expected)
-
modelFixture
public static org.apache.jena.rdf.model.Model modelFixture(String content)
Create aModelas a text fixture- Parameters:
content- The model content in Turtle. Common prefixes may be assumed.- Returns:
- A new model containing triples parsed from the content
-
resourceFixture
public static org.apache.jena.rdf.model.Resource resourceFixture(org.apache.jena.rdf.model.Model m, String uri)Return a resource with the given URI.- Parameters:
m- Optional model. If null, the resource will be created using theResourceFactoryuri- Resource URI. If the URI starts withhttp:, it will be left intact otherwise it is assumed relative to thebaseURIFixture()- Returns:
- A resource
-
resourceFixture
public static org.apache.jena.rdf.model.Resource resourceFixture(String src)
Return a resource which is the (assumed sole) root subject of the model given by the turtle source. Common prefixes are assumed.
-
propertyFixture
public static org.apache.jena.rdf.model.Property propertyFixture(org.apache.jena.rdf.model.Model m, String uri)Return a property with the given URI.- Parameters:
m- Optional model. If null, the property will be created using theResourceFactoryuri- Resource URI. If the URI starts withhttp:, it will be left intact otherwise it is assumed relative to thebaseURIFixture()- Returns:
- A property
-
baseURIFixture
public static String baseURIFixture()
Return a base URI that is guaranteed not to resolve.- Returns:
- "http://example.test/test#"
-
isOnlyValue
public static boolean isOnlyValue(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object)Test that the given resource/property has the given object value and ONLY the given object value.- Parameters:
subject- subject resourcepredicate- property to testobject- the expected value or null to not test the value, just that there is one
-
testResourcesMatch
public static void testResourcesMatch(org.apache.jena.rdf.model.Resource expected, org.apache.jena.rdf.model.Resource actual, org.apache.jena.rdf.model.Property... omit)Compare the properties of two resources, omitting any of the list of blocked properties. Single, unadorned, bNode values on the expected resource are treated as wild cards, the actual is required to just have some value for that property.
-
-