1 20 21 package org.jivesoftware.smackx; 22 23 import org.jivesoftware.smack.PacketCollector; 24 import org.jivesoftware.smack.XMPPConnection; 25 import org.jivesoftware.smack.filter.PacketIDFilter; 26 import org.jivesoftware.smack.packet.IQ; 27 import org.jivesoftware.smack.test.SmackTestCase; 28 import org.jivesoftware.smackx.packet.Version; 29 30 35 public class VersionTest extends SmackTestCase { 36 37 public VersionTest(String arg0) { 38 super(arg0); 39 } 40 41 46 public void testGetServerVersion() { 47 Version version = new Version(); 48 version.setType(IQ.Type.GET); 49 version.setTo(getServiceName()); 50 51 PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getPacketID())); 53 54 getConnection(0).sendPacket(version); 55 56 IQ result = (IQ)collector.nextResult(5000); 58 collector.cancel(); 60 61 assertNotNull("No result from the server", result); 62 63 assertEquals("Incorrect result type", IQ.Type.RESULT, result.getType()); 64 assertNotNull("No name specified in the result", ((Version)result).getName()); 65 assertNotNull("No version specified in the result", ((Version)result).getVersion()); 66 } 67 68 protected int getMaxConnections() { 69 return 1; 70 } 71 72 protected void setUp() throws Exception { 73 XMPPConnection.DEBUG_ENABLED = false; 74 super.setUp(); 75 } 76 } 77 | Popular Tags |