org.junit.Assert.assertNotEquals()方法的使用及代码示例

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

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

Assert.assertNotEquals介绍

[英]Asserts that two doubles or floats are not equal to within a positive delta. If they are, an AssertionError is thrown. If the expected value is infinity then the delta value is ignored.NaNs are considered equal: assertNotEquals(Double.NaN, Double.NaN, *) fails
[中]断言两个double或float在正增量内不等于。如果是,则抛出断言错误。如果预期值为无穷大,则忽略增量值。NAN被视为相等:assertNotEquals(Double.NaN, Double.NaN, *)失败

代码示例

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

@Test
public void equalsBasics() {
  MergedContextConfiguration mergedConfig = new MergedContextConfiguration(null, null, null, null, null);
  assertEquals(mergedConfig, mergedConfig);
  assertNotEquals(mergedConfig, null);
  assertNotEquals(mergedConfig, 1);
}

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

private void assertEqualsAndHashCodeContracts(Object master, Object equal, Object notEqual, Object subclass) {
  assertEquals("Should be equal", master, equal);
  assertEquals("Hash code for equal instances should match", master.hashCode(), equal.hashCode());
  assertNotEquals("Should not be equal", master, notEqual);
  assertNotEquals("Hash code for non-equal instances should not match", master.hashCode(), notEqual.hashCode());
  assertEquals("Subclass should be equal", master, subclass);
  assertEquals("Hash code for subclass should match", master.hashCode(), subclass.hashCode());
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void equalsWith() {
  Timed<Integer> t1 = new Timed<Integer>(1, 5, TimeUnit.SECONDS);
  Timed<Integer> t2 = new Timed<Integer>(1, 5, TimeUnit.SECONDS);
  Timed<Integer> t3 = new Timed<Integer>(2, 5, TimeUnit.SECONDS);
  Timed<Integer> t4 = new Timed<Integer>(1, 4, TimeUnit.SECONDS);
  Timed<Integer> t5 = new Timed<Integer>(1, 5, TimeUnit.MINUTES);
  assertEquals(t1, t1);
  assertEquals(t1, t2);
  assertNotEquals(t1, t3);
  assertNotEquals(t1, t4);
  assertNotEquals(t2, t3);
  assertNotEquals(t2, t4);
  assertNotEquals(t2, t5);
  assertNotEquals(t3, t1);
  assertNotEquals(t3, t2);
  assertNotEquals(t3, t4);
  assertNotEquals(t3, t5);
  assertNotEquals(t4, t1);
  assertNotEquals(t4, t2);
  assertNotEquals(t4, t3);
  assertNotEquals(t4, t5);
  assertNotEquals(t5, t1);
  assertNotEquals(t5, t2);
  assertNotEquals(t5, t3);
  assertNotEquals(t5, t4);
  assertNotEquals(new Object(), t1);
  assertFalse(t1.equals(new Object()));
}

代码示例来源:origin: bumptech/glide

@Test
public void testAllocatesBitmapsInOrderGivenByAllocationOrder() {
 PreFillType smallWidth =
   new PreFillType.Builder(50, 100).setConfig(Bitmap.Config.ARGB_8888).build();
 PreFillType smallHeight =
   new PreFillType.Builder(100, 50).setConfig(Bitmap.Config.RGB_565).build();
 PreFillType[] expectedOrder =
   new PreFillType[] { smallWidth, smallHeight, smallWidth, smallHeight, };
 HashMap<PreFillType, Integer> allocationOrder = new HashMap<>();
 allocationOrder.put(smallWidth, 2);
 allocationOrder.put(smallHeight, 2);
 BitmapPreFillRunner handler = getHandler(allocationOrder);
 handler.run();
 Bitmap[] expectedBitmaps = new Bitmap[expectedOrder.length];
 for (int i = 0; i < expectedBitmaps.length; i++) {
  PreFillType current = expectedOrder[i];
  expectedBitmaps[i] =
    Bitmap.createBitmap(current.getWidth(), current.getHeight(), current.getConfig());
 }
 Bitmap current = addedBitmaps.get(0);
 for (int i = 1; i < addedBitmaps.size(); i++) {
  assertNotEquals(current, addedBitmaps.get(i));
  current = addedBitmaps.get(i);
 }
 assertThat(addedBitmaps).hasSize(4);
}

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

@Test
public void originListMatch() throws Exception {
  Map<String, Object> attributes = new HashMap<>();
  WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
  this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
  List<String> allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com");
  OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed);
  assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
  assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
}

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

@Test
public void equalsWithDifferentLocations() {
  String[] locations1 = new String[] { "foo", "bar}" };
  String[] locations2 = new String[] { "baz", "quux}" };
  MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(),
      locations1, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
  MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(),
      locations2, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
  assertNotEquals(mergedConfig1, mergedConfig2);
  assertNotEquals(mergedConfig2, mergedConfig1);
}

代码示例来源:origin: apache/geode

@Test
public void testGenerate() {
 final ThreePhraseGenerator tpg = new ThreePhraseGenerator();
 final String phrase = tpg.generate('-');
 assertNotNull("Generated string is null", phrase);
 assertNotEquals("Generated string is empty", "", phrase);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testTestCategoryFound() throws Exception {
  assertNotNull("No plugin annotation on FakePlugin.", p);
  final Map<String, PluginEntry> testCategory = pluginCache.getCategory(p.category());
  assertNotEquals("No plugins were found.", 0, pluginCache.size());
  assertNotNull("The category '" + p.category() + "' was not found.", testCategory);
  assertFalse(testCategory.isEmpty());
}

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

@Test
public void testEmptyList() {
 List<Boolean> testList = new ArrayList<>();
 testList.add(true);
 testList.add(true);
 testList.add(true);
 DebugOverlayDrawable testD = new DebugOverlayDrawable(testList);
 DebugOverlayDrawable emptyD = new DebugOverlayDrawable(new ArrayList<>());
 assertNotEquals(testD.hashCode(), emptyD.hashCode());
 assertFalse(testD.isEquivalentTo(emptyD));
}

代码示例来源:origin: remkop/picocli

public void checkAssertion() {
    assertEquals("", systemErrRule.getLog());
    assertNotEquals(0, commandScript.length());
    assertTrue(commandScript.delete());
  }
});

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

@Override
  public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
    URI uri = request.getURI();
    assertEquals("https", uri.getScheme());
    assertNotNull(uri.getHost());
    assertNotEquals(-1, uri.getPort());
    assertNotNull(request.getRemoteAddress());
    assertEquals("/foo", uri.getPath());
    assertEquals("param=bar", uri.getQuery());
    return Mono.empty();
  }
}

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

public static void assertClassLoaderIsSingular(ClassLoader classLoader)
 {
  // This is a check against the current HadoopTask which creates a single URLClassLoader with null parent
  Assert.assertNull(classLoader.getParent());
  Assert.assertFalse(classLoader instanceof ApplicationClassLoader);
  Assert.assertTrue(classLoader instanceof URLClassLoader);

  final ClassLoader appLoader = HadoopDruidConverterConfig.class.getClassLoader();
  Assert.assertNotEquals(StringUtils.format("ClassLoader [%s] is not isolated!", classLoader), appLoader, classLoader);
 }
}

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

public static void copyResource(String resource, File out) throws IOException
 {
  Files.copy(TestUtils.class.getResourceAsStream(resource), out.toPath());
  Assert.assertTrue(out.exists());
  Assert.assertNotEquals(0, out.length());
 }
}

代码示例来源:origin: org.apache.commons/commons-lang3

private void assertNotEqualsArchNotNull(final Processor.Arch arch, final Processor processor) {
  assertNotNull(arch);
  assertNotNull(processor);
  assertNotEquals(arch, processor.getArch());
}

代码示例来源:origin: neo4j/neo4j

public static void assertNotEqual( AnyValue a, AnyValue b )
{
  assertNotEquals( a + " should not be equivalent to " + b, a, b );
  assertNotEquals( b + " should not be equivalent to " + a, b, a );
  assertFalse( a + " should not equal " + b, a.ternaryEquals( b ) );
  assertFalse( b + " should not equal " + a, b.ternaryEquals( a ) );
}

代码示例来源:origin: thinkaurelius/titan

@Test
public void testPartitionHashes() {
  assertEquals(8, idManager.getPartitionBound());
  Set<Long> hashs = Sets.newHashSet();
  for (long i=1;i<idManager.getPartitionBound()*2;i++) hashs.add(idManager.getPartitionHashForId(i));
  assertTrue(hashs.size()>idManager.getPartitionBound()/2);
  assertNotEquals(idManager.getPartitionHashForId(101),idManager.getPartitionHashForId(102));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testEquals() {
  assertEquals(new TypeLiteral<String>() {}, new TypeLiteral<String>() {});
  assertEquals(new TypeLiteral<List<String>>() {}, new TypeLiteral<List<String>>() {});
  assertNotEquals(new TypeLiteral<String>() {}, new TypeLiteral<List<String>>() {});
}

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

@Test
public void originValueMatch() throws Exception {
  Map<String, Object> attributes = new HashMap<>();
  WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
  this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com");
  List<String> allowed = Collections.singletonList("http://mydomain1.com");
  OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed);
  assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
  assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
}

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

@Test
public void equalsWithDifferentProfiles() {
  String[] activeProfiles1 = new String[] { "catbert", "dogbert" };
  String[] activeProfiles2 = new String[] { "X", "Y" };
  MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(),
      EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader);
  MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(),
      EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader);
  assertNotEquals(mergedConfig1, mergedConfig2);
  assertNotEquals(mergedConfig2, mergedConfig1);
}

代码示例来源:origin: gchq/Gaffer

@Test
public void shouldSerialiseWithHistoricValues() throws Exception {
  assertNotNull("historicSerialisationPairs should not be null.", historicSerialisationPairs);
  assertNotEquals("historicSerialisationPairs should not be empty.", 0, historicSerialisationPairs.length);
  for (final Pair<INPUT, OUTPUT> pair : historicSerialisationPairs) {
    assertNotNull("historicSerialisationPairs first value should not be null", pair.getFirst());
    serialiseFirst(pair);
    assertNotNull("historicSerialisationPairs second value should not be null", pair.getSecond());
    deserialiseSecond(pair);
  }
}

相关文章