Commit c5ffbaee authored by Sven Bunge's avatar Sven Bunge

Migrate junit tests from 3.x to 4.x:

* Use annotations
* Use org.junit.* instead of junit.framework.*
* Small code cleanups
parent 92a75372
package org.jivesoftware.admin; package org.jivesoftware.admin;
import junit.framework.TestCase; import org.junit.Test;
/** import static org.junit.Assert.assertFalse;
* import static org.junit.Assert.assertTrue;
*/
public class AuthCheckFilterTest extends TestCase { public class AuthCheckFilterTest {
// login.jsp,index.jsp?logout=true,setup/index.jsp,setup/setup-,.gif,.png,error-serverdown.jsp // login.jsp,index.jsp?logout=true,setup/index.jsp,setup/setup-,.gif,.png,error-serverdown.jsp
@Test
public void testExcludeRules() { public void testExcludeRules() {
assertFalse(AuthCheckFilter.testURLPassesExclude("blahblah/login.jsp", "login.jsp")); assertFalse(AuthCheckFilter.testURLPassesExclude("blahblah/login.jsp", "login.jsp"));
assertTrue(AuthCheckFilter.testURLPassesExclude("login.jsp", "login.jsp")); assertTrue(AuthCheckFilter.testURLPassesExclude("login.jsp", "login.jsp"));
......
package org.jivesoftware.openfire; package org.jivesoftware.openfire;
import junit.framework.Assert;
import org.junit.Test; import org.junit.Test;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.PacketExtension; import org.xmpp.packet.PacketExtension;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** /**
* This tests the business rules for storing messages as described in <a href="http://xmpp.org/extensions/xep-0160.html#types">3. Handling of Message Types</a>. * This tests the business rules for storing messages as described in <a href="http://xmpp.org/extensions/xep-0160.html#types">3. Handling of Message Types</a>.
* *
...@@ -17,7 +19,7 @@ public class OfflineMessageStoreTest { ...@@ -17,7 +19,7 @@ public class OfflineMessageStoreTest {
// XEP-0160: "groupchat" message types SHOULD NOT be stored offline // XEP-0160: "groupchat" message types SHOULD NOT be stored offline
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.groupchat); message.setType(Message.Type.groupchat);
Assert.assertFalse(OfflineMessageStore.shouldStoreMessage(message)); assertFalse(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -25,7 +27,7 @@ public class OfflineMessageStoreTest { ...@@ -25,7 +27,7 @@ public class OfflineMessageStoreTest {
// XEP-0160: "headline" message types SHOULD NOT be stored offline // XEP-0160: "headline" message types SHOULD NOT be stored offline
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.headline); message.setType(Message.Type.headline);
Assert.assertFalse(OfflineMessageStore.shouldStoreMessage(message)); assertFalse(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -33,7 +35,7 @@ public class OfflineMessageStoreTest { ...@@ -33,7 +35,7 @@ public class OfflineMessageStoreTest {
// XEP-0160: "error" message types SHOULD NOT be stored offline, // XEP-0160: "error" message types SHOULD NOT be stored offline,
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.error); message.setType(Message.Type.error);
Assert.assertFalse(OfflineMessageStore.shouldStoreMessage(message)); assertFalse(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -41,10 +43,10 @@ public class OfflineMessageStoreTest { ...@@ -41,10 +43,10 @@ public class OfflineMessageStoreTest {
// XEP-0160: Messages with a 'type' attribute whose value is "normal" (or messages with no 'type' attribute) SHOULD be stored offline. // XEP-0160: Messages with a 'type' attribute whose value is "normal" (or messages with no 'type' attribute) SHOULD be stored offline.
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.normal); message.setType(Message.Type.normal);
Assert.assertTrue(OfflineMessageStore.shouldStoreMessage(message)); assertTrue(OfflineMessageStore.shouldStoreMessage(message));
Message message2 = new Message(); Message message2 = new Message();
Assert.assertTrue(OfflineMessageStore.shouldStoreMessage(message2)); assertTrue(OfflineMessageStore.shouldStoreMessage(message2));
} }
@Test @Test
...@@ -52,7 +54,7 @@ public class OfflineMessageStoreTest { ...@@ -52,7 +54,7 @@ public class OfflineMessageStoreTest {
// XEP-0160: "chat" message types SHOULD be stored offline unless they only contain chat state notifications // XEP-0160: "chat" message types SHOULD be stored offline unless they only contain chat state notifications
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.chat); message.setType(Message.Type.chat);
Assert.assertFalse(OfflineMessageStore.shouldStoreMessage(message)); assertFalse(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -61,7 +63,7 @@ public class OfflineMessageStoreTest { ...@@ -61,7 +63,7 @@ public class OfflineMessageStoreTest {
Message message = new Message(); Message message = new Message();
message.setType(Message.Type.chat); message.setType(Message.Type.chat);
message.setBody(" "); message.setBody(" ");
Assert.assertTrue(OfflineMessageStore.shouldStoreMessage(message)); assertTrue(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -70,7 +72,7 @@ public class OfflineMessageStoreTest { ...@@ -70,7 +72,7 @@ public class OfflineMessageStoreTest {
message.setType(Message.Type.chat); message.setType(Message.Type.chat);
PacketExtension chatState = new PacketExtension("composing", "http://jabber.org/protocol/chatstates"); PacketExtension chatState = new PacketExtension("composing", "http://jabber.org/protocol/chatstates");
message.addExtension(chatState); message.addExtension(chatState);
Assert.assertFalse(OfflineMessageStore.shouldStoreMessage(message)); assertFalse(OfflineMessageStore.shouldStoreMessage(message));
} }
@Test @Test
...@@ -81,6 +83,6 @@ public class OfflineMessageStoreTest { ...@@ -81,6 +83,6 @@ public class OfflineMessageStoreTest {
message.addExtension(chatState); message.addExtension(chatState);
PacketExtension packetExtension2 = new PacketExtension("received", "urn:xmpp:receipts"); PacketExtension packetExtension2 = new PacketExtension("received", "urn:xmpp:receipts");
message.addExtension(packetExtension2); message.addExtension(packetExtension2);
Assert.assertTrue(OfflineMessageStore.shouldStoreMessage(message)); assertTrue(OfflineMessageStore.shouldStoreMessage(message));
} }
} }
package org.jivesoftware.openfire.carbons; package org.jivesoftware.openfire.carbons;
import junit.framework.Assert;
import org.jivesoftware.openfire.forward.Forwarded; import org.jivesoftware.openfire.forward.Forwarded;
import org.junit.Test; import org.junit.Test;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import static org.junit.Assert.assertEquals;
/** /**
* @author Christian Schudt * @author Christian Schudt
*/ */
...@@ -20,7 +21,7 @@ public class MessageCarbonsTest { ...@@ -20,7 +21,7 @@ public class MessageCarbonsTest {
Sent sent = new Sent(forwarded); Sent sent = new Sent(forwarded);
String xml = sent.getElement().asXML(); String xml = sent.getElement().asXML();
Assert.assertEquals("<sent xmlns=\"urn:xmpp:carbons:2\"><forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded></sent>", xml); assertEquals("<sent xmlns=\"urn:xmpp:carbons:2\"><forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded></sent>", xml);
} }
@Test @Test
...@@ -33,6 +34,6 @@ public class MessageCarbonsTest { ...@@ -33,6 +34,6 @@ public class MessageCarbonsTest {
Received received = new Received(forwarded); Received received = new Received(forwarded);
String xml = received.getElement().asXML(); String xml = received.getElement().asXML();
Assert.assertEquals("<received xmlns=\"urn:xmpp:carbons:2\"><forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded></received>", xml); assertEquals("<received xmlns=\"urn:xmpp:carbons:2\"><forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded></received>", xml);
} }
} }
package org.jivesoftware.openfire.forward; package org.jivesoftware.openfire.forward;
import junit.framework.Assert;
import org.junit.Test; import org.junit.Test;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import static org.junit.Assert.assertEquals;
/** /**
* @author Christian Schudt * @author Christian Schudt
*/ */
...@@ -17,6 +18,6 @@ public class ForwardTest { ...@@ -17,6 +18,6 @@ public class ForwardTest {
Forwarded forwarded = new Forwarded(message); Forwarded forwarded = new Forwarded(message);
String xml = forwarded.getElement().asXML(); String xml = forwarded.getElement().asXML();
Assert.assertEquals("<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded>", xml); assertEquals("<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded>", xml);
} }
} }
package org.jivesoftware.openfire.handler; package org.jivesoftware.openfire.handler;
import junit.framework.Assert;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.util.XMPPDateTimeFormat; import org.jivesoftware.util.XMPPDateTimeFormat;
import org.junit.Test; import org.junit.Test;
...@@ -12,6 +11,9 @@ import java.util.Date; ...@@ -12,6 +11,9 @@ import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.TimeZone; import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* @author csh * @author csh
*/ */
...@@ -20,16 +22,16 @@ public class IQEntityTimeHandlerTest { ...@@ -20,16 +22,16 @@ public class IQEntityTimeHandlerTest {
@Test @Test
public void testIQInfo() { public void testIQInfo() {
IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler(); IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler();
Assert.assertTrue(iqEntityTimeHandler.getFeatures().hasNext()); assertTrue(iqEntityTimeHandler.getFeatures().hasNext());
Assert.assertEquals(iqEntityTimeHandler.getFeatures().next(), "urn:xmpp:time"); assertEquals(iqEntityTimeHandler.getFeatures().next(), "urn:xmpp:time");
Assert.assertEquals(iqEntityTimeHandler.getInfo().getNamespace(), "urn:xmpp:time"); assertEquals(iqEntityTimeHandler.getInfo().getNamespace(), "urn:xmpp:time");
Assert.assertEquals(iqEntityTimeHandler.getInfo().getName(), "time"); assertEquals(iqEntityTimeHandler.getInfo().getName(), "time");
} }
@Test @Test
public void testTimeZone() { public void testTimeZone() {
IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler(); IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler();
Assert.assertEquals(iqEntityTimeHandler.formatsTimeZone(TimeZone.getTimeZone("GMT-8:00")), "-08:00"); assertEquals(iqEntityTimeHandler.formatsTimeZone(TimeZone.getTimeZone("GMT-8:00")), "-08:00");
} }
@Test @Test
...@@ -39,7 +41,7 @@ public class IQEntityTimeHandlerTest { ...@@ -39,7 +41,7 @@ public class IQEntityTimeHandlerTest {
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
calendar.setTime(date); calendar.setTime(date);
calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
Assert.assertEquals(iqEntityTimeHandler.getUtcDate(date), DatatypeConverter.printDateTime(calendar)); assertEquals(iqEntityTimeHandler.getUtcDate(date), DatatypeConverter.printDateTime(calendar));
} }
@Test @Test
...@@ -67,12 +69,12 @@ public class IQEntityTimeHandlerTest { ...@@ -67,12 +69,12 @@ public class IQEntityTimeHandlerTest {
IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler(); IQEntityTimeHandler iqEntityTimeHandler = new IQEntityTimeHandler();
IQ input = new IQ(IQ.Type.get, "1"); IQ input = new IQ(IQ.Type.get, "1");
IQ result = iqEntityTimeHandler.handleIQ(input); IQ result = iqEntityTimeHandler.handleIQ(input);
Assert.assertEquals(result.getChildElement().getName(), "time"); assertEquals(result.getChildElement().getName(), "time");
Assert.assertEquals(result.getChildElement().getNamespace().getText(), "urn:xmpp:time"); assertEquals(result.getChildElement().getNamespace().getText(), "urn:xmpp:time");
Assert.assertEquals(result.getChildElement().content().size(), 2); assertEquals(result.getChildElement().content().size(), 2);
Assert.assertTrue(result.getChildElement().content().get(0) instanceof Element); assertTrue(result.getChildElement().content().get(0) instanceof Element);
Assert.assertTrue(result.getChildElement().content().get(1) instanceof Element); assertTrue(result.getChildElement().content().get(1) instanceof Element);
Assert.assertEquals(((Element) result.getChildElement().content().get(0)).getName(), "tzo"); assertEquals(((Element) result.getChildElement().content().get(0)).getName(), "tzo");
Assert.assertEquals(((Element) result.getChildElement().content().get(1)).getName(), "utc"); assertEquals(((Element) result.getChildElement().content().get(1)).getName(), "utc");
} }
} }
...@@ -14,21 +14,19 @@ import java.lang.reflect.Method; ...@@ -14,21 +14,19 @@ import java.lang.reflect.Method;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import junit.framework.TestCase;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.admin.AdminConsole; import org.jivesoftware.admin.AdminConsole;
import org.junit.After;
import org.junit.Test;
public class AdminConsoleTest extends TestCase { import static org.junit.Assert.*;
public AdminConsoleTest() {
} public class AdminConsoleTest {
/** /**
* Resets the admin console internal data structures. * Resets the admin console internal data structures.
*/ */
@Override @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
Class c = AdminConsole.class; Class c = AdminConsole.class;
Method init = c.getDeclaredMethod("load", (Class[])null); Method init = c.getDeclaredMethod("load", (Class[])null);
...@@ -36,6 +34,7 @@ public class AdminConsoleTest extends TestCase { ...@@ -36,6 +34,7 @@ public class AdminConsoleTest extends TestCase {
init.invoke((Object)null, (Object[])null); init.invoke((Object)null, (Object[])null);
} }
@Test
public void testGetGlobalProps() throws Exception { public void testGetGlobalProps() throws Exception {
String name = AdminConsole.getAppName(); String name = AdminConsole.getAppName();
String image = AdminConsole.getLogoImage(); String image = AdminConsole.getLogoImage();
...@@ -43,6 +42,7 @@ public class AdminConsoleTest extends TestCase { ...@@ -43,6 +42,7 @@ public class AdminConsoleTest extends TestCase {
assertEquals("images/header-title.gif", image); assertEquals("images/header-title.gif", image);
} }
@Test
public void testModifyGlobalProps() throws Exception { public void testModifyGlobalProps() throws Exception {
// Add a new stream to the AdminConsole: // Add a new stream to the AdminConsole:
String filename = TestUtils.prepareFilename( String filename = TestUtils.prepareFilename(
...@@ -56,6 +56,7 @@ public class AdminConsoleTest extends TestCase { ...@@ -56,6 +56,7 @@ public class AdminConsoleTest extends TestCase {
assertEquals("foo.gif", img); assertEquals("foo.gif", img);
} }
@Test
public void testNewTabs() throws Exception { public void testNewTabs() throws Exception {
// Add a new stream to the AdminConsole: // Add a new stream to the AdminConsole:
String filename = TestUtils.prepareFilename( String filename = TestUtils.prepareFilename(
...@@ -67,8 +68,8 @@ public class AdminConsoleTest extends TestCase { ...@@ -67,8 +68,8 @@ public class AdminConsoleTest extends TestCase {
assertNotNull(tabs); assertNotNull(tabs);
assertTrue(tabs.size() > 0); assertTrue(tabs.size() > 0);
boolean found = false; boolean found = false;
for (Iterator iter=tabs.iterator(); iter.hasNext(); ) { for (Object tab1 : tabs) {
Element tab = (Element)iter.next(); Element tab = (Element) tab1;
if ("foobar".equals(tab.attributeValue("id"))) { if ("foobar".equals(tab.attributeValue("id"))) {
found = true; found = true;
assertEquals("Foo Bar", tab.attributeValue("name")); assertEquals("Foo Bar", tab.attributeValue("name"));
...@@ -80,6 +81,7 @@ public class AdminConsoleTest extends TestCase { ...@@ -80,6 +81,7 @@ public class AdminConsoleTest extends TestCase {
} }
} }
@Test
public void testTabOverwrite() throws Exception { public void testTabOverwrite() throws Exception {
// Add a new stream to the AdminConsole: // Add a new stream to the AdminConsole:
String filename = TestUtils.prepareFilename( String filename = TestUtils.prepareFilename(
...@@ -88,8 +90,8 @@ public class AdminConsoleTest extends TestCase { ...@@ -88,8 +90,8 @@ public class AdminConsoleTest extends TestCase {
AdminConsole.addModel("test3", in); AdminConsole.addModel("test3", in);
in.close(); in.close();
boolean found = false; boolean found = false;
for (Iterator tabs=AdminConsole.getModel().selectNodes("//tab").iterator(); tabs.hasNext(); ) { for (Object o : AdminConsole.getModel().selectNodes("//tab")) {
Element tab = (Element)tabs.next(); Element tab = (Element) o;
if ("server".equals(tab.attributeValue("id"))) { if ("server".equals(tab.attributeValue("id"))) {
found = true; found = true;
assertEquals("New Server Title", tab.attributeValue("name")); assertEquals("New Server Title", tab.attributeValue("name"));
......
package org.jivesoftware.util; package org.jivesoftware.util;
import java.util.UUID; import java.util.UUID;
import junit.framework.TestCase;
import org.junit.Test; import org.junit.Test;
public class AesEncryptorTest extends TestCase { import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
public class AesEncryptorTest {
@Test @Test
public void testEncryptionUsingDefaultKey() { public void testEncryptionUsingDefaultKey() {
...@@ -47,15 +50,10 @@ public class AesEncryptorTest extends TestCase { ...@@ -47,15 +50,10 @@ public class AesEncryptorTest extends TestCase {
@Test @Test
public void testEncryptionForNullString() { public void testEncryptionForNullString() {
String test = null;
Encryptor encryptor = new AesEncryptor(); Encryptor encryptor = new AesEncryptor();
String b64Encrypted = encryptor.encrypt(test); String b64Encrypted = encryptor.encrypt(null);
assertNull(b64Encrypted); assertNull(b64Encrypted);
} }
} }
...@@ -2,11 +2,13 @@ package org.jivesoftware.util; ...@@ -2,11 +2,13 @@ package org.jivesoftware.util;
import java.util.UUID; import java.util.UUID;
import junit.framework.TestCase;
import org.junit.Test; import org.junit.Test;
public class BlowfishEncryptorTest extends TestCase { import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
public class BlowfishEncryptorTest {
@Test @Test
public void testEncryptionUsingDefaultKey() { public void testEncryptionUsingDefaultKey() {
...@@ -49,15 +51,10 @@ public class BlowfishEncryptorTest extends TestCase { ...@@ -49,15 +51,10 @@ public class BlowfishEncryptorTest extends TestCase {
@Test @Test
public void testEncryptionForNullString() { public void testEncryptionForNullString() {
Encryptor encryptor = new Blowfish();
String test = null;
String b64Encrypted = encryptor.encrypt(null);
Encryptor encryptor = new Blowfish();
String b64Encrypted = encryptor.encrypt(test);
assertNull(b64Encrypted);
}
assertNull(b64Encrypted);
}
} }
...@@ -5,18 +5,21 @@ import java.util.List; ...@@ -5,18 +5,21 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import junit.framework.TestCase; import org.junit.Test;
import static org.junit.Assert.assertEquals;
/** /**
* Basic tests for code used by CertificateManager. * Basic tests for code used by CertificateManager.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class CertificateTest extends TestCase { public class CertificateTest {
/** /**
* Verify that all CN elements are found. * Verify that all CN elements are found.
*/ */
@Test
public void testCN() { public void testCN() {
Pattern cnPattern = Pattern.compile("(?i)(cn=)([^,]*)"); Pattern cnPattern = Pattern.compile("(?i)(cn=)([^,]*)");
String text = "EMAILADDRESS=XXXXX@scifi.com, CN=scifi.com, CN=jabber.scifi.com, OU=Domain validated only, O=XX, L=Skx, C=SE"; String text = "EMAILADDRESS=XXXXX@scifi.com, CN=scifi.com, CN=jabber.scifi.com, OU=Domain validated only, O=XX, L=Skx, C=SE";
......
...@@ -19,22 +19,27 @@ ...@@ -19,22 +19,27 @@
*/ */
package org.jivesoftware.util; package org.jivesoftware.util;
import junit.framework.TestCase; import org.junit.Test;
import static org.junit.Assert.assertEquals;
/** /**
* Simple test of the int enum class. * Simple test of the int enum class.
* *
* @author Iain Shigeoka * @author Iain Shigeoka
*/ */
public class IntEnumTest extends TestCase { public class IntEnumTest {
/** /**
* Create a test case with a given name. * Tests the IntEnum's enforcement of unique int values for each enum type
*
* @param name The name of the test
*/ */
public IntEnumTest (String name){ @Test
super(name); public void testStaticEnumUniqueEnforcement(){
IntEnum e = new IntEnum("plain",1);
IntEnum.register(e);
new TestIntEnum("test",1); // auto registers the same value - does it clash with super class?
assertEquals("plain",IntEnum.getEnumFromInt(IntEnum.class,1).getName());
assertEquals("test",TestIntEnum.getTypeFromInt(1).getName());
} }
static public class TestIntEnum extends IntEnum{ static public class TestIntEnum extends IntEnum{
...@@ -46,14 +51,4 @@ public class IntEnumTest extends TestCase { ...@@ -46,14 +51,4 @@ public class IntEnumTest extends TestCase {
return (TestIntEnum) getEnumFromInt(TestIntEnum.class,value); return (TestIntEnum) getEnumFromInt(TestIntEnum.class,value);
} }
} }
/**
* Tests the IntEnum's enforcement of unique int values for each enum type
*/
public void testStaticEnumUniqueEnforcement(){
IntEnum e = new IntEnum("plain",1);
IntEnum.register(e);
new TestIntEnum("test",1); // auto registers the same value - does it clash with super class?
assertEquals("plain",IntEnum.getEnumFromInt(IntEnum.class,1).getName());
assertEquals("test",TestIntEnum.getTypeFromInt(1).getName());
}
} }
\ No newline at end of file
...@@ -7,17 +7,21 @@ ...@@ -7,17 +7,21 @@
package org.jivesoftware.util; package org.jivesoftware.util;
import junit.framework.TestCase; import org.junit.Test;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** /**
* Test cases for the JID class. * Test cases for the JID class.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class JIDTest extends TestCase { public class JIDTest {
@Test
public void testDomain() { public void testDomain() {
new JID("mycomapny.com"); new JID("mycomapny.com");
new JID("wfink-adm"); new JID("wfink-adm");
...@@ -39,6 +43,7 @@ public class JIDTest extends TestCase { ...@@ -39,6 +43,7 @@ public class JIDTest extends TestCase {
assertTrue("A domain with _ was accepted", failed); assertTrue("A domain with _ was accepted", failed);
} }
@Test
public void testUsernames() { public void testUsernames() {
new JID("john@mycomapny.com"); new JID("john@mycomapny.com");
new JID("john_paul@mycomapny.com"); new JID("john_paul@mycomapny.com");
...@@ -52,6 +57,7 @@ public class JIDTest extends TestCase { ...@@ -52,6 +57,7 @@ public class JIDTest extends TestCase {
assertTrue("A username with spaces was accepted", failed); assertTrue("A username with spaces was accepted", failed);
} }
@Test
public void testCompare() { public void testCompare() {
JID jid1 = new JID("john@mycomapny.com"); JID jid1 = new JID("john@mycomapny.com");
JID jid2 = new JID("john@mycomapny.com"); JID jid2 = new JID("john@mycomapny.com");
......
...@@ -9,15 +9,17 @@ ...@@ -9,15 +9,17 @@
*/ */
package org.jivesoftware.util; package org.jivesoftware.util;
import junit.framework.TestCase;
import org.jivesoftware.openfire.ldap.LdapManager; import org.jivesoftware.openfire.ldap.LdapManager;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/** /**
* @author Daniel Henninger * @author Daniel Henninger
*/ */
public class LDAPTest extends TestCase { public class LDAPTest {
@Test
public void testEncloseDN() { public void testEncloseDN() {
String before = "ou=Jive Software\\, Inc,dc=support,dc=jive,dc=com"; String before = "ou=Jive Software\\, Inc,dc=support,dc=jive,dc=com";
String after = "ou=\"Jive Software, Inc\",dc=\"support\",dc=\"jive\",dc=\"com\""; String after = "ou=\"Jive Software, Inc\",dc=\"support\",dc=\"jive\",dc=\"com\"";
......
...@@ -22,10 +22,14 @@ package org.jivesoftware.util; ...@@ -22,10 +22,14 @@ package org.jivesoftware.util;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import junit.framework.TestCase; import org.junit.Test;
public class XMLPropertiesTest extends TestCase { import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class XMLPropertiesTest {
@Test
public void testAttributes() throws Exception { public void testAttributes() throws Exception {
String xml = "<root><foo></foo></root>"; String xml = "<root><foo></foo></root>";
XMLProperties props = new XMLProperties(new ByteArrayInputStream(xml.getBytes())); XMLProperties props = new XMLProperties(new ByteArrayInputStream(xml.getBytes()));
...@@ -35,6 +39,7 @@ public class XMLPropertiesTest extends TestCase { ...@@ -35,6 +39,7 @@ public class XMLPropertiesTest extends TestCase {
assertEquals(props.getAttribute("foo","bar"), "test123"); assertEquals(props.getAttribute("foo","bar"), "test123");
} }
@Test
public void testGetProperty() throws Exception { public void testGetProperty() throws Exception {
XMLProperties props = new XMLProperties( XMLProperties props = new XMLProperties(
"./resources/org/jivesoftware/util/XMLProperties.test01.xml"); "./resources/org/jivesoftware/util/XMLProperties.test01.xml");
...@@ -44,6 +49,7 @@ public class XMLPropertiesTest extends TestCase { ...@@ -44,6 +49,7 @@ public class XMLPropertiesTest extends TestCase {
assertNull(props.getProperty("nothing.something")); assertNull(props.getProperty("nothing.something"));
} }
@Test
public void testGetChildPropertiesIterator() throws Exception { public void testGetChildPropertiesIterator() throws Exception {
XMLProperties props = new XMLProperties( XMLProperties props = new XMLProperties(
"./resources/org/jivesoftware/util/XMLProperties.test02.xml"); "./resources/org/jivesoftware/util/XMLProperties.test02.xml");
...@@ -59,6 +65,7 @@ public class XMLPropertiesTest extends TestCase { ...@@ -59,6 +65,7 @@ public class XMLPropertiesTest extends TestCase {
} }
} }
@Test
public void testGetPropertyWithXMLEntity() throws Exception { public void testGetPropertyWithXMLEntity() throws Exception {
String xml = "<root><foo>foo&amp;bar</foo></root>"; String xml = "<root><foo>foo&amp;bar</foo></root>";
XMLProperties props = new XMLProperties(new ByteArrayInputStream(xml.getBytes())); XMLProperties props = new XMLProperties(new ByteArrayInputStream(xml.getBytes()));
......
...@@ -19,26 +19,21 @@ ...@@ -19,26 +19,21 @@
*/ */
package org.jivesoftware.util; package org.jivesoftware.util;
import junit.framework.TestCase; import org.junit.Ignore;
import org.junit.Test;
/** /**
* <p>Test the writing of dom4j documents using the XPP serializer.</p> * <p>Test the writing of dom4j documents using the XPP serializer.</p>
* *
* @author Iain Shigeoka * @author Iain Shigeoka
*/ */
public class XPPWriterTest extends TestCase { public class XPPWriterTest {
/**
* <p>Create a new test with the given name.</p>
*
* @param name The name of the test
*/
public XPPWriterTest(String name){
super(name);
}
/** /**
* <p>Run a standard config document through a round trip and compare.</p> * <p>Run a standard config document through a round trip and compare.</p>
*/ */
@Test
@Ignore
public void testRoundtrip(){ public void testRoundtrip(){
// NOTE: disabling this test case until we get resources working again. // NOTE: disabling this test case until we get resources working again.
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment