コード例 #1
1
  @Test
  public void testReadBandRasterData() {
    Date startDate = Calendar.getInstance().getTime();
    // Product product = new Product("name", "desc", 100, 200);
    File file =
        TestUtil.getTestFile(
            productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP");
    // File rasterFile = TestUtil.getTestFile(productsFolder + "mediumImage.tif");
    System.setProperty("snap.dataio.reader.tileWidth", "100");
    System.setProperty("snap.dataio.reader.tileHeight", "200");
    try {

      Product finalProduct = reader.readProductNodes(file, null);
      ProductData data = ProductData.createInstance(ProductData.TYPE_UINT16, 20000);
      data.setElemFloatAt(3, 5);
      reader.readBandRasterData(
          finalProduct.getBandAt(0), 2000, 2000, 100, 200, data, new NullProgressMonitor());
      assertNotEquals(0, data.getElemFloatAt(0));
      assertNotEquals(-1000, data.getElemFloatAt(0));
      assertNotEquals(0, data.getElemFloatAt(1999));
      assertNotEquals(-1000, data.getElemFloatAt(1999));
      assertNotEquals(5, data.getElemFloatAt(3));
      Date endDate = Calendar.getInstance().getTime();
      assertTrue(
          "The load time for the product is too big!",
          (endDate.getTime() - startDate.getTime()) / (60 * 1000) < 30);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(e.getMessage(), false);
    }
  }
  @Test
  public void testTwoContextsSameClass() throws Exception {
    GenericApplicationContext context = new GenericApplicationContext();
    context.registerBeanDefinition(
        "bfpp", new RootBeanDefinition(DefaultConfiguringBeanFactoryPostProcessor.class));
    context.registerBeanDefinition("foo", new RootBeanDefinition(MyIdGenerator.class));
    context.refresh();
    MessageHeaders headers = new MessageHeaders(null);
    assertEquals(1, headers.getId().getMostSignificantBits());
    assertEquals(2, headers.getId().getLeastSignificantBits());

    GenericApplicationContext context2 = new GenericApplicationContext();
    context2.registerBeanDefinition(
        "bfpp", new RootBeanDefinition(DefaultConfiguringBeanFactoryPostProcessor.class));
    context2.registerBeanDefinition("foo", new RootBeanDefinition(MyIdGenerator.class));
    context2.refresh();

    context.close();
    context2.close();

    headers = new MessageHeaders(null);
    assertNotEquals(1, headers.getId().getMostSignificantBits());
    assertNotEquals(2, headers.getId().getLeastSignificantBits());

    assertNull(TestUtils.getPropertyValue(headers, "idGenerator"));
  }
コード例 #3
0
  @Test
  public void testGetVersionedCacheEntry() {

    VersionedValue value = remoteCache.getVersioned("aKey");
    assertNull("expected null but received: " + value, remoteCache.getVersioned("aKey"));

    remoteCache.put("aKey", "aValue");
    assertEquals("aValue", remoteCache.get("aKey"));
    VersionedValue valueBinary = remoteCache.getVersioned("aKey");
    assertNotNull(valueBinary);
    assertEquals(valueBinary.getValue(), "aValue");

    // now put the same value
    remoteCache.put("aKey", "aValue");
    VersionedValue entry2 = remoteCache.getVersioned("aKey");
    assertEquals(entry2.getValue(), "aValue");

    assertNotEquals(entry2.getVersion(), valueBinary.getVersion());
    assertNotEquals(valueBinary, entry2);

    // now put a different value
    remoteCache.put("aKey", "anotherValue");
    VersionedValue entry3 = remoteCache.getVersioned("aKey");
    assertEquals(entry3.getValue(), "anotherValue");
    assertNotEquals(entry3.getVersion(), entry2.getVersion());
    assertNotEquals(entry3, entry2);
  }
コード例 #4
0
  @Test
  public void testEquality() {
    ProtoEnumSoyType a = ProtoEnumSoyType.get(TestProto.Color.getDescriptor());
    ProtoEnumSoyType b = ProtoEnumSoyType.get(TestProto.Color.getDescriptor());

    assertEquals(a, a);
    assertEquals(a.hashCode(), a.hashCode());

    assertEquals(a, b);
    assertEquals(b, a);
    assertEquals(a.hashCode(), b.hashCode());

    ProtoEnumSoyType c = ProtoEnumSoyType.get(TestProto.Fruit.getDescriptor());
    assertNotEquals(a, c);
    assertNotEquals(c, a);

    ProtoEnumSoyType d =
        ProtoEnumSoyType.get(
            TestProto.Order.getDescriptor().findFieldByName("color").getEnumType());
    assertEquals(a, d);
    assertEquals(d, a);
    assertEquals(a.hashCode(), d.hashCode());

    ProtoEnumSoyType e =
        ProtoEnumSoyType.get(
            TestProto.Order.getDescriptor().findFieldByName("fruit").getEnumType());
    assertEquals(c, e);
    assertEquals(e, c);
    assertEquals(c.hashCode(), e.hashCode());
    assertNotEquals(a, e);
  }
コード例 #5
0
ファイル: TestTxnLib.java プロジェクト: anukat2015/mantis
  @Test
  public void libTxn_4() {
    long v1 = counter1.value();
    long v2 = counter2.value();
    assertEquals(0, v1);
    assertEquals(0, v2);

    // Txn.executeWrite(unit, () -> {

    unit.begin(ReadWrite.WRITE);

    counter1.inc();
    counter2.inc();
    assertEquals("Counter out of step", counter1.get(), counter2.get());
    assertNotEquals("Counter 1 can see wrong state", counter1.get(), counter1.value());
    assertNotEquals("Counter 2 can see wrong state", counter2.get(), counter2.value());
    counter2.inc();
    assertNotEquals("Counter 1 and 2 shoudl differ", counter1.get(), counter2.get());
    unit.commit();
    unit.end();
    // }) ;
    assertEquals("Component 1 inconsistent", 1, counter1.value());
    assertEquals("Component 2 inconsistent", 2, counter2.value());

    Txn.executeRead(
        unit,
        () -> {
          assertEquals("Component 1 inconsistent (R)", 1, counter1.get());
          assertEquals("Component 2 inconsistent (R)", 2, counter2.get());
        });
  }
コード例 #6
0
ファイル: RuleKeyTest.java プロジェクト: JoeHorn/buck
  @Test
  public void setInputPathSourcePath() {
    ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

    SourcePathResolver resolver =
        new SourcePathResolver(
            new BuildRuleResolver(TargetGraph.EMPTY, new BuildTargetNodeToBuildRuleTransformer()));
    // Changing the name of a named source path should change the hash...
    assertNotEquals(
        createEmptyRuleKey(resolver)
            .setReflectively("key", new PathSourcePath(projectFilesystem, Paths.get("something")))
            .build(),
        createEmptyRuleKey(resolver)
            .setReflectively(
                "key", new PathSourcePath(projectFilesystem, Paths.get("something", "else")))
            .build());

    // ... as should changing the key
    assertNotEquals(
        createEmptyRuleKey(resolver)
            .setReflectively("key", new PathSourcePath(projectFilesystem, Paths.get("something")))
            .build(),
        createEmptyRuleKey(resolver)
            .setReflectively(
                "different-key", new PathSourcePath(projectFilesystem, Paths.get("something")))
            .build());
  }
コード例 #7
0
  @Test
  public void testChangeRole() throws Exception {
    Role startingRole = humanCharacter.getRole();

    int startingHealth = humanCharacter.getHealth();
    int startingDamage = humanCharacter.getDamage();
    int startingSpeed = humanCharacter.getSpeed();
    int startingFireRate = humanCharacter.getFireRate();

    Role newRole = new Sniper();

    humanCharacter.changeRole(newRole);

    assertNotEquals("the role has not changed", startingRole, humanCharacter.getRole());
    assertEquals("the new role is not the one that was set", newRole, humanCharacter.getRole());

    assertNotEquals(
        "the health has not changed after switching role",
        startingHealth,
        humanCharacter.getHealth());
    assertNotEquals(
        "the damage has not changed after switching role",
        startingDamage,
        humanCharacter.getDamage());
    assertNotEquals(
        "the speed has not changed after switching role", startingSpeed, humanCharacter.getSpeed());
    assertNotEquals(
        "the fire-rate has not changed after switching role",
        startingFireRate,
        humanCharacter.getFireRate());
  }
コード例 #8
0
ファイル: BitsTypeTest.java プロジェクト: xieboxin/yangtools
  @Test
  public void canCreateBitsType() {
    MockitoAnnotations.initMocks(this);

    QName qName = QName.create("TestQName");
    SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);
    List<BitsTypeDefinition.Bit> listBit = Collections.singletonList(bit);
    BitsType bitsType = BitsType.create(schemaPath, listBit);

    assertNotEquals("Description is not null", null, bitsType.getDescription());
    assertEquals("QName", BaseTypes.BITS_QNAME, bitsType.getQName());
    assertEquals("Should be empty string", "", bitsType.getUnits());
    assertNotEquals("Description should not be null", null, bitsType.toString());
    assertNotEquals("Reference is not null", null, bitsType.getReference());
    assertEquals("BaseType should be null", null, bitsType.getBaseType());
    assertEquals("Default value should be null", null, bitsType.getDefaultValue());
    assertEquals("getPath should equal schemaPath", schemaPath, bitsType.getPath());
    assertEquals("Status should be CURRENT", Status.CURRENT, bitsType.getStatus());
    assertEquals("Should be empty list", Collections.EMPTY_LIST, bitsType.getUnknownSchemaNodes());
    assertEquals("Values should be [enumPair]", listBit, bitsType.getBits());

    assertEquals("Hash code of bitsType should be equal", bitsType.hashCode(), bitsType.hashCode());
    assertNotEquals("bitsType shouldn't equal to null", null, bitsType);
    assertEquals("bitsType should equals to itself", bitsType, bitsType);
    assertNotEquals("bitsType shouldn't equal to object of other type", "str", bitsType);
  }
コード例 #9
0
  // Test initial AUDIT process with pending group requests
  private void testInitialAuditWithPendingGroupRequests(DeviceId deviceId) {
    PortNumber[] ports1 = {PortNumber.portNumber(31), PortNumber.portNumber(32)};
    PortNumber[] ports2 = {PortNumber.portNumber(41), PortNumber.portNumber(42)};
    GroupId gId1 = new DefaultGroupId(1);
    Group group1 = createSouthboundGroupEntry(gId1, Arrays.asList(ports1), 0, deviceId);
    GroupId gId2 = new DefaultGroupId(2);
    // Non zero reference count will make the group manager to queue
    // the extraneous groups until reference count is zero.
    Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 2, deviceId);
    List<Group> groupEntries = Arrays.asList(group1, group2);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    // First group metrics would trigger the device audit completion
    // post which all pending group requests are also executed.
    GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
    Group createdGroup = groupService.getGroup(deviceId, key);
    int createdGroupId = createdGroup.id().id();
    assertNotEquals(gId1.id(), createdGroupId);
    assertNotEquals(gId2.id(), createdGroupId);

    List<GroupOperation> expectedGroupOps =
        Arrays.asList(
            GroupOperation.createDeleteGroupOperation(gId1, Group.Type.SELECT),
            GroupOperation.createAddGroupOperation(
                createdGroup.id(), Group.Type.SELECT, createdGroup.buckets()));
    if (deviceId.equals(DID)) {
      internalProvider.validate(deviceId, expectedGroupOps);
    } else {
      this.validate(deviceId, expectedGroupOps);
    }
  }
コード例 #10
0
 @Test
 public void testAddProduct() throws Exception {
   ProductBagApi bags = new ProductBagApi(new MockContext());
   String bagString = bags.toString();
   // make sure error conditions don't mutate the bags
   boolean result =
       bags.addProduct(null, new Product.Builder("product name", "product sku", 1).build());
   assertFalse(result);
   assertEquals(bagString, bags.toString());
   assertEquals(0, bags.getBags().size());
   result = bags.addProduct("bag name", null);
   // add an empty bag
   assertTrue(result);
   assertNotEquals(bagString, bags.toString());
   assertEquals(1, bags.getBags().size());
   // now test a simple add of a bag that doesn't exist
   result =
       bags.addProduct(
           "some bag name", new Product.Builder("product name", "product sku", 1).build());
   assertTrue(result);
   assertEquals(2, bags.getBags().size());
   assertEquals("some bag name", bags.findBag("some bag name").getName());
   assertNotEquals(bagString, bags.toString());
   bagString = bags.toString();
   // adding with an existing bag shouldn't create a whole new bag
   bags.addProduct(
       "some bag name", new Product.Builder("product name 2", "product sku 2", 1).build());
   assertEquals(2, bags.getBags().size());
   assertEquals("product name 2", bags.getBags().get(1).getProducts().get(1).getName());
   assertNotEquals(bagString, bags.toString());
 }
コード例 #11
0
  @Test
  public void testEquals() throws Exception {
    SparseBinaryFeatureVector featureVectorA = new SparseBinaryFeatureVector();

    featureVectorA.activateFeature(6);
    featureVectorA.activateFeature(3);
    featureVectorA.activateFeature(10);
    featureVectorA.activateFeature(0);

    SparseBinaryFeatureVector featureVectorB = new SparseBinaryFeatureVector();

    featureVectorB.activateFeature(4);
    featureVectorB.activateFeature(3);
    featureVectorB.activateFeature(10);
    featureVectorB.activateFeature(0);

    SparseBinaryFeatureVector featureVectorC = new SparseBinaryFeatureVector();

    featureVectorC.activateFeature(0);
    featureVectorC.activateFeature(3);
    featureVectorC.activateFeature(10);
    featureVectorC.activateFeature(6);

    Assert.assertNotEquals(featureVectorA, featureVectorB);
    Assert.assertNotEquals(featureVectorA, null);
    Assert.assertEquals(featureVectorA, featureVectorC);
  }
コード例 #12
0
  @Test
  public void testPoint() {
    ValuePointColored p1 = ValuePointColored.at(Point.at(10.0), 1.0, true);
    ValuePointColored p2 = ValuePointColored.at(Point.at(10.0), 1.0, true);

    ValuePointColored p3 = ValuePointColored.at(Point.at(13.0), 1.0, true);
    ValuePointColored p4 = ValuePointColored.at(Point.at(10.0), 2.0, false);

    assertTrue(p1.equals(p2));
    assertEquals(p1.hashCode(), p2.hashCode());

    assertFalse(p1.equals(p3));
    assertNotEquals(p3.hashCode(), p2.hashCode());

    assertFalse(p1.equals(p4));
    assertNotEquals(p4.hashCode(), p2.hashCode());

    assertTrue(p1.toString().contains("1.0@"));

    assertEquals(1, p1.getValue(), 0.000001);
    assertEquals(Point.at(10.0), p1.getPoint());

    assertTrue(p1.getBest());
    assertFalse(p4.getBest());

    assertTrue(p4.compareTo(ValuePoint.at(Point.at(13.0), 1.0)) > 0);
    assertTrue(p3.compareTo(ValuePoint.at(Point.at(10.0), 2.0)) < 0);
    assertTrue(
        ValuePointColored.at(Point.at(19.0), 2.0, true)
                .compareTo(ValuePoint.at(Point.at(10.0), 2.0))
            == 0);
  }
コード例 #13
0
  @Test
  public void canCreateEnumerationType() {
    MockitoAnnotations.initMocks(this);

    QName qName = QName.create("TestQName");
    SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(qName), true);

    List<EnumTypeDefinition.EnumPair> listEnumPair = Collections.singletonList(enumPair);
    Optional<EnumTypeDefinition.EnumPair> defaultValue = Optional.of(enumPair);

    EnumerationType enumerationType =
        EnumerationType.create(schemaPath, listEnumPair, defaultValue);

    assertNotEquals("Description is not null", null, enumerationType.getDescription());
    assertEquals("QName", BaseTypes.ENUMERATION_QNAME, enumerationType.getQName());
    assertEquals("Should be empty string", "", enumerationType.getUnits());
    assertNotEquals("Description should not be null", null, enumerationType.toString());
    assertNotEquals("Reference is not null", null, enumerationType.getReference());
    assertEquals("BaseType should be null", null, enumerationType.getBaseType());
    assertEquals("Default value should be enumPair", enumPair, enumerationType.getDefaultValue());
    assertEquals("getPath should equal schemaPath", schemaPath, enumerationType.getPath());
    assertEquals("Status should be CURRENT", Status.CURRENT, enumerationType.getStatus());
    assertEquals(
        "Should be empty list", Collections.EMPTY_LIST, enumerationType.getUnknownSchemaNodes());
    assertEquals("Values should be [enumPair]", listEnumPair, enumerationType.getValues());

    assertEquals(
        "Hash code of enumerationType should be equal",
        enumerationType.hashCode(),
        enumerationType.hashCode());
    assertNotEquals("EnumerationType shouldn't equal to null", null, enumerationType);
    assertEquals("EnumerationType should equals to itself", enumerationType, enumerationType);
    assertNotEquals(
        "EnumerationType shouldn't equal to object of other type", "str", enumerationType);
  }
コード例 #14
0
  @Test
  public void testEquals() {
    CompositeFastList<String> composite = new CompositeFastList<String>();
    MutableList<String> list = FastList.newList();

    Verify.assertEqualsAndHashCode(composite, list);

    MutableList<String> list2 = FastList.newListWith("one", "two", "three");

    CompositeFastList<String> composite2 = new CompositeFastList<String>();
    MutableList<String> firstBit = FastList.newListWith("one", "two");
    MutableList<String> secondBit = FastList.newListWith("three");
    composite2.addAll(firstBit);
    composite2.addAll(secondBit);

    Verify.assertEqualsAndHashCode(list2, composite2);

    Assert.assertNotEquals(firstBit, composite2);
    Assert.assertNotEquals(composite2, firstBit);

    MutableList<String> list1 = FastList.newListWith("one", null, "three");

    CompositeFastList<String> composite1 = new CompositeFastList<String>();
    MutableList<String> firstBit1 = FastList.newListWith("one", null);
    MutableList<String> secondBit1 = FastList.newListWith("three");
    composite1.addAll(firstBit1);
    composite1.addAll(secondBit1);

    Verify.assertEqualsAndHashCode(list1, composite1);
  }
コード例 #15
0
  @Test
  public void mapTargetAddressNew() {
    smg1.addValue(value1);
    smg1.addObject(obj1);
    smg1.addPointsToEdge(edge1);

    destSMG.addObject(destObj);

    mapping1.map(obj1, destObj);

    SMGNodeMapping origMapping1 = new SMGNodeMapping(mapping1);
    SMGNodeMapping origMapping2 = new SMGNodeMapping(mapping2);
    SMG origDestSMG = new SMG(destSMG);

    SMGJoinMapTargetAddress mta =
        new SMGJoinMapTargetAddress(smg1, null, destSMG, mapping1, mapping2, value1, value2);
    Assert.assertNotEquals(origDestSMG, mta.getSMG());
    Assert.assertNotEquals(origMapping1, mta.getMapping1());
    Assert.assertNotEquals(origMapping2, mta.getMapping2());

    Assert.assertFalse(origDestSMG.getValues().contains(mta.getValue()));

    SMGEdgePointsTo newEdge = destSMG.getPointer(mta.getValue());
    Assert.assertSame(destObj, newEdge.getObject());
    Assert.assertEquals(0, newEdge.getOffset());

    Assert.assertSame(mta.getValue(), mta.getMapping1().get(value1));
    Assert.assertSame(mta.getValue(), mta.getMapping2().get(value2));
  }
コード例 #16
0
  @Test
  public void testGetAllEdgesWithDelete() {
    graph = createGraph();
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 5);
    na.setNode(1, 1, 5);
    na.setNode(2, 2, 5);
    na.setNode(3, 3, 5);
    graph.edge(0, 1, 1, true);
    graph.edge(0, 2, 1, true);
    graph.edge(1, 2, 1, true);
    graph.edge(2, 3, 1, true);
    AllEdgesIterator iter = graph.getAllEdges();
    assertEquals(4, GHUtility.count(iter));
    assertEquals(4, iter.getMaxId());

    // delete
    graph.markNodeRemoved(1);
    graph.optimize();
    iter = graph.getAllEdges();
    assertEquals(2, GHUtility.count(iter));
    assertEquals(4, iter.getMaxId());

    iter = graph.getAllEdges();
    iter.next();
    EdgeIteratorState eState = iter.detach(false);
    assertEquals(iter.toString(), eState.toString());
    iter.next();
    assertNotEquals(iter.toString(), eState.toString());

    EdgeIteratorState eState2 = iter.detach(true);
    assertEquals(iter.getAdjNode(), eState2.getBaseNode());
    iter.next();
    assertNotEquals(iter.getAdjNode(), eState2.getBaseNode());
  }
コード例 #17
0
  @Test
  public void testCaptionChange() {
    selectMenuPath(EDIT_ROW_5);
    assertEquals(
        "Save button caption should've been \""
            + GridConstants.DEFAULT_SAVE_CAPTION
            + "\" to begin with",
        GridConstants.DEFAULT_SAVE_CAPTION,
        getSaveButton().getText());
    assertEquals(
        "Cancel button caption should've been \""
            + GridConstants.DEFAULT_CANCEL_CAPTION
            + "\" to begin with",
        GridConstants.DEFAULT_CANCEL_CAPTION,
        getCancelButton().getText());

    selectMenuPath("Component", "Editor", "Change Save Caption");
    assertNotEquals(
        "Save button caption should've changed while editor is open",
        GridConstants.DEFAULT_SAVE_CAPTION,
        getSaveButton().getText());

    getCancelButton().click();

    selectMenuPath("Component", "Editor", "Change Cancel Caption");
    selectMenuPath(EDIT_ROW_5);
    assertNotEquals(
        "Cancel button caption should've changed while editor is closed",
        GridConstants.DEFAULT_CANCEL_CAPTION,
        getCancelButton().getText());
  }
コード例 #18
0
  @Test
  public void roomReadyAndPlayerDontMove() throws JSONException {
    UserProfile profile = new UserProfile("aaaa", "bbbb");
    GameProfile gameProfile = profile.getGameProfile();
    final int defaultTestX = 500;
    gameProfile.setX(defaultTestX);
    final int defaultTestY = 500;
    gameProfile.setY(defaultTestY);
    gameProfile.setScore(1);
    Room room = mock(Room.class);

    doReturn(profile).when(gameServer).getPlayerBySession(anyString());
    doReturn(room).when(gameServer).getPlayerRoomBySession(anyString());
    when(room.isFinished()).thenReturn(false);

    JSONObject object = new JSONObject();

    object.put("direction", -1);
    moveActionStrategy.processGameAction(object, httpSession);

    assertEquals(gameProfile.getX(), defaultTestX, 0);

    object.put("direction", 100);
    moveActionStrategy.processGameAction(object, httpSession);
    moveActionStrategy.processGameAction(object, httpSession);

    assertNotEquals(gameProfile.getX(), 1.0d, 0d);
    assertNotEquals(gameProfile.getY(), 1.0d, 0d);
  }
コード例 #19
0
  @Test
  /**
   * Tests a master key which may sign, but is stripped. In this case, if there is a different
   * subkey available which can sign, that one should be selected.
   */
  public void testImportStrippedFlags() throws Exception {

    UncachedKeyRing key = readRingFromResource("/test-keys/stripped_flags.asc");
    long masterKeyId = key.getMasterKeyId();

    SaveKeyringResult result;

    result = mProviderHelper.saveSecretKeyRing(key, new ProgressScaler());
    Assert.assertTrue("import of keyring should succeed", result.success());

    long signId;
    {
      CanonicalizedSecretKeyRing ring = mProviderHelper.getCanonicalizedSecretKeyRing(masterKeyId);
      Assert.assertTrue("master key should have sign flag", ring.getPublicKey().canSign());
      Assert.assertTrue("master key should have encrypt flag", ring.getPublicKey().canEncrypt());

      signId = ring.getSecretSignId();
      Assert.assertNotEquals("encrypt id should not be 0", 0, signId);
      Assert.assertNotEquals(
          "encrypt key should be different from master key", masterKeyId, signId);
    }

    {
      CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
      Assert.assertEquals(
          "signing key should be same id cached as uncached", signId, ring.getSecretSignId());
    }
  }
コード例 #20
0
ファイル: ConditionalTest.java プロジェクト: ckaestne/VarexJ
 @Test
 public void testEquals() throws Exception {
   Conditional<Integer> v1 = Choice(fa, One(1), One(2));
   assertEquals(v1, Choice(fa, One(1), One(2)));
   assertNotEquals(Choice(fa, One(2), One(1)), v1);
   assertNotEquals(Choice(fb, One(1), One(2)), v1);
 }
コード例 #21
0
ファイル: ResItemTest.java プロジェクト: KamiSempai/LocaLaser
  @Test
  public void testMerge() throws Exception {
    ResValue value1 = new ResValue("value1", null, Quantity.OTHER);
    ResValue value2 = new ResValue("value2", "Comment", Quantity.FEW);
    ResValue value3 = new ResValue("value3", "Comment2", Quantity.ZERO);
    resItem.addValue(value1);
    resItem.addValue(value2);
    resItem.addValue(value3);

    ResItem resItem2 = new ResItem(resItem.key + "_"); // Merge should work independent from res key
    ResValue value4 = new ResValue("value4", null, Quantity.OTHER);
    ResValue value5 = new ResValue("value5", "Comment", Quantity.FEW);
    ResValue value6 = new ResValue("value6", "Comment2", Quantity.TWO);
    resItem2.addValue(value4);
    resItem2.addValue(value5);
    resItem2.addValue(value6);

    assert resItem.merge(resItem2) == resItem;

    assertEquals(4, resItem.values.size());
    assertNotEquals(value1, resItem.valueForQuantity(Quantity.OTHER));
    assertNotEquals(value2, resItem.valueForQuantity(Quantity.FEW));
    assertEquals(value3, resItem.valueForQuantity(Quantity.ZERO));
    assertEquals(value4, resItem.valueForQuantity(Quantity.OTHER));
    assertEquals(value5, resItem.valueForQuantity(Quantity.FEW));
    assertEquals(value6, resItem.valueForQuantity(Quantity.TWO));
  }
コード例 #22
0
  @Test
  public void testIsoMorphismTwoLibs() {

    IGraphNativeLibrary lib1 = new IGraphNativeLibrary();
    IGraphNativeLibrary lib2 = new IGraphNativeLibrary();

    IGraphGraph g1 = null;
    IGraphGraph g2 = null;

    try {

      g1 = lib1.generateWattsStrogatz(1000, 1, 0.0, 2, false, false);
      g2 = lib2.generateWattsStrogatz(1000, 1, 0.0, 2, false, false);

      assertNotEquals("objects are similar", g1, g2);
      assertNotEquals("objects are similar", g1.graphStruct, g2.graphStruct);

      boolean iso = lib1.computeIsomorphicm(g1, g2);
      assertTrue("graphs are not isomorphic", iso);

      boolean iso2 = lib2.computeIsomorphicm(g1, g2);
      assertTrue("graphs are not isomorphic", iso2);

    } finally {
      if (g1 != null) lib1.clearGraphMemory(g1);
      if (g2 != null) lib2.clearGraphMemory(g2);
    }
  }
コード例 #23
0
  @Test
  public <T> void test1_mockUpBaseTypeUsingTypeVariableWithDefaultBoundOfJavaLangObject() {
    new MockUp<T>() {
      @Mock
      public boolean equals(Object o) {
        return true;
      }

      @Mock
      public int hashCode() {
        return 1;
      }

      @Mock
      public String toString() {
        return "Mocked";
      }
    };

    Object obj1 = new StringBuilder("TEST");
    assertNotEquals(1, obj1.hashCode());
    assertFalse(obj1.equals("test"));
    assertNotEquals("Mocked", obj1.toString());

    Object obj2 = new ClassWithObjectOverrides();
    assertEquals("Mocked", obj2.toString());
    assertEquals(1, obj2.hashCode());
    //noinspection SimplifiableJUnitAssertion
    assertTrue(obj2.equals("test"));
  }
コード例 #24
0
ファイル: CardTest.java プロジェクト: Rostanxd/jpoker
 @Test
 public void testEqualsOtherObjects() {
   System.out.println("equalsOtherObjects");
   Card card = new Card(Card.Suit.CLUB, Card.Rank.ACE);
   assertNotEquals("card: " + card + " != null", card, null);
   assertNotEquals("card: " + card + " != 0", card, 0);
   assertNotEquals("card: " + card + " != \"2C\"", card, "2C");
 }
コード例 #25
0
  @Test
  public void testHashCode() {
    assertEquals(jobPartitionState.hashCode(), jobPartitionState.hashCode());
    assertEquals(jobPartitionState.hashCode(), jobPartitionStateSameAttributes.hashCode());

    assertNotEquals(jobPartitionState.hashCode(), jobPartitionStateOtherAddress.hashCode());
    assertNotEquals(jobPartitionState.hashCode(), jobPartitionStateOtherState.hashCode());
  }
コード例 #26
0
 // test pour le constructeur
 @Test
 public void testRobot() {
   RobotImpl rob = new RobotImpl("1 2 N", "LMLMLMLMM");
   assertEquals(1, rob.getActualX());
   RobotImpl rob1 = new RobotImpl("-1 -2 N", "LMLMLMLMM");
   assertNotEquals(-1, rob1.getActualX());
   assertNotEquals(-2, rob1.getActualY());
 }
コード例 #27
0
 @Test
 public void testHashCode() throws Exception {
   final MapLookupExtractor fn2 = new MapLookupExtractor(ImmutableMap.of("foo", "bar"));
   Assert.assertEquals(fn.hashCode(), fn2.hashCode());
   final MapLookupExtractor fn3 = new MapLookupExtractor(ImmutableMap.of("foo2", "bar"));
   Assert.assertNotEquals(fn.hashCode(), fn3.hashCode());
   final MapLookupExtractor fn4 = new MapLookupExtractor(ImmutableMap.of("foo", "bar2"));
   Assert.assertNotEquals(fn.hashCode(), fn4.hashCode());
 }
コード例 #28
0
 @Test
 public void equalsAndHashCode() {
   ImmutableBag<String> immutable = this.newBag();
   MutableBag<String> mutable = HashBag.newBag(immutable);
   Verify.assertEqualsAndHashCode(immutable, mutable);
   Assert.assertNotEquals(immutable, FastList.newList(mutable));
   Assert.assertEquals(this.newBag().toMapOfItemToCount().hashCode(), this.newBag().hashCode());
   Assert.assertNotEquals(immutable, mutable.with("5").without("1"));
 }
コード例 #29
0
ファイル: RecruiterTest.java プロジェクト: jbandyo/OC2
  @Test
  public void thereCanBeMoreThanOneJobseekersWithSameName() {
    Recruiter recruiter1 = Recruiter.named("George");
    Recruiter recruiter2 = Recruiter.named("George");
    Recruiter recruiter3 = Recruiter.named("George");

    Assert.assertNotEquals(recruiter1, recruiter2);
    Assert.assertNotEquals(recruiter1, recruiter3);
    Assert.assertNotEquals(recruiter2, recruiter3);
  }
コード例 #30
0
  @Test
  public void testDuplicateArchimateElements() {
    ArchimateTestModel tm = new ArchimateTestModel();
    IArchimateModel model = tm.createNewModel();
    IFolder folder = model.getFolder(FolderType.BUSINESS);

    IArchimateElement element1 =
        (IArchimateElement)
            tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    element1.setName("Actor 1");
    element1.setDocumentation("Doc 1");
    assertEquals(1, folder.getElements().size());
    assertSame(element1, folder.getElements().get(0));

    IArchimateElement element2 =
        (IArchimateElement)
            tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    element2.setName("Actor 2");
    element2.setDocumentation("Doc 2");
    assertEquals(2, folder.getElements().size());
    assertSame(element2, folder.getElements().get(1));

    IArchimateRelationship relation =
        (IArchimateRelationship)
            tm.createModelElementAndAddToModel(
                IArchimatePackage.eINSTANCE.getAssociationRelationship());
    relation.connect(element1, element2);
    assertTrue(element1.getSourceRelationships().contains(relation));
    assertTrue(element2.getTargetRelationships().contains(relation));

    DuplicateCommandHandler handler =
        new DuplicateCommandHandler(new Object[] {element1, element2});
    handler.duplicate();

    assertEquals(4, folder.getElements().size());
    assertSame(element1, folder.getElements().get(0));
    assertSame(element2, folder.getElements().get(1));

    IArchimateElement copy1 = (IArchimateElement) folder.getElements().get(2);
    assertNotSame(element1, copy1);
    assertNotEquals(element1.getId(), copy1.getId());
    assertEquals(element1.getName() + " (copy)", copy1.getName());
    assertEquals(element1.getDocumentation(), copy1.getDocumentation());

    IArchimateElement copy2 = (IArchimateElement) folder.getElements().get(3);
    assertNotSame(element2, copy2);
    assertNotEquals(element2.getId(), copy2.getId());
    assertEquals(element2.getName() + " (copy)", copy2.getName());
    assertEquals(element2.getDocumentation(), copy2.getDocumentation());

    assertTrue(copy1.getSourceRelationships().isEmpty());
    assertTrue(copy1.getTargetRelationships().isEmpty());
    assertTrue(copy2.getSourceRelationships().isEmpty());
    assertTrue(copy2.getTargetRelationships().isEmpty());
  }