當前位置: 首頁>>代碼示例>>Java>>正文


Java Assert.assertNotSame方法代碼示例

本文整理匯總了Java中org.junit.Assert.assertNotSame方法的典型用法代碼示例。如果您正苦於以下問題:Java Assert.assertNotSame方法的具體用法?Java Assert.assertNotSame怎麽用?Java Assert.assertNotSame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.Assert的用法示例。


在下文中一共展示了Assert.assertNotSame方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testExport

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testExport() {
    RegistryProtocol registryProtocol = new RegistryProtocol();
    registryProtocol.setCluster(new FailfastCluster());
    registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());

    Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
    registryProtocol.setProtocol(dubboProtocol);
    URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
    DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
            newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
    Exporter<DemoService> exporter = registryProtocol.export(invoker);
    Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
    //同一個invoker,多次export的exporter不同
    Assert.assertNotSame(exporter, exporter2);
    exporter.unexport();
    exporter2.unexport();
    
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:20,代碼來源:RegistryProtocolTest.java

示例2: testVmBoundEcho

import org.junit.Assert; //導入方法依賴的package包/類
public void testVmBoundEcho() throws Exception
{
    this.setupServer();

    FastServletProxyFactory fspf = new FastServletProxyFactory();
    fspf.setUseLocalService(false);
    Echo echo = fspf.create(Echo.class, "http://localhost:" + PORT + "/JrpipServlet");
    Assert.assertNotSame(echo.getClass(), EchoImpl.class);
    Assert.assertEquals("hello", echo.echo("hello"));
    Assert.assertEquals("goodbye", echo.echo("goodbye"));
    Thread.sleep(600L);
    Assert.assertTrue(this.servlet.getThankYous() > 0);

    this.tearDownServer();
    this.setupServer();

    try
    {
        echo.echo("hello");
        Assert.fail("must not get here");
    }
    catch (JrpipVmBoundException e)
    {
        LOGGER.info("expected exception thrown for testing", e);
    }
}
 
開發者ID:goldmansachs,項目名稱:jrpip,代碼行數:27,代碼來源:VmBoundServiceTest.java

示例3: testValueFactoryThrowsSynchronously

import org.junit.Assert; //導入方法依賴的package包/類
public void testValueFactoryThrowsSynchronously(boolean specifyJff) {
	// use our own so we don't get main thread deadlocks, which isn't the point of this test.
	JoinableFutureFactory jff = specifyJff ? new JoinableFutureContext().getFactory() : null;
	AtomicBoolean executed = new AtomicBoolean(false);
	AsyncLazy<Object> lazy = new AsyncLazy<>(
		() -> {
			Assert.assertFalse(executed.get());
			executed.set(true);
			throw new RuntimeException();
		},
		jff);

	CompletableFuture<? extends Object> future1 = lazy.getValueAsync();
	CompletableFuture<? extends Object> future2 = lazy.getValueAsync();
	Assert.assertNotSame("Futures must be different to isolate cancellation.", future1, future2);
	Assert.assertTrue(future1.isDone());
	Assert.assertTrue(future1.isCompletedExceptionally());
	Assert.assertFalse(future1.isCancelled());

	thrown.expect(CompletionException.class);
	thrown.expectCause(isA(RuntimeException.class));
	future1.join();
}
 
開發者ID:tunnelvisionlabs,項目名稱:java-threading,代碼行數:24,代碼來源:AsyncLazyTest.java

示例4: testApplicationReport

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testApplicationReport() {
  long timestamp = System.currentTimeMillis();
  ApplicationReport appReport1 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport2 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport3 =
      createApplicationReport(1, 1, timestamp);
  Assert.assertEquals(appReport1, appReport2);
  Assert.assertEquals(appReport2, appReport3);
  appReport1.setApplicationId(null);
  Assert.assertNull(appReport1.getApplicationId());
  Assert.assertNotSame(appReport1, appReport2);
  appReport2.setCurrentApplicationAttemptId(null);
  Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
  Assert.assertNotSame(appReport2, appReport3);
  Assert.assertNull(appReport1.getAMRMToken());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:TestApplicatonReport.java

示例5: testEqualsAndHash

import org.junit.Assert; //導入方法依賴的package包/類
/**
 * Test equals and hash code operation with all possible combinations
 * 
 * @param modelClass
 *            the entity to test.
 * @param idProperties
 *            the list of business key parts.
 * @throws InstantiationException
 *             due to reflection.
 * @throws IllegalAccessException
 *             due to reflection.
 * @throws InvocationTargetException
 *             due to reflection.
 * @param <T>
 *            The type of the entity to test.
 */
protected <T> void testEqualsAndHash(final Class<T> modelClass, final String... idProperties)
		throws InstantiationException, IllegalAccessException, InvocationTargetException {
	final T systemUser = modelClass.newInstance();
	final T systemUser2 = modelClass.newInstance();
	Assert.assertFalse(systemUser.equals(null)); // NOPMD NOSONAR -- for coverage
	Assert.assertEquals(systemUser, systemUser);
	Assert.assertEquals(systemUser, systemUser2);
	Assert.assertFalse(systemUser.equals(1));
	Assert.assertNotSame(0, systemUser.hashCode());

	// Get all identifier combinations
	final List<List<String>> combinations = combinations(idProperties);

	// For each, compute equality and hash code
	testCombinations(modelClass, combinations);

	// Test inheritance "canEqual" if available (as Scala)
	final T mockCanEqual = Mockito.mock(modelClass);
	systemUser.equals(mockCanEqual);
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:37,代碼來源:AbstractBusinessEntityTest.java

示例6: testDuplicateCreate

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testDuplicateCreate()  {

  Source avroSource1 = sourceFactory.create("avroSource1", "avro");
  Source avroSource2 = sourceFactory.create("avroSource2", "avro");

  Assert.assertNotNull(avroSource1);
  Assert.assertNotNull(avroSource2);
  Assert.assertNotSame(avroSource1, avroSource2);
  Assert.assertTrue(avroSource1 instanceof AvroSource);
  Assert.assertTrue(avroSource2 instanceof AvroSource);

  Source s1 = sourceFactory.create("avroSource1", "avro");
  Source s2 = sourceFactory.create("avroSource2", "avro");

  Assert.assertNotSame(avroSource1, s1);
  Assert.assertNotSame(avroSource2, s2);

}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:20,代碼來源:TestDefaultSourceFactory.java

示例7: testGet_InternalFilesDir

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGet_InternalFilesDir() throws Exception {
  File dir = mContext.getFilesDir();

  DynamicDefaultDiskStorage supplier = createInternalFilesDirStorage();

  // initial state
  Assert.assertNull(supplier.mCurrentState.delegate);

  // after first initialization
  DiskStorage storage = supplier.get();
  Assert.assertEquals(storage, supplier.mCurrentState.delegate);
  Assert.assertTrue(storage instanceof DefaultDiskStorage);

  File baseDir = new File(dir, mBaseDirectoryName);
  Assert.assertTrue(baseDir.exists());
  Assert.assertTrue(getStorageSubdirectory(baseDir, 1).exists());

  // no change => should get back the same storage instance
  DiskStorage storage2 = supplier.get();
  Assert.assertEquals(storage, storage2);

  // root directory has been moved (proxy for delete). So we should get back a different instance
  File baseDirOrig = baseDir.getAbsoluteFile();
  Assert.assertTrue(baseDirOrig.renameTo(new File(dir, "dummydir")));
  DiskStorage storage3 = supplier.get();
  Assert.assertNotSame(storage, storage3);
  Assert.assertTrue(storage3 instanceof DefaultDiskStorage);
  Assert.assertTrue(baseDir.exists());
  Assert.assertTrue(getStorageSubdirectory(baseDir, 1).exists());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:DynamicDefaultDiskStorageTest.java

示例8: testInvokeChangeType

import org.junit.Assert; //導入方法依賴的package包/類
/**
 * Test change functions on server.
 * @throws IOException IOException
 * @throws IntrospectionException IntrospectionException
 * @throws InstanceNotFoundException InstanceNotFoundException
 * @throws ReflectionException ReflectionException
 */
@Test
public void testInvokeChangeType() throws IOException, IntrospectionException, InstanceNotFoundException, ReflectionException {
    //connect to server
    final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,serverObj.getConnectorSystemPort());
    //get MBeanServerConnection
    MBeanServerConnection mbsConnection = JmxServerHelper.getMBeanServer(connection);
    //check if mbeans are registered
    Assert.assertNotSame(0,mbsConnection.getMBeanCount());
    //get networkManager
    ObjectName networkManagerOn = JmxServerHelper.findObjectName(mbsConnection,"de.b4sh.byter","NetworkManager");
    //list functions
    final List<MBeanOperationInfo> functions = JmxServerHelper.getOperations(mbsConnection,networkManagerOn);
    //do actual test for network
    String networkTypeOld = JmxServerHelper.getNetworkManagerNetworkType(mbsConnection,networkManagerOn);
    String networkResponse = JmxServerHelper.setNetworkManagerNetworkType(mbsConnection,networkManagerOn, NetworkType.BufferedNetwork.getKey());
    Assert.assertNotEquals("",networkResponse);
    log.log(Level.INFO, "TEST: Change Response:" + networkResponse);
    String networkType = JmxServerHelper.getNetworkManagerNetworkType(mbsConnection,networkManagerOn);
    Assert.assertNotEquals(networkType,networkTypeOld);
    //do actual test for writer
    String writerTypeOld = JmxServerHelper.getNetworkManagerWriterType(mbsConnection,networkManagerOn);
    String writerResponse = JmxServerHelper.setNetworkManagerWriterType(mbsConnection,networkManagerOn, WriterType.BufferedWriter.getKey());
    Assert.assertNotEquals("",writerResponse);
    log.log(Level.INFO, "TEST: Change Response:" + writerResponse);
    String writerType = JmxServerHelper.getNetworkManagerWriterType(mbsConnection,networkManagerOn);
    Assert.assertNotEquals(writerType,writerTypeOld);
}
 
開發者ID:deB4SH,項目名稱:Byter,代碼行數:35,代碼來源:JmxNetworkManagerTest.java

示例9: test_not_share_connect

import org.junit.Assert; //導入方法依賴的package包/類
/**
 * 測試不共享連接
 */
@Test
public void test_not_share_connect(){
    init(1);
    Assert.assertNotSame(demoClient.getLocalAddress(), helloClient.getLocalAddress());
    Assert.assertNotSame(demoClient, helloClient);
    destoy();
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:11,代碼來源:ReferenceCountExchangeClientTest.java

示例10: assertNotSame

import org.junit.Assert; //導入方法依賴的package包/類
protected void assertNotSame(final Object unexpected, final Object actual) {
    checkThread();
    try {
        Assert.assertNotSame(unexpected, actual);
    } catch (final AssertionError e) {
        handleThrowable(e);
    }
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:9,代碼來源:AsyncTestBase.java

示例11: patchName

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void patchName() {
	ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
	processInstance.setName("newName");
	ScheduleApprovalProcessInstance savedProcessInstance = processRepository.save(processInstance);
	Assert.assertEquals("newName", savedProcessInstance.getName());
	Assert.assertNotSame(processInstance, savedProcessInstance);
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:9,代碼來源:ProcessInstanceRepositoryTest.java

示例12: t2testClientNetworkChangeAttributes

import org.junit.Assert; //導入方法依賴的package包/類
/**
 * change attributes and read them back afterwards.
 * @throws IOException ioe
 */
@Test
public void t2testClientNetworkChangeAttributes() throws IOException {
    //connect to server
    final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,clientObj.getConnectorSystemPort());
    MBeanServerConnection mbs = JmxServerHelper.getMBeanServer(connection);
    Assert.assertNotSame(0,mbs.getMBeanCount());
    ObjectName network = JmxServerHelper.findObjectName(mbs,"de.b4sh.byter","Network");
    Assert.assertNotNull(network);
    //test things here
    final int networkBufferSizeOld = JmxClientNetworkHelper.getNetworkBufferSize(mbs,network);
    JmxClientNetworkHelper.changeNetworkBufferSize(mbs,network,12345);
    final int networkBufferSizeNew = JmxClientNetworkHelper.getNetworkBufferSize(mbs,network);
    Assert.assertNotEquals(networkBufferSizeNew,networkBufferSizeOld);
    Assert.assertEquals(networkBufferSizeNew,12345);

    final String hostaddressOld = JmxClientNetworkHelper.getServerHostAddress(mbs,network);
    JmxClientNetworkHelper.changeServerHostAddress(mbs,network,"127.0.0.1");
    final String hostaddressNew = JmxClientNetworkHelper.getServerHostAddress(mbs,network);
    Assert.assertNotEquals(hostaddressNew,hostaddressOld);
    Assert.assertEquals(hostaddressNew,"127.0.0.1");

    final int hostportOld = JmxClientNetworkHelper.getServerHostPort(mbs,network);
    JmxClientNetworkHelper.changeServerHostPort(mbs,network,80);
    final int hostportNew = JmxClientNetworkHelper.getServerHostPort(mbs,network);
    Assert.assertNotEquals(hostportNew,hostportOld);
    Assert.assertEquals(80,hostportNew);

    final int targetPregenChunkSizeOld = JmxClientNetworkHelper.getTargetPregenChunkSize(mbs,network);
    JmxClientNetworkHelper.changePregenChunkSize(mbs,network,12345);
    final int targetPregenChunkSizeNew = JmxClientNetworkHelper.getTargetPregenChunkSize(mbs,network);
    Assert.assertNotEquals(targetPregenChunkSizeOld,targetPregenChunkSizeNew);
    Assert.assertEquals(12345,targetPregenChunkSizeNew);

    final long transmitTargetOld = JmxClientNetworkHelper.getTransmitTarget(mbs,network);
    JmxClientNetworkHelper.changeTransmitTarget(mbs,network,12345);
    final long transmitTargetNew = JmxClientNetworkHelper.getTransmitTarget(mbs,network);
    Assert.assertNotEquals(transmitTargetNew,transmitTargetOld);
    Assert.assertEquals(transmitTargetNew,12345);
}
 
開發者ID:deB4SH,項目名稱:Byter,代碼行數:44,代碼來源:JmxClientNetworkTest.java

示例13: testCreateOrResetDeflater_Uncached

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testCreateOrResetDeflater_Uncached() {
  compressor.setCaching(false);
  Deflater deflater1 = compressor.createOrResetDeflater();
  Deflater deflater2 = compressor.createOrResetDeflater();
  Assert.assertNotSame(deflater1, deflater2);
}
 
開發者ID:lizhangqu,項目名稱:CorePatch,代碼行數:8,代碼來源:DeflateCompressorTest.java

示例14: testGetApplicationReportException

import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGetApplicationReportException() throws Exception {
  ApplicationCLI cli = createAndGetAppCLI();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  when(client.getApplicationReport(any(ApplicationId.class))).thenThrow(
      new ApplicationNotFoundException("History file for application"
          + applicationId + " is not found"));
  int exitCode = cli.run(new String[] { "application", "-status",
      applicationId.toString() });
  verify(sysOut).println(
      "Application with id '" + applicationId
          + "' doesn't exist in RM or Timeline Server.");
  Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:15,代碼來源:TestYarnCLI.java

示例15: testEquals

import org.junit.Assert; //導入方法依賴的package包/類
@Test
@SuppressWarnings("EqualsIncompatibleType") // For ErrorProne
public void testEquals() {
  Assert.assertEquals(DEFAULT_QUALIFIED_RECOMMENDATION, DEFAULT_QUALIFIED_RECOMMENDATION);
  Assert.assertEquals(DEFAULT_QUALIFIED_RECOMMENDATION, CLONED_DEFAULT_QUALIFIED_RECOMMENDATION);
  Assert.assertNotSame(DEFAULT_QUALIFIED_RECOMMENDATION, CLONED_DEFAULT_QUALIFIED_RECOMMENDATION);
  for (QualifiedRecommendation mutation : ALL_MUTATIONS) {
    Assert.assertNotEquals(DEFAULT_QUALIFIED_RECOMMENDATION, mutation);
  }
  Assert.assertFalse(DEFAULT_QUALIFIED_RECOMMENDATION.equals(null));
  Assert.assertFalse(DEFAULT_QUALIFIED_RECOMMENDATION.equals("foo"));
}
 
開發者ID:lizhangqu,項目名稱:CorePatch,代碼行數:13,代碼來源:QualifiedRecommendationTest.java


注:本文中的org.junit.Assert.assertNotSame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。