当前位置: 首页>>代码示例>>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;未经允许,请勿转载。