mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Reworked some Jingle unit tests to use Junit's "expected="
Also don't use randomString() because then the unit tests also depend on the correct behavior of it.
This commit is contained in:
parent
2b11074950
commit
08a4ee4eb2
5 changed files with 54 additions and 66 deletions
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.fail;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
|
@ -38,12 +37,10 @@ public class JingleActionTest extends SmackTestSuite {
|
||||||
for (JingleAction a : JingleAction.values()) {
|
for (JingleAction a : JingleAction.values()) {
|
||||||
assertEquals(a, JingleAction.fromString(a.toString()));
|
assertEquals(a, JingleAction.fromString(a.toString()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
@Test(expected = IllegalArgumentException.class)
|
||||||
JingleAction inexistentAction = JingleAction.fromString("inexistent-action");
|
public void nonExistendEnumTest() {
|
||||||
fail();
|
JingleAction.fromString("inexistent-action");
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNotNull;
|
import static junit.framework.TestCase.assertNotNull;
|
||||||
import static junit.framework.TestCase.assertNotSame;
|
import static junit.framework.TestCase.assertNotSame;
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static junit.framework.TestCase.assertNull;
|
||||||
import static junit.framework.TestCase.fail;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
|
@ -33,25 +32,25 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class JingleContentTest extends SmackTestSuite {
|
public class JingleContentTest extends SmackTestSuite {
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void emptyBuilderThrowsTest() {
|
||||||
|
JingleContent.Builder builder = JingleContent.getBuilder();
|
||||||
|
builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void onlyCreatorBuilderThrowsTest() {
|
||||||
|
JingleContent.Builder builder = JingleContent.getBuilder();
|
||||||
|
builder.setCreator(JingleContent.Creator.initiator);
|
||||||
|
builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserTest() {
|
public void parserTest() {
|
||||||
|
|
||||||
JingleContent.Builder builder = JingleContent.getBuilder();
|
JingleContent.Builder builder = JingleContent.getBuilder();
|
||||||
|
|
||||||
try {
|
|
||||||
builder.build();
|
|
||||||
fail();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
builder.setCreator(JingleContent.Creator.initiator);
|
builder.setCreator(JingleContent.Creator.initiator);
|
||||||
|
|
||||||
try {
|
|
||||||
builder.build();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
builder.setName("A name");
|
builder.setName("A name");
|
||||||
|
|
||||||
JingleContent content = builder.build();
|
JingleContent content = builder.build();
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.fail;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
|
@ -41,12 +40,10 @@ public class JingleErrorTest extends SmackTestSuite {
|
||||||
assertEquals("<unsupported-info xmlns='urn:xmpp:jingle:errors:1'/>",
|
assertEquals("<unsupported-info xmlns='urn:xmpp:jingle:errors:1'/>",
|
||||||
JingleError.fromString("unsupported-info").toXML().toString());
|
JingleError.fromString("unsupported-info").toXML().toString());
|
||||||
assertEquals("unknown-session", JingleError.fromString("unknown-session").getMessage());
|
assertEquals("unknown-session", JingleError.fromString("unknown-session").getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
@Test(expected = IllegalArgumentException.class)
|
||||||
JingleError.fromString("inexistent-error");
|
public void illegalArgumentTest() {
|
||||||
fail();
|
JingleError.fromString("inexistent-error");
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.fail;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
|
||||||
|
@ -66,26 +65,22 @@ public class JingleReasonTest extends SmackTestSuite {
|
||||||
JingleReason.IncompatibleParameters.toXML().toString());
|
JingleReason.IncompatibleParameters.toXML().toString());
|
||||||
assertEquals("<reason><alternative-session><sid>1234</sid></alternative-session></reason>",
|
assertEquals("<reason><alternative-session><sid>1234</sid></alternative-session></reason>",
|
||||||
JingleReason.AlternativeSession("1234").toXML().toString());
|
JingleReason.AlternativeSession("1234").toXML().toString());
|
||||||
// Alternative sessionID must not be empty
|
}
|
||||||
try {
|
|
||||||
JingleReason.AlternativeSession("");
|
|
||||||
fail();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
// Alternative sessionID must not be null
|
|
||||||
try {
|
|
||||||
JingleReason.AlternativeSession(null);
|
|
||||||
fail();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
@Test(expected = NullPointerException.class)
|
||||||
JingleReason.Reason nonExistent = JingleReason.Reason.fromString("illegal-reason");
|
public void alternativeSessionEmptyStringTest() {
|
||||||
fail();
|
// Alternative sessionID must not be empty
|
||||||
} catch (IllegalArgumentException e) {
|
JingleReason.AlternativeSession("");
|
||||||
// Expected
|
}
|
||||||
}
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void alternativeSessionNullStringTest() {
|
||||||
|
// Alternative sessionID must not be null
|
||||||
|
JingleReason.AlternativeSession(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void illegalArgumentTest() {
|
||||||
|
JingleReason.Reason.fromString("illegal-reason");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,8 @@ package org.jivesoftware.smackx.jingle;
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNotNull;
|
import static junit.framework.TestCase.assertNotNull;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static junit.framework.TestCase.assertTrue;
|
||||||
import static junit.framework.TestCase.fail;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||||
|
@ -37,25 +35,27 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
*/
|
*/
|
||||||
public class JingleTest extends SmackTestSuite {
|
public class JingleTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void parserTest() throws XmppStringprepException {
|
public void emptyBuilderTest() {
|
||||||
String sessionId = StringUtils.randomString(24);
|
Jingle.Builder builder = Jingle.getBuilder();
|
||||||
|
builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void onlySessionIdBuilderTest() {
|
||||||
|
String sessionId = "testSessionId";
|
||||||
|
|
||||||
Jingle.Builder builder = Jingle.getBuilder();
|
Jingle.Builder builder = Jingle.getBuilder();
|
||||||
try {
|
|
||||||
builder.build();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
builder.setSessionId(sessionId);
|
builder.setSessionId(sessionId);
|
||||||
|
builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
@Test
|
||||||
builder.build();
|
public void parserTest() throws XmppStringprepException {
|
||||||
fail();
|
String sessionId = "testSessionId";
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Expected
|
Jingle.Builder builder = Jingle.getBuilder();
|
||||||
}
|
builder.setSessionId(sessionId);
|
||||||
builder.setAction(JingleAction.session_initiate);
|
builder.setAction(JingleAction.session_initiate);
|
||||||
|
|
||||||
FullJid romeo = JidCreate.fullFrom("romeo@montague.lit/orchard");
|
FullJid romeo = JidCreate.fullFrom("romeo@montague.lit/orchard");
|
||||||
|
|
Loading…
Reference in a new issue