1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 12:37:58 +01:00

Fix or suppress warnings

This commit is contained in:
Florian Schmaus 2014-04-03 23:00:36 +02:00
parent d8a5610d7b
commit ef43ba6322
14 changed files with 40 additions and 42 deletions

View file

@ -24,7 +24,9 @@ import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
import org.jivesoftware.smack.util.StringUtils;
import java.util.regex.Matcher;
@ -78,6 +80,7 @@ class HTTPProxySocketFactory
{
String proxyhost = proxy.getProxyAddress();
int proxyPort = proxy.getProxyPort();
@SuppressWarnings("resource")
Socket socket = new Socket(proxyhost,proxyPort);
String hostport = "CONNECT " + host + ":" + port;
String proxyLine;

View file

@ -22,6 +22,7 @@ import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
/**
@ -67,6 +68,7 @@ public class Socks4ProxySocketFactory
}
@SuppressWarnings("resource")
private Socket socks4ProxifiedSocket(String host, int port)
throws IOException
{

View file

@ -16,13 +16,13 @@
*/
package org.jivesoftware.smack.util;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.fail;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLNotEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Locale;
import java.util.Properties;
@ -49,7 +49,6 @@ public class PacketParserUtilsTest {
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
}
@SuppressWarnings("deprecation")
@Test
public void singleMessageBodyTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
@ -199,7 +198,6 @@ public class PacketParserUtilsTest {
}
@SuppressWarnings("deprecation")
@Test
public void singleMessageSubjectTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
@ -349,7 +347,6 @@ public class PacketParserUtilsTest {
}
@SuppressWarnings("deprecation")
@Test
public void multipleMessageBodiesTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
@ -503,7 +500,6 @@ public class PacketParserUtilsTest {
}
@SuppressWarnings("deprecation")
@Test
public void multipleMessageSubjectsTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage();
@ -657,7 +653,6 @@ public class PacketParserUtilsTest {
}
@SuppressWarnings("deprecation")
@Test
public void invalidMessageBodyContainingTagTest() throws Exception {
String control = XMLBuilder.create("message")
@ -691,7 +686,6 @@ public class PacketParserUtilsTest {
}
@SuppressWarnings("deprecation")
@Test
public void invalidXMLInMessageBody() throws Exception {
String validControl = XMLBuilder.create("message")
@ -768,7 +762,6 @@ public class PacketParserUtilsTest {
assertXMLEqual(stanza, presence.toXML().toString());
}
@SuppressWarnings("deprecation")
@Test
public void validatePresenceProbe() throws Exception {
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>";
@ -779,7 +772,6 @@ public class PacketParserUtilsTest {
assertEquals(Presence.Type.unsubscribed, presence.getType());
}
@SuppressWarnings("deprecation")
@Test
public void validatePresenceOptionalElements() throws Exception {
String stanza = "<presence xml:lang='en' type='unsubscribed'>"

View file

@ -21,6 +21,7 @@ import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.provider.ProviderManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
@ -184,7 +185,8 @@ public class EnhancedDebuggerWindow {
* Creates the main debug window that provides information about Smack and also shows
* a tab panel for each connection that is being debugged.
*/
private void createDebug() {
@SuppressWarnings({ "rawtypes", "unchecked" })
private void createDebug() {
frame = new JFrame("Smack Debug Window");

View file

@ -422,7 +422,6 @@ public class EntityCapsManager extends Manager {
*
* If we are connected and there was already a presence send, another
* presence is send to inform others about your new Entity Caps node string.
* @throws NotConnectedException
*
*/
public void updateLocalEntityCaps() {

View file

@ -269,7 +269,8 @@ abstract public class Node
*
* @param listener The handler for the event
*/
public void addItemEventListener(ItemEventListener listener)
@SuppressWarnings("unchecked")
public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{
PacketListener conListener = new ItemEventTranslator(listener);
itemEventToListenerMap.put(listener, conListener);
@ -281,7 +282,7 @@ abstract public class Node
*
* @param listener The handler to unregister
*/
public void removeItemEventListener(ItemEventListener listener)
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{
PacketListener conListener = itemEventToListenerMap.remove(listener);
@ -396,14 +397,16 @@ abstract public class Node
*/
public class ItemEventTranslator implements PacketListener
{
private ItemEventListener listener;
@SuppressWarnings("rawtypes")
private ItemEventListener listener;
public ItemEventTranslator(ItemEventListener eventListener)
public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener)
{
listener = eventListener;
}
public void processPacket(Packet packet)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processPacket(Packet packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
@ -414,7 +417,7 @@ abstract public class Node
{
delay = (DelayInformation)packet.getExtension("x", "jabber:x:delay");
}
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), (List<Item>)itemsElem.getItems(), getSubscriptionIds(packet), (delay == null ? null : delay.getStamp()));
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), (List<Item>)itemsElem.getItems(), getSubscriptionIds(packet), (delay == null ? null : delay.getStamp()));
listener.handlePublishedItems(eventItems);
}
}
@ -448,7 +451,8 @@ abstract public class Node
{
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
Collection<? extends PacketExtension> pubItems = itemsElem.getItems();
Iterator<RetractItem> it = (Iterator<RetractItem>)pubItems.iterator();
@SuppressWarnings("unchecked")
Iterator<RetractItem> it = (Iterator<RetractItem>)pubItems.iterator();
List<String> items = new ArrayList<String>(pubItems.size());
while (it.hasNext())

View file

@ -30,7 +30,6 @@ import java.io.IOException;
*
* @author Vyacheslav Blinov
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
public class XHTMLExtensionProvider implements PacketExtensionProvider {
public static final String BODY_ELEMENT = "body";

View file

@ -16,8 +16,9 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb.packet;
import static junit.framework.Assert.*;
import static org.custommonkey.xmlunit.XMLAssert.*;
import static org.junit.Assert.assertEquals;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.util.Properties;

View file

@ -16,8 +16,9 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb.packet;
import static junit.framework.Assert.*;
import static org.custommonkey.xmlunit.XMLAssert.*;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.Properties;

View file

@ -16,8 +16,9 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb.packet;
import static junit.framework.Assert.*;
import static org.custommonkey.xmlunit.XMLAssert.*;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
import java.util.Properties;

View file

@ -16,8 +16,8 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb.packet;
import static junit.framework.Assert.*;
import static org.custommonkey.xmlunit.XMLAssert.*;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import java.util.Properties;

View file

@ -192,6 +192,7 @@ public class Socks5ProxyTest {
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
proxy.start();
@SuppressWarnings("resource")
Socket socket = new Socket(proxy.getLocalAddresses().get(0), proxy.getPort());
OutputStream out = socket.getOutputStream();
@ -222,6 +223,7 @@ public class Socks5ProxyTest {
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
proxy.start();
@SuppressWarnings("resource")
Socket socket = new Socket(proxy.getLocalAddresses().get(0), proxy.getPort());
OutputStream out = socket.getOutputStream();
@ -252,6 +254,7 @@ public class Socks5ProxyTest {
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
proxy.start();
@SuppressWarnings("resource")
Socket socket = new Socket(proxy.getLocalAddresses().get(0), proxy.getPort());
OutputStream out = socket.getOutputStream();
@ -300,6 +303,7 @@ public class Socks5ProxyTest {
// add digest to allow connection
proxy.addTransfer(digest);
@SuppressWarnings("resource")
Socket socket = new Socket(proxy.getLocalAddresses().get(0), proxy.getPort());
OutputStream out = socket.getOutputStream();

View file

@ -20,25 +20,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.iqversion.packet.Version;
import org.junit.Before;
import org.junit.Test;
public class VersionTest {
private DummyConnection dummyCon;
private ThreadedDummyConnection threadedCon;
@Before
public void setup() {
dummyCon = new DummyConnection();
threadedCon = new ThreadedDummyConnection();
}
@Test
public void checkProvider() throws Exception {
// @formatter:off

View file

@ -86,7 +86,8 @@ public class ConnectionDetachedPacketCollectorTest
catch (InterruptedException e)
{
}
Packet packet = collector.nextResult();
@SuppressWarnings("unused")
Packet packet = collector.nextResult();
// System.out.println(Thread.currentThread().getName() + " packet: " + packet);
}
}