Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional logging #299

Merged
merged 1 commit into from
Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.buddycloud.channelserver.pubsub.model.impl.GlobalItemIDImpl;
import org.buddycloud.channelserver.pubsub.subscription.Subscriptions;
import org.buddycloud.channelserver.utils.XMLConstants;
import org.buddycloud.channelserver.utils.node.item.payload.Buddycloud;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.dom.DOMElement;
Expand Down Expand Up @@ -82,7 +83,10 @@ public void process(Element elm, JID actor, IQ reqIQ, Element rsm) throws Interr
setErrorCondition(PacketError.Type.modify, PacketError.Condition.bad_request);
} catch (IllegalArgumentException e) {
LOGGER.error(e);
setErrorCondition(PacketError.Type.modify, PacketError.Condition.bad_request);
createExtendedErrorReply(
PacketError.Type.modify, PacketError.Condition.bad_request,
"global-id-error", Buddycloud.NS_ERROR, e.getMessage()
);
}
outQueue.put(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,17 @@ public void testProvidingEmptyItemIdReturnsError() throws Exception {
}

@Test
public void testItemWhichDoesntExistReturnsItemNotFoundError()
public void itemWhichDoesntExistReturnsItemNotFoundError()
throws Exception {

Mockito.when(channelManager.nodeExists(node)).thenReturn(true);
Mockito.when(channelManager.getNodeItem(node, "item-id")).thenReturn(
null);
itemDelete.setChannelManager(channelManager);

itemDelete.process(element, jid, request, null);

Packet response = queue.poll(100, TimeUnit.MILLISECONDS);
Packet response = queue.poll();

PacketError error = response.getError();
Assert.assertNotNull(error);
Expand Down Expand Up @@ -285,12 +286,12 @@ public void testSuccessfulRequestSendsResponseStanza() throws Exception {
itemDelete.process(element, jid, request, null);

Mockito.verify(channelManager).deleteNodeItemById(node, "item-id");
IQ response = (IQ) queue.poll(100, TimeUnit.MILLISECONDS);
IQ response = (IQ) queue.poll();

Assert.assertEquals(IQ.Type.result.toString(), response.getElement()
.attribute("type").getValue());
// Check that no notifications are sent
Packet notification = queue.poll(100, TimeUnit.MILLISECONDS);
Packet notification = queue.poll();
Assert.assertNull(notification);
}

Expand Down Expand Up @@ -485,4 +486,32 @@ public void requestsThreadWhenDeletingParentPost() throws Exception {
notification.getElement().element("event").element("items")
.element("retract").attributeValue("id"));
}

@Test
public void canDeleteItemUsingAFullItemId() throws Exception {

NodeItem nodeItem = new NodeItemImpl(node, "item-id", new Date(),
payload.replaceAll("romeo@shakespeare.lit",
"juliet@shakespeare.lit"), "item-id");

Mockito.when(channelManager.nodeExists(node)).thenReturn(true);
Mockito.when(
channelManager.getNodeItem(Mockito.eq("/user/capulet@shakespeare.lit/posts"),
Mockito.eq("item-id"))).thenReturn(nodeItem);

IQ request = toIq(readStanzaAsString("/iq/pubsub/item/delete/request-full-id.stanza"));

itemDelete.setChannelManager(channelManager);

itemDelete.process(element, jid, request, null);

Mockito.verify(channelManager).deleteNodeItemById(node, "item-id");
IQ response = (IQ) queue.poll();

Assert.assertEquals(IQ.Type.result.toString(), response.getElement()
.attribute("type").getValue());
// Check that no notifications are sent
Packet notification = queue.poll();
Assert.assertNull(notification);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<iq type='set'
from='juliet@shakespeare.lit/thebalcony'
to='channels.shakespeare.lit'
id='retract1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<retract node='/user/capulet@shakespeare.lit/posts'>
<item id='tag:null@channels.example.com,/user/capulet@shakespeare.lit/posts,item-id' notify='true' />
</retract>
</pubsub>
</iq>