Skip to content
Open
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
@@ -1,6 +1,7 @@
package org.buddycloud.channelserver.channel.node.configuration;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
Expand Down Expand Up @@ -123,8 +124,18 @@ private List<FormField> getConfigurationValuesFromDisco(IQ request) {
}

private List<FormField> getConfigurationValues(IQ request) {
Element element = request.getElement().element("pubsub")
.element("configure").element("x");
Element configure = request.getElement().element("pubsub").element("configure");

if(configure == null) {
return Collections.emptyList();
}

Element element = configure.element("x");

if(element == null) {
return Collections.emptyList();
}

DataForm dataForm = new DataForm(element);
List<FormField> fields = dataForm.getFields();
return fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public void setUp() {
parser.setFieldFactory(new Factory());
}

@Test(expected = NodeConfigurationException.class)
public void testPassingPacketWhichDoesntContainConfigureElementThrowsException() {
Element iq = new DOMElement("iq");
iq.addElement("pubsub", JabberPubsub.NS_PUBSUB_OWNER);
IQ request = new IQ(iq);

parser.parse(request);
}

@Test
public void testNotProvidingAnyConfigurationFieldsReturnsOnlyLastUpdatedDate()
throws NodeStoreException {
Expand Down Expand Up @@ -382,4 +373,35 @@ public void testRequiredFieldsGetSetIfNotPresentInExistingData() throws Exceptio
Assert.assertNotNull(configurationValues.get(LastUpdatedDate.FIELD_NAME));

}

/**
* We expect this to <b>not</b> throw a {@link NodeConfigurationException}
*
* @see https://github.com/buddycloud/buddycloud-server-java/issues/200
*/
@Test
public void testParseIQWithMissingForm() {
Element iq = new DOMElement("iq");
Element pubsub = iq.addElement("pubsub");
pubsub.addAttribute("xmlns", JabberPubsub.NS_PUBSUB_OWNER);
pubsub.addElement("configure");

IQ request = new IQ(iq);
parser.parse(request);
}

/**
* We expect this to <b>not</b> throw a {@link NodeConfigurationException}
*
* @see https://github.com/buddycloud/buddycloud-server-java/issues/200
*/
@Test
public void testParseIQWithMissingConfigure() {
Element iq = new DOMElement("iq");
Element pubsub = iq.addElement("pubsub");
pubsub.addAttribute("xmlns", JabberPubsub.NS_PUBSUB_OWNER);

IQ request = new IQ(iq);
parser.parse(request);
}
}