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

View File

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

View File

@ -16,13 +16,13 @@
*/ */
package org.jivesoftware.smack.util; 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.assertXMLEqual;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLNotEqual; 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.assertTrue;
import static org.junit.Assert.fail;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
@ -49,7 +49,6 @@ public class PacketParserUtilsTest {
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
} }
@SuppressWarnings("deprecation")
@Test @Test
public void singleMessageBodyTest() throws Exception { public void singleMessageBodyTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage(); String defaultLanguage = Packet.getDefaultLanguage();
@ -199,7 +198,6 @@ public class PacketParserUtilsTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void singleMessageSubjectTest() throws Exception { public void singleMessageSubjectTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage(); String defaultLanguage = Packet.getDefaultLanguage();
@ -349,7 +347,6 @@ public class PacketParserUtilsTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void multipleMessageBodiesTest() throws Exception { public void multipleMessageBodiesTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage(); String defaultLanguage = Packet.getDefaultLanguage();
@ -503,7 +500,6 @@ public class PacketParserUtilsTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void multipleMessageSubjectsTest() throws Exception { public void multipleMessageSubjectsTest() throws Exception {
String defaultLanguage = Packet.getDefaultLanguage(); String defaultLanguage = Packet.getDefaultLanguage();
@ -657,7 +653,6 @@ public class PacketParserUtilsTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void invalidMessageBodyContainingTagTest() throws Exception { public void invalidMessageBodyContainingTagTest() throws Exception {
String control = XMLBuilder.create("message") String control = XMLBuilder.create("message")
@ -691,7 +686,6 @@ public class PacketParserUtilsTest {
} }
@SuppressWarnings("deprecation")
@Test @Test
public void invalidXMLInMessageBody() throws Exception { public void invalidXMLInMessageBody() throws Exception {
String validControl = XMLBuilder.create("message") String validControl = XMLBuilder.create("message")
@ -768,7 +762,6 @@ public class PacketParserUtilsTest {
assertXMLEqual(stanza, presence.toXML().toString()); assertXMLEqual(stanza, presence.toXML().toString());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void validatePresenceProbe() throws Exception { public void validatePresenceProbe() throws Exception {
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>"; 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()); assertEquals(Presence.Type.unsubscribed, presence.getType());
} }
@SuppressWarnings("deprecation")
@Test @Test
public void validatePresenceOptionalElements() throws Exception { public void validatePresenceOptionalElements() throws Exception {
String stanza = "<presence xml:lang='en' type='unsubscribed'>" 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 org.jivesoftware.smack.provider.ProviderManager;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.net.URL; import java.net.URL;
@ -184,7 +185,8 @@ public class EnhancedDebuggerWindow {
* Creates the main debug window that provides information about Smack and also shows * Creates the main debug window that provides information about Smack and also shows
* a tab panel for each connection that is being debugged. * 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"); 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 * 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. * presence is send to inform others about your new Entity Caps node string.
* @throws NotConnectedException
* *
*/ */
public void updateLocalEntityCaps() { public void updateLocalEntityCaps() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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