/**
  * Test method for {@link
  * org.jhove2.persist.berkeleydpl.BerkeleyDbBaseModuleAccessor#persistModule(org.jhove2.module.Module)}.
  */
 @Test
 public void testPersistModule() {
   Long oldId = bdbUTF8Module.getModuleId();
   try {
     bdbUTF8Module = (UTF8Module) bdbUTF8Module.getModuleAccessor().persistModule(bdbUTF8Module);
     assertEquals(oldId.longValue(), bdbUTF8Module.getModuleId().longValue());
     BerkeleyDbBaseModuleAccessor ma =
         (BerkeleyDbBaseModuleAccessor) bdbUTF8Module.getModuleAccessor();
     bdbUTF8Module = (UTF8Module) ma.retrieveModule(bdbUTF8Module.getModuleId());
     assertEquals(oldId.longValue(), bdbUTF8Module.getModuleId().longValue());
   } catch (JHOVE2Exception e) {
     e.printStackTrace();
     fail(e.getMessage());
   }
 }
 /** goal 0-100 (impose finish at 100) */
 @Test
 public void testGetEnd() {
   int offset = 0;
   int limit = 5;
   Long finish = 100l;
   long total = 213;
   Sharding d = new Sharding();
   d.setLimit(offset, limit, finish);
   d.setCounts(total);
   long end = d.getEnd();
   assertEquals(finish.longValue(), end);
 }
  @Test
  public final void testTotalIterableOfLong() {
    final Iterable<Long> numbers1 = asList(convertToBoxed(NUMBERS1));
    final Iterable<Long> numbers2 = asList(convertToBoxed(NUMBERS2));

    long total1 = 0;
    for (final Long n : numbers1) total1 += n.longValue();

    long total2 = 0;
    for (final Long n : numbers2) total2 += n.longValue();

    final long expected1 = total1;
    final long actual1 = total(numbers1);
    // System.out.println("expected: " + expected1 + "\nactual:   " + actual1);
    assertTrue(expected1 == actual1);
    final long expected2 = total2;
    final long actual2 = total(numbers2);
    // System.out.println("expected: " + expected2 + "\nactual:   " + actual2);
    assertTrue(expected2 == actual2);

    final Iterable<Long> numbers3 = asList(convertToBoxed(NUMBERS3));
    final Iterable<Long> numbers4 = asList(convertToBoxed(NUMBERS4));

    long total3 = 0;
    for (final Long n : numbers3) total3 += n.longValue();

    long total4 = 0;
    for (final Long n : numbers4) total4 += n.longValue();

    final long expected3 = total3;
    final long actual3 = total(numbers3);
    // System.out.println("expected: " + expected3 + "\nactual:   " + actual3);
    assertTrue(expected3 == actual3);

    final long expected4 = total4;
    final long actual4 = total(numbers4);
    // System.out.println("expected: " + expected4 + "\nactual:   " + actual4);
    assertTrue(expected4 == actual4);
  }
Example #4
0
  @Test
  public static void testName() throws Exception {
    Long a = 1L;
    Long b = 1L;
    assertTrue(a == b);
    a = a.longValue() + 100;
    b = b.longValue() + 100;
    assertTrue(a == b);

    a = a.longValue() + 200;
    b = b.longValue() + 200;

    assertFalse(a == b); // 不等了。。。!!!
    assertTrue(a.longValue() == b.longValue());
  }
  @Test
  public final void testTotalBoxedLongBoxedLongBoxedLongBoxedLongBoxedLongBoxedLongArray() {
    final Long[] numbers1 = convertToBoxed(NUMBERS1);
    final Long[] numbers2 = convertToBoxed(NUMBERS2);

    for (final Long n1 : numbers1) {
      for (final Long n2 : numbers2) {
        for (final Long n3 : numbers1) {
          for (final Long n4 : numbers2) {
            for (final Long n5 : numbers1) {
              @SuppressWarnings("boxing")
              long total1 = n1 + n2 + n3 + n4 + n5;
              for (final Long n : numbers1) total1 += n.longValue();

              @SuppressWarnings("boxing")
              final Long expected1 = total1;
              @SuppressWarnings("boxing")
              final Long actual1 = total(n1, n2, n3, n4, n5, numbers1);
              // System.out.println("expected: " + expected1 + "\nactual:   " + actual1);
              assertThat(actual1, is(equalTo(expected1)));

              @SuppressWarnings("boxing")
              long total2 = n1 + n2 + n3 + n4 + n5;
              for (final Long n : numbers2) total2 += n.longValue();

              @SuppressWarnings("boxing")
              final Long expected2 = total2;
              @SuppressWarnings("boxing")
              final Long actual2 = total(n1, n2, n3, n4, n5, numbers2);
              // System.out.println("expected: " + expected2 + "\nactual:   " + actual2);
              assertThat(actual2, is(equalTo(expected2)));
            }
          }
        }
      }
    }

    final Long[] numbers3 = new Long[NUMBERS3.length];
    System.arraycopy(convertToBoxed(NUMBERS3), 0, numbers3, 0, NUMBERS3.length);
    final Long[] numbers4 = new Long[NUMBERS4.length];
    System.arraycopy(convertToBoxed(NUMBERS4), 0, numbers4, 0, NUMBERS4.length);

    for (final Long n1 : numbers3) {
      for (final Long n2 : numbers4) {
        for (final Long n3 : numbers3) {
          for (final Long n4 : numbers4) {
            for (final Long n5 : numbers3) {
              @SuppressWarnings("boxing")
              long total3 = n1 + n2 + n3 + n4 + n5;
              for (final Long n : numbers3) total3 += n.longValue();

              @SuppressWarnings("boxing")
              final Long expected3 = total3;
              @SuppressWarnings("boxing")
              final Long actual3 = total(n1, n2, n3, n4, n5, numbers3);
              // System.out.println("expected: " + expected3 + "\nactual:   " + actual3);
              assertThat(actual3, is(equalTo(expected3)));

              @SuppressWarnings("boxing")
              long total4 = n1 + n2 + n3 + n4 + n5;
              for (final Long n : numbers4) total4 += n.longValue();

              @SuppressWarnings("boxing")
              final Long expected4 = total4;
              @SuppressWarnings("boxing")
              final Long actual4 = total(n1, n2, n3, n4, n5, numbers4);
              // System.out.println("expected: " + expected4 + "\nactual:   " + actual4);
              assertThat(actual4, is(equalTo(expected4)));
            }
          }
        }
      }
    }
  }