1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Add more checkstyle tests

- Lines containing tab(s) after space
- Usage of printStackTrace
- Usage of println
- Add SupressionCommentFilter module

SuppressionCommentFilter can be enabled with
// CHECKSTYLE:OFF
and disabled with
// CHECKSTYLE:ON
This commit is contained in:
Florian Schmaus 2015-03-17 21:19:06 +01:00
parent 4f64bb1036
commit b2221d5483
59 changed files with 382 additions and 202 deletions

View file

@ -134,17 +134,11 @@ public class DummyConnection extends AbstractXMPPConnection {
@Override
public void send(PlainStreamElement element) {
if (SmackConfiguration.DEBUG) {
System.out.println("[SEND]: " + element.toXML());
}
queue.add(element);
}
@Override
protected void sendStanzaInternal(Stanza packet) {
if (SmackConfiguration.DEBUG) {
System.out.println("[SEND]: " + packet.toXML());
}
queue.add(packet);
}
@ -194,10 +188,6 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param packet the packet to process.
*/
public void processPacket(Stanza packet) {
if (SmackConfiguration.DEBUG) {
System.out.println("[RECV]: " + packet.toXML());
}
invokePacketCollectorsAndNotifyRecvListeners(packet);
}

View file

@ -20,6 +20,8 @@ import java.io.IOException;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ;
@ -33,6 +35,8 @@ import org.jivesoftware.smack.packet.IQ.Type;
*
*/
public class ThreadedDummyConnection extends DummyConnection {
private static final Logger LOGGER = Logger.getLogger(ThreadedDummyConnection.class.getName());
private BlockingQueue<IQ> replyQ = new ArrayBlockingQueue<IQ>(1);
private BlockingQueue<Stanza> messageQ = new LinkedBlockingQueue<Stanza>(5);
private volatile boolean timeout = false;
@ -82,7 +86,7 @@ public class ThreadedDummyConnection extends DummyConnection {
if (!messageQ.isEmpty())
new ProcessQueue(messageQ).start();
else
System.out.println("No messages to process");
LOGGER.warning("No messages to process");
}
class ProcessQueue extends Thread {
@ -97,7 +101,7 @@ public class ThreadedDummyConnection extends DummyConnection {
try {
processPacket(processQ.take());
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.log(Level.WARNING, "exception", e);
}
}
}

View file

@ -754,25 +754,30 @@ public class PacketParserUtilsTest {
@Test
public void validateSimplePresence() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence from='juliet@example.com/balcony' to='romeo@example.net'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXMLEqual(stanza, presence.toXML().toString());
// CHECKSTYLE:ON
}
@Test
public void validatePresenceProbe() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXMLEqual(stanza, presence.toXML().toString());
assertEquals(Presence.Type.unsubscribed, presence.getType());
// CHECKSTYLE:ON
}
@Test
public void validatePresenceOptionalElements() throws Exception {
// CHECKSTYLE:OFF
String stanza = "<presence xml:lang='en' type='unsubscribed'>"
+ "<show>dnd</show>"
+ "<status>Wooing Juliet</status>"
@ -786,6 +791,7 @@ public class PacketParserUtilsTest {
assertEquals("en", presence.getLanguage());
assertEquals("Wooing Juliet", presence.getStatus());
assertEquals(1, presence.getPriority());
// CHECKSTYLE:ON
}
@Test