mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Fix unit-tests initialization
Remove the TestSuite class. We now have SmackTestSuite ^ | InitExtensions ^ | $UnitTest where most basic setup is done in a static block within SmackTestSuite (only stringencoder setup right now). Also some minor fixes in unit tests.
This commit is contained in:
parent
c6594aec2f
commit
0897b76718
24 changed files with 44 additions and 107 deletions
|
@ -25,11 +25,10 @@ import org.jivesoftware.smack.sasl.packet.SaslStreamElements.AuthMechanism;
|
|||
import org.jivesoftware.smack.sasl.packet.SaslStreamElements.Response;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
||||
public class SCRAMSHA1MechanismTest {
|
||||
public class SCRAMSHA1MechanismTest extends SmackTestSuite {
|
||||
|
||||
public static final String USERNAME = "user";
|
||||
public static final String PASSWORD = "pencil";
|
||||
|
@ -38,11 +37,6 @@ public class SCRAMSHA1MechanismTest {
|
|||
public static final String CLIENT_FINAL_MESSAGE = "c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts=";
|
||||
public static final String SERVER_FINAL_MESSAGE = "v=rmF9pqV8S7suAoZWja4dJRkFsKQ=";
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
SmackTestSuite.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScramSha1Mechanism() throws NotConnectedException, SmackException, InterruptedException {
|
||||
final DummyConnection con = new DummyConnection();
|
||||
|
|
|
@ -23,23 +23,14 @@ import net.iharder.Base64;
|
|||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64.Encoder;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.junit.runners.model.RunnerBuilder;
|
||||
|
||||
/**
|
||||
* The SmackTestSuite takes care of initializing Smack for the unit tests. For example the Base64
|
||||
* encoder is configured.
|
||||
*/
|
||||
public class SmackTestSuite extends Suite {
|
||||
public class SmackTestSuite {
|
||||
|
||||
public SmackTestSuite(Class<?> klass, RunnerBuilder builder) throws InitializationError {
|
||||
super(klass, builder);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
static {
|
||||
org.jivesoftware.smack.util.stringencoder.Base64.setEncoder(new Encoder() {
|
||||
|
||||
@Override
|
||||
|
@ -91,7 +82,6 @@ public class SmackTestSuite extends Suite {
|
|||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
package org.jivesoftware.smackx;
|
||||
|
||||
import org.jivesoftware.smack.extensions.ExtensionsInitializer;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
public class InitExtensions {
|
||||
public class InitExtensions extends SmackTestSuite {
|
||||
|
||||
static {
|
||||
(new ExtensionsInitializer()).initialize();
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
@ -35,7 +36,7 @@ import org.powermock.reflect.Whitebox;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class CloseListenerTest {
|
||||
public class CloseListenerTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.junit.Test;
|
||||
|
@ -36,7 +37,7 @@ import org.powermock.reflect.Whitebox;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataListenerTest {
|
||||
public class DataListenerTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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.smackx.bytestreams.ibb;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.CloseTest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtensionTest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataTest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.OpenTest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.provider.OpenIQProviderTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(SmackTestSuite.class)
|
||||
@Suite.SuiteClasses( { CloseTest.class, DataPacketExtensionTest.class, DataTest.class,
|
||||
OpenTest.class, OpenIQProviderTest.class, CloseListenerTest.class,
|
||||
DataListenerTest.class, InBandBytestreamManagerTest.class,
|
||||
InBandBytestreamRequestTest.class,
|
||||
InBandBytestreamSessionMessageTest.class,
|
||||
InBandBytestreamSessionTest.class, InitiationListenerTest.class })
|
||||
public class IBBTestsSuite {
|
||||
// the class remains completely empty,
|
||||
// being used only as a holder for the above annotations
|
||||
}
|
|
@ -28,6 +28,7 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.util.ConnectionUtils;
|
||||
|
@ -44,7 +45,7 @@ import org.jxmpp.jid.JidTestUtil;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class InBandBytestreamManagerTest {
|
||||
public class InBandBytestreamManagerTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final FullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -37,7 +38,7 @@ import org.mockito.ArgumentCaptor;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class InBandBytestreamRequestTest {
|
||||
public class InBandBytestreamRequestTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
@ -52,7 +53,7 @@ import org.powermock.reflect.Whitebox;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class InBandBytestreamSessionMessageTest {
|
||||
public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final FullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
@ -53,7 +54,7 @@ import org.powermock.reflect.Whitebox;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class InBandBytestreamSessionTest {
|
||||
public class InBandBytestreamSessionTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final FullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.mockito.Mockito.verify;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.junit.Before;
|
||||
|
@ -39,7 +40,7 @@ import org.powermock.reflect.Whitebox;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class InitiationListenerTest {
|
||||
public class InitiationListenerTest extends InitExtensions {
|
||||
|
||||
static final FullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final FullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
@ -32,7 +33,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class CloseTest {
|
||||
public class CloseTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNotInstantiateWithInvalidArguments1() {
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertNull;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
@ -31,7 +32,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataPacketExtensionTest {
|
||||
public class DataPacketExtensionTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNotInstantiateWithInvalidArgument1() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Properties;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
@ -34,7 +35,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataTest {
|
||||
public class DataTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNotInstantiateWithInvalidArgument() {
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
@ -33,7 +34,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class OpenTest {
|
||||
public class OpenTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldNotInstantiateWithInvalidArguments1() {
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.junit.Test;
|
||||
|
@ -36,7 +37,7 @@ import com.jamesmurty.utils.XMLBuilder;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class OpenIQProviderTest {
|
||||
public class OpenIQProviderTest extends InitExtensions {
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
{
|
||||
|
@ -73,7 +74,7 @@ public class OpenIQProviderTest {
|
|||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
||||
private XmlPullParser getParser(String control) throws XmlPullParserException,
|
||||
private static XmlPullParser getParser(String control) throws XmlPullParserException,
|
||||
IOException {
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setInput(new StringReader(control));
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Collection;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base32;
|
||||
import org.jivesoftware.smack.util.stringencoder.StringEncoder;
|
||||
|
@ -36,7 +35,6 @@ import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
|
|||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
@ -44,11 +42,6 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
|
||||
public class EntityCapsManagerTest extends InitExtensions {
|
||||
|
||||
@Before
|
||||
public void initSmackTestSuite() {
|
||||
SmackTestSuite.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="http://xmpp.org/extensions/xep-0115.html#ver-gen-complex">XEP-
|
||||
* 0115 Complex Generation Example</a>
|
||||
|
@ -80,7 +73,7 @@ public class EntityCapsManagerTest extends InitExtensions {
|
|||
assertTrue(di.containsDuplicateIdentities());
|
||||
}
|
||||
|
||||
private void testSimpleDirectoryCache(StringEncoder stringEncoder) throws IOException {
|
||||
private static void testSimpleDirectoryCache(StringEncoder stringEncoder) throws IOException {
|
||||
|
||||
EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(createTempDirectory());
|
||||
EntityCapsManager.setPersistentCache(cache);
|
||||
|
|
|
@ -25,10 +25,11 @@ import org.jivesoftware.smack.DummyConnection;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.iqversion.packet.Version;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VersionTest {
|
||||
public class VersionTest extends InitExtensions {
|
||||
@Test
|
||||
public void checkProvider() throws Exception {
|
||||
// @formatter:off
|
||||
|
|
|
@ -33,21 +33,14 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.ping.packet.Ping;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PingTest extends InitExtensions {
|
||||
|
||||
@Before
|
||||
public void initSmackTestSuite() {
|
||||
SmackTestSuite.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkProvider() throws Exception {
|
||||
// @formatter:off
|
||||
|
|
|
@ -21,21 +21,14 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VCardTest extends InitExtensions {
|
||||
|
||||
@Before
|
||||
public void initSmackTestSuite() {
|
||||
SmackTestSuite.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseFullVCardIQStanza() throws Throwable {
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
|
@ -73,7 +72,7 @@ public class DataLayoutTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLayoutSpecialCharacters() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testLayoutSpecialCharacters() throws XmlPullParserException, IOException {
|
||||
|
||||
DataLayout layout = new DataLayout("Label - & \u00E9 \u00E1 ");
|
||||
Fieldref reffield = new Fieldref("testField1");
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement;
|
||||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.BasicValidateElement;
|
||||
|
@ -45,7 +44,7 @@ public class DataValidationTest {
|
|||
private static final String TEST_OUTPUT_FAIL = "<validate xmlns='http://jabber.org/protocol/xdata-validate'><list-range min='1-1-1' max='999'/></validate>";
|
||||
|
||||
@Test
|
||||
public void testMin() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testMin() throws XmlPullParserException, IOException {
|
||||
|
||||
ValidateElement dv = new BasicValidateElement(null);
|
||||
|
||||
|
@ -67,7 +66,7 @@ public class DataValidationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRange() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testRange() throws XmlPullParserException, IOException {
|
||||
|
||||
ValidateElement dv = new RangeValidateElement("xs:string", "min-val", "max-val");
|
||||
|
||||
|
@ -99,7 +98,7 @@ public class DataValidationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRange2() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testRange2() throws XmlPullParserException, IOException {
|
||||
|
||||
ValidateElement dv = new RangeValidateElement(null, null, null);
|
||||
|
||||
|
@ -124,7 +123,7 @@ public class DataValidationTest {
|
|||
}
|
||||
|
||||
@Test(expected=NumberFormatException.class)
|
||||
public void testRangeFailure() throws IOException, SmackException, XmlPullParserException {
|
||||
public void testRangeFailure() throws IOException, XmlPullParserException {
|
||||
XmlPullParser parser = getParser(TEST_OUTPUT_FAIL);
|
||||
DataValidationProvider.parse(parser);
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ public class DataValidationTest {
|
|||
* @throws XmlPullParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
private XmlPullParser getParser(String output) throws XmlPullParserException, IOException {
|
||||
private static XmlPullParser getParser(String output) throws XmlPullParserException, IOException {
|
||||
return TestUtils.getParser(output, "validate");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class XHTMLExtensionProviderTest {
|
|||
assertThat(sampleXhtml(), equalsCharSequence(attachmentsInfo.getBodies().get(0)));
|
||||
}
|
||||
|
||||
private String sampleXhtml() {
|
||||
private static String sampleXhtml() {
|
||||
return "<body xmlns='http://www.w3.org/1999/xhtml'>" +
|
||||
"<span style='color: rgb(0, 0, 0); font-family: sans-serif, 'trebuchet ms'" +
|
||||
", 'lucida grande', 'lucida sans unicode', arial, helvetica, " +
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
|
||||
/**
|
||||
* This class can be used in conjunction with a mocked XMPP connection (
|
||||
* {@link ConnectionUtils#createMockedConnection(Protocol, String, String)}) to
|
||||
* {@link ConnectionUtils#createMockedConnection(Protocol, org.jxmpp.jid.FullJid, org.jxmpp.jid.DomainBareJid)}) to
|
||||
* verify an XMPP protocol. This can be accomplished in the following was:
|
||||
* <ul>
|
||||
* <li>add responses to packets sent over the mocked XMPP connection by the
|
||||
|
@ -176,7 +176,7 @@ public class Protocol {
|
|||
return requests;
|
||||
}
|
||||
|
||||
private String prettyFormat(String input, int indent) {
|
||||
private static String prettyFormat(String input, int indent) {
|
||||
try {
|
||||
Source xmlInput = new StreamSource(new StringReader(input));
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
|
@ -193,7 +193,7 @@ public class Protocol {
|
|||
}
|
||||
}
|
||||
|
||||
private String prettyFormat(String input) {
|
||||
private static String prettyFormat(String input) {
|
||||
return prettyFormat(input, 2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue