org.testng.Assert.assertNotSame()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.testng.Assert.assertNotSame()方法的一些代码示例,展示了Assert.assertNotSame()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNotSame()方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertNotSame

Assert.assertNotSame介绍

[英]Asserts that two objects do not refer to the same object. If they do, an AssertionError is thrown.
[中]断言两个对象不引用同一个对象。如果是,则抛出断言错误。

代码示例

代码示例来源:origin: org.testng/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertNotSame(actual, expected);
 }
});

代码示例来源:origin: org.testng/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertNotSame(actual, expected, message);
 }
});

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two objects do not refer to the same object. If they do,
 * an AssertionError is thrown.
 * @param actual the actual value
 * @param expected the expected value
 */
public static void assertNotSame(Object actual, Object expected) {
 assertNotSame(actual, expected, null);
}

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two objects do not refer to the same object. If they do, an AssertionError is
 * thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 */
public static void assertNotSame(Object actual, Object expected) {
 assertNotSame(actual, expected, null);
}

代码示例来源:origin: cbeust/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertNotSame(actual, expected, message);
 }
});

代码示例来源:origin: cbeust/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertNotSame(actual, expected);
 }
});

代码示例来源:origin: spring-projects/spring-framework

@Test(dependsOnMethods = { "dirtyContext" })
public void verifyContextWasDirtied() {
  performCommonAssertions();
  assertNotSame(super.applicationContext, this.dirtiedApplicationContext,
    "The application context should have been 'dirtied'.");
  this.dirtiedApplicationContext = super.applicationContext;
}

代码示例来源:origin: prestodb/presto

protected static void assertNotCompact(Block block)
{
  assertNotSame(block.copyRegion(0, block.getPositionCount()), block);
}

代码示例来源:origin: prestodb/presto

@Test
public void testCache()
{
  PageFunctionCompiler cacheCompiler = new PageFunctionCompiler(createTestMetadataManager(), 100);
  assertSame(
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()),
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()));
  assertSame(
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")),
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")));
  assertSame(
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")),
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2")));
  assertSame(
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()),
      cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2")));
  PageFunctionCompiler noCacheCompiler = new PageFunctionCompiler(createTestMetadataManager(), 0);
  assertNotSame(
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()),
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()));
  assertNotSame(
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")),
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")));
  assertNotSame(
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")),
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2")));
  assertNotSame(
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()),
      noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2")));
}

代码示例来源:origin: prestodb/presto

@Test
public void testGetAllNodes()
{
  DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig);
  AllNodes allNodes = manager.getAllNodes();
  Set<Node> activeNodes = allNodes.getActiveNodes();
  assertEqualsIgnoreOrder(activeNodes, this.activeNodes);
  for (Node actual : activeNodes) {
    for (Node expected : this.activeNodes) {
      assertNotSame(actual, expected);
    }
  }
  assertEqualsIgnoreOrder(activeNodes, manager.getNodes(ACTIVE));
  Set<Node> inactiveNodes = allNodes.getInactiveNodes();
  assertEqualsIgnoreOrder(inactiveNodes, this.inactiveNodes);
  for (Node actual : inactiveNodes) {
    for (Node expected : this.inactiveNodes) {
      assertNotSame(actual, expected);
    }
  }
  assertEqualsIgnoreOrder(inactiveNodes, manager.getNodes(INACTIVE));
}

代码示例来源:origin: cbeust/testng

private void testFast(boolean useInterceptor) {
  TestNG tng = create();
  tng.setTestClasses(new Class[] { FooTest.class });
  if (useInterceptor) {
   tng.setMethodInterceptor(new FastTestsFirstInterceptor());
  }
  TestListenerAdapter tla = new TestListenerAdapter();
//    tng.setParallel("methods");
  tng.addListener((ITestNGListener) tla);
  tng.run();

  Assert.assertEquals(tla.getPassedTests().size(), 3);
  ITestResult first = tla.getPassedTests().get(0);

  String method = "zzzfast";
  if (useInterceptor) {
   Assert.assertEquals(first.getMethod().getMethodName(), method);
  } else {
   Assert.assertNotSame(first.getMethod().getMethodName(), method);
  }
 }

代码示例来源:origin: apache/incubator-pinot

new IdealState((ZNRecord) znRecordSerializer.deserialize(znRecordSerializer.serialize(idealState.getRecord())));
_realtimeSegmentRelocator.relocateSegments(realtimeTagConfig, idealState);
Assert.assertNotSame(idealState, prevIdealState);
segmentNameToExpectedNumCompletedInstances.put("segment0", 1);
verifySegmentAssignment(idealState, prevIdealState, completedInstanceList, nReplicas,
  new IdealState((ZNRecord) znRecordSerializer.deserialize(znRecordSerializer.serialize(idealState.getRecord())));
_realtimeSegmentRelocator.relocateSegments(realtimeTagConfig, idealState);
Assert.assertNotSame(idealState, prevIdealState);
segmentNameToExpectedNumCompletedInstances.put("segment0", 2);
verifySegmentAssignment(idealState, prevIdealState, completedInstanceList, nReplicas,
  new IdealState((ZNRecord) znRecordSerializer.deserialize(znRecordSerializer.serialize(idealState.getRecord())));
_realtimeSegmentRelocator.relocateSegments(realtimeTagConfig, idealState);
Assert.assertNotSame(idealState, prevIdealState);
segmentNameToExpectedNumCompletedInstances.put("segment0", 3);
verifySegmentAssignment(idealState, prevIdealState, completedInstanceList, nReplicas,
  new IdealState((ZNRecord) znRecordSerializer.deserialize(znRecordSerializer.serialize(idealState.getRecord())));
_realtimeSegmentRelocator.relocateSegments(realtimeTagConfig, idealState);
Assert.assertNotSame(idealState, prevIdealState);
segmentNameToExpectedNumCompletedInstances.put("segment1", 1);
segmentNameToExpectedNumCompletedInstances.put("segment2", 1);
  new IdealState((ZNRecord) znRecordSerializer.deserialize(znRecordSerializer.serialize(idealState.getRecord())));
_realtimeSegmentRelocator.relocateSegments(realtimeTagConfig, idealState);
Assert.assertNotSame(idealState, prevIdealState);
segmentNameToExpectedNumCompletedInstances.put("segment1", 2);
segmentNameToExpectedNumCompletedInstances.put("segment2", 2);

代码示例来源:origin: prestodb/presto

@Test
public void testFileSystemCache()
    throws IOException
{
  ImpersonatingHdfsAuthentication auth = new ImpersonatingHdfsAuthentication(new SimpleHadoopAuthentication());
  HdfsEnvironment environment =
      new HdfsEnvironment(
          new HiveHdfsConfiguration(new HdfsConfigurationUpdater(new HiveClientConfig())),
          new HiveClientConfig(),
          auth);
  FileSystem fs1 = getFileSystem(environment, "user");
  FileSystem fs2 = getFileSystem(environment, "user");
  assertSame(fs1, fs2);
  FileSystem fs3 = getFileSystem(environment, "other_user");
  assertNotSame(fs1, fs3);
  FileSystem fs4 = getFileSystem(environment, "other_user");
  assertSame(fs3, fs4);
}

代码示例来源:origin: magro/memcached-session-manager

@Test( enabled = true, dataProviderClass = TestUtils.class, dataProvider = STICKYNESS_PROVIDER )
public void testInvalidSessionNotFound( @Nonnull final SessionAffinityMode sessionAffinity ) throws IOException, InterruptedException, HttpException {
  setStickyness(sessionAffinity);
  final String sessionId1 = makeRequest( _httpClient, _portTomcat1, null );
  assertNotNull( sessionId1, "No session created." );
  /*
   * wait some time, as processExpires runs every second and the
   * maxInactiveTime is set to 1 sec...
   */
  Thread.sleep( 2100 );
  final String sessionId2 = makeRequest( _httpClient, _portTomcat1, sessionId1 );
  assertNotSame( sessionId1, sessionId2, "Expired session returned." );
}

代码示例来源:origin: magro/memcached-session-manager

private void checkSessionFunctionalityWithMsmDisabled() throws IOException, HttpException, InterruptedException {
  assertTrue( _tomcat1.getManager().getMemcachedSessionService().isSticky() );
  final String sessionId1 = makeRequest( _httpClient, _portTomcat1, null );
  assertNotNull( sessionId1, "No session created." );
  assertNull( new SessionIdFormat().extractMemcachedId( sessionId1 ), "Got a memcached node id, even with msm disabled." );
  waitForSessionExpiration( true );
  final String sessionId2 = makeRequest( _httpClient, _portTomcat1, sessionId1 );
  assertNotSame( sessionId2, sessionId1, "SessionId not changed." );
}

代码示例来源:origin: magro/memcached-session-manager

assertNotSame( makeRequest( _httpClient, _portTomcat1, sessionId1 ), sessionId1,
    "The sessionId should have changed due to expired sessin" );

代码示例来源:origin: magro/memcached-session-manager

assertNotSame( makeRequest( _httpClient, _portTomcat1, sessionId1 ), sessionId1,
    "The sessionId should have changed due to expired sessin" );

代码示例来源:origin: facebook/jcommon

/**
 * This test will submit several tasks two of which will
 * expire. We check the drainer(s) in the pending list
 * before and after the expiration.
 */
@Test(groups = "fast")
public void testExpiringDualDrainer() throws Exception {
 // submit three tasks
 executorFront2.execute(slowTask);
 executorFront2.execute(countTask);
 executorFront2.execute(slowTask);
 Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);
 AnnotatedRunnable drainer2 = mockExecutor.getRunnableList().get(1);
 mockExecutor.removeHead().run();
 // Drainer1 expires after the 1st task completes, 
 // and is rescheduled to the end of the pending list.
 Assert.assertEquals(mockExecutor.getNumPendingTasks(), 2);
 // Drainer2 should be on the head of the pending list    
 Assert.assertSame(drainer2, mockExecutor.getRunnableList().get(0));
 mockExecutor.removeHead().run();
 // Drainer2 expires after the 2nd and 3rd task complete.     
 AnnotatedRunnable drainer1 = mockExecutor.getRunnableList().get(0);
 // Drainer1 should be on the head of the pending list
 Assert.assertNotSame(drainer1, drainer2);
 // should have 2 slow tasks and 1 count tasks 
 Assert.assertEquals(count.get(), 3);
 // must clear the timer offset
 DateTimeUtils.setCurrentMillisOffset(0);
}

代码示例来源:origin: magro/memcached-session-manager

final String secondNode = extractNodeId( sid2 );
assertNotSame( secondNode, firstNode, "First node again selected" );

代码示例来源:origin: magro/memcached-session-manager

assertNotSame( response2.getSessionId(), sessionId1 );
final String sessionId2 = response2.getResponseSessionId();
assertNotNull( sessionId2 );

相关文章