2013-02-07 15:19:47 +01:00
|
|
|
/**
|
|
|
|
*
|
2013-04-07 21:15:32 +02:00
|
|
|
* Copyright 2011 Robin Collier
|
2013-02-07 15:19:47 +01:00
|
|
|
*
|
|
|
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-03-30 04:34:21 +02:00
|
|
|
package org.jivesoftware.smackx.pubsub;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
2011-09-08 23:32:06 +02:00
|
|
|
import org.jivesoftware.smack.SmackConfiguration;
|
2014-01-31 04:41:25 +01:00
|
|
|
import org.jivesoftware.smack.ThreadedDummyConnection;
|
2011-09-08 23:32:06 +02:00
|
|
|
import org.jivesoftware.smack.XMPPException;
|
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
|
|
|
import org.jivesoftware.smack.packet.PacketExtension;
|
|
|
|
import org.jivesoftware.smack.packet.XMPPError;
|
|
|
|
import org.jivesoftware.smack.packet.XMPPError.Condition;
|
|
|
|
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
|
|
|
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity;
|
|
|
|
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
|
|
|
import org.junit.Assert;
|
2011-03-30 04:34:21 +02:00
|
|
|
import org.junit.Test;
|
2013-04-07 21:15:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Robin Collier
|
|
|
|
*
|
|
|
|
*/
|
2011-03-30 04:34:21 +02:00
|
|
|
public class ConfigureFormTest
|
|
|
|
{
|
|
|
|
@Test
|
|
|
|
public void checkChildrenAssocPolicy()
|
|
|
|
{
|
|
|
|
ConfigureForm form = new ConfigureForm(FormType.submit);
|
|
|
|
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
|
|
|
|
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
|
|
|
|
}
|
2011-09-08 23:32:06 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getConfigFormWithInsufficientPriviliges() throws XMPPException
|
|
|
|
{
|
|
|
|
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
|
|
|
PubSubManager mgr = new PubSubManager(con);
|
|
|
|
DiscoverInfo info = new DiscoverInfo();
|
2013-03-18 09:50:48 +01:00
|
|
|
Identity ident = new Identity("pubsub", null, "leaf");
|
2011-09-08 23:32:06 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
catch (XMPPException e)
|
|
|
|
{
|
|
|
|
Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 03:26:22 +02:00
|
|
|
@Test (expected=XMPPException.class)
|
2011-09-08 23:32:06 +02:00
|
|
|
public void getConfigFormWithTimeout() throws XMPPException
|
|
|
|
{
|
|
|
|
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
|
|
|
PubSubManager mgr = new PubSubManager(con);
|
|
|
|
DiscoverInfo info = new DiscoverInfo();
|
2013-03-18 09:50:48 +01:00
|
|
|
Identity ident = new Identity("pubsub", null, "leaf");
|
2011-09-08 23:32:06 +02:00
|
|
|
info.addIdentity(ident);
|
|
|
|
con.addIQReply(info);
|
|
|
|
|
|
|
|
Node node = mgr.getNode("princely_musings");
|
|
|
|
|
2013-03-19 03:37:36 +01:00
|
|
|
SmackConfiguration.setPacketReplyTimeout(100);
|
|
|
|
con.setTimeout();
|
|
|
|
|
2011-09-09 03:26:22 +02:00
|
|
|
node.getNodeConfiguration();
|
2011-09-08 23:32:06 +02:00
|
|
|
}
|
2011-03-30 04:34:21 +02:00
|
|
|
}
|