mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +01:00
Delete some outdated code from the old integration-test dir
The code in the integration-test/ directories should either be migrated to sinttest (or unit tests), or get deleted. This is a first small step towards this goal.
This commit is contained in:
parent
57d7ac4d5d
commit
f329b447f2
3 changed files with 0 additions and 275 deletions
|
@ -1,43 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2005 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* A test case for the Cache class.
|
||||
*/
|
||||
public class CacheTest extends TestCase {
|
||||
|
||||
public void testMaxSize() {
|
||||
Cache<Integer, String> cache = new Cache<Integer, String>(100, -1);
|
||||
for (int i=0; i < 1000; i++) {
|
||||
cache.put(i, "value");
|
||||
assertTrue("Cache size must never be larger than 100.", cache.size() <= 100);
|
||||
}
|
||||
}
|
||||
|
||||
public void testLRU() {
|
||||
Cache<Integer, String> cache = new Cache<Integer, String>(100, -1);
|
||||
for (int i=0; i < 1000; i++) {
|
||||
cache.put(i, "value");
|
||||
assertTrue("LRU algorithm for cache key of '0' failed.",
|
||||
cache.get(new Integer(0)) != null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package org.jivesoftware.smack.util;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Roster;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
public class ConnectionUtils {
|
||||
|
||||
private ConnectionUtils() {}
|
||||
|
||||
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
|
||||
Roster r0 = con0.getRoster();
|
||||
Roster r1 = con1.getRoster();
|
||||
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||
r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||
r0.createEntry(con1.getUser(), "u2", null);
|
||||
r1.createEntry(con0.getUser(), "u1", null);
|
||||
}
|
||||
|
||||
public static void letsAllBeFriends(XMPPConnection[] connections) throws XMPPException {
|
||||
for (XMPPConnection c1 : connections) {
|
||||
for (XMPPConnection c2 : connections) {
|
||||
if (c1 == c2)
|
||||
continue;
|
||||
becomeFriends(c1, c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,203 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2006 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.util;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserFactory;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
public class XMPPErrorTest extends SmackTestCase {
|
||||
|
||||
public XMPPErrorTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the creation of a new xmppError locally.
|
||||
*/
|
||||
public void testLocalErrorCreation() {
|
||||
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found);
|
||||
error.toXML();
|
||||
|
||||
assertEquals(error.getCondition(), "item-not-found");
|
||||
assertEquals(error.getCode(), 404);
|
||||
assertEquals(error.getType(), XMPPError.Type.CANCEL);
|
||||
assertNull(error.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the creation of a new xmppError locally.
|
||||
*/
|
||||
public void testLocalErrorWithCommentCreation() {
|
||||
String message = "Error Message";
|
||||
XMPPError error = new XMPPError(XMPPError.Condition.item_not_found, message);
|
||||
error.toXML();
|
||||
|
||||
assertEquals(error.getCondition(), "item-not-found");
|
||||
assertEquals(error.getCode(), 404);
|
||||
assertEquals(error.getType(), XMPPError.Type.CANCEL);
|
||||
assertEquals(error.getMessage(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the creation of a new xmppError locally where there is not a default defined.
|
||||
*/
|
||||
public void testUserDefinedErrorWithCommentCreation() {
|
||||
String message = "Error Message";
|
||||
XMPPError error = new XMPPError(new XMPPError.Condition("my_own_error"), message);
|
||||
error.toXML();
|
||||
|
||||
assertEquals(error.getCondition(), "my_own_error");
|
||||
assertEquals(error.getCode(), 0);
|
||||
assertNull(error.getType());
|
||||
assertEquals(error.getMessage(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the parser with an xml with the 404 error.
|
||||
*/
|
||||
public void test404() {
|
||||
// Make the XML to test
|
||||
String xml = "<error code='404' type='cancel'>" +
|
||||
"<item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
"</error></iq>";
|
||||
try {
|
||||
// Create the xml parser
|
||||
XmlPullParser parser = getParserFromXML(xml);
|
||||
// Create a packet from the xml
|
||||
XMPPError packet = parseError(parser);
|
||||
|
||||
assertNotNull(packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the parser with an xml with the 404 error.
|
||||
*/
|
||||
public void testCancel() {
|
||||
// Make the XML to test
|
||||
String xml = "<error type='cancel'>" +
|
||||
"<conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
"</error>";
|
||||
try {
|
||||
// Create the xml parser
|
||||
XmlPullParser parser = getParserFromXML(xml);
|
||||
// Create a packet from the xml
|
||||
XMPPError error = parseError(parser);
|
||||
|
||||
assertNotNull(error);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testMessageAndApplicationDefinedError() {
|
||||
String xml = "<error type='modify' code='404'>" +
|
||||
"<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
"<text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>" +
|
||||
"Some special application diagnostic information..." +
|
||||
"</text>" +
|
||||
"<special-application-condition xmlns='application-ns'/>" +
|
||||
"</error>";
|
||||
try {
|
||||
// Create the xml parser
|
||||
XmlPullParser parser = getParserFromXML(xml);
|
||||
// Create a packet from the xml
|
||||
XMPPError error = parseError(parser);
|
||||
|
||||
String sendingXML = error.toXML();
|
||||
|
||||
assertNotNull(error);
|
||||
assertNotNull(sendingXML);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the parser with an xml with the 404 error.
|
||||
*/
|
||||
public void testCancelWithMessage() {
|
||||
// Make the XML to test
|
||||
String xml = "<error type='cancel'>" +
|
||||
"<conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
"<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='langcode'>" +
|
||||
"Some special application diagnostic information!" +
|
||||
"</text>" +
|
||||
"</error>";
|
||||
try {
|
||||
// Create the xml parser
|
||||
XmlPullParser parser = getParserFromXML(xml);
|
||||
// Create a packet from the xml
|
||||
XMPPError error = parseError(parser);
|
||||
|
||||
assertNotNull(error);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the parser with an xml with the 404 error.
|
||||
*/
|
||||
public void testCancelWithMessageAndApplicationError() {
|
||||
// Make the XML to test
|
||||
String xml = "<error type='cancel' code='10'>" +
|
||||
"<conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
"<text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>" +
|
||||
"Some special application diagnostic information!" +
|
||||
"</text>" +
|
||||
"<application-defined-error xmlns='application-ns'/>" +
|
||||
"</error>";
|
||||
try {
|
||||
// Create the xml parser
|
||||
XmlPullParser parser = getParserFromXML(xml);
|
||||
// Create a packet from the xml
|
||||
XMPPError error = parseError(parser);
|
||||
|
||||
assertNotNull(error);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private XMPPError parseError(XmlPullParser parser) throws Exception {
|
||||
parser.next();
|
||||
return PacketParserUtils.parseError(parser);
|
||||
}
|
||||
|
||||
private XmlPullParser getParserFromXML(String xml) throws XmlPullParserException {
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||
parser.setInput(new StringReader(xml));
|
||||
return parser;
|
||||
}
|
||||
|
||||
protected int getMaxConnections() {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue