Example #1
0
  @Test
  public void testCollectionData() {
    Log.info(Log.FAC_TEST, "Starting testCollectionData");

    Collection cd = new Collection();
    Assert.assertNotNull(cd);
    Assert.assertTrue(cd.validate());

    Log.info(Log.FAC_TEST, "Completed testCollectionData");
  }
Example #2
0
  @Test
  public void testSize() {
    Log.info(Log.FAC_TEST, "Starting testSize");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    Assert.assertTrue(cd.size() == lrs.length);

    Log.info(Log.FAC_TEST, "Completed testSize");
  }
Example #3
0
  @Test
  public void testRemoveInt() {
    Log.info(Log.FAC_TEST, "Starting testRemoveInt");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    cd.remove(0);
    Assert.assertEquals(cd.get(0), lrs[1]);

    Log.info(Log.FAC_TEST, "Completed testRemoveInt");
  }
Example #4
0
  @Test
  public void testAddGet() {
    Log.info(Log.FAC_TEST, "Starting testAddGet");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    for (int i = 0; i < lrs.length; ++i) {
      Assert.assertEquals(cd.get(i), lrs[i]);
    }

    Log.info(Log.FAC_TEST, "Completed testAddGet");
  }
Example #5
0
  @Test
  public void testEncodeDecodeByteArray() {
    Log.info(Log.FAC_TEST, "Starting testEncodeDecodeByteArray");

    Collection cd = new Collection();
    Collection cdec = new Collection();
    Collection bdec = new Collection();

    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    XMLEncodableTester.encodeDecodeByteArrayTest("Collection", cd, cdec, bdec);

    Log.info(Log.FAC_TEST, "Completed testEncodeDecodeByteArray");
  }
Example #6
0
  @Test
  public void testContents() {
    Log.info(Log.FAC_TEST, "Starting testContents");

    Collection cd = new Collection();
    Assert.assertTrue(cd.validate());
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    LinkedList<Link> c = cd.contents();
    Assert.assertNotNull(c);
    Assert.assertTrue(c.size() == lrs.length);
    for (int i = 0; i < lrs.length; ++i) {
      Assert.assertEquals(c.get(i), lrs[i]);
    }

    // Test iterator
    int j = 0;
    for (Link l : cd) {
      Assert.assertEquals(l, lrs[j++]);
    }

    Log.info(Log.FAC_TEST, "Completed testContents");
  }
Example #7
0
  @Test
  public void testValidate() {
    Log.info(Log.FAC_TEST, "Starting testValidate");

    Collection cd = new Collection();
    Assert.assertTrue(cd.validate());
    cd.add(lrs[0]);
    Assert.assertTrue(cd.validate());
    cd.remove(0);
    Assert.assertTrue(cd.validate());

    Log.info(Log.FAC_TEST, "Completed testValidate");
  }
Example #8
0
  @Test
  public void testRemoveLink() {
    Log.info(Log.FAC_TEST, "Starting testRemoveLink");

    Collection cd = new Collection();
    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
    }
    cd.remove(lrs[0]);
    Assert.assertEquals(cd.get(0), lrs[1]);
    LinkAuthenticator la2alt =
        new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);

    Link lr2alt = new Link(name3, la2alt);
    cd.remove(lr2alt);
    Assert.assertEquals(cd.get(1), lrs[3]);

    Log.info(Log.FAC_TEST, "Completed testRemoveLink");
  }
Example #9
0
  @Test
  public void testEqualsObject() {
    Log.info(Log.FAC_TEST, "Starting testEqualsObject");

    Collection cd = new Collection();
    Collection cd2 = new Collection();
    Collection cd3 = new Collection();

    for (int i = 0; i < lrs.length; ++i) {
      cd.add(lrs[i]);
      cd2.add(lrs[i]);
      cd3.add(lrs[lrs.length - i - 1]);
    }
    Assert.assertEquals(cd, cd2);
    Assert.assertFalse(cd.equals(cd3));
    cd.remove(2);
    Collection cd4 = cd2.clone();
    Assert.assertFalse(cd.equals(cd2));
    Assert.assertEquals(cd4, cd2);
    cd2.remove(2);
    Assert.assertEquals(cd, cd2);

    cd2.remove(2); // remove last entry
    cd2.add(new Link(name3, las[2]));
    cd2.add(new Link(name4, las[3]));
    Assert.assertEquals(cd2, cd4);

    Log.info(Log.FAC_TEST, "Completed testEqualsObject");
  }