From f329b447f23c5d8882786029d2b0e12556918025 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 8 Apr 2020 21:17:59 +0200 Subject: [PATCH] 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. --- .../jivesoftware/smack/util/CacheTest.java | 43 ---- .../smack/util/ConnectionUtils.java | 29 --- .../smack/util/XMPPErrorTest.java | 203 ------------------ 3 files changed, 275 deletions(-) delete mode 100644 smack-core/src/integration-test/java/org/jivesoftware/smack/util/CacheTest.java delete mode 100644 smack-core/src/integration-test/java/org/jivesoftware/smack/util/ConnectionUtils.java delete mode 100644 smack-core/src/integration-test/java/org/jivesoftware/smack/util/XMPPErrorTest.java diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/CacheTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/util/CacheTest.java deleted file mode 100644 index 0243ca330..000000000 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/CacheTest.java +++ /dev/null @@ -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 cache = new Cache(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 cache = new Cache(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); - } - } -} diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/ConnectionUtils.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/util/ConnectionUtils.java deleted file mode 100644 index e02b72c84..000000000 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/ConnectionUtils.java +++ /dev/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); - } - } - } -} diff --git a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/XMPPErrorTest.java b/smack-core/src/integration-test/java/org/jivesoftware/smack/util/XMPPErrorTest.java deleted file mode 100644 index 8d2a0df4f..000000000 --- a/smack-core/src/integration-test/java/org/jivesoftware/smack/util/XMPPErrorTest.java +++ /dev/null @@ -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 = "" + - "" + - ""; - 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 = "" + - "" + - ""; - 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 = "" + - "" + - "" + - "Some special application diagnostic information..." + - "" + - "" + - ""; - 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 = "" + - "" + - "" + - "Some special application diagnostic information!" + - "" + - ""; - 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 = "" + - "" + - "" + - "Some special application diagnostic information!" + - "" + - "" + - ""; - 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; - } -}