示例#1
0
 protected void checkNumericContent(final Container cont2, final int num) {
   final NodeIterator nit = cont2.iterator();
   for (int i = 0; i < num; i += 1) {
     Assert.assertEquals(i, ((Literal) nit.nextNode()).getInt());
   }
   Assert.assertFalse(nit.hasNext());
 }
示例#2
0
 protected void seeWhatsThere(final Container cont2, final boolean[] found) {
   final NodeIterator nit = cont2.iterator();
   while (nit.hasNext()) {
     final int v = ((Literal) nit.nextNode()).getInt();
     Assert.assertFalse(found[v]);
     found[v] = true;
   }
 }
示例#3
0
 protected void retainOnlySpecified(final Container cont2, final int num, final boolean[] retain) {
   final NodeIterator nit = cont2.iterator();
   for (int i = 0; i < num; i++) {
     nit.nextNode();
     if (retain[i] == false) {
       nit.remove();
     }
   }
   Assert.assertFalse(nit.hasNext());
 }
示例#4
0
 private void testContainer(final Model model, final Container cont1, final Container cont2) {
   final Literal tvLiteral = model.createLiteral("test 12 string 2");
   // Resource tvResObj = model.createResource( new ResTestObjF() );
   final Object tvLitObj = new LitTestObj(1234);
   model.createBag();
   model.createAlt();
   model.createSeq();
   final String lang = "en";
   //
   Assert.assertEquals(0, cont1.size());
   Assert.assertEquals(0, cont2.size());
   //
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvBoolean).contains(AbstractModelTestBase.tvBoolean));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvByte).contains(AbstractModelTestBase.tvByte));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvShort).contains(AbstractModelTestBase.tvShort));
   Assert.assertTrue(cont1.add(AbstractModelTestBase.tvInt).contains(AbstractModelTestBase.tvInt));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvLong).contains(AbstractModelTestBase.tvLong));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvFloat).contains(AbstractModelTestBase.tvFloat));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvDouble).contains(AbstractModelTestBase.tvDouble));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvChar).contains(AbstractModelTestBase.tvChar));
   Assert.assertTrue(
       cont1.add(AbstractModelTestBase.tvString).contains(AbstractModelTestBase.tvString));
   Assert.assertFalse(cont1.contains(AbstractModelTestBase.tvString, lang));
   Assert.assertTrue(
       cont1
           .add(AbstractModelTestBase.tvString, lang)
           .contains(AbstractModelTestBase.tvString, lang));
   Assert.assertTrue(cont1.add(tvLiteral).contains(tvLiteral));
   // assertTrue( cont1.add( tvResObj ).contains( tvResObj ) );
   Assert.assertTrue(cont1.add(tvLitObj).contains(tvLitObj));
   Assert.assertEquals(12, cont1.size());
   //
   final int num = 10;
   for (int i = 0; i < num; i += 1) {
     cont2.add(i);
   }
   Assert.assertEquals(num, cont2.size());
   checkNumericContent(cont2, num);
   //
   final boolean[] found = new boolean[num];
   final boolean[] retain = {true, true, true, false, false, false, false, false, true, true};
   retainOnlySpecified(cont2, num, retain);
   seeWhatsThere(cont2, found);
   for (int i = 0; i < num; i += 1) {
     Assert.assertEquals(i + "th element of array", retain[i], found[i]);
   }
 }