本文整理了Java中org.testng.Assert.assertNotEquals()
方法的一些代码示例,展示了Assert.assertNotEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNotEquals()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertNotEquals
暂无
代码示例来源:origin: cbeust/testng
@Test(expectedExceptions = AssertionError.class)
public void mixedArraysAssertNotEquals() {
assertNotEquals(
new int[] {42},
new Integer[] {42},
"arrays of wrapped values are compared by value in assertNotEquals");
assertNotEquals(
new Integer[] {42},
new int[] {42},
"arrays of wrapped values are compared by value in assertNotEquals");
}
代码示例来源:origin: prestodb/presto
@Test
public void testEquality()
{
HostAddress address1 = HostAddress.fromParts("[1111:2222:3333:4444:5555:6666:7777:8888]", 1234);
HostAddress address1NoBrackets = HostAddress.fromParts("1111:2222:3333:4444:5555:6666:7777:8888", 1234);
assertEquals(address1, address1NoBrackets);
HostAddress address1FromString = HostAddress.fromString("[1111:2222:3333:4444:5555:6666:7777:8888]:1234");
assertEquals(address1, address1FromString);
HostAddress address2 = HostAddress.fromParts("[1111:2222:3333:4444:5555:6666:7777:9999]", 1234);
assertNotEquals(address1, address2);
HostAddress address3 = HostAddress.fromParts("[1111:2222:3333:4444:5555:6666:7777:8888]", 1235);
assertNotEquals(address1, address3);
}
代码示例来源:origin: apache/incubator-gobblin
private void testGPG(Map<String, Object> encryptionProperties) throws IOException {
StreamCodec encryptor = EncryptionFactory.buildStreamCryptoProvider(encryptionProperties);
Assert.assertNotNull(encryptor);
Map<String, Object> decryptionProperties = new HashMap<>();
decryptionProperties.put(EncryptionConfigParser.ENCRYPTION_ALGORITHM_KEY, GPGCodec.TAG);
decryptionProperties.put(EncryptionConfigParser.ENCRYPTION_KEYSTORE_PATH_KEY, GPGFileEncryptor.class.getResource(
PRIVATE_KEY).toString());
decryptionProperties.put(EncryptionConfigParser.ENCRYPTION_KEYSTORE_PASSWORD_KEY, GPGFileEncryptorTest.PASSPHRASE);
StreamCodec decryptor = EncryptionFactory.buildStreamCryptoProvider(decryptionProperties);
Assert.assertNotNull(decryptor);
ByteArrayOutputStream cipherOut = new ByteArrayOutputStream();
OutputStream cipherStream = encryptor.encodeOutputStream(cipherOut);
cipherStream.write(GPGFileEncryptorTest.EXPECTED_FILE_CONTENT_BYTES);
cipherStream.close();
byte[] encryptedBytes = cipherOut.toByteArray();
Assert.assertTrue(encryptedBytes.length > 0, "Expected to be able to write ciphertext!");
try (InputStream is = decryptor.decodeInputStream(new ByteArrayInputStream(encryptedBytes))) {
byte[] decryptedBytes = IOUtils.toByteArray(is);
Assert.assertNotEquals(GPGFileEncryptorTest.EXPECTED_FILE_CONTENT_BYTES, encryptedBytes);
Assert.assertEquals(GPGFileEncryptorTest.EXPECTED_FILE_CONTENT_BYTES, decryptedBytes);
}
}
}
代码示例来源:origin: apache/incubator-gobblin
@Test(groups = {"gobblin.util.io"})
public void test() {
Gson gson = GsonInterfaceAdapter.getGson(Object.class);
TestClass test = new TestClass();
test.absent = Optional.absent();
Assert.assertNotEquals(test, new TestClass());
String ser = gson.toJson(test);
BaseClass deser = gson.fromJson(ser, BaseClass.class);
Assert.assertEquals(test, deser);
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-1935", expectedExceptions = AssertionError.class,
expectedExceptionsMessageRegExp = "did not expect to find \\[x\\] but found \\[x\\]")
public void testEqualityMessage() {
Assert.assertNotEquals("x", "x");
}
代码示例来源:origin: prestodb/presto
assertEquals(elementBlock.getPositionCount(), map.size() * 2);
assertNotEquals(pos, -1);
if (entry.getValue() == null) {
assertTrue(elementBlock.isNull(pos));
assertEquals(BIGINT.getLong(elementBlock, pos), (long) entry.getValue());
assertEquals(elementBlock.seekKey(utf8Slice("not-inserted-" + i)), -1);
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testCopy() throws CopyNotSupportedException {
Schema schema = new Schema.Parser().parse(AVRO_SCHEMA);
CopyableSchema copyableSchema = new CopyableSchema(schema);
Schema copy = copyableSchema.copy();
Assert.assertEquals(schema, copy);
copy.addProp("foo", "bar");
Assert.assertNotEquals(schema, copy);
}
}
代码示例来源:origin: cbeust/testng
@Test(expectedExceptions = AssertionError.class)
public void arrayAssertNotEquals() {
assertNotEquals(
new int[] {42},
new int[] {42},
"arrays of primitives are compared by value in assertNotEquals");
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public void run() {
Assert.assertEquals(SharedResourcesBrokerFactory.getImplicitBroker(), IMPLICIT);
SharedResourcesBroker<SimpleScopeType> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(
ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance());
Assert.assertNotEquals(SharedResourcesBrokerFactory.getImplicitBroker(), broker);
SharedResourcesBrokerFactory.registerImplicitBroker(broker);
Assert.assertEquals(SharedResourcesBrokerFactory.getImplicitBroker(), broker);
ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<?> future = executorService.submit(new InnerImplicitBrokerTest(broker));
try {
future.get();
} catch (ExecutionException | InterruptedException ee) {
throw new RuntimeException(ee);
}
executorService.shutdownNow();
}
}
代码示例来源:origin: killbill/killbill
@Test(groups = "fast")
public void testEquals() throws Exception {
final UUID accountId = UUID.randomUUID();
final UUID tenantId = UUID.randomUUID();
final String userName = UUID.randomUUID().toString();
final DateTime createdDate = clock.getUTCNow();
final String reasonCode = UUID.randomUUID().toString();
final String comment = UUID.randomUUID().toString();
final UUID userToken = UUID.randomUUID();
final DefaultCallContext callContext = new DefaultCallContext(accountId, tenantId, userName, createdDate, reasonCode, comment, userToken);
Assert.assertEquals(callContext, callContext);
final DefaultCallContext sameCallContext = new DefaultCallContext(accountId, tenantId, userName, createdDate, reasonCode, comment, userToken);
Assert.assertEquals(sameCallContext, callContext);
final DefaultCallContext otherCallContext = new DefaultCallContext(accountId, tenantId, UUID.randomUUID().toString(), createdDate, reasonCode, comment, userToken);
Assert.assertNotEquals(otherCallContext, callContext);
}
}
代码示例来源:origin: cbeust/testng
@Test(expectedExceptions = AssertionError.class)
public void boxedArrayAssertNotEquals() {
assertNotEquals(
new Integer[] {42},
new Integer[] {42},
"arrays of wrapped values are compared by value in assertNotEquals");
}
代码示例来源:origin: apache/incubator-gobblin
private void doTestRegisterAndGetLatest(Properties properties) throws SchemaRegistryException {
SchemaRegistryClient schemaRegistryClient = new MockSchemaRegistryClient();
KafkaSchemaRegistry<Integer, Schema> kafkaSchemaRegistry =
new ConfluentKafkaSchemaRegistry(properties, schemaRegistryClient);
Schema schema1 =
SchemaBuilder.record(TEST_RECORD_NAME + "1").namespace(TEST_NAMESPACE).fields().name(TEST_FIELD_NAME).type()
.stringType().noDefault().endRecord();
Schema schema2 =
SchemaBuilder.record(TEST_RECORD_NAME + "2").namespace(TEST_NAMESPACE).fields().name(TEST_FIELD_NAME).type()
.stringType().noDefault().endRecord();
kafkaSchemaRegistry.register(schema1, TEST_TOPIC_NAME);
kafkaSchemaRegistry.register(schema2, TEST_TOPIC_NAME);
Assert.assertNotEquals(schema1, kafkaSchemaRegistry.getLatestSchemaByTopic(TEST_TOPIC_NAME));
Assert.assertEquals(schema2, kafkaSchemaRegistry.getLatestSchemaByTopic(TEST_TOPIC_NAME));
}
}
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testUniqueReplicable() {
Random random = new Random();
byte[] b = new byte[10];
random.nextBytes(b);
Assert.assertEquals(new Guid(b), new Guid(b));
byte[] other = new byte[10];
for (int i = 0; i < 1000; i++) {
random.nextBytes(other);
Assert.assertNotEquals(new Guid(b), new Guid(other));
}
}
代码示例来源:origin: cbeust/testng
@Test
public void verify() {
Assert.assertNotEquals(n % 2, 0);
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testMergeFourGroups()
{
DisjointSet<Integer> disjoint = new DisjointSet<>();
// insert pair (i, i+1); assert all inserts are considered new
List<Integer> inputs = IntStream.range(0, 96).boxed().collect(Collectors.toList());
Collections.shuffle(inputs);
for (int i : inputs) {
assertTrue(disjoint.findAndUnion(i, i + 4));
}
// assert every pair (i, j) is in the same set
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
if ((i - j) % 4 == 0) {
assertEquals(disjoint.find(i), disjoint.find(j));
assertFalse(disjoint.findAndUnion(i, j));
}
else {
assertNotEquals(disjoint.find(i), disjoint.find(j));
}
}
}
Collection<Set<Integer>> equivalentClasses = disjoint.getEquivalentClasses();
assertEquals(equivalentClasses.size(), 4);
equivalentClasses.stream()
.forEach(equivalentClass -> assertEquals(equivalentClass.size(), 25));
}
代码示例来源:origin: cbeust/testng
@Test(dataProvider="nonIdenticalArraysWithNull")
public void nonIdenticalarrayWithNullValue(String[] actual, String[] expected) {
Assert.assertNotEquals(actual, expected);
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Encrypt a test string with a symmetric key and check that it can be decrypted
* @throws IOException
* @throws PGPException
*/
@Test
public void encryptSym() throws IOException, PGPException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = GPGFileEncryptor.encryptFile(baos, PASSWORD, "DES");
os.write(EXPECTED_FILE_CONTENT_BYTES);
os.close();
baos.close();
byte[] encryptedBytes = baos.toByteArray();
try (InputStream is = GPGFileDecryptor.decryptFile(new ByteArrayInputStream(encryptedBytes), "test")) {
byte[] decryptedBytes = IOUtils.toByteArray(is);
Assert.assertNotEquals(EXPECTED_FILE_CONTENT_BYTES, encryptedBytes);
Assert.assertEquals(EXPECTED_FILE_CONTENT_BYTES, decryptedBytes);
}
}
代码示例来源:origin: cbeust/testng
@Test (dataProvider = "dp")
public void testSample1(int num) {
assertNotEquals(num, 0);
}
代码示例来源:origin: Netflix/servo
@Test
public void testEqualsCount() throws Exception {
BasicGauge<Long> c1 = newInstance("42");
BasicGauge<Long> c2 = newInstance("43");
BasicGauge<Long> c3 = newInstance("43");
assertNotEquals(c1, c2);
assertEquals(c2, c3);
}
}
代码示例来源:origin: cbeust/testng
@Test (dataProvider = "dp")
public void testSample2(int num) {
assertNotEquals(num, 0);
}
内容来源于网络,如有侵权,请联系作者删除!