use of org.apache.jena.rdf.model.Container in project jena by apache.
the class AbstractContainerMethods method testContainerOfIntegers.
public void testContainerOfIntegers() {
final int num = 10;
final Container c = createContainer();
for (int i = 0; i < num; i += 1) {
c.add(i);
}
Assert.assertEquals(num, c.size());
final NodeIterator it = c.iterator();
for (int i = 0; i < num; i += 1) {
Assert.assertEquals(i, ((Literal) it.nextNode()).getInt());
}
Assert.assertFalse(it.hasNext());
}
use of org.apache.jena.rdf.model.Container in project jena by apache.
the class AbstractContainerMethods method testContainerOfIntegersWithRemoving.
protected void testContainerOfIntegersWithRemoving(final boolean[] retain) {
final int num = retain.length;
final boolean[] found = new boolean[num];
final Container c = createContainer();
for (int i = 0; i < num; i += 1) {
c.add(i);
}
final NodeIterator it = c.iterator();
for (boolean aRetain : retain) {
it.nextNode();
if (aRetain == false) {
it.remove();
}
}
final NodeIterator s = c.iterator();
while (s.hasNext()) {
final int v = ((Literal) s.nextNode()).getInt();
Assert.assertFalse(found[v]);
found[v] = true;
}
for (int i = 0; i < num; i += 1) {
Assert.assertEquals("element " + i, retain[i], found[i]);
}
}
use of org.apache.jena.rdf.model.Container in project jena by apache.
the class SecuredContainerTest method setup.
@Override
@Before
public void setup() {
super.setup();
final Container container = baseModel.getBag("http://example.com/testContainer");
container.add("SomeDummyItem");
setSecuredRDFNode(SecuredContainerImpl.getInstance(securedModel, container), container);
}
use of org.apache.jena.rdf.model.Container in project jena by apache.
the class AbstractContainerMethods method testFillingContainer.
public void testFillingContainer() {
final Container c = createContainer();
final String lang = "fr";
final Literal tvLiteral = model.createLiteral("test 12 string 2");
// Resource tvResObj = model.createResource( new ResTestObjF() );
c.add(AbstractModelTestBase.tvBoolean);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvBoolean));
c.add(AbstractModelTestBase.tvByte);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvByte));
c.add(AbstractModelTestBase.tvShort);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvShort));
c.add(AbstractModelTestBase.tvInt);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvInt));
c.add(AbstractModelTestBase.tvLong);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvLong));
c.add(AbstractModelTestBase.tvChar);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvChar));
c.add(AbstractModelTestBase.tvFloat);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvFloat));
c.add(AbstractModelTestBase.tvString);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvString));
c.add(AbstractModelTestBase.tvString, lang);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvString, lang));
c.add(tvLiteral);
Assert.assertTrue(c.contains(tvLiteral));
// c.add( tvResObj ); assertTrue( c.contains( tvResObj ) );
c.add(AbstractModelTestBase.tvLitObj);
Assert.assertTrue(c.contains(AbstractModelTestBase.tvLitObj));
Assert.assertEquals(11, c.size());
}
use of org.apache.jena.rdf.model.Container in project jena by apache.
the class AbstractContainerMethods method testEmptyContainer.
public void testEmptyContainer() {
final Container c = createContainer();
Assert.assertTrue(model.contains(c, RDF.type, getContainerType()));
Assert.assertEquals(0, c.size());
Assert.assertFalse(c.contains(AbstractModelTestBase.tvBoolean));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvByte));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvShort));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvInt));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvLong));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvChar));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvFloat));
Assert.assertFalse(c.contains(AbstractModelTestBase.tvString));
}
Aggregations