本文整理了Java中junit.framework.TestCase.assertNotSame()
方法的一些代码示例,展示了TestCase.assertNotSame()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.assertNotSame()
方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:assertNotSame
[英]Asserts that two objects do not refer to the same object. If they do refer to the same object an AssertionFailedError is thrown.
[中]断言两个对象不引用同一个对象。如果它们确实引用同一个对象,则抛出断言失败错误。
代码示例来源:origin: google/guava
@Override
public synchronized void starting() {
assertTrue(stateHistory.isEmpty());
assertNotSame(State.NEW, service.state());
stateHistory.add(State.STARTING);
}
代码示例来源:origin: google/guava
@Override
public synchronized void running() {
assertEquals(State.STARTING, Iterables.getOnlyElement(stateHistory));
stateHistory.add(State.RUNNING);
service.awaitRunning();
assertNotSame(State.STARTING, service.state());
}
代码示例来源:origin: google/guava
@Override
public synchronized void stopping(State from) {
assertEquals(from, Iterables.getLast(stateHistory));
stateHistory.add(State.STOPPING);
if (from == State.STARTING) {
try {
service.awaitRunning();
fail();
} catch (IllegalStateException expected) {
assertThat(expected).hasCauseThat().isNull();
assertThat(expected)
.hasMessageThat()
.isEqualTo("Expected the service " + service + " to be RUNNING, but was STOPPING");
}
}
assertNotSame(from, service.state());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void randomDeviceIdTest() {
int a = OmemoManager.randomDeviceId();
int b = OmemoManager.randomDeviceId();
assertNotSame(a, b); // This is highly unlikely
assertTrue(a > 0);
assertTrue(b > 0);
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void generateOmemoPreKeys() {
TreeMap<Integer, T_PreKey> keys = store.generateOmemoPreKeys(31, 49);
assertNotNull("Generated data structure must not be null.", keys);
byte[] lastKey = null;
for (int i = 31; i <= 79; i++) {
assertEquals("Key ids must be ascending order, starting at 31.", Integer.valueOf(i), keys.firstKey());
assertNotNull("Every id must match to a key.", keys.get(keys.firstKey()));
byte[] bytes = store.keyUtil().preKeyToBytes(keys.get(keys.firstKey()));
assertNotNull("Serialized preKey must not be null.", bytes);
assertNotSame("Serialized preKey must not be of length 0.", 0, bytes.length);
if (lastKey != null) {
assertFalse("PreKeys MUST NOT be equal.", Arrays.equals(lastKey, bytes));
}
lastKey = bytes;
keys.remove(keys.firstKey());
}
assertEquals("After deleting 49 keys, there must be no keys left.", 0, keys.size());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void fingerprintTest() {
OmemoFingerprint first = new OmemoFingerprint("FINGER");
OmemoFingerprint second = new OmemoFingerprint("TOE");
assertNotSame(first, second);
assertEquals(first, new OmemoFingerprint("FINGER"));
}
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testWhenPostRequestChangedClientIpSessionIsInvalid() throws Exception {
final String clientIp = "127.0.0.2:10000";
final String sessionId = "111";
final HttpServletRequest req = MockLoginAzkabanServlet
.getRequestWithNoUpstream(clientIp, sessionId, "POST");
final StringWriter writer = new StringWriter();
final HttpServletResponse resp = getResponse(writer);
final MockLoginAzkabanServlet servlet = MockLoginAzkabanServlet.getServletWithSession(sessionId,
"user", "127.0.0.1");
servlet.doPost(req, resp);
// Assert that our response was written (we have a valid session)
assertNotSame("SUCCESS_MOCK_LOGIN_SERVLET", writer.toString());
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void omemoIdentityKeyPairSerializationTest() throws CorruptedOmemoKeyException {
IdentityKeyPair ikp = keyUtil.generateOmemoIdentityKeyPair();
byte[] bytes = keyUtil.identityKeyPairToBytes(ikp);
assertNotNull("serialized identityKeyPair must not be null.",
bytes);
assertNotSame("serialized identityKeyPair must not be of length 0.",
0, bytes.length);
IdentityKeyPair ikp2 = keyUtil.identityKeyPairFromBytes(bytes);
assertTrue("Deserialized IdentityKeyPairs PublicKey must equal the originals one.",
ikp.getPublicKey().equals(ikp2.getPublicKey()));
}
代码示例来源:origin: igniterealtime/Smack
assertNotSame(transport, transport1);
assertNotSame(transport.getSessionId(), transport1.getSessionId());
代码示例来源:origin: igniterealtime/Smack
byte[] bytes = store.keyUtil().signedPreKeyToBytes(spk);
assertNotNull("Serialized signedPreKey must not be null", bytes);
assertNotSame("Serialized signedPreKey must not be of length 0.", 0, bytes.length);
代码示例来源:origin: igniterealtime/Smack
@Test
public void parserTest() throws Exception {
JingleContent.Builder builder = JingleContent.getBuilder();
builder.setCreator(JingleContent.Creator.initiator);
builder.setName("A name");
JingleContent content = builder.build();
assertNotNull(content);
assertNull(content.getDescription());
assertEquals(JingleContent.Creator.initiator, content.getCreator());
assertEquals("A name", content.getName());
builder.setSenders(JingleContent.Senders.both);
content = builder.build();
assertEquals(JingleContent.Senders.both, content.getSenders());
builder.setDisposition("session");
JingleContent content1 = builder.build();
assertEquals("session", content1.getDisposition());
assertNotSame(content.toXML(null).toString(), content1.toXML(null).toString());
assertEquals(content1.toXML(null).toString(), builder.build().toXML(null).toString());
String xml =
"<content creator='initiator' disposition='session' name='A name' senders='both'>" +
"</content>";
assertEquals(xml, content1.toXML(null).toString());
}
}
代码示例来源:origin: igniterealtime/Smack
assertNotSame("Serialized identityKey must be of length > 0.", 0, bytesA1.length);
assertNotSame("Serialized identityKey must be of length > 0.", 0, bytesB.length);
代码示例来源:origin: org.drools/drools-compiler
assertNotSame( smems1[1], smems2[1] );
代码示例来源:origin: org.drools/drools-compiler
assertNotSame(b1Mem.getSegmentMemory(), b2Mem.getSegmentMemory());
代码示例来源:origin: com.google.guava/guava-tests
@Override public synchronized void running() {
assertEquals(State.STARTING, Iterables.getOnlyElement(stateHistory));
stateHistory.add(State.RUNNING);
service.awaitRunning();
assertNotSame(State.STARTING, service.state());
}
代码示例来源:origin: terl/lazysodium-java
@Test
public void sha256Compare() throws SodiumException {
String hashed1 = lazySodium.cryptoHashSha256(MESSAGE);
String hashed2 = lazySodium.cryptoHashSha256(MESSAGE);
TestCase.assertNotSame(hashed1, hashed2);
}
代码示例来源:origin: io.snappydata/gemfire-junit
public void beforeUpdate(EntryEvent event) throws CacheWriterException {
assertTrue(event.getOperation().isUpdate());
assertTrue(event.getRegion().containsKey(this.key));
assertTrue(event.getRegion().containsValueForKey(this.key));
assertNotNull(event.getRegion().getEntry(this.key));
assertNotSame(this.value, event.getRegion().get(this.key));
this.validationSuccessful = true;
}
代码示例来源:origin: apache/oozie
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl + "/test"};
assertNotSame("The request with the no existing url will fail but was not", 0, new OozieCLI().run(args));
return null;
}
}, conf, "oozie_4");
代码示例来源:origin: imglib/imglib2
@Test
public void testCopy() throws IllegalAccessException, InstantiationException
{
final Class< ? extends MyInterface > originalClass = MyClass.class;
final ClassCopier< MyInterface > copier = new ClassCopier<>( originalClass, MyInterface.class );
final Class< ? extends MyInterface > copiedClass = copier.copy();
assertNotSame( originalClass, copiedClass );
}
代码示例来源:origin: arnaudroger/SimpleFlatMapper
@Test
public void testFormatProperty() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd") {
@Override
public String toString() {
return "SDF";
}
};
FormatProperty property = new FormatProperty(format);
assertNotSame(format, property.format());
assertEquals(format, property.format());
assertEquals("Format{SDF}", property.toString());
}
内容来源于网络,如有侵权,请联系作者删除!