@Test
 public void testJoin6() {
   Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
   Stamp alwaysNull = StampFactory.alwaysNull();
   Stamp join = join(alwaysNull, dExactNonNull);
   Assert.assertFalse(join.isLegal());
   Assert.assertFalse(StampTool.isPointerNonNull(join));
   Assert.assertFalse(StampTool.isPointerAlwaysNull(join));
 }
  @Test
  public void testRemove() {
    Assert.assertFalse(this.set.remove(this.k2));
    Assert.assertFalse(this.set.remove(this.keyE));

    addFromArray(this.set, this.key0, this.key1, this.key2, this.key3, this.key4);

    Assert.assertTrue(this.set.remove(this.k2));
    Assert.assertFalse(this.set.remove(this.k2));
    Assert.assertEquals(4, this.set.size());
    TestUtils.assertSortedListEquals(this.set.toArray(), 0, 1, 3, 4);
  }
  @Test
  public void listRequest() {
    JdbcContentPersistenceService tested = getTested();
    tested.LIST_PAGE_SIZE = 3;

    String sysContentType = "testtypelist";

    // case - no table exists for type
    {
      ListRequest req = tested.listRequestInit(sysContentType);
      Assert.assertFalse(req.hasContent());
    }

    // case - data handling test
    {

      // store in reverse order to see if listing uses correct ordering
      for (int i = 7; i >= 1; i--) addContent(tested, sysContentType, "aaa-" + i);

      ListRequest req = tested.listRequestInit(sysContentType);
      Assert.assertTrue(req.hasContent());
      Assert.assertNotNull(req.content());
      Assert.assertEquals(3, req.content().size());
      Assert.assertEquals("aaa-1", req.content().get(0).getId());
      // assert content is correctly loaded
      Assert.assertEquals(
          "aaa-1", req.content().get(0).getContent().get(ContentObjectFields.SYS_ID));
      Assert.assertEquals(
          "value aaa-1",
          req.content().get(0).getContent().get(ContentObjectFields.SYS_DESCRIPTION));
      // assert id only for others
      Assert.assertEquals("aaa-2", req.content().get(1).getId());
      Assert.assertEquals("aaa-3", req.content().get(2).getId());

      req = tested.listRequestNext(req);
      Assert.assertTrue(req.hasContent());
      Assert.assertNotNull(req.content());
      Assert.assertEquals(3, req.content().size());
      Assert.assertEquals("aaa-4", req.content().get(0).getId());
      Assert.assertEquals("aaa-5", req.content().get(1).getId());
      Assert.assertEquals("aaa-6", req.content().get(2).getId());

      req = tested.listRequestNext(req);
      Assert.assertTrue(req.hasContent());
      Assert.assertNotNull(req.content());
      Assert.assertEquals(1, req.content().size());
      Assert.assertEquals("aaa-7", req.content().get(0).getId());

      req = tested.listRequestNext(req);
      Assert.assertFalse(req.hasContent());
    }
  }
  @Test
  public void testConstructors() {
    VariableStatistics vs1 = new VariableStatistics();
    Assert.assertEquals(vs1.getCount(), 0);
    Assert.assertEquals(vs1.getSum(), 0, TOLERANCE);
    Assert.assertEquals(vs1.getSumSquares(), 0, TOLERANCE);

    VariableStatistics set1 = getVS1();
    VariableStatistics set2 = getVS1();
    Assert.assertTrue(set1.equivalent(set2));
    Assert.assertFalse(set1.equivalent(vs1));

    Assert.assertEquals(set1.getCount(), DATA_SET_SIZE);
    Assert.assertEquals(set1.getSum(), 30, TOLERANCE);
    Assert.assertEquals(set1.getSumSquares(), 166, TOLERANCE);
    Assert.assertEquals(set1.getMean(), 5, TOLERANCE);
    double stdev = set1.getStandardDeviation();
    Assert.assertEquals(stdev, 1.63299, TOLERANCE);

    set2 = getVS2();
    Assert.assertEquals(set2.getCount(), DATA_SET_SIZE);
    Assert.assertEquals(set2.getSum(), 30, TOLERANCE);
    Assert.assertEquals(set2.getSumSquares(), 216, TOLERANCE);
    Assert.assertEquals(set2.getMean(), 5, TOLERANCE);
    stdev = set2.getStandardDeviation();
    Assert.assertEquals(stdev, 3.3166, TOLERANCE);
  }
 @Test
 public void testJoin8() {
   Stamp bExact = StampFactory.exactNonNull(getType(B.class));
   Stamp dExact = StampFactory.exact(getType(D.class));
   Stamp join = join(bExact, dExact);
   Assert.assertFalse(join.isLegal());
 }
  @Test
  public void testAdd() {
    Assert.assertTrue(this.set.add(this.key1));
    Assert.assertFalse(this.set.add(this.key1));
    Assert.assertEquals(1, this.set.size());

    Assert.assertTrue(this.set.add(this.keyE));
    Assert.assertFalse(this.set.add(this.keyE));

    Assert.assertEquals(2, this.set.size());

    Assert.assertTrue(this.set.add(this.key2));
    Assert.assertFalse(this.set.add(this.key2));

    Assert.assertEquals(3, this.set.size());
  }
  @Test
  public void testIterable2() {
    addFromArray(this.set, this.keyE, this.key1, this.key2, this.key2, this.key3, this.key4);
    this.set.remove(this.k2);
    Assert.assertEquals(4, this.set.size());

    int counted = 0;
    for (final KTypeCursor<KType> cursor : this.set) {
      if (cursor.index == getKeys(this.set).length) {

        Assert.assertTrue(this.isAllocatedDefaultKey(this.set));
        TestUtils.assertEquals2(this.keyE, cursor.value);
        counted++;
        continue;
      }

      Assert.assertTrue(this.set.contains(cursor.value));
      TestUtils.assertEquals2(cursor.value, this.getKeys(this.set)[cursor.index]);
      counted++;
    }
    Assert.assertEquals(counted, this.set.size());

    this.set.clear();
    Assert.assertFalse(this.set.iterator().hasNext());
  }
Esempio n. 8
0
 public void assertFalse(boolean b) {
   try {
     Assert.assertFalse(b);
   } catch (Error e) {
     lastTestFailed = true;
     throw e;
   }
 }
  @Test
  public void simulateClusterTableCreation() {
    JdbcContentPersistenceService tested = getTested();

    Assert.assertFalse(tested.checkTableExists("table1"));
    createTable("TABLE1");
    Assert.assertTrue(tested.checkTableExists("table1"));
  }
 @Test
 public void testJoin7() {
   Stamp aExact = StampFactory.exact(getType(A.class));
   Stamp e = StampFactory.declared(getType(E.class));
   Stamp join = join(aExact, e);
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
   Assert.assertFalse(StampTool.isExactType(join));
 }
 @Test
 public void testJoin5() {
   Stamp dExact = StampFactory.exact(getType(D.class));
   Stamp c = StampFactory.declared(getType(C.class));
   Stamp join = join(c, dExact);
   Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
   Assert.assertNull(StampTool.typeOrNull(join));
   Assert.assertFalse(StampTool.isExactType(join));
 }
Esempio n. 12
0
 @Test
 public void testNullKey() {
   this.set.add((KType) null);
   Assert.assertEquals(1, this.set.size());
   Assert.assertTrue(this.set.contains(null));
   Assert.assertTrue(this.set.remove(null));
   Assert.assertEquals(0, this.set.size());
   Assert.assertFalse(this.set.contains(null));
 }
  @Test
  public void checkAndEnsureTableExists() {
    JdbcContentPersistenceService tested = getTested();

    Assert.assertFalse(tested.checkTableExists("table1"));
    Assert.assertFalse(tested.checkTableExists("table1"));

    tested.ensureTableExists("table1");
    Assert.assertTrue(tested.checkTableExists("table1"));

    tested.ensureTableExists("table1");
    Assert.assertTrue(tested.checkTableExists("table1"));
    Assert.assertTrue(tested.checkTableExists("table1"));

    Assert.assertFalse(tested.checkTableExists("table_2"));
    tested.ensureTableExists("table_2");
    Assert.assertTrue(tested.checkTableExists("table_2"));
    Assert.assertTrue(tested.checkTableExists("table1"));
  }
Esempio n. 14
0
  @Test
  public void testAtomicCommitMissingFinal() {
    TaskAttemptContext taskAttemptContext = getTaskAttemptContext(config);
    JobContext jobContext =
        new JobContextImpl(
            taskAttemptContext.getConfiguration(),
            taskAttemptContext.getTaskAttemptID().getJobID());
    Configuration conf = jobContext.getConfiguration();

    String workPath = "/tmp1/" + String.valueOf(rand.nextLong());
    String finalPath = "/tmp1/" + String.valueOf(rand.nextLong());
    FileSystem fs = null;
    try {
      OutputCommitter committer = new CopyCommitter(null, taskAttemptContext);
      fs = FileSystem.get(conf);
      fs.mkdirs(new Path(workPath));

      conf.set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, workPath);
      conf.set(DistCpConstants.CONF_LABEL_TARGET_FINAL_PATH, finalPath);
      conf.setBoolean(DistCpConstants.CONF_LABEL_ATOMIC_COPY, true);

      Assert.assertTrue(fs.exists(new Path(workPath)));
      Assert.assertFalse(fs.exists(new Path(finalPath)));
      committer.commitJob(jobContext);
      Assert.assertFalse(fs.exists(new Path(workPath)));
      Assert.assertTrue(fs.exists(new Path(finalPath)));

      // Test for idempotent commit
      committer.commitJob(jobContext);
      Assert.assertFalse(fs.exists(new Path(workPath)));
      Assert.assertTrue(fs.exists(new Path(finalPath)));

    } catch (IOException e) {
      LOG.error("Exception encountered while testing for preserve status", e);
      Assert.fail("Atomic commit failure");
    } finally {
      TestDistCpUtils.delete(fs, workPath);
      TestDistCpUtils.delete(fs, finalPath);
    }
  }
  public void testBasic() throws Exception {
    HashSet<ObjectID> hashSet = new HashSet<ObjectID>();
    StripedObjectIDSet stripedObjectIdSet = new StripedObjectIDSet();

    // test ADD
    for (int i = -100; i < 100; i++) {
      Assert.assertTrue(hashSet.add(new ObjectID(i)));
      Assert.assertTrue(stripedObjectIdSet.add(new ObjectID(i)));
    }
    Assert.assertTrue(checkSame(stripedObjectIdSet, hashSet));

    // test contains
    for (int i = -100; i < 100; i++) {
      Assert.assertTrue(stripedObjectIdSet.contains(new ObjectID(i)));
    }

    // test contains All
    Assert.assertTrue(stripedObjectIdSet.containsAll(hashSet));

    // test size
    Assert.assertEquals(200, stripedObjectIdSet.size());

    for (int i = -100; i < 0; i++) {
      hashSet.remove(new ObjectID(i));
    }

    // test RetainAll
    Assert.assertTrue(stripedObjectIdSet.retainAll(hashSet));
    Assert.assertEquals(100, stripedObjectIdSet.size());

    // test remove
    Assert.assertTrue(stripedObjectIdSet.remove(new ObjectID(0)));
    Assert.assertFalse(stripedObjectIdSet.remove(new ObjectID(-1)));

    stripedObjectIdSet.add(new ObjectID(0));

    // test removeAll
    Assert.assertTrue(stripedObjectIdSet.removeAll(hashSet));
    Assert.assertEquals(0, stripedObjectIdSet.size());

    // test clear
    for (int i = -100; i < 100; i++) {
      Assert.assertTrue(stripedObjectIdSet.add(new ObjectID(i)));
    }
    Assert.assertEquals(200, stripedObjectIdSet.size());
    stripedObjectIdSet.clear();
    Assert.assertEquals(0, stripedObjectIdSet.size());
  }
 @Test
 public void testEncodedMemoryCacheGetSuccessful() {
   setupEncodedMemoryCacheGetSuccess();
   when(mProducerContext.getLowestPermittedRequestLevel())
       .thenReturn(ImageRequest.RequestLevel.ENCODED_MEMORY_CACHE);
   mEncodedMemoryCacheProducer.produceResults(mConsumer, mProducerContext);
   ArgumentCaptor<EncodedImage> argumentCaptor = ArgumentCaptor.forClass(EncodedImage.class);
   verify(mConsumer).onNewResult(argumentCaptor.capture(), eq(true));
   EncodedImage encodedImage = argumentCaptor.getValue();
   Assert.assertSame(
       mFinalEncodedImage.getUnderlyingReferenceTestOnly(),
       encodedImage.getUnderlyingReferenceTestOnly());
   verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
   Map<String, String> extraMap = ImmutableMap.of(EncodedMemoryCacheProducer.VALUE_FOUND, "true");
   verify(mProducerListener).onProducerFinishWithSuccess(mRequestId, PRODUCER_NAME, extraMap);
   Assert.assertFalse(mFinalImageReference.isValid());
 }
Esempio n. 17
0
 @Test
 public void testSessionIsNotExpired() {
   Assert.assertFalse(session.isExpired());
 }
Esempio n. 18
0
  @Test
  /*! #if ($TemplateOptions.KTypeGeneric) !*/
  @SuppressWarnings("unchecked")
  /*! #end !*/
  public void testEquals() {
    final KTypeSet<KType> l0 = getFrom();
    Assert.assertEquals(l0, createNewSetInstance());

    KTypeSet<KType> l1 = getFrom(this.k1, this.k2, this.k3, this.k4, this.k5);
    KTypeSet<KType> l2 = getFrom(this.k2, this.k1);

    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    Assert.assertFalse(l1.equals(null));
    Assert.assertFalse(l2.equals(null));

    l2.add(this.k5);
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l2.add(this.k4);
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l2.add(this.k3);
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    l1.add(this.keyE);
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l2.add(this.keyE);

    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    l2.remove(this.keyE);

    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l2.add(this.keyE);

    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    l2.remove(this.k7); // not present, sets are still OK
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    l2.remove(this.k2);

    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l1.remove(this.k2);
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    l1.add(this.k7);
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l2.clear();
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);

    l1.clear();
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l2, l1);
    // Check consistency with hashCode:
    Assert.assertEquals(l1.hashCode(), l2.hashCode());

    // Same size, different contents
    l1 = getFrom(this.k1, this.k2, this.k3, this.k4, this.k5);
    l2 = getFrom(this.k2, this.k1, this.key5, this.key6, this.key7);

    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l2, l1);
  }
 @Test
 public void exampleAssertFalse() {
   Assert.assertFalse(
       "Person One's age should not be equal to the specified value", getPersonOneAge() == 13);
 }