Java Code Examples for org.testng.Assert#assertNotSame()

The following examples show how to use org.testng.Assert#assertNotSame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReturnRequestStatusTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private void deleteEmployeeById(String employeeNumber) throws AxisFault {
    OMElement result;
    OMElement payload = fac.createOMElement("deleteEmployeeById", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    result = new AxisServiceClient().sendReceive(payload, serviceEndPoint, "deleteEmployeeById");

    Assert.assertTrue(result.toString().contains("SUCCESSFUL"), "Response Not Successful");
    OMNamespace nameSpace = result.getNamespace();
    Assert.assertNotNull(nameSpace.getPrefix(), "Invalid prefix. prefix value null");
    Assert.assertNotSame(nameSpace.getPrefix(), "", "Invalid prefix");
    Assert.assertEquals(nameSpace.getNamespaceURI(), "http://ws.wso2.org/dataservice", "Invalid NamespaceURI");
}
 
Example 2
Source File: TrackSegmentTest.java    From jpx with Apache License 2.0 6 votes vote down vote up
@Test
public void toBuilder() {
	final TrackSegment object = TrackSegment.of(
		IntStream.range(0, 25)
			.mapToObj(i -> WayPoint.builder().build(i, i))
			.collect(Collectors.toList())
	);

	Assert.assertEquals(
		object.toBuilder().build(),
		object
	);
	Assert.assertNotSame(
		object.toBuilder().build(),
		object
	);
}
 
Example 3
Source File: SortingTests.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Test()
public void testSortRowsAndColumns1() throws Exception {
    final DataFrame<LocalDate,String> frame = TestDataFrames.getQuotes("blk");
    final DataFrame<LocalDate,String> sorted = frame.copy();
    sorted.rows().sort(false, "Close");
    sorted.cols().sort((col0, col1) -> col0.key().compareTo(col1.key()));
    for (int i=0; i<frame.rowCount(); ++i) {
        for (int j = 0; j<frame.colCount(); ++j) {
            final LocalDate date = frame.rows().key(i);
            final String column = frame.cols().key(j);
            final Object left = frame.data().getValue(date, column);
            final Object right = sorted.data().getValue(date, column);
            Assert.assertEquals(left, right, "Values equal at (" + date + "," + column + ")");
            Assert.assertNotSame(sorted.data().getValue(i,j), frame.data().getValue(i,j));
        }
    }
}
 
Example 4
Source File: TestZkBaseDataAccessor.java    From helix with Apache License 2.0 6 votes vote down vote up
@Test
public void testSyncGetStat() {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String testName = className + "_" + methodName;

  System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));

  String path = String.format("/%s/%s", _rootPath, "msg_0");
  ZNRecord record = new ZNRecord("msg_0");
  ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);

  Stat stat = accessor.getStat(path, 0);
  Assert.assertNull(stat);

  boolean success = accessor.create(path, record, AccessOption.EPHEMERAL);
  Assert.assertTrue(success);

  stat = accessor.getStat(path, 0);
  Assert.assertNotNull(stat);
  Assert.assertEquals(stat.getVersion(), 0);
  Assert.assertNotSame(stat.getEphemeralOwner(), 0);

  System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));

}
 
Example 5
Source File: DataLineUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "tableColumnsData")
public void testToArray(final TableColumnCollection columns) {
    final DataLine subject = new DataLine(columns, IllegalArgumentException::new);
    final String[] array = subject.toArray();
    for (int i = 0; i < columns.columnCount(); i++) {
        Assert.assertNull(array[i]);
    }
    Assert.assertNotSame(subject.toArray(), subject.toArray());
}
 
Example 6
Source File: DefaultMappingTest.java    From scheduler with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testClone"})
public void testEquals() {
    Mapping c1 = new DefaultMapping();

    c1.addOnlineNode(ns.get(0));
    c1.addOnlineNode(ns.get(1));
    c1.addOfflineNode(ns.get(2));
    c1.addReadyVM(vms.get(0));
    c1.addRunningVM(vms.get(1), ns.get(0));
    c1.addSleepingVM(vms.get(2), ns.get(0));
    c1.addRunningVM(vms.get(3), ns.get(1));
    c1.addRunningVM(vms.get(4), ns.get(1));

    Mapping c2 = c1.copy();

    Assert.assertEquals(c1, c2);
    Assert.assertEquals(c1.hashCode(), c2.hashCode());

    //Remove a VM, not equals
    c1.remove(vms.get(0));
    Assert.assertNotSame(c1, c2);

    //Put the VM elsewhere
    c1 = c2.copy();
    c1.addRunningVM(vms.get(0), ns.get(0));
    Assert.assertNotSame(c1, c2);

    //Remove a node
    c1 = c2.copy();
    c1.remove(ns.get(2));
    Assert.assertNotSame(c1, c2);

    //Move a VM
    c1 = c2.copy();
    c1.addRunningVM(vms.get(3), ns.get(0));
    Assert.assertNotSame(c1, c2);

}
 
Example 7
Source File: SeqTest.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void asISeq() {
	final Seq<String> iseq = ISeq.of("1");
	Assert.assertSame(iseq.asISeq(), iseq);

	final Seq<String> mseq = MSeq.of("1");
	Assert.assertNotSame(mseq.asISeq(), mseq);
	Assert.assertEquals(mseq.asISeq(), mseq);
}
 
Example 8
Source File: ResumeVMTest.java    From scheduler with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testInstantiate"})
public void testEquals() {
    ResumeVM a = new ResumeVM(vms.get(0), ns.get(0), ns.get(1), 3, 5);
    ResumeVM b = new ResumeVM(vms.get(0), ns.get(0), ns.get(1), 3, 5);
    Assert.assertFalse(a.equals(new Object()));
    Assert.assertTrue(a.equals(a));
    Assert.assertEquals(a, b);
    Assert.assertEquals(a.hashCode(), b.hashCode());

    Assert.assertNotSame(a, new ResumeVM(vms.get(0), ns.get(0), ns.get(1), 4, 5));
    Assert.assertNotSame(a, new ResumeVM(vms.get(0), ns.get(0), ns.get(1), 3, 4));
    Assert.assertNotSame(a, new ResumeVM(vms.get(1), ns.get(0), ns.get(1), 3, 5));
    Assert.assertNotSame(a, new ResumeVM(vms.get(0), ns.get(2), ns.get(1), 3, 5));
    Assert.assertNotSame(a, new ResumeVM(vms.get(0), ns.get(0), ns.get(2), 3, 5));
}
 
Example 9
Source File: CachedSchedulerTest.java    From reactive-streams-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void directTasks() throws Exception {
    int n = 100;
    
    CountDownLatch cdl = new CountDownLatch(n);
    
    for (int i = 0; i < n; i++) {
        Assert.assertNotSame(Scheduler.REJECTED, scheduler.schedule(cdl::countDown));
    }
    
    cdl.await(5, TimeUnit.SECONDS);
    
    Assert.assertEquals(0, cdl.getCount());
}
 
Example 10
Source File: FlagStatIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testNonEqualFS(){
    FlagStat.FlagStatus l1 = makeFlagStatus();
    FlagStat.FlagStatus l2 = makeFlagStatus();
    l2.duplicates++;
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l1.hashCode(), l2.hashCode());
    Assert.assertNotSame(l1, l2);
}
 
Example 11
Source File: ManagedLedgerTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void avoidUseSameOpAddEntryBetweenDifferentLedger() throws Exception {
    ManagedLedgerFactoryConfig config = new ManagedLedgerFactoryConfig();
    config.setMaxCacheSize(0);
    ManagedLedgerFactoryImpl factory = new ManagedLedgerFactoryImpl(bkc, zkc, config);
    ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("my_test_ledger");

    List<OpAddEntry> oldOps = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        OpAddEntry op = OpAddEntry.create(ledger, ByteBufAllocator.DEFAULT.buffer(128), null, null);
        if (i > 4) {
            op.setLedger(mock(LedgerHandle.class));
        }
        oldOps.add(op);
        ledger.pendingAddEntries.add(op);
    }

    ledger.updateLedgersIdsComplete(mock(Stat.class));
    for (int i = 0; i < 10; i++) {
        OpAddEntry oldOp = oldOps.get(i);
        if (i > 4) {
            Assert.assertEquals(oldOp.getState(), OpAddEntry.State.CLOSED);
        } else {
            Assert.assertEquals(oldOp.getState(), OpAddEntry.State.INITIATED);
        }
        OpAddEntry newOp = ledger.pendingAddEntries.poll();
        Assert.assertEquals(newOp.getState(), OpAddEntry.State.INITIATED);
        if (i > 4) {
            Assert.assertNotSame(oldOp, newOp);
        } else {
            Assert.assertSame(oldOp, newOp);
        }
    }
}
 
Example 12
Source File: FilterIntervalsIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "dataAnnotationBasedFilters")
public void testAnnotationBasedFilters(final File intervalsFile,
                                       final List<String> excludedIntervals,
                                       final File annotatedIntervalsFile,
                                       final double minimumGCContent,
                                       final double maximumGCContent,
                                       final double minimumMappability,
                                       final double maximumMappability,
                                       final double minimumSegmentalDuplicationContent,
                                       final double maximumSegmentalDuplicationContent,
                                       final List<Integer> expectedIndices) {
    final File outputFile = createTempFile("filter-intervals-test", ".interval_list");
    final ArgumentsBuilder argsBuilder = new ArgumentsBuilder()
            .add(StandardArgumentDefinitions.INTERVALS_LONG_NAME, intervalsFile.getAbsolutePath())
            .add(CopyNumberStandardArgument.ANNOTATED_INTERVALS_FILE_LONG_NAME, annotatedIntervalsFile.getAbsolutePath())
            .add(FilterIntervals.MINIMUM_GC_CONTENT_LONG_NAME, Double.toString(minimumGCContent))
            .add(FilterIntervals.MAXIMUM_GC_CONTENT_LONG_NAME, Double.toString(maximumGCContent))
            .add(FilterIntervals.MINIMUM_MAPPABILITY_LONG_NAME, Double.toString(minimumMappability))
            .add(FilterIntervals.MAXIMUM_MAPPABILITY_LONG_NAME, Double.toString(maximumMappability))
            .add(FilterIntervals.MINIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(minimumSegmentalDuplicationContent))
            .add(FilterIntervals.MAXIMUM_SEGMENTAL_DUPLICATION_CONTENT_LONG_NAME, Double.toString(maximumSegmentalDuplicationContent))
            .add(IntervalArgumentCollection.INTERVAL_MERGING_RULE_LONG_NAME, IntervalMergingRule.OVERLAPPING_ONLY.toString())
            .addOutput(outputFile);
    excludedIntervals.forEach(i -> argsBuilder.add(IntervalArgumentCollection.EXCLUDE_INTERVALS_LONG_NAME, i));
    runCommandLine(argsBuilder);
    final IntervalList result = IntervalList.fromFile(outputFile);
    final IntervalList all = IntervalList.fromFile(intervalsFile);
    final List<Interval> allIntervals = all.getIntervals();
    final IntervalList expected = new IntervalList(all.getHeader().getSequenceDictionary());
    expectedIndices.stream().map(allIntervals::get).map(Interval::new).forEach(expected::add);
    Assert.assertEquals(result, expected);
    Assert.assertNotSame(result, expected);
}
 
Example 13
Source File: MysqlSchemaCodegenTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetDefaultDatabaseName() {
    final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen();
    codegen.setDefaultDatabaseName("valid_db_name");
    Assert.assertSame(codegen.getDefaultDatabaseName(), "valid_db_name");
    codegen.setDefaultDatabaseName("12345");
    Assert.assertNotSame(codegen.getDefaultDatabaseName(), "12345");
}
 
Example 14
Source File: SuspendVMTest.java    From scheduler with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testInstantiate"})
public void testEquals() {
    SuspendVM a = new SuspendVM(vms.get(0), ns.get(0), ns.get(1), 3, 5);
    SuspendVM b = new SuspendVM(vms.get(0), ns.get(0), ns.get(1), 3, 5);
    Assert.assertFalse(a.equals(new Object()));
    Assert.assertTrue(a.equals(a));
    Assert.assertEquals(a, b);
    Assert.assertEquals(a.hashCode(), b.hashCode());

    Assert.assertNotSame(a, new SuspendVM(vms.get(0), ns.get(0), ns.get(1), 4, 5));
    Assert.assertNotSame(a, new SuspendVM(vms.get(0), ns.get(0), ns.get(1), 3, 4));
    Assert.assertNotSame(a, new SuspendVM(vms.get(1), ns.get(0), ns.get(1), 3, 5));
    Assert.assertNotSame(a, new SuspendVM(vms.get(0), ns.get(2), ns.get(1), 3, 5));
    Assert.assertNotSame(a, new SuspendVM(vms.get(0), ns.get(0), ns.get(2), 3, 5));
}
 
Example 15
Source File: SeqTest.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void asMSeq() {
	final Seq<String> mseq = MSeq.of("1");
	Assert.assertSame(mseq.asMSeq(), mseq);

	final Seq<String> iseq = ISeq.of("1");
	Assert.assertNotSame(iseq.asMSeq(), iseq);
	Assert.assertEquals(iseq.asMSeq(), iseq);
}
 
Example 16
Source File: RouteTest.java    From jpx with Apache License 2.0 5 votes vote down vote up
@Test
public void toBuilder() {
	final Route object = nextRoute(new Random(3));

	Assert.assertEquals(
		object.toBuilder().build(),
		object
	);
	Assert.assertNotSame(
		object.toBuilder().build(),
		object
	);
}
 
Example 17
Source File: CustomAssertion.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
public static void assertNotSame(final Object actual, final Object expected, final String message) {
    if (SeleniumTestsContextManager.getThreadContext().isSoftAssertEnabled()) {
        softAssertNotSame(actual, expected, message);
    } else {
        Assert.assertNotSame(actual, expected, message);
    }
}
 
Example 18
Source File: TestFramework.java    From xian with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateModes() throws Exception
{
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
    client.start();
    try
    {
        byte[] writtenBytes = {1, 2, 3};
        client.create().forPath("/test", writtenBytes); // should be persistent

        client.close();
        client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
        client.start();

        byte[] readBytes = client.getData().forPath("/test");
        Assert.assertEquals(writtenBytes, readBytes);

        client.create().withMode(CreateMode.EPHEMERAL).forPath("/ghost", writtenBytes);

        client.close();
        client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
        client.start();

        readBytes = client.getData().forPath("/test");
        Assert.assertEquals(writtenBytes, readBytes);
        Stat stat = client.checkExists().forPath("/ghost");
        Assert.assertNull(stat);

        String realPath = client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/pseq", writtenBytes);
        Assert.assertNotSame(realPath, "/pseq");

        client.close();
        client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
        client.start();

        readBytes = client.getData().forPath(realPath);
        Assert.assertEquals(writtenBytes, readBytes);

        realPath = client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/eseq", writtenBytes);
        Assert.assertNotSame(realPath, "/eseq");

        client.close();
        client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
        client.start();

        stat = client.checkExists().forPath(realPath);
        Assert.assertNull(stat);
    }
    finally
    {
        CloseableUtils.closeQuietly(client);
    }
}
 
Example 19
Source File: TestControllerManager.java    From helix with Apache License 2.0 4 votes vote down vote up
@Test
public void simpleSessionExpiryTest() throws Exception {
  // Logger.getRootLogger().setLevel(Level.WARN);

  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  final String clusterName = className + "_" + methodName;
  int n = 5;

  System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));

  MockParticipantManager[] participants = new MockParticipantManager[n];

  TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
      "localhost", // participant name prefix
      "TestDB", // resource name prefix
      1, // resources
      16, // partitions per resource
      n, // number of nodes
      3, // replicas
      "MasterSlave", true); // do rebalance

  // start controller
  ClusterControllerManager controller =
      new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
  controller.syncStart();

  // start participants
  for (int i = 0; i < n; i++) {
    String instanceName = "localhost_" + (12918 + i);
    participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
    participants[i].syncStart();
  }

  boolean result =
      ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
          clusterName));
  Assert.assertTrue(result);
  String oldSessionId = controller.getSessionId();

  // expire zk-connection on localhost_12918
  ZkTestHelper.expireSession(controller.getZkClient());

  // wait until session expiry callback happens
  TimeUnit.MILLISECONDS.sleep(100);

  result =
      ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
          clusterName));
  Assert.assertTrue(result);
  String newSessionId = controller.getSessionId();
  Assert.assertNotSame(newSessionId, oldSessionId);

  // cleanup
  controller.syncStop();
  for (int i = 0; i < n; i++) {
    participants[i].syncStop();
  }

  deleteCluster(clusterName);
  System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
 
Example 20
Source File: AvroTestToolsTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Test
public void testGenericRecordDataComparisonWithoutSchema() throws Exception {
  Schema avroSchema = (new Schema.Parser()).parse(
      "{\n" + "  \"namespace\": \"com.linkedin.compliance.test\",\n" + "  \"type\": \"record\",\n"
          + "  \"name\": \"SimpleTest\",\n" + "  \"fields\": [\n" + "    {\n" + "      \"name\": \"memberId\",\n"
          + "      \"type\": \"int\"\n" + "    },\n" + "    {\n" + "      \"name\": \"name\",\n"
          + "      \"type\": \"string\"\n" + "    }\n" + "  ]\n" + "}");

  Schema avroSchemaDiffInNamespace = (new Schema.Parser()).parse(
      "{\n" + "  \"namespace\": \"com.linkedin.whatever\",\n" + "  \"type\": \"record\",\n"
          + "  \"name\": \"SimpleTest\",\n" + "  \"fields\": [\n" + "    {\n" + "      \"name\": \"memberId\",\n"
          + "      \"type\": \"int\"\n" + "    },\n" + "    {\n" + "      \"name\": \"name\",\n"
          + "      \"type\": \"string\"\n" + "    }\n" + "  ]\n" + "}");

  Schema nullableSchema = (new Schema.Parser()).parse(
      "{\n" + "  \"namespace\": \"com.linkedin.compliance.test\",\n" + "  \"type\": \"record\",\n"
          + "  \"name\": \"SimpleTest\",\n" + "  \"fields\": [\n" + "    {\n" + "      \"name\": \"memberId\",\n"
          + "      \"type\": [\n" + "        \"null\",\n" + "        \"int\",\n" + "        \"string\"\n"
          + "      ]\n" + "    },\n" + "    {\n" + "      \"name\": \"name\",\n" + "      \"type\": \"string\"\n"
          + "    }\n" + "  ]\n" + "}");

  GenericRecordBuilder builder_0 = new GenericRecordBuilder(avroSchema);
  builder_0.set("memberId", "1");
  builder_0.set("name", "alice");
  GenericData.Record record_0 = builder_0.build();

  GenericRecordBuilder builder_1 = new GenericRecordBuilder(avroSchemaDiffInNamespace);
  builder_1.set("memberId", "1");
  builder_1.set("name", "alice");
  GenericData.Record record_1 = builder_1.build();

  GenericRecordBuilder builder_2 = new GenericRecordBuilder(avroSchemaDiffInNamespace);
  builder_2.set("memberId", "1");
  builder_2.set("name", "alice");
  GenericData.Record record_2 = builder_2.build();

  GenericRecordBuilder builder_3 = new GenericRecordBuilder(avroSchemaDiffInNamespace);
  builder_3.set("memberId", "2");
  builder_3.set("name", "bob");
  GenericData.Record record_3 = builder_3.build();

  GenericRecordBuilder builder_4 = new GenericRecordBuilder(nullableSchema);
  builder_4.set("memberId", null);
  builder_4.set("name", "bob");
  GenericData.Record record_4 = builder_4.build();

  GenericRecordBuilder builder_5 = new GenericRecordBuilder(nullableSchema);
  builder_5.set("memberId", null);
  builder_5.set("name", "bob");
  GenericData.Record record_5 = builder_5.build();

  Assert.assertTrue(!record_0.equals(record_1));

  AvroTestTools.GenericRecordWrapper wrapper_0 = new GenericRecordWrapper(record_0);
  GenericRecordWrapper wrapper_1 = new GenericRecordWrapper(record_1);
  GenericRecordWrapper wrapper_2 = new GenericRecordWrapper(record_2);
  GenericRecordWrapper wrapper_3 = new GenericRecordWrapper(record_3);
  GenericRecordWrapper wrapper_4 = new GenericRecordWrapper(record_4);
  GenericRecordWrapper wrapper_5 = new GenericRecordWrapper(record_5);

  Assert.assertEquals(wrapper_0, wrapper_1);
  Assert.assertEquals(wrapper_1, wrapper_2);
  Assert.assertNotSame(wrapper_2, wrapper_3);
  Assert.assertEquals(wrapper_4, wrapper_5);
}