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

's;^\s+$;;' on all source files

And add checkstyle test for lines containing only whitespace characters.
This commit is contained in:
Florian Schmaus 2015-03-17 11:33:02 +01:00
parent 05c97c494b
commit 0fde39fa45
193 changed files with 1066 additions and 1062 deletions

View file

@ -133,7 +133,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
itemToPublish.setNode("romeo/avatar");
itemToPublish.setAction(DiscoverItems.Item.UPDATE_ACTION);
itemsToPublish.addItem(itemToPublish);
try {
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getServiceName(),
itemsToPublish);
@ -141,7 +141,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
catch (Exception e) {
fail(e.getMessage());
}
}*/
protected int getMaxConnections() {

View file

@ -140,7 +140,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
Socks5BytestreamSession session = initiatorByteStreamManager.establishSession(
targetConnection.getUser());
OutputStream outputStream = session.getOutputStream();
assertTrue(session.isDirect());
// verify stream
@ -284,9 +284,9 @@ public class Socks5ByteStreamTest extends SmackTestCase {
Socks5BytestreamManager initiatorByteStreamManager = Socks5BytestreamManager.getBytestreamManager(initiatorConnection);
Socks5BytestreamSession session = initiatorByteStreamManager.establishSession(targetConnection.getUser());
assertTrue(session.isMediated());
// verify stream
final byte[] receivedData = new byte[3];
final InputStream inputStream = session.getInputStream();

View file

@ -81,7 +81,7 @@ public class AdHocCommandDiscoTest extends SmackTestCase {
};
}
});
AdHocCommandManager manager2 = AdHocCommandManager.getAddHocCommandsManager(getConnection(1));
DiscoverItems items = manager2.discoverCommands(getFullJID(0));

View file

@ -47,7 +47,7 @@ public class EntityCapsTest extends SmackTestCase {
sdm1 = ServiceDiscoveryManager.getInstanceFor(con1);
letsAllBeFriends();
}
public void testLocalEntityCaps() throws InterruptedException {
DiscoverInfo info = EntityCapsManager.getDiscoveryInfoByNodeVer(ecm1.getLocalNodeVer());
assertFalse(info.containsFeature(DISCOVER_TEST_FEATURE));

View file

@ -33,7 +33,7 @@ class CarExtension implements PacketExtension
color = col;
numTires = num;
}
public String getColor()
{
return color;
@ -59,5 +59,5 @@ class CarExtension implements PacketExtension
return "<" + getElementName() + " xmlns='" + getNamespace() + "'><paint color='" +
getColor() + "'/><tires num='" + getNumTires() + "'/></" + getElementName() + ">";
}
}

View file

@ -32,11 +32,11 @@ public class CarExtensionProvider extends PacketExtensionProvider
{
String color = null;
int numTires = 0;
for (int i=0; i<2; i++)
{
while (parser.next() != XmlPullParser.START_TAG);
if (parser.getName().equals("paint"))
{
color = parser.getAttributeValue(0);
@ -49,5 +49,5 @@ public class CarExtensionProvider extends PacketExtensionProvider
while (parser.next() != XmlPullParser.END_TAG);
return new CarExtension(color, numTires);
}
}

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.jivesoftware.smackx.pubsub;
import java.util.Iterator;
import java.util.List;
@ -43,10 +43,10 @@ public class EntityUseCases extends SingleUserTestCase
DiscoverInfo info = myNode.discoverInfo();
assertTrue(info.getIdentities().hasNext());
Identity ident = info.getIdentities().next();
assertEquals("leaf", ident.getType());
}
public void testDiscoverNodeItems() throws Exception
{
LeafNode myNode = getRandomPubnode(getManager(), true, false);
@ -55,33 +55,33 @@ public class EntityUseCases extends SingleUserTestCase
myNode.send(new Item());
myNode.send(new Item());
DiscoverItems items = myNode.discoverItems();
int count = 0;
for(Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); it.next(),count++);
assertEquals(4, count);
}
public void testDiscoverSubscriptions() throws Exception
{
getManager().getSubscriptions();
}
public void testDiscoverNodeSubscriptions() throws Exception
{
LeafNode myNode = getRandomPubnode(getManager(), true, true);
myNode.subscribe(getConnection(0).getUser());
List<Subscription> subscriptions = myNode.getSubscriptions();
assertTrue(subscriptions.size() < 3);
for (Subscription subscription : subscriptions)
{
assertNull(subscription.getNode());
}
}
public void testRetrieveAffiliation() throws Exception
{
getManager().getAffiliations();

View file

@ -45,7 +45,7 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
node.send((Item)null);
node.send((Item)null);
node.send((Item)null);
LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId());
user2Node.subscribe(getBareJID(1));
@ -61,7 +61,7 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
node.send((Item)null);
node.send((Item)null);
node.send((Item)null);
LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId());
Subscription sub1 = user2Node.subscribe(getBareJID(1));

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.jivesoftware.smackx.pubsub;
import java.util.Collection;
import org.jivesoftware.smack.XMPPException;
@ -46,7 +46,7 @@ public class OwnerUseCases extends SingleUserTestCase
{
// Generate reasonably unique for multiple tests
String id = "TestConfigNode" + System.currentTimeMillis();
// Create and configure a node
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open);
@ -56,7 +56,7 @@ public class OwnerUseCases extends SingleUserTestCase
form.setPublishModel(PublishModel.open);
LeafNode node = (LeafNode)getManager().createNode(id, form);
ConfigureForm currentForm = node.getNodeConfiguration();
assertEquals(AccessModel.open, currentForm.getAccessModel());
assertFalse(currentForm.isDeliverPayloads());
@ -69,7 +69,7 @@ public class OwnerUseCases extends SingleUserTestCase
{
// Generate reasonably unique for multiple tests
String id = "TestConfigNode2" + System.currentTimeMillis();
// Create and configure a node
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open);
@ -77,16 +77,16 @@ public class OwnerUseCases extends SingleUserTestCase
form.setNotifyRetract(true);
form.setPersistentItems(true);
form.setPublishModel(PublishModel.open);
LeafNode myNode = (LeafNode)getManager().createNode(id, form);
ConfigureForm config = myNode.getNodeConfiguration();
assertEquals(AccessModel.open, config.getAccessModel());
assertFalse(config.isDeliverPayloads());
assertTrue(config.isNotifyRetract());
assertTrue(config.isPersistItems());
assertEquals(PublishModel.open, config.getPublishModel());
ConfigureForm submitForm = new ConfigureForm(config.createAnswerForm());
submitForm.setAccessModel(AccessModel.whitelist);
submitForm.setDeliverPayloads(true);
@ -108,14 +108,14 @@ public class OwnerUseCases extends SingleUserTestCase
ConfigureForm form = getManager().getDefaultConfiguration();
assertNotNull(form);
}
public void testDeleteNode() throws Exception
{
LeafNode myNode = getManager().createNode();
assertNotNull(getManager().getNode(myNode.getId()));
getManager(0).deleteNode(myNode.getId());
try
{
assertNull(getManager().getNode(myNode.getId()));
@ -125,23 +125,23 @@ public class OwnerUseCases extends SingleUserTestCase
{
}
}
public void testPurgeItems() throws XMPPException
{
LeafNode node = getRandomPubnode(getManager(), true, false);
node.send(new Item());
node.send(new Item());
node.send(new Item());
node.send(new Item());
node.send(new Item());
Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 5);
node.deleteAllItems();
items = node.getItems();
// Pubsub service may keep the last notification (in spec), so 0 or 1 may be returned on get items.
assertTrue(items.size() < 2);
}

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.jivesoftware.smackx.pubsub;
import java.util.Collection;
import java.util.List;
@ -126,39 +126,39 @@ public class PublisherUseCases extends SingleUserTestCase
public void testDeleteItems() throws XMPPException
{
LeafNode node = getPubnode(true, false);
node.send(new Item("1"));
node.send(new Item("2"));
node.send(new Item("3"));
node.send(new Item("4"));
node.deleteItem("1");
Collection<? extends Item> items = node.getItems();
assertEquals(3, items.size());
}
public void testPersistItems() throws XMPPException
{
LeafNode node = getPubnode(true, false);
node.send(new Item("1"));
node.send(new Item("2"));
node.send(new Item("3"));
node.send(new Item("4"));
Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 4);
}
public void testItemOverwritten() throws XMPPException
{
LeafNode node = getPubnode(true, false);
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test", null, "<test/>")));
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test2", null, "<test2/>")));
List<? extends Item> items = node.getItems();
assertEquals(1, items.size());
assertEquals("1", items.get(0).getId());

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.jivesoftware.smackx.pubsub;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.util.ArrayList;
@ -40,7 +40,7 @@ public class SubscriberUseCases extends SingleUserTestCase
{
LeafNode node = getPubnode(false, false);
Subscription sub = node.subscribe(getJid());
assertEquals(getJid(), sub.getJid());
assertNotNull(sub.getId());
assertEquals(node.getId(), sub.getNode());
@ -50,7 +50,7 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testSubscribeBadJid() throws Exception
{
LeafNode node = getPubnode(false, false);
try
{
node.subscribe("this@over.here");
@ -71,12 +71,12 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = getPubnode(false, false);
node.subscribe(getJid(), form);
}
public void testSubscribeConfigRequired() throws Exception
{
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open);
// Openfire specific field - nothing in the spec yet
FormField required = new FormField("pubsub#subscription_required");
required.setType(FormField.TYPE_BOOLEAN);
@ -85,31 +85,31 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = (LeafNode)getManager().createNode("Pubnode" + System.currentTimeMillis(), form);
Subscription sub = node.subscribe(getJid());
assertEquals(getJid(), sub.getJid());
assertNotNull(sub.getId());
assertEquals(node.getId(), sub.getNode());
assertEquals(true, sub.isConfigRequired());
}
public void testUnsubscribe() throws Exception
{
LeafNode node = getPubnode(false, false);
node.subscribe(getJid());
Collection<Subscription> subs = node.getSubscriptions();
node.unsubscribe(getJid());
Collection<Subscription> afterSubs = node.getSubscriptions();
assertEquals(subs.size()-1, afterSubs.size());
}
public void testUnsubscribeWithMultipleNoSubId() throws Exception
{
LeafNode node = getPubnode(false, false);
node.subscribe(getBareJID(0));
node.subscribe(getBareJID(0));
node.subscribe(getBareJID(0));
try
{
node.unsubscribe(getBareJID(0));
@ -119,7 +119,7 @@ public class SubscriberUseCases extends SingleUserTestCase
{
}
}
public void testUnsubscribeWithMultipleWithSubId() throws Exception
{
LeafNode node = getPubnode(false, false);
@ -128,7 +128,7 @@ public class SubscriberUseCases extends SingleUserTestCase
node.subscribe(getJid());
node.unsubscribe(getJid(), sub.getId());
}
public void testGetOptions() throws Exception
{
LeafNode node = getPubnode(false, false);
@ -136,7 +136,7 @@ public class SubscriberUseCases extends SingleUserTestCase
SubscribeForm form = node.getSubscriptionOptions(getJid(), sub.getId());
assertNotNull(form);
}
// public void testSubscribeWithConfig() throws Exception
// {
// LeafNode node = getPubnode(false, false);
@ -154,7 +154,7 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = getPubnode(true, false);
runNodeTests(node);
}
private void runNodeTests(LeafNode node) throws Exception
{
node.send((Item)null);
@ -162,17 +162,17 @@ public class SubscriberUseCases extends SingleUserTestCase
node.send((Item)null);
node.send((Item)null);
node.send((Item)null);
Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 5);
long curTime = System.currentTimeMillis();
node.send(new Item("1-" + curTime));
node.send(new Item("2-" + curTime));
node.send(new Item("3-" + curTime));
node.send(new Item("4-" + curTime));
node.send(new Item("5-" + curTime));
items = node.getItems();
assertTrue(items.size() == 10);
@ -183,35 +183,35 @@ public class SubscriberUseCases extends SingleUserTestCase
idPayload.put("7-" + curTime, "<a href=\"/up/here\"/>");
idPayload.put("8-" + curTime, "<entity>text<inner></inner></entity>");
idPayload.put("9-" + curTime, "<entity><inner><text></text></inner></entity>");
for (Map.Entry<String, String> payload : idPayload.entrySet())
{
payloadNode.send(new PayloadItem<SimplePayload>(payload.getKey(), new SimplePayload("a", "pubsub:test", payload.getValue())));
}
payloadNode.send(new PayloadItem<SimplePayload>("6-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test'/>")));
payloadNode.send(new PayloadItem<SimplePayload>("7-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href=\'/up/here\'/>")));
payloadNode.send(new PayloadItem<SimplePayload>("8-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'>text<inner>a</inner></entity>")));
payloadNode.send(new PayloadItem<SimplePayload>("9-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>")));
List<PayloadItem<SimplePayload>> payloadItems = payloadNode.getItems();
Map<String, PayloadItem<SimplePayload>> idMap = new HashMap<String, PayloadItem<SimplePayload>>();
for (PayloadItem<SimplePayload> payloadItem : payloadItems)
{
idMap.put(payloadItem.getId(), payloadItem);
}
assertEquals(4, payloadItems.size());
PayloadItem<SimplePayload> testItem = idMap.get("6-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test'/>", testItem.getPayload().toXML());
testItem = idMap.get("7-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test' href=\'/up/here\'/>", testItem.getPayload().toXML());
testItem = idMap.get("8-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", testItem.getPayload().toXML());
@ -224,13 +224,13 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testGetSpecifiedItems() throws Exception
{
LeafNode node = getPubnode(true, true);
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
node.send(new PayloadItem<SimplePayload>("2", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='2'/>")));
node.send(new PayloadItem<SimplePayload>("3", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='3'/>")));
node.send(new PayloadItem<SimplePayload>("4", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='4'/>")));
node.send(new PayloadItem<SimplePayload>("5", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='5'/>")));
Collection<String> ids = new ArrayList<String>(3);
ids.add("1");
ids.add("3");
@ -249,13 +249,13 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testGetLastNItems() throws XMPPException
{
LeafNode node = getPubnode(true, false);
node.send(new Item("1"));
node.send(new Item("2"));
node.send(new Item("3"));
node.send(new Item("4"));
node.send(new Item("5"));
List<Item> items = node.getItems(2);
assertEquals(2, items.size());
assertTrue(listContainsId("4", items));

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.pubsub.test.SingleUserTestCase;

View file

@ -59,7 +59,7 @@ public class TestEvents extends SmackTestCase
{
String nodeId = "MyTestNode";
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = null;
try
{
@ -72,10 +72,10 @@ public class TestEvents extends SmackTestCase
else
throw e;
}
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
assertNotNull(subNode);
}
@ -84,7 +84,7 @@ public class TestEvents extends SmackTestCase
// Setup event source
String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, false, true);
BlockingQueue<NodeConfigCoordinator> queue = new ArrayBlockingQueue<NodeConfigCoordinator>(3);
@ -96,7 +96,7 @@ public class TestEvents extends SmackTestCase
NodeConfigListener sub1Handler = new NodeConfigCoordinator(queue, "sub1");
subNode.subscribe(getConnection(1).getUser());
subNode.addConfigurationListener(sub1Handler);
ConfigureForm currentConfig = creatorNode.getNodeConfiguration();
ConfigureForm form = new ConfigureForm(currentConfig.createAnswerForm());
form.setPersistentItems(true);
@ -107,7 +107,7 @@ public class TestEvents extends SmackTestCase
ConfigurationEvent event = queue.poll(5, TimeUnit.SECONDS).event;
assertEquals(nodeId, event.getNode());
assertNull(event.getConfiguration());
currentConfig = creatorNode.getNodeConfiguration();
form = new ConfigureForm(currentConfig.createAnswerForm());
form.setDeliverPayloads(true);
@ -128,7 +128,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -136,16 +136,16 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.send(new Item(itemId));
ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().iterator().next().getId());
}
public void testPublishAndReceiveNoPayload() throws Exception
{
// Setup event source
@ -154,7 +154,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -162,11 +162,11 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.publish(new Item(itemId));
ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().get(0).getId());
@ -180,7 +180,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -188,12 +188,12 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
String payloadString = "<book xmlns=\"pubsub:test:book\"><author>Sir Arthur Conan Doyle</author></book>";
creatorNode.send(new PayloadItem<SimplePayload>(itemId, new SimplePayload("book", "pubsub:test:book", payloadString)));
ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size());
PayloadItem<SimplePayload> item = coord.events.getItems().get(0);
@ -221,7 +221,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
Node subNode = subMgr.getNode(nodeId);
@ -229,12 +229,12 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<CarExtension>> sub1Handler = new ItemEventCoordinator<PayloadItem<CarExtension>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
String payloadString = "<car xmlns='pubsub:test:vehicle'><paint color='green'/><tires num='4'/></car>";
creatorNode.send(new PayloadItem(itemId, new SimplePayload("car", "pubsub:test:vehicle", payloadString)));
ItemEventCoordinator<PayloadItem<CarExtension>> coord = queue.take();
assertEquals(1, coord.events.getItems().size());
PayloadItem item = coord.events.getItems().get(0);
@ -246,7 +246,7 @@ public class TestEvents extends SmackTestCase
assertEquals(4, car.getNumTires());
}
*/
public void testSendAndReceiveMultipleSubs() throws Exception
{
// Setup event source
@ -255,7 +255,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -263,7 +263,7 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
ItemEventCoordinator<Item> sub2Handler = new ItemEventCoordinator<Item>(queue, "sub2");
subNode.addItemEventListener(sub2Handler);
Subscription sub2 = subNode.subscribe(getConnection(1).getUser());
@ -271,16 +271,16 @@ public class TestEvents extends SmackTestCase
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.send(new Item(itemId));
for(int i=0; i<2; i++)
{
ItemEventCoordinator<Item> coord = queue.poll(10, TimeUnit.SECONDS);
if (coord == null)
fail();
assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().iterator().next().getId());
if (coord.id.equals("sub1") || coord.id.equals("sub2"))
{
assertEquals(2, coord.events.getSubscriptions().size());
@ -293,14 +293,14 @@ public class TestEvents extends SmackTestCase
// Setup event source
String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3);
ItemEventCoordinator<PayloadItem<SimplePayload>> creatorHandler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "creator");
creatorNode.addItemEventListener(creatorHandler);
creatorNode.subscribe(getConnection(0).getUser());
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -308,24 +308,24 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
ItemEventCoordinator<PayloadItem<SimplePayload>> sub2Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub2");
subNode.addItemEventListener(sub2Handler);
Subscription sub2 = subNode.subscribe(getConnection(1).getUser());
assertEquals(Subscription.State.subscribed, sub1.getState());
assertEquals(Subscription.State.subscribed, sub2.getState());
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
Collection<PayloadItem<SimplePayload>> items = new ArrayList<PayloadItem<SimplePayload>>(3);
String ids[] = {"First-" + itemId, "Second-" + itemId, "Third-" + itemId};
items.add(new PayloadItem<SimplePayload>(ids[0], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
items.add(new PayloadItem<SimplePayload>(ids[1], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
items.add(new PayloadItem<SimplePayload>(ids[2], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
creatorNode.send(items);
for(int i=0; i<3; i++)
{
ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS);
@ -350,7 +350,7 @@ public class TestEvents extends SmackTestCase
// Setup event source
String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
// Send event
@ -380,11 +380,11 @@ public class TestEvents extends SmackTestCase
// Setup event source
String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -395,7 +395,7 @@ public class TestEvents extends SmackTestCase
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
Collection<Item> items = new ArrayList<Item>(3);
String id1 = "First-" + itemId;
String id2 = "Second-" + itemId;
@ -404,9 +404,9 @@ public class TestEvents extends SmackTestCase
items.add(new Item(id2));
items.add(new Item(id3));
creatorNode.send(items);
creatorNode.deleteItem(id1);
ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.event.getItemIds().size());
assertEquals(id1, coord.event.getItemIds().get(0));
@ -424,11 +424,11 @@ public class TestEvents extends SmackTestCase
// Setup event source
String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3);
// Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -439,7 +439,7 @@ public class TestEvents extends SmackTestCase
// Send event
String itemId = String.valueOf(System.currentTimeMillis());
Collection<Item> items = new ArrayList<Item>(3);
String id1 = "First-" + itemId;
String id2 = "Second-" + itemId;
@ -448,9 +448,9 @@ public class TestEvents extends SmackTestCase
items.add(new Item(id2));
items.add(new Item(id3));
creatorNode.send(items);
creatorNode.deleteAllItems();
ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS);
assertNull(nodeId, coord.event);
}
@ -461,31 +461,31 @@ public class TestEvents extends SmackTestCase
String nodeId1 = "Node-1-" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
String nodeId2 = "Node-2-" + System.currentTimeMillis();
LeafNode creatorNode1 = getPubnode(creatorMgr, nodeId1, true, false);
LeafNode creatorNode2 = getPubnode(creatorMgr, nodeId2, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode1 = (LeafNode)subMgr.getNode(nodeId1);
LeafNode subNode2 = (LeafNode)subMgr.getNode(nodeId2);
subNode1.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub1"));
subNode2.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub2"));
subNode1.subscribe(getConnection(1).getUser());
subNode2.subscribe(getConnection(1).getUser());
creatorNode1.send(new Item("item1"));
creatorNode2.send(new Item("item2"));
boolean check1 = false;
boolean check2 = false;
for (int i=0; i<2; i++)
{
ItemEventCoordinator<Item> event = queue.poll(5, TimeUnit.SECONDS);
if (event.id.equals("sub1"))
{
assertEquals(event.events.getNodeId(), nodeId1);
@ -506,7 +506,7 @@ public class TestEvents extends SmackTestCase
private BlockingQueue<ItemEventCoordinator<T>> theQueue;
private ItemPublishEvent<T> events;
private String id;
ItemEventCoordinator(BlockingQueue<ItemEventCoordinator<T>> queue, String id)
{
theQueue = queue;
@ -524,15 +524,15 @@ public class TestEvents extends SmackTestCase
{
return "ItemEventCoordinator: " + id;
}
}
class NodeConfigCoordinator implements NodeConfigListener
{
private BlockingQueue<NodeConfigCoordinator> theQueue;
private String id;
private ConfigurationEvent event;
NodeConfigCoordinator(BlockingQueue<NodeConfigCoordinator> queue, String id)
{
theQueue = queue;
@ -558,7 +558,7 @@ public class TestEvents extends SmackTestCase
private BlockingQueue<ItemDeleteCoordinator> theQueue;
private String id;
private ItemDeleteEvent event;
ItemDeleteCoordinator(BlockingQueue<ItemDeleteCoordinator> queue, String id)
{
theQueue = queue;

View file

@ -26,7 +26,7 @@ import junit.framework.TestCase;
public class TestMessageContent extends TestCase
{
String payloadXmlWithNS = "<book xmlns='pubsub:test:book'><author name='Stephen King'/></book>";
public void testItemWithId()
{
Item item = new Item("123");
@ -47,21 +47,21 @@ public class TestMessageContent extends TestCase
public void testSimplePayload()
{
SimplePayload payloadNS = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
assertEquals(payloadXmlWithNS, payloadNS.toXML());
String payloadXmlWithNoNS = "<book><author name='Stephen King'/></book>";
SimplePayload payloadNoNS = new SimplePayload("book", null, "<book><author name='Stephen King'/></book>");
assertEquals(payloadXmlWithNoNS, payloadNoNS.toXML());
}
public void testPayloadItemWithId()
{
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("123", payload);
String xml = "<item id='123'>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML());
assertEquals("item", item.getElementName());
@ -71,7 +71,7 @@ public class TestMessageContent extends TestCase
{
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload);
String xml = "<item>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML());
}
@ -99,14 +99,14 @@ public class TestMessageContent extends TestCase
{
}
}
public void testRetractItem()
{
RetractItem item = new RetractItem("1234");
assertEquals("<retract id='1234'/>", item.toXML());
assertEquals("retract", item.getElementName());
try
{
new RetractItem(null);
@ -116,7 +116,7 @@ public class TestMessageContent extends TestCase
{
}
}
public void testGetItemsRequest()
{
GetItemsRequest request = new GetItemsRequest("testId");
@ -124,10 +124,10 @@ public class TestMessageContent extends TestCase
request = new GetItemsRequest("testId", 5);
assertEquals("<items node='testId' max_items='5'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty");
assertEquals("<items node='testId' subid='qwerty'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty", 5);
assertEquals("<items node='testId' subid='qwerty' max_items='5'/>", request.toXML());
}

View file

@ -55,7 +55,7 @@ abstract public class PubSubTestCase extends SmackTestCase
protected LeafNode getPubnode(PubSubManager pubMgr, boolean persistItems, boolean deliverPayload, String nodeId) throws XMPPException
{
LeafNode node = null;
try
{
node = (LeafNode)pubMgr.getNode(nodeId);
@ -76,7 +76,7 @@ abstract public class PubSubTestCase extends SmackTestCase
if (manager == null)
{
manager = new PubSubManager[getMaxConnections()];
for(int i=0; i<manager.length; i++)
{
manager[i] = new PubSubManager(getConnection(i), getService());
@ -84,7 +84,7 @@ abstract public class PubSubTestCase extends SmackTestCase
}
return manager[idx];
}
protected String getService()
{
return "pubsub." + getServiceName();

View file

@ -31,7 +31,7 @@ public class SingleUserTestCase extends PubSubTestCase
{
return getManager(0);
}
protected LeafNode getPubnode(boolean persistItems, boolean deliverPayload) throws XMPPException
{
return getRandomPubnode(getManager(), persistItems, deliverPayload);

View file

@ -32,8 +32,8 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
*/
public abstract class InBandBytestreamListener implements BytestreamListener {
public void incomingBytestreamRequest(BytestreamRequest request) {
incomingBytestreamRequest((InBandBytestreamRequest) request);
}

View file

@ -70,7 +70,7 @@ import org.jivesoftware.smack.SmackException;
*/
public class Socks5Proxy {
private static final Logger LOGGER = Logger.getLogger(Socks5Proxy.class.getName());
/* SOCKS5 proxy singleton */
private static Socks5Proxy socks5Server;

View file

@ -40,7 +40,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
*/
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
private File cacheDir;
private StringEncoder filenameEncoder;

View file

@ -119,9 +119,9 @@ public class AdHocCommandManager extends Manager {
* ID matches the sessionid attribute sent by command responders.
*/
private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<String, LocalCommand>();
private final ServiceDiscoveryManager serviceDiscoveryManager;
/**
* Thread that reaps stale sessions.
*/

View file

@ -241,13 +241,13 @@ public class AdHocCommandData extends IQ {
public static class SpecificError implements ExtensionElement {
public static final String namespace = "http://jabber.org/protocol/commands";
public SpecificErrorCondition condition;
public SpecificError(SpecificErrorCondition condition) {
this.condition = condition;
}
public String getElementName() {
return condition.toString();
}
@ -258,7 +258,7 @@ public class AdHocCommandData extends IQ {
public SpecificErrorCondition getCondition() {
return condition;
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName());

View file

@ -440,7 +440,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
public int compareTo(DiscoverInfo.Identity other) {
String otherLang = other.lang == null ? "" : other.lang;
String thisLang = lang == null ? "" : lang;
// This can be removed once the deprecated constructor is removed.
String otherType = other.type == null ? "" : other.type;
String thisType = type == null ? "" : type;

View file

@ -47,7 +47,7 @@ public class JivePropertiesExtension implements ExtensionElement {
public static final String ELEMENT = "properties";
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtension.class.getName());
private final Map<String, Object> properties;
public JivePropertiesExtension() {

View file

@ -149,7 +149,7 @@ public class DiscussionHistory {
if (!isConfigured()) {
return null;
}
MUCInitialPresence.History mucHistory = new MUCInitialPresence.History();
if (maxChars > -1) {
mucHistory.setMaxChars(maxChars);

View file

@ -31,5 +31,5 @@ public interface InvitationRejectionListener {
* @param reason the reason why the invitee declined the invitation.
*/
public abstract void invitationDeclined(String invitee, String reason);
}

View file

@ -115,7 +115,7 @@ public class PEPManager {
PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.set);
//pubSub.setFrom(connection.getUser());
// Send the message that contains the roster
connection.sendStanza(pubSub);
}

View file

@ -48,7 +48,7 @@ public class PEPEvent implements ExtensionElement {
this.item = item;
}
public void addPEPItem(PEPItem item) {
this.item = item;
}

View file

@ -28,11 +28,11 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* @author Jeff Williams
*/
public abstract class PEPItem implements ExtensionElement {
String id;
abstract String getNode();
abstract String getItemDetailsXML();
/**
* Creates a new PEPItem.
*
@ -41,7 +41,7 @@ public abstract class PEPItem implements ExtensionElement {
super();
this.id = id;
}
/**
* Returns the XML element name of the extension sub-packet root element.
* Always returns "x"

View file

@ -28,7 +28,7 @@ import org.jivesoftware.smack.packet.IQ;
* @author Jeff Williams
*/
public class PEPPubSub extends IQ {
public static final String ELEMENT = "pubsub";
public static final String NAMESPACE = "http://jabber.org/protocol/pubsub";

View file

@ -44,7 +44,7 @@ public class PrivacyList {
private final String listName;
/** Holds the list of {@link PrivacyItem} */
private final List<PrivacyItem> items;
protected PrivacyList(boolean isActiveList, boolean isDefaultList,
String listName, List<PrivacyItem> privacyItems) {
super();

View file

@ -264,7 +264,7 @@ public class PrivacyListManager extends Manager {
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an empty privacy message
Privacy request = new Privacy();
// Send the package to the server and get the answer
return getRequest(request);
}
@ -371,10 +371,10 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
// Send the package to the server and get the answer
Privacy privacyAnswer = getRequest(request);
return privacyAnswer.getPrivacyList(listName);
}
@ -427,7 +427,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setActiveName(listName);
// Send the package to the server
setRequest(request);
}
@ -443,7 +443,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
// Send the package to the server
setRequest(request);
}
@ -461,7 +461,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDefaultName(listName);
// Send the package to the server
setRequest(request);
}
@ -477,7 +477,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineDefaultList(true);
// Send the package to the server
setRequest(request);
}

View file

@ -303,7 +303,7 @@ public class Privacy extends IQ {
buf.append("<default name=\"").escape(getDefaultName()).append("\"/>");
}
}
// Add the list with their privacy items
for (Map.Entry<String, List<PrivacyItem>> entry : this.getItemLists().entrySet()) {
String listName = entry.getKey();
@ -326,5 +326,5 @@ public class Privacy extends IQ {
return buf;
}
}

View file

@ -74,7 +74,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
return privacy;
}
// Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
boolean done = false;
@ -96,7 +96,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
privacy.setPrivacyList(listName, items);
}
// Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
// Retrieves the required attributes

View file

@ -29,13 +29,13 @@ public enum AccessModel
/** Subscription request must be approved and only subscribers may retrieve items */
authorize,
/** Anyone with a presence subscription of both or from may subscribe and retrieve items */
presence,
/** Anyone in the specified roster group(s) may subscribe and retrieve items */
roster,
/** Only those on a whitelist may subscribe and retrieve items */
whitelist;
}

View file

@ -33,7 +33,7 @@ public class Affiliation implements ExtensionElement
{
protected String node;
protected Type type;
public enum Type
{
member, none, outcast, owner, publisher
@ -50,17 +50,17 @@ public class Affiliation implements ExtensionElement
node = nodeId;
type = affiliation;
}
public String getNodeId()
{
return node;
}
public Type getType()
{
return type;
}
public String getElementName()
{
return "subscription";
@ -77,7 +77,7 @@ public class Affiliation implements ExtensionElement
builder.append(getElementName());
appendAttribute(builder, "node", node);
appendAttribute(builder, "affiliation", type.toString());
builder.append("/>");
return builder.toString();
}

View file

@ -28,12 +28,12 @@ import java.util.List;
public class AffiliationsExtension extends NodeExtension
{
protected List<Affiliation> items = Collections.emptyList();
public AffiliationsExtension()
{
super(PubSubElementType.AFFILIATIONS);
}
public AffiliationsExtension(List<Affiliation> subList)
{
super(PubSubElementType.AFFILIATIONS);
@ -57,12 +57,12 @@ public class AffiliationsExtension extends NodeExtension
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
builder.append(">");
for (Affiliation item : items)
{
builder.append(item.toXML());
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -26,10 +26,10 @@ public enum ChildrenAssociationPolicy
{
/** Anyone may associate leaf nodes with the collection */
all,
/** Only collection node owners may associate leaf nodes with the collection. */
owners,
/** Only those on a whitelist may associate leaf nodes with the collection. */
whitelist;
}

View file

@ -32,18 +32,18 @@ import org.jivesoftware.smack.packet.ExtensionElement;
public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension
{
private ConfigureForm form;
public ConfigurationEvent(String nodeId)
{
super(PubSubElementType.CONFIGURATION, nodeId);
}
public ConfigurationEvent(String nodeId, ConfigureForm configForm)
{
super(PubSubElementType.CONFIGURATION, nodeId);
form = configForm;
}
public ConfigureForm getConfiguration()
{
return form;

View file

@ -45,7 +45,7 @@ public class ConfigureForm extends Form
{
super(configDataForm);
}
/**
* Create a decorator from an existing {@link Form} for node configuration.
* Typically, this can be used to create a decorator for an answer form
@ -57,7 +57,7 @@ public class ConfigureForm extends Form
{
super(nodeConfigForm.getDataFormToSend());
}
/**
* Create a new form for configuring a node. This would typically only be used
* when creating and configuring a node at the same time via {@link PubSubManager#createNode(String, Form)}, since
@ -69,7 +69,7 @@ public class ConfigureForm extends Form
{
super(formType);
}
/**
* Get the currently configured {@link AccessModel}, null if it is not set.
*
@ -78,13 +78,13 @@ public class ConfigureForm extends Form
public AccessModel getAccessModel()
{
String value = getFieldValue(ConfigureNodeFields.access_model);
if (value == null)
return null;
else
return AccessModel.valueOf(value);
}
/**
* Sets the value of access model.
*
@ -118,7 +118,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt);
}
/**
* The id's of the child nodes associated with a collection node (both leaf and collection).
*
@ -128,7 +128,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.children);
}
/**
* Set the list of child node ids that are associated with a collection node.
*
@ -139,7 +139,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.children, FormField.Type.text_multi);
setAnswer(ConfigureNodeFields.children.getFieldName(), children);
}
/**
* Returns the policy that determines who may associate children with the node.
*
@ -148,13 +148,13 @@ public class ConfigureForm extends Form
public ChildrenAssociationPolicy getChildrenAssociationPolicy()
{
String value = getFieldValue(ConfigureNodeFields.children_association_policy);
if (value == null)
return null;
else
return ChildrenAssociationPolicy.valueOf(value);
}
/**
* Sets the policy that determines who may associate children with the node.
*
@ -167,7 +167,7 @@ public class ConfigureForm extends Form
values.add(policy.toString());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
}
/**
* List of JID's that are on the whitelist that determines who can associate child nodes
* with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -179,7 +179,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.children_association_whitelist);
}
/**
* Set the JID's in the whitelist of users that can associate child nodes with the collection
* node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -269,7 +269,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
}
/**
* Sets whether the node will deliver payloads with event notifications.
*
@ -289,7 +289,7 @@ public class ConfigureForm extends Form
public ItemReply getItemReply()
{
String value = getFieldValue(ConfigureNodeFields.itemreply);
if (value == null)
return null;
else
@ -329,7 +329,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_items, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_items.getFieldName(), max);
}
/**
* Gets the maximum payload size in bytes.
*
@ -350,7 +350,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max);
}
/**
* Gets the node type
*
@ -359,13 +359,13 @@ public class ConfigureForm extends Form
public NodeType getNodeType()
{
String value = getFieldValue(ConfigureNodeFields.node_type);
if (value == null)
return null;
else
return NodeType.valueOf(value);
}
/**
* Sets the node type
*
@ -386,7 +386,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
}
/**
* Sets whether subscribers should be notified when the configuration changes.
*
@ -407,7 +407,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
}
/**
* Sets whether subscribers should be notified when the node is deleted.
*
@ -429,7 +429,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
}
/**
* Sets whether subscribers should be notified when items are deleted
* from the node.
@ -441,7 +441,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.notify_retract, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
}
/**
* Determines whether items should be persisted in the node.
*
@ -451,7 +451,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
}
/**
* Sets whether items should be persisted in the node.
*
@ -472,7 +472,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
}
/**
* Sets whether to deliver notifications to available users only.
*
@ -492,7 +492,7 @@ public class ConfigureForm extends Form
public PublishModel getPublishModel()
{
String value = getFieldValue(ConfigureNodeFields.publish_model);
if (value == null)
return null;
else
@ -509,7 +509,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.publish_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString()));
}
/**
* List of the multi user chat rooms that are specified as reply rooms.
*
@ -519,7 +519,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.replyroom);
}
/**
* Sets the multi user chat rooms that are specified as reply rooms.
*
@ -530,7 +530,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms);
}
/**
* Gets the specific JID's for reply to.
*
@ -540,7 +540,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.replyto);
}
/**
* Sets the specific JID's for reply to.
*
@ -551,7 +551,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyto, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos);
}
/**
* Gets the roster groups that are allowed to subscribe and retrieve items.
*
@ -561,7 +561,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
}
/**
* Sets the roster groups that are allowed to subscribe and retrieve items.
*
@ -572,7 +572,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups);
}
/**
* Determines if subscriptions are allowed.
*
@ -604,7 +604,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
}
/**
* Gets the human readable node title.
*
@ -625,7 +625,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.title, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.title.getFieldName(), title);
}
/**
* The type of node data, usually specified by the namespace of the payload (if any).
*
@ -646,27 +646,27 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.type, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.type.getFieldName(), type);
}
@Override
public String toString()
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields())
{
result.append('(');
result.append(formField.getVariable());
result.append(':');
StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues())
{
if (valuesBuilder.length() > 0)
result.append(',');
valuesBuilder.append(value);
}
if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET");
result.append(valuesBuilder);
@ -684,21 +684,21 @@ public class ConfigureForm extends Form
private String getFieldValue(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
}
private List<String> getFieldValues(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues();
}
private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);

View file

@ -44,7 +44,7 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link URL}</b></p>
*/
body_xslt,
/**
* The collection with which a node is affiliated
*
@ -68,21 +68,21 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
deliver_payloads,
/**
* Whether owners or publisher should receive replies to items
*
* <p><b>Value: {@link ItemReply}</b></p>
*/
itemreply,
/**
* Who may associate leaf nodes with a collection
*
* <p><b>Value: {@link ChildrenAssociationPolicy}</b></p>
*/
children_association_policy,
/**
* The list of JIDs that may associate leaf nodes with a
* collection
@ -90,14 +90,14 @@ public enum ConfigureNodeFields
* <p><b>Value: List of JIDs as Strings</b></p>
*/
children_association_whitelist,
/**
* The child nodes (leaf or collection) associated with a collection
*
* <p><b>Value: List of Strings</b></p>
*/
children,
/**
* The maximum number of child nodes that can be associated with a
* collection
@ -105,35 +105,35 @@ public enum ConfigureNodeFields
* <p><b>Value: int</b></p>
*/
children_max,
/**
* The maximum number of items to persist
*
* <p><b>Value: int</b></p>
*/
max_items,
/**
* The maximum payload size in bytes
*
* <p><b>Value: int</b></p>
*/
max_payload_size,
/**
* Whether the node is a leaf (default) or collection
*
* <p><b>Value: {@link NodeType}</b></p>
*/
node_type,
/**
* Whether to notify subscribers when the node configuration changes
*
* <p><b>Value: boolean</b></p>
*/
notify_config,
/**
* Whether to notify subscribers when the node is deleted
*
@ -147,7 +147,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
notify_retract,
/**
* Whether to persist items to storage. This is required to have multiple
* items in the node.
@ -155,7 +155,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p>
*/
persist_items,
/**
* Whether to deliver notifications to available users only
*
@ -169,42 +169,42 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link PublishModel}</b></p>
*/
publish_model,
/**
* The specific multi-user chat rooms to specify for replyroom
*
* <p><b>Value: List of JIDs as Strings</b></p>
*/
replyroom,
/**
* The specific JID(s) to specify for replyto
*
* <p><b>Value: List of JIDs as Strings</b></p>
*/
replyto,
/**
* The roster group(s) allowed to subscribe and retrieve items
*
* <p><b>Value: List of strings</b></p>
*/
roster_groups_allowed,
/**
* Whether to allow subscriptions
*
* <p><b>Value: boolean</b></p>
*/
subscribe,
/**
* A friendly name for the node
*
* <p><b>Value: String</b></p>
*/
title,
/**
* The type of node data, ussually specified by the namespace
* of the payload(if any);MAY be a list-single rather than a
@ -213,7 +213,7 @@ public enum ConfigureNodeFields
* <p><b>Value: String</b></p>
*/
type;
public String getFieldName()
{
return "pubsub#" + toString();

View file

@ -34,13 +34,13 @@ public class EventElement implements EmbeddedPacketExtension
{
private EventElementType type;
private NodeExtension ext;
public EventElement(EventElementType eventType, NodeExtension eventExt)
{
type = eventType;
ext = eventExt;
}
public EventElementType getEventType()
{
return type;

View file

@ -29,16 +29,16 @@ public enum EventElementType
/** A node has had its configuration changed */
configuration,
/** A node has been deleted */
delete,
/** Items have been published to a node */
items,
/** All items have been purged from a node */
purge,
/** A node has been subscribed to */
subscription
}

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smackx.xdata.Form;
public class FormNode extends NodeExtension
{
private Form configForm;
/**
* Create a {@link FormNode} which contains the specified form.
*
@ -44,7 +44,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm;
}
/**
* Create a {@link FormNode} which contains the specified form, which is
* associated with the specified node.
@ -61,7 +61,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm;
}
/**
* Get the Form that is to be sent, or was retrieved from the server.
*
@ -71,7 +71,7 @@ public class FormNode extends NodeExtension
{
return configForm;
}
@Override
public CharSequence toXML()
{
@ -83,7 +83,7 @@ public class FormNode extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");

View file

@ -29,16 +29,16 @@ public enum FormNodeType
{
/** Form for configuring an existing node */
CONFIGURE_OWNER,
/** Form for configuring a node during creation */
CONFIGURE,
/** Form for configuring subscription options */
OPTIONS,
/** Form which represents the default node configuration options */
DEFAULT;
public PubSubElementType getNodeElement()
{
return PubSubElementType.valueOf(toString());

View file

@ -27,12 +27,12 @@ public class GetItemsRequest extends NodeExtension
{
protected final String subId;
protected final int maxItems;
public GetItemsRequest(String nodeId)
{
this(nodeId, null, -1);
}
public GetItemsRequest(String nodeId, String subscriptionId)
{
this(nodeId, subscriptionId, -1);

View file

@ -45,7 +45,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class Item extends NodeExtension
{
private String id;
/**
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
@ -57,7 +57,7 @@ public class Item extends NodeExtension
{
super(PubSubElementType.ITEM);
}
/**
* Create an <tt>Item</tt> with an id but no payload. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false.
@ -88,7 +88,7 @@ public class Item extends NodeExtension
super(PubSubElementType.ITEM_EVENT, nodeId);
id = itemId;
}
/**
* Get the item id. Unique to the node it is associated with.
*
@ -98,7 +98,7 @@ public class Item extends NodeExtension
{
return id;
}
@Override
public String getNamespace()
{
@ -109,14 +109,14 @@ public class Item extends NodeExtension
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (id != null)
{
builder.append(" id='");
builder.append(id);
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());

View file

@ -27,7 +27,7 @@ import java.util.List;
public class ItemDeleteEvent extends SubscriptionEvent
{
private List<String> itemIds = Collections.emptyList();
/**
* Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
* items (by id) have been deleted, and that the event matches the listed
@ -41,12 +41,12 @@ public class ItemDeleteEvent extends SubscriptionEvent
public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds)
{
super(nodeId, subscriptionIds);
if (deletedItemIds == null)
throw new IllegalArgumentException("deletedItemIds cannot be null");
itemIds = deletedItemIds;
}
/**
* Get the item id's of the items that have been deleted.
*
@ -56,7 +56,7 @@ public class ItemDeleteEvent extends SubscriptionEvent
{
return Collections.unmodifiableList(itemIds);
}
@Override
public String toString()
{

View file

@ -29,7 +29,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
private List<T> items;
private Date originalDate;
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published.
@ -42,7 +42,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published. The list of subscription ids
@ -58,7 +58,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId, subscriptionIds);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published in the past. The published
@ -74,11 +74,11 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
super(nodeId, subscriptionIds);
items = eventItems;
if (publishedDate != null)
originalDate = publishedDate;
}
/**
* Get the list of {@link Item} that were published.
*
@ -88,7 +88,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
return Collections.unmodifiableList(items);
}
/**
* Indicates whether this event was delayed. That is, the items
* were published to the node at some time in the past. This will
@ -103,7 +103,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
return (originalDate != null);
}
/**
* Gets the original date the items were published. This is only
* valid if {@link #isDelayed()} is true.
@ -120,5 +120,5 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " +
(isDelayed() ? originalDate.toString() : "false") + ']';
}
}

View file

@ -26,7 +26,7 @@ public enum ItemReply
{
/** The node owner */
owner,
/** The item publisher */
publisher;
}

View file

@ -42,19 +42,19 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
/** An items element, which has an optional <b>max_items</b> attribute when requesting items */
items(PubSubElementType.ITEMS, "max_items"),
/** A retract element, which has an optional <b>notify</b> attribute when publishing deletions */
retract(PubSubElementType.RETRACT, "notify");
private PubSubElementType elem;
private String att;
private ItemsElementType(PubSubElementType nodeElement, String attribute)
{
elem = nodeElement;
att = attribute;
}
public PubSubElementType getNodeElement()
{
return elem;
@ -89,7 +89,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
type = itemsType;
this.items = items;
}
/**
* Construct an instance with a list representing items that have been published or deleted.
*
@ -113,7 +113,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
this.items = items;
this.notify = notify;
}
/**
* Get the type of element
*
@ -123,13 +123,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return type;
}
@SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions()
{
return (List<ExtensionElement>)getItems();
}
/**
* Gets the items related to the type of request or event.
*
@ -149,7 +149,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return notify;
}
@Override
public CharSequence toXML()
{
@ -163,7 +163,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(getElementName());
builder.append(" node='");
builder.append(getNode());
if (notify != null)
{
builder.append("' ");
@ -180,7 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(item.toXML());
}
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -43,7 +43,7 @@ public class LeafNode extends Node
{
super(connection, nodeName);
}
/**
* Get information on the items in the node in standard
* {@link DiscoverItems} format.
@ -75,7 +75,7 @@ public class LeafNode extends Node
{
return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null);
}
/**
* Get the current items stored in the node based
* on the subscription associated with the provided
@ -113,7 +113,7 @@ public class LeafNode extends Node
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids)
{
itemList.add(new Item(id));
@ -138,7 +138,7 @@ public class LeafNode extends Node
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
return getItems(request);
}
/**
* Get items persisted on the node, limited to the specified number
* based on the subscription associated with the provided subscriptionId.
@ -218,10 +218,10 @@ public class LeafNode extends Node
public void publish() throws NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.sendStanza(packet);
}
/**
* Publishes an event to the node. This is a simple item
* with no payload.
@ -265,7 +265,7 @@ public class LeafNode extends Node
public <T extends Item> void publish(Collection<T> items) throws NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.sendStanza(packet);
}
@ -289,10 +289,10 @@ public class LeafNode extends Node
public void send() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Publishes an event to the node. This can be either a simple item
* with no payload, or one with it. This is determined by the Node
@ -324,7 +324,7 @@ public class LeafNode extends Node
items.add((item == null ? (T)new Item() : item));
send(items);
}
/**
* Publishes multiple events to the node. Same rules apply as in {@link #send(Item)}.
*
@ -346,10 +346,10 @@ public class LeafNode extends Node
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Purges the node of all items.
*
@ -363,10 +363,10 @@ public class LeafNode extends Node
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
con.createPacketCollectorAndSend(request).nextResultOrThrow();
}
/**
* Delete the item with the specified id from the node.
*
@ -382,7 +382,7 @@ public class LeafNode extends Node
items.add(itemId);
deleteItem(items);
}
/**
* Delete the items with the specified id's from the node.
*
@ -395,7 +395,7 @@ public class LeafNode extends Node
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> items = new ArrayList<Item>(itemIds.size());
for (String id : itemIds)
{
items.add(new Item(id));

View file

@ -50,11 +50,11 @@ abstract public class Node
protected XMPPConnection con;
protected String id;
protected Jid to;
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
/**
* Construct a node associated to the supplied connection with the specified
* node id.
@ -105,7 +105,7 @@ abstract public class Node
Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
}
/**
* Update the configuration with the contents of the new {@link Form}
*
@ -121,7 +121,7 @@ abstract public class Node
getId(), submitForm), PubSubNamespace.OWNER);
con.createPacketCollectorAndSend(packet).nextResultOrThrow();
}
/**
* Discover node information in standard {@link DiscoverInfo} format.
*
@ -138,7 +138,7 @@ abstract public class Node
info.setNode(getId());
return (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow();
}
/**
* Get the subscriptions currently associated with this node.
*
@ -308,7 +308,7 @@ abstract public class Node
PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
/**
* The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the
@ -352,7 +352,7 @@ abstract public class Node
{
unsubscribe(jid, null);
}
/**
* Remove the specific subscription related to the specified JID.
*
@ -427,7 +427,7 @@ abstract public class Node
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{
StanzaListener conListener = itemEventToListenerMap.remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
@ -453,11 +453,11 @@ abstract public class Node
public void removeConfigurationListener(NodeConfigListener listener)
{
StanzaListener conListener = configEventToListenerMap .remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
/**
* Register an listener for item delete events. This listener
* gets called whenever an item is deleted from the node.
@ -470,7 +470,7 @@ abstract public class Node
itemDeleteToListenerMap.put(listener, delListener);
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString());
con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge));
}
@ -482,7 +482,7 @@ abstract public class Node
public void removeItemDeleteListener(ItemDeleteListener listener)
{
StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
if (conListener != null)
con.removeSyncStanzaListener(conListener);
}
@ -492,12 +492,12 @@ abstract public class Node
{
return super.toString() + " " + getClass().getName() + " id: " + id;
}
protected PubSub createPubsubPacket(Type type, ExtensionElement ext)
{
return createPubsubPacket(type, ext, null);
}
protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
{
return PubSub.createPubsubPacket(to, type, ext, ns);
@ -513,11 +513,11 @@ abstract public class Node
{
HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null;
if (headers != null)
{
values = new ArrayList<String>(headers.getHeaders().size());
for (Header header : headers.getHeaders())
{
values.add(header.getValue());
@ -541,7 +541,7 @@ abstract public class Node
{
listener = eventListener;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processPacket(Stanza packet)
{
@ -566,13 +566,13 @@ abstract public class Node
{
listener = eventListener;
}
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
{
listener.handlePurge();
@ -594,7 +594,7 @@ abstract public class Node
}
}
}
/**
* This class translates low level node configuration events into api level objects for
* user consumption.
@ -609,7 +609,7 @@ abstract public class Node
{
listener = eventListener;
}
public void processPacket(Stanza packet)
{
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
@ -629,7 +629,7 @@ abstract public class Node
{
private String firstElement;
private String secondElement;
EventContentFilter(String elementName)
{
firstElement = elementName;
@ -647,27 +647,27 @@ abstract public class Node
return false;
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
if (event == null)
return false;
NodeExtension embedEvent = event.getEvent();
if (embedEvent == null)
return false;
if (embedEvent.getElementName().equals(firstElement))
{
if (!embedEvent.getNode().equals(getId()))
return false;
if (secondElement == null)
return true;
if (embedEvent instanceof EmbeddedPacketExtension)
{
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
return true;
}

View file

@ -19,12 +19,12 @@ package org.jivesoftware.smackx.pubsub;
abstract public class NodeEvent
{
private String nodeId;
protected NodeEvent(String id)
{
nodeId = id;
}
public String getNodeId()
{
return nodeId;

View file

@ -30,7 +30,7 @@ public class NodeExtension implements ExtensionElement
{
private final PubSubElementType element;
private final String node;
/**
* Constructs a <tt>NodeExtension</tt> with an element name specified
* by {@link PubSubElementType} and the specified node id.
@ -64,7 +64,7 @@ public class NodeExtension implements ExtensionElement
{
return node;
}
public String getElementName()
{
return element.getElementName();

View file

@ -27,29 +27,29 @@ public class OptionsExtension extends NodeExtension
{
protected String jid;
protected String id;
public OptionsExtension(String subscriptionJid)
{
this(subscriptionJid, null, null);
}
public OptionsExtension(String subscriptionJid, String nodeId)
{
this(subscriptionJid, nodeId, null);
}
public OptionsExtension(String jid, String nodeId, String subscriptionId)
{
super(PubSubElementType.OPTIONS, nodeId);
this.jid = jid;
id = subscriptionId;
}
public String getJid()
{
return jid;
}
public String getId()
{
return id;

View file

@ -46,7 +46,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class PayloadItem<E extends ExtensionElement> extends Item
{
private E payload;
/**
* Create an <tt>Item</tt> with no id and a payload The id will be set by the server.
*
@ -55,7 +55,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(E payloadExt)
{
super();
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
@ -70,12 +70,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, E payloadExt)
{
super(itemId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* Create an <tt>Item</tt> with an id, node id and payload.
*
@ -92,12 +92,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, String nodeId, E payloadExt)
{
super(itemId, nodeId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* Get the payload associated with this <tt>Item</tt>. Customising the payload
* parsing from the server can be accomplished as described in {@link ItemProvider}.
@ -108,19 +108,19 @@ public class PayloadItem<E extends ExtensionElement> extends Item
{
return payload;
}
@Override
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (getId() != null)
{
builder.append(" id='");
builder.append(getId());
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());
@ -129,7 +129,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
builder.append(">");
builder.append(payload.toXML());
builder.append("</item>");
return builder.toString();
}

View file

@ -53,28 +53,28 @@ public enum PubSubElementType
private String eName;
private PubSubNamespace nSpace;
private PubSubElementType(String elemName, PubSubNamespace ns)
{
eName = elemName;
nSpace = ns;
}
public PubSubNamespace getNamespace()
{
return nSpace;
}
public String getElementName()
{
return eName;
}
public static PubSubElementType valueOfFromElemName(String elemName, String namespace)
{
int index = namespace.lastIndexOf('#');
String fragment = (index == -1 ? null : namespace.substring(index+1));
if (fragment != null)
{
return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US));

View file

@ -57,7 +57,7 @@ final public class PubSubManager
private XMPPConnection con;
private DomainBareJid to;
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
/**
* Create a pubsub manager associated to the specified connection. Defaults the service
* name to <i>pubsub</i>
@ -70,7 +70,7 @@ final public class PubSubManager
con = connection;
to = JidCreate.domainBareFrom("pubsub." + connection.getServiceName());
}
/**
* Create a pubsub manager associated to the specified connection where
* the pubsub requests require a specific to address for packets.
@ -83,7 +83,7 @@ final public class PubSubManager
con = connection;
to = toAddress;
}
/**
* Creates an instant node, if supported.
*
@ -97,14 +97,14 @@ final public class PubSubManager
{
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
/**
* Creates a node with default configuration.
*
@ -120,7 +120,7 @@ final public class PubSubManager
{
return (LeafNode)createNode(id, null);
}
/**
* Creates a node with specified configuration.
*
@ -139,12 +139,12 @@ final public class PubSubManager
{
PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null);
boolean isLeafNode = true;
if (config != null)
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
}
@ -155,7 +155,7 @@ final public class PubSubManager
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
@ -174,13 +174,13 @@ final public class PubSubManager
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
Node node = nodeMap.get(id);
if (node == null)
{
DiscoverInfo info = new DiscoverInfo();
info.setTo(to);
info.setNode(id);
DiscoverInfo infoReply = (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow();
if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) {
@ -205,7 +205,7 @@ final public class PubSubManager
}
return (T) node;
}
/**
* Get all the nodes that currently exist as a child of the specified
* collection node. If the service does not support collection nodes
@ -225,14 +225,14 @@ final public class PubSubManager
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
DiscoverItems items = new DiscoverItems();
if (nodeId != null)
items.setNode(nodeId);
items.setTo(to);
DiscoverItems nodeItems = (DiscoverItems) con.createPacketCollectorAndSend(items).nextResultOrThrow();
return nodeItems;
}
/**
* Gets the subscriptions on the root node.
*
@ -248,7 +248,7 @@ final public class PubSubManager
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}
/**
* Gets the affiliations on the root node.
*
@ -280,7 +280,7 @@ final public class PubSubManager
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
nodeMap.remove(nodeId);
}
/**
* Returns the default settings for Node configuration.
*
@ -297,7 +297,7 @@ final public class PubSubManager
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT);
}
/**
* Gets the supported features of the servers pubsub implementation
* as a standard {@link DiscoverInfo} instance.

View file

@ -27,7 +27,7 @@ import java.util.Collection;
public class PublishItem<T extends Item> extends NodeExtension
{
protected Collection<T> items;
/**
* Construct a request to publish an item to a node.
*
@ -61,13 +61,13 @@ public class PublishItem<T extends Item> extends NodeExtension
builder.append(" node='");
builder.append(getNode());
builder.append("'>");
for (Item item : items)
{
builder.append(item.toXML());
}
builder.append("</publish>");
return builder.toString();
}
}

View file

@ -26,10 +26,10 @@ public enum PublishModel
{
/** Only publishers may publish */
publishers,
/** Only subscribers may publish */
subscribers,
/** Anyone may publish */
open;
}

View file

@ -39,7 +39,7 @@ public class RetractItem implements ExtensionElement
throw new IllegalArgumentException("itemId must not be 'null'");
id = itemId;
}
public String getId()
{
return id;

View file

@ -29,7 +29,7 @@ public class SimplePayload implements ExtensionElement
private final String elemName;
private final String ns;
private final CharSequence payload;
/**
* Construct a <tt>SimplePayload</tt> object with the specified element name,
* namespace and content. The content must be well formed XML.

View file

@ -24,13 +24,13 @@ package org.jivesoftware.smackx.pubsub;
public class SubscribeExtension extends NodeExtension
{
protected String jid;
public SubscribeExtension(String subscribeJid)
{
super(PubSubElementType.SUBSCRIBE);
jid = subscribeJid;
}
public SubscribeExtension(String subscribeJid, String nodeId)
{
super(PubSubElementType.SUBSCRIBE, nodeId);
@ -47,7 +47,7 @@ public class SubscribeExtension extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");
@ -57,7 +57,7 @@ public class SubscribeExtension extends NodeExtension
builder.append(" jid='");
builder.append(getJid());
builder.append("'/>");
return builder.toString();
}
}

View file

@ -44,17 +44,17 @@ public class SubscribeForm extends Form
{
super(configDataForm);
}
public SubscribeForm(Form subscribeOptionsForm)
{
super(subscribeOptionsForm.getDataFormToSend());
}
public SubscribeForm(DataForm.Type formType)
{
super(formType);
}
/**
* Determines if an entity wants to receive notifications.
*
@ -64,7 +64,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.deliver));
}
/**
* Sets whether an entity wants to receive notifications.
*
@ -85,7 +85,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.digest));
}
/**
* Sets whether notifications should be delivered as aggregations or not.
*
@ -137,7 +137,7 @@ public class SubscribeForm extends Form
throw exc;
}
}
/**
* Sets the time at which the leased subscription will expire, or has expired.
*
@ -148,7 +148,7 @@ public class SubscribeForm extends Form
addField(SubscribeOptionFields.expire, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
}
/**
* Determines whether the entity wants to receive an XMPP message body in
* addition to the payload format.
@ -159,7 +159,7 @@ public class SubscribeForm extends Form
{
return parseBoolean(getFieldValue(SubscribeOptionFields.include_body));
}
/**
* Sets whether the entity wants to receive an XMPP message body in
* addition to the payload format.
@ -181,14 +181,14 @@ public class SubscribeForm extends Form
public List<PresenceState> getShowValues()
{
ArrayList<PresenceState> result = new ArrayList<PresenceState>(5);
for (String state : getFieldValues(SubscribeOptionFields.show_values))
{
result.add(PresenceState.valueOf(state));
}
return result;
}
/**
* Sets the list of {@link PresenceState} for which an entity wants
* to receive notifications.
@ -198,7 +198,7 @@ public class SubscribeForm extends Form
public void setShowValues(Collection<PresenceState> stateValues)
{
ArrayList<String> values = new ArrayList<String>(stateValues.size());
for (PresenceState state : stateValues)
{
values.add(state.toString());
@ -206,8 +206,8 @@ public class SubscribeForm extends Form
addField(SubscribeOptionFields.show_values, FormField.Type.list_multi);
setAnswer(SubscribeOptionFields.show_values.getFieldName(), values);
}
static private boolean parseBoolean(String fieldValue)
{
return ("1".equals(fieldValue) || "true".equals(fieldValue));
@ -216,21 +216,21 @@ public class SubscribeForm extends Form
private String getFieldValue(SubscribeOptionFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues().get(0);
}
private List<String> getFieldValues(SubscribeOptionFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues();
}
private void addField(SubscribeOptionFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);

View file

@ -40,7 +40,7 @@ public enum SubscribeOptionFields
* <p><b>Value: boolean</b></p>
*/
digest,
/**
* The minimum number of seconds between sending any two notifications digests
*
@ -61,38 +61,38 @@ public enum SubscribeOptionFields
* <p><b>Value: boolean</b></p>
*/
include_body,
/**
* The presence states for which an entity wants to receive notifications.
*
* <p><b>Value: {@link PresenceState}</b></p>
*/
show_values,
/**
*
*
* <p><b>Value: </b></p>
*/
subscription_type,
/**
*
* <p><b>Value: </b></p>
*/
subscription_depth;
public String getFieldName()
{
if (this == show_values)
return "pubsub#" + toString().replace('_', '-');
return "pubsub#" + toString();
}
static public SubscribeOptionFields valueOfFromElement(String elementName)
{
String portion = elementName.substring(elementName.lastIndexOf('#' + 1));
if ("show-values".equals(portion))
return show_values;
else

View file

@ -27,7 +27,7 @@ public class Subscription extends NodeExtension
protected String id;
protected State state;
protected boolean configRequired = false;
public enum State
{
subscribed, unconfigured, pending, none
@ -43,7 +43,7 @@ public class Subscription extends NodeExtension
{
this(subscriptionJid, null, null, null);
}
/**
* Used to constructs a subscription request to the specified node with the specified
* JID.
@ -55,7 +55,7 @@ public class Subscription extends NodeExtension
{
this(subscriptionJid, nodeId, null, null);
}
/**
* Constructs a representation of a subscription reply to the specified node
* and JID. The server will have supplied the subscription id and current state.
@ -72,7 +72,7 @@ public class Subscription extends NodeExtension
id = subscriptionId;
this.state = state;
}
/**
* Constructs a representation of a subscription reply to the specified node
* and JID. The server will have supplied the subscription id and current state
@ -92,7 +92,7 @@ public class Subscription extends NodeExtension
this.state = state;
this.configRequired = configRequired;
}
/**
* Gets the JID the subscription is created for
*
@ -102,7 +102,7 @@ public class Subscription extends NodeExtension
{
return jid;
}
/**
* Gets the subscription id
*
@ -112,7 +112,7 @@ public class Subscription extends NodeExtension
{
return id;
}
/**
* Gets the current subscription state.
*
@ -132,21 +132,21 @@ public class Subscription extends NodeExtension
{
return configRequired;
}
public String toXML()
{
StringBuilder builder = new StringBuilder("<subscription");
appendAttribute(builder, "jid", jid);
if (getNode() != null)
appendAttribute(builder, "node", getNode());
if (id != null)
appendAttribute(builder, "subid", id);
if (state != null)
appendAttribute(builder, "subscription", state.toString());
builder.append("/>");
return builder.toString();
}

View file

@ -50,7 +50,7 @@ abstract public class SubscriptionEvent extends NodeEvent
protected SubscriptionEvent(String nodeId, List<String> subscriptionIds)
{
super(nodeId);
if (subscriptionIds != null)
subIds = subscriptionIds;
}
@ -64,7 +64,7 @@ abstract public class SubscriptionEvent extends NodeEvent
{
return Collections.unmodifiableList(subIds);
}
/**
* Set the list of subscription id's for this event.
*

View file

@ -27,7 +27,7 @@ import java.util.List;
public class SubscriptionsExtension extends NodeExtension
{
protected List<Subscription> items = Collections.emptyList();
/**
* Subscriptions to the root node
*
@ -36,7 +36,7 @@ public class SubscriptionsExtension extends NodeExtension
public SubscriptionsExtension(List<Subscription> subList)
{
super(PubSubElementType.SUBSCRIPTIONS);
if (subList != null)
items = subList;
}
@ -76,7 +76,7 @@ public class SubscriptionsExtension extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");
@ -84,12 +84,12 @@ public class SubscriptionsExtension extends NodeExtension
builder.append("'");
}
builder.append(">");
for (Subscription item : items)
{
builder.append(item.toXML());
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

@ -28,29 +28,29 @@ public class UnsubscribeExtension extends NodeExtension
{
protected String jid;
protected String id;
public UnsubscribeExtension(String subscriptionJid)
{
this(subscriptionJid, null, null);
}
public UnsubscribeExtension(String subscriptionJid, String nodeId)
{
this(subscriptionJid, nodeId, null);
}
public UnsubscribeExtension(String jid, String nodeId, String subscriptionId)
{
super(PubSubElementType.UNSUBSCRIBE, nodeId);
this.jid = jid;
id = subscriptionId;
}
public String getJid()
{
return jid;
}
public String getId()
{
return id;

View file

@ -35,7 +35,7 @@ public interface ItemDeleteListener
* @param items The event with item deletion details
*/
void handleDeletedItems(ItemDeleteEvent items);
/**
* Called when <b>all</b> items are deleted from a node the listener is
* registered with.

View file

@ -30,24 +30,24 @@ public enum PubSubNamespace
ERROR("errors"),
EVENT("event"),
OWNER("owner");
private String fragment;
private PubSubNamespace(String fragment)
{
this.fragment = fragment;
}
public String getXmlns()
{
String ns = PubSub.NAMESPACE;
if (fragment != null)
ns += '#' + fragment;
return ns;
}
public String getFragment()
{
return fragment;
@ -56,7 +56,7 @@ public enum PubSubNamespace
public static PubSubNamespace valueOfFromXmlns(String ns)
{
int index = ns.lastIndexOf('#');
if (index != -1)
{
String suffix = ns.substring(ns.lastIndexOf('#')+1);

View file

@ -41,14 +41,14 @@ public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
boolean isRequired = false;
int tag = parser.next();
if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options"))
{
tag = parser.next();
if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required"))
isRequired = true;
while (tag != XmlPullParser.END_TAG && !parser.getName().equals("subscribe-options")) tag = parser.next();
}
while (parser.getEventType() != XmlPullParser.END_TAG) parser.next();

View file

@ -32,11 +32,11 @@ import java.util.List;
* @author Gaston Dombiak
*/
public class ReportedData {
private List<Column> columns = new ArrayList<Column>();
private List<Row> rows = new ArrayList<Row>();
private String title = "";
/**
* Returns a new ReportedData if the packet is used for reporting data and includes an
* extension that matches the elementName and namespace "x","jabber:x:data".

View file

@ -95,7 +95,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
LOGGER.log(Level.SEVERE, "Failed to parse file size from " + fileSize, e);
}
}
Date fileDate = new Date();
if (date != null) {
try {
@ -104,7 +104,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
// couldn't parse date, use current date-time
}
}
File file = new File(name, fileSize);
file.setHash(hash);
file.setDate(fileDate);

View file

@ -87,9 +87,9 @@ public class VCard extends IQ {
public static final String NAMESPACE = "vcard-temp";
private static final Logger LOGGER = Logger.getLogger(VCard.class.getName());
private static final String DEFAULT_MIME_TYPE = "image/jpeg";
/**
* Phone types:
* VOICE?, FAX?, PAGER?, MSG?, CELL?, VIDEO?, BBS?, MODEM?, ISDN?, PCS?, PREF?
@ -404,7 +404,7 @@ public class VCard extends IQ {
public void setEncodedImage(String encodedAvatar) {
setAvatar(encodedAvatar, DEFAULT_MIME_TYPE);
}
/**
* Return the byte representation of the avatar(if one exists), otherwise returns null if
* no avatar could be found.

View file

@ -73,7 +73,7 @@ public class Form {
public Form(DataForm dataForm) {
this.dataForm = dataForm;
}
/**
* Creates a new Form of a given type from scratch.
*
@ -82,7 +82,7 @@ public class Form {
public Form(DataForm.Type type) {
this.dataForm = new DataForm(type);
}
/**
* Adds a new field to complete as part of the form.
*
@ -91,7 +91,7 @@ public class Form {
public void addField(FormField field) {
dataForm.addField(field);
}
/**
* Sets a new String value to a given form's field. The field whose variable matches the
* requested variable will be completed with the specified value. If no field could be found
@ -401,7 +401,7 @@ public class Form {
public DataForm.Type getType() {
return dataForm.getType();
}
/**
* Sets instructions that explain how to fill out the form and what the form is about.
@ -417,7 +417,7 @@ public class Form {
}
// Set the new list of instructions
dataForm.setInstructions(instructionsList);
}
@ -430,7 +430,7 @@ public class Form {
public void setTitle(String title) {
dataForm.setTitle(title);
}
/**
* Returns a DataForm that serves to send this Form to the server. If the form is of type
* submit, it may contain fields with no value. These fields will be removed since they only
@ -451,7 +451,7 @@ public class Form {
}
return dataForm;
}
/**
* Returns true if the form is a form to fill out.
*
@ -460,7 +460,7 @@ public class Form {
private boolean isFormType() {
return DataForm.Type.form == dataForm.getType();
}
/**
* Returns true if the form is a form to submit.
*

View file

@ -73,11 +73,11 @@ public class DataForm implements ExtensionElement {
private final List<Item> items = new ArrayList<Item>();
private final List<FormField> fields = new ArrayList<FormField>();
private final List<Element> extensionElements = new ArrayList<Element>();
public DataForm(Type type) {
this.type = type;
}
/**
* Returns the meaning of the data within the context. The data could be part of a form
* to fill out, a form submission or data results.
@ -87,7 +87,7 @@ public class DataForm implements ExtensionElement {
public Type getType() {
return type;
}
/**
* Returns the description of the data. It is similar to the title on a web page or an X
* window. You can put a <title/> on either a form to fill out, or a set of data results.
@ -214,7 +214,7 @@ public class DataForm implements ExtensionElement {
fields.add(field);
}
}
/**
* Adds a new instruction to the list of instructions that explain how to fill out the form
* and what the form is about. The dataform could include multiple instructions since each
@ -320,7 +320,7 @@ public class DataForm implements ExtensionElement {
public static final String ELEMENT = "reported";
private List<FormField> fields = new ArrayList<FormField>();
public ReportedData(List<FormField> fields) {
this.fields = fields;
}
@ -345,7 +345,7 @@ public class DataForm implements ExtensionElement {
return buf;
}
}
/**
*
* Represents items of reported data.
@ -356,11 +356,11 @@ public class DataForm implements ExtensionElement {
public static final String ELEMENT = "item";
private List<FormField> fields = new ArrayList<FormField>();
public Item(List<FormField> fields) {
this.fields = fields;
}
/**
* Returns the fields that define the data that goes with the item.
*
@ -369,7 +369,7 @@ public class DataForm implements ExtensionElement {
public List<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public CharSequence toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.openElement(ELEMENT);

View file

@ -665,5 +665,5 @@ public class InBandBytestreamSessionTest {
protocol.verifyAll();
}
}

View file

@ -77,7 +77,7 @@ public class CloseTest {
close.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
close.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
close.setStanzaId("us71g45j");
assertXMLEqual(control, close.toXML().toString());
}

View file

@ -76,7 +76,7 @@ public class DataPacketExtensionTest {
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }));
assertNull(data.getDecodedData());
}
private static Properties outputProperties = new Properties();
{
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");

View file

@ -56,7 +56,7 @@ public class DataTest {
@Test
public void shouldReturnValidIQStanzaXML() throws Exception {
String encodedData = Base64.encode("Test");
String control = XMLBuilder.create("iq")
.a("from", "romeo@montague.lit/orchard")
.a("to", "juliet@capulet.lit/balcony")
@ -74,7 +74,7 @@ public class DataTest {
data.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
data.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
data.setStanzaId("kr91n475");
assertXMLEqual(control, data.toXML().toString());
}

View file

@ -75,7 +75,7 @@ public class OpenTest {
assertEquals(4096, open.getBlockSize());
assertEquals(StanzaType.MESSAGE, open.getStanza());
}
private static Properties outputProperties = new Properties();
{
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
@ -99,9 +99,9 @@ public class OpenTest {
open.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
open.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
open.setStanzaId("jn3h8g65");
assertXMLEqual(control, open.toXML().toString());
}
}

View file

@ -51,10 +51,10 @@ public class OpenIQProviderTest {
.a("sid", "i781hf64")
.a("stanza", "iq")
.asString(outputProperties);
OpenIQProvider oip = new OpenIQProvider();
Open open = oip.parse(getParser(control));
assertEquals(StanzaType.IQ, open.getStanza());
}
@ -66,10 +66,10 @@ public class OpenIQProviderTest {
.a("sid", "i781hf64")
.a("stanza", "message")
.asString(outputProperties);
OpenIQProvider oip = new OpenIQProvider();
Open open = oip.parse(getParser(control));
assertEquals(StanzaType.MESSAGE, open.getStanza());
}

View file

@ -60,7 +60,7 @@ public class DelayInformationTest extends InitExtensions {
GregorianCalendar calendar = new GregorianCalendar(2002, 9 - 1, 10, 23, 8, 25);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = calendar.getTime();
control = XMLBuilder.create("x")
.a("xmlns", "jabber:x:delay")
.a("from", "capulet.com")
@ -70,7 +70,7 @@ public class DelayInformationTest extends InitExtensions {
parser = PacketParserUtils.getParserFor(control);
delayInfo = (DelayInformation) p.parse(parser);
assertEquals("capulet.com", delayInfo.getFrom());
assertEquals(date, delayInfo.getStamp());
assertEquals("Offline Storage", delayInfo.getReason());
@ -101,7 +101,7 @@ public class DelayInformationTest extends InitExtensions {
DelayInformationProvider p = new DelayInformationProvider();
DelayInformation delayInfo;
String control;
// XEP-0082 date format
control = XMLBuilder.create("delay")
.a("xmlns", "urn:xmpp:delay")
@ -110,7 +110,7 @@ public class DelayInformationTest extends InitExtensions {
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
cal.add(Calendar.MILLISECOND, 120);
assertEquals(cal.getTime(), delayInfo.getStamp());
@ -132,9 +132,9 @@ public class DelayInformationTest extends InitExtensions {
.a("from", "capulet.com")
.a("stamp", "2002-9-10T23:08:25Z")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
assertEquals(calendar.getTime(), delayInfo.getStamp());
}
@ -151,9 +151,9 @@ public class DelayInformationTest extends InitExtensions {
.a("from", "capulet.com")
.a("stamp", "20020910T23:08:25")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
assertEquals(calendar.getTime(), delayInfo.getStamp());
// XEP-0091 date format without leading 0 in month
@ -165,7 +165,7 @@ public class DelayInformationTest extends InitExtensions {
}
dateInPast.add(Calendar.DAY_OF_MONTH, -3);
dateInPast.set(Calendar.MILLISECOND, 0);
control = XMLBuilder.create("x")
.a("xmlns", "jabber:x:delay")
.a("from", "capulet.com")
@ -185,7 +185,7 @@ public class DelayInformationTest extends InitExtensions {
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
assertEquals(controlDate, delayInfo.getStamp());
}
@ -195,7 +195,7 @@ public class DelayInformationTest extends InitExtensions {
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:41:07Z'/></presence>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
DelayInformation delay = DelayInformationManager.getXep203DelayInformation(presence);
assertNotNull(delay);
Date date = XmppDateTime.parseDate("2002-09-10T23:41:07Z");

View file

@ -44,19 +44,19 @@ public class ForwardedTest {
XmlPullParser parser;
String control;
Forwarded fwd;
control = XMLBuilder.create("forwarded")
.a("xmlns", "urn:xmpp:forwarded:0")
.e("message")
.a("from", "romeo@montague.com")
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
fwd = (Forwarded) new ForwardedProvider().parse(parser);
// no delay in packet
assertEquals(null, fwd.getDelayInformation());
// check message
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedPacket().getFrom()));
@ -97,11 +97,11 @@ public class ForwardedTest {
public void forwardedEmptyTest() throws Exception {
XmlPullParser parser;
String control;
control = XMLBuilder.create("forwarded")
.a("xmlns", "urn:xmpp:forwarded:0")
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
new ForwardedProvider().parse(parser);
}

View file

@ -92,13 +92,13 @@ public class PingTest extends InitExtensions {
@Test
public void checkSuccessfulPing() throws Exception {
ThreadedDummyConnection threadedCon = getAuthentiactedDummyConnection();
PingManager pinger = PingManager.getInstanceFor(threadedCon);
boolean pingSuccess = pinger.ping(DUMMY_AT_EXAMPLE_ORG);
assertTrue(pingSuccess);
}
/**
@ -121,7 +121,7 @@ public class PingTest extends InitExtensions {
}
fail();
}
/**
* Server returns an exception for entity.
* @throws Exception
@ -144,17 +144,17 @@ public class PingTest extends InitExtensions {
PingManager pinger = PingManager.getInstanceFor(threadedCon);
boolean pingSuccess = pinger.ping(DUMMY_AT_EXAMPLE_ORG);
assertFalse(pingSuccess);
}
@Test
public void checkPingToServerSuccess() throws Exception {
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSuccess = pinger.pingMyServer();
assertTrue(pingSuccess);
}
@ -180,10 +180,10 @@ public class PingTest extends InitExtensions {
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSuccess = pinger.pingMyServer();
assertTrue(pingSuccess);
}
@Test
public void checkPingToServerTimeout() throws SmackException, IOException, XMPPException, InterruptedException {
DummyConnection con = getAuthenticatedDummyConnectionWithoutIqReplies();
@ -198,7 +198,7 @@ public class PingTest extends InitExtensions {
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
DiscoverInfo info = new DiscoverInfo();
info.addFeature(Ping.NAMESPACE);
//@formatter:off
String reply =
"<iq type='result' id='qrzSp-16' to='test@myserver.com'>" +
@ -211,7 +211,7 @@ public class PingTest extends InitExtensions {
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
assertTrue(pingSupported);
}
@ -220,7 +220,7 @@ public class PingTest extends InitExtensions {
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
DiscoverInfo info = new DiscoverInfo();
info.addFeature(Ping.NAMESPACE);
//@formatter:off
String reply =
"<iq type='result' id='qrzSp-16' to='test@myserver.com'>" +
@ -233,7 +233,7 @@ public class PingTest extends InitExtensions {
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
assertFalse(pingSupported);
}

View file

@ -49,7 +49,7 @@ public class PrivacyProviderTest extends InitExtensions {
// @formatter:on
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
assertTrue(iqPrivacyList instanceof Privacy);
Privacy privacyList = (Privacy) iqPrivacyList;
List<PrivacyItem> pl = privacyList.getPrivacyList("public");
@ -58,7 +58,7 @@ public class PrivacyProviderTest extends InitExtensions {
assertEquals("tybalt@example.com", first.getValue());
assertEquals(false, first.isAllow());
assertEquals(1, first.getOrder());
PrivacyItem second = pl.get(1);
assertEquals(true, second.isAllow());
assertEquals(2, second.getOrder());

View file

@ -49,7 +49,7 @@ public class ConfigureFormTest
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
}
@Test
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException, InterruptedException
{
@ -59,14 +59,14 @@ public class ConfigureFormTest
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
XMPPError error = new XMPPError(Condition.forbidden);
errorIq.setError(error);
con.addIQReply(errorIq);
try
{
node.getNodeConfiguration();
@ -86,12 +86,12 @@ public class ConfigureFormTest
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
Node node = mgr.getNode("princely_musings");
SmackConfiguration.setDefaultPacketReplyTimeout(100);
con.setTimeout();
node.getNodeConfiguration();
}
}

View file

@ -102,17 +102,17 @@ public class ItemValidationTest extends InitExtensions {
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
assertTrue(eventExt instanceof EventElement);
EventElement event = (EventElement) eventExt;
assertEquals(EventElementType.items, event.getEventType());
assertEquals(1, event.getExtensions().size());
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
assertTrue(itemExt instanceof Item);
assertEquals("testid1", ((Item)itemExt).getId());
@ -122,7 +122,7 @@ public class ItemValidationTest extends InitExtensions {
public void parseSimplePayloadItem() throws Exception
{
String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
@ -133,7 +133,7 @@ public class ItemValidationTest extends InitExtensions {
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
EventElement event = (EventElement) eventExt;
@ -141,10 +141,10 @@ public class ItemValidationTest extends InitExtensions {
assertTrue(itemExt instanceof PayloadItem<?>);
PayloadItem<?> item = (PayloadItem<?>)itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
SimplePayload payload = (SimplePayload) item.getPayload();
assertEquals("foo", payload.getElementName());
assertEquals("smack:test", payload.getNamespace());
@ -169,7 +169,7 @@ public class ItemValidationTest extends InitExtensions {
"<published>2003-12-13T18:30:02Z</published>" +
"<updated>2003-12-13T18:30:02Z</updated>" +
"</entry>";
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
@ -180,7 +180,7 @@ public class ItemValidationTest extends InitExtensions {
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
EventElement event = (EventElement) eventExt;
@ -188,10 +188,10 @@ public class ItemValidationTest extends InitExtensions {
assertTrue(itemExt instanceof PayloadItem<?>);
PayloadItem<?> item = (PayloadItem<?>)itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
SimplePayload payload = (SimplePayload) item.getPayload();
assertEquals("entry", payload.getElementName());
assertEquals("http://www.w3.org/2005/Atom", payload.getNamespace());
@ -202,7 +202,7 @@ public class ItemValidationTest extends InitExtensions {
public void parseEmptyTag() throws Exception
{
String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
@ -213,24 +213,24 @@ public class ItemValidationTest extends InitExtensions {
"</items>" +
"</event>" +
"</message>");
Stanza message = PacketParserUtils.parseMessage(parser);
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
assertTrue(eventExt instanceof EventElement);
EventElement event = (EventElement) eventExt;
assertEquals(EventElementType.items, event.getEventType());
assertEquals(1, event.getExtensions().size());
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
assertTrue(itemExt instanceof PayloadItem<?>);
PayloadItem<?> item = (PayloadItem<?>)itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
assertXMLEqual(itemContent, ((SimplePayload)item.getPayload()).toXML().toString());
}
}

View file

@ -50,13 +50,13 @@ public class DeliveryReceiptTest extends InitExtensions {
public void receiptTest() throws Exception {
XmlPullParser parser;
String control;
control = XMLBuilder.create("message")
.a("from", "romeo@montague.com")
.e("request")
.a("xmlns", "urn:xmpp:receipts")
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
Message p = PacketParserUtils.parseMessage(parser);

View file

@ -54,15 +54,15 @@ public class DataFormTest {
df.addInstruction(instruction);
FormField field = new FormField("testField1");
df.addField(field);
assertNotNull( df.toXML());
String output = df.toXML().toString();
assertEquals(TEST_OUTPUT_1, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
df = pr.parse(parser);
assertNotNull(df);
assertNotNull(df.getFields());
assertEquals(1 , df.getFields().size() );
@ -81,7 +81,7 @@ public class DataFormTest {
df.addInstruction(instruction);
FormField field = new FormField("testField1");
df.addField(field);
DataLayout layout = new DataLayout("Label");
Fieldref reffield = new Fieldref("testField1");
layout.getPageLayout().add(reffield);
@ -89,25 +89,25 @@ public class DataFormTest {
section.getSectionLayout().add(new Text("SectionText"));
layout.getPageLayout().add(section);
layout.getPageLayout().add(new Text("PageText"));
df.addExtensionElement(layout);
assertNotNull( df.toXML());
String output = df.toXML().toString();
assertEquals(TEST_OUTPUT_2, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
df = pr.parse(parser);
assertNotNull(df);
assertNotNull(df.getExtensionElements());
assertEquals(1 , df.getExtensionElements().size() );
Element element = df.getExtensionElements().get(0);
assertNotNull(element);
layout = (DataLayout) element;
assertEquals(3 , layout.getPageLayout().size());
assertNotNull( df.toXML());
@ -126,22 +126,22 @@ public class DataFormTest {
ValidateElement dv = new RangeValidateElement("xs:integer","1111", "9999");
field.setValidateElement(dv);
assertNotNull( df.toXML());
String output = df.toXML().toString();
assertEquals(TEST_OUTPUT_3, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
df = pr.parse(parser);
assertNotNull(df);
assertNotNull(df.getFields());
assertEquals(1 , df.getFields().size() );
Element element = df.getFields().get(0).getValidateElement();
assertNotNull(element);
dv = (ValidateElement) element;
assertEquals("xs:integer" , dv.getDatatype());
assertNotNull( df.toXML());

View file

@ -55,15 +55,15 @@ public class DataLayoutTest {
section.getSectionLayout().add(new Text("SectionText"));
layout.getPageLayout().add(section);
layout.getPageLayout().add(new Text( "PageText"));
assertNotNull( layout.toXML());
String output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_2, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
layout = DataLayoutProvider.parse(parser);
assertEquals(3 , layout.getPageLayout().size());
assertEquals("Label", layout.getLabel());
@ -74,7 +74,7 @@ public class DataLayoutTest {
@Test
public void testLayoutSpecialCharacters() throws XmlPullParserException, IOException, SmackException {
DataLayout layout = new DataLayout("Label - & \u00E9 \u00E1 ");
Fieldref reffield = new Fieldref("testField1");
layout.getPageLayout().add(reffield);
@ -82,22 +82,22 @@ public class DataLayoutTest {
section.getSectionLayout().add(new Text( "SectionText - & \u00E9 \u00E1 "));
layout.getPageLayout().add(section);
layout.getPageLayout().add(new Text( "PageText - & \u00E9 \u00E1 "));
section = new Section("<html>Number of Persons by<br/> Nationality and Status</html>");
section.getSectionLayout().add(new Reportedref());
layout.getPageLayout().add(section);
layout.getPageLayout().add(new Text( "<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>"));
assertNotNull( layout.toXML());
String output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_SPECIAL, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
layout = DataLayoutProvider.parse(parser);
assertEquals(5 , layout.getPageLayout().size());
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
section = (Section) layout.getPageLayout().get(1);
@ -109,7 +109,7 @@ public class DataLayoutTest {
text = (Text) layout.getPageLayout().get(4);
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
assertNotNull( layout.toXML());
output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_SPECIAL, output);
@ -118,17 +118,17 @@ public class DataLayoutTest {
@Test
public void testLayoutFromFile() throws Exception {
DataFormProvider pr = new DataFormProvider();
XmlPullParser parser = PacketParserUtils.newXmppParser();
parser.setInput(new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8"));
parser.next();
DataForm form = pr.parse(parser);
assertNotNull( form);
assertEquals(1 , form.getExtensionElements().size());
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
assertEquals(5 , layout.getPageLayout().size());
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
Section section = (Section) layout.getPageLayout().get(1);
@ -140,7 +140,7 @@ public class DataLayoutTest {
text = (Text) layout.getPageLayout().get(4);
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
assertNotNull( layout.toXML());
String output = layout.toXML().toString();
assertEquals(TEST_OUTPUT_SPECIAL, output);

View file

@ -48,7 +48,7 @@ public class DataValidationHelperTest {
catch (ValidationConsistencyException e) {
assertEquals("Field type 'jid-single' is not consistent with validation method 'basic'.", e.getMessage());
}
try {
new ListRange(-1L, 1L);
fail("No correct check on consistency");
@ -56,7 +56,7 @@ public class DataValidationHelperTest {
catch (IllegalArgumentException e) {
assertEquals("unsigned 32-bit integers can't be negative", e.getMessage());
}
element.setListRange(new ListRange(10L, 100L));
try {
element.checkConsistency(field);

View file

@ -46,21 +46,21 @@ public class DataValidationTest {
@Test
public void testMin() throws XmlPullParserException, IOException, SmackException {
ValidateElement dv = new BasicValidateElement(null);
assertNotNull( dv.toXML());
String output = dv.toXML().toString();
assertEquals(TEST_OUTPUT_MIN, output);
XmlPullParser parser = getParser(TEST_INPUT_MIN);
dv = DataValidationProvider.parse(parser);
assertNotNull(dv);
assertEquals("xs:string", dv.getDatatype());
assertTrue( dv instanceof BasicValidateElement);
assertNotNull( dv.toXML());
output = dv.toXML().toString();
assertEquals(TEST_OUTPUT_MIN, output);
@ -68,18 +68,18 @@ public class DataValidationTest {
@Test
public void testRange() throws XmlPullParserException, IOException, SmackException {
ValidateElement dv = new RangeValidateElement("xs:string", "min-val", "max-val");
ListRange listRange = new ListRange(111L, 999L);
dv.setListRange(listRange );
assertNotNull( dv.toXML());
String output = dv.toXML().toString();
assertEquals(TEST_OUTPUT_RANGE, output);
XmlPullParser parser = getParser(output);
dv = DataValidationProvider.parse(parser);
assertNotNull(dv);
@ -91,8 +91,8 @@ public class DataValidationTest {
assertNotNull(rdv.getListRange());
assertEquals(new Long(111), rdv.getListRange().getMin());
assertEquals(999, rdv.getListRange().getMax().intValue());
assertNotNull( dv.toXML());
output = dv.toXML().toString();
assertEquals(TEST_OUTPUT_RANGE, output);
@ -100,15 +100,15 @@ public class DataValidationTest {
@Test
public void testRange2() throws XmlPullParserException, IOException, SmackException {
ValidateElement dv = new RangeValidateElement(null, null, null);
assertNotNull( dv.toXML());
String output = dv.toXML().toString();
assertEquals(TEST_OUTPUT_RANGE2, output);
XmlPullParser parser = getParser(output);
dv = DataValidationProvider.parse(parser);
assertNotNull(dv);
@ -117,7 +117,7 @@ public class DataValidationTest {
RangeValidateElement rdv = (RangeValidateElement) dv;
assertEquals(null, rdv.getMin());
assertEquals(null, rdv.getMax());
assertNotNull( rdv.toXML());
output = rdv.toXML().toString();
assertEquals(TEST_OUTPUT_RANGE2, output);