1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-15 03:59:38 +02:00

Make DataForm type an enum

This commit is contained in:
Florian Schmaus 2015-01-10 20:10:46 +01:00
parent 98c69f6895
commit f1a1215f35
14 changed files with 63 additions and 97 deletions

View file

@ -116,7 +116,7 @@ public class EntityCapsManagerTest extends InitExtensions {
di.addFeature("http://jabber.org/protocol/muc");
di.addFeature("http://jabber.org/protocol/disco#info");
DataForm df = new DataForm("result");
DataForm df = new DataForm(DataForm.Type.result);
FormField ff = new FormField("os");
ff.addValue("Mac");
@ -173,7 +173,7 @@ public class EntityCapsManagerTest extends InitExtensions {
// Failure 2: Duplicate features
di.addFeature("http://jabber.org/protocol/disco#info");
DataForm df = new DataForm("result");
DataForm df = new DataForm(DataForm.Type.result);
FormField ff = new FormField("os");
ff.addValue("Mac");
@ -205,7 +205,7 @@ public class EntityCapsManagerTest extends InitExtensions {
// Failure 3: Another service discovery information form with the same
// FORM_TYPE
df = new DataForm("result");
df = new DataForm(DataForm.Type.result);
ff = new FormField("FORM_TYPE");
ff.setType(FormField.Type.hidden);

View file

@ -28,7 +28,7 @@ import org.junit.Test;
public class RoomInfoTest {
@Test
public void validateRoomWithEmptyForm() {
DataForm dataForm = new DataForm("result");
DataForm dataForm = new DataForm(DataForm.Type.result);
DiscoverInfo discoInfo = new DiscoverInfo();
discoInfo.addExtension(dataForm);
@ -40,7 +40,7 @@ public class RoomInfoTest {
@Test
public void validateRoomWithForm() {
DataForm dataForm = new DataForm("result");
DataForm dataForm = new DataForm(DataForm.Type.result);
FormField desc = new FormField("muc#roominfo_description");
desc.addValue("The place for all good witches!");

View file

@ -30,6 +30,7 @@ import org.jivesoftware.smack.packet.XMPPError.Condition;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.junit.Assert;
import org.junit.Test;
@ -43,7 +44,7 @@ public class ConfigureFormTest
@Test
public void checkChildrenAssocPolicy()
{
ConfigureForm form = new ConfigureForm(FormType.submit);
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
}

View file

@ -44,14 +44,14 @@ import org.xmlpull.v1.XmlPullParserException;
*
*/
public class DataFormTest {
private static final String TEST_OUTPUT_1 = "<x xmlns='jabber:x:data' type='SUBMIT'><instructions>InstructionTest1</instructions><field var='testField1'></field></x>";
private static final String TEST_OUTPUT_2 = "<x xmlns='jabber:x:data' type='SUBMIT'><instructions>InstructionTest1</instructions><field var='testField1'></field><page xmlns='http://jabber.org/protocol/xdata-layout' label='Label'><fieldref var='testField1'/><section label='section Label'><text>SectionText</text></section><text>PageText</text></page></x>";
private static final String TEST_OUTPUT_3 = "<x xmlns='jabber:x:data' type='SUBMIT'><instructions>InstructionTest1</instructions><field var='testField1'><validate xmlns='http://jabber.org/protocol/xdata-validate' datatype='xs:integer'><range min='1111' max='9999'/></validate></field></x>";
private static final String TEST_OUTPUT_1 = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field var='testField1'></field></x>";
private static final String TEST_OUTPUT_2 = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field var='testField1'></field><page xmlns='http://jabber.org/protocol/xdata-layout' label='Label'><fieldref var='testField1'/><section label='section Label'><text>SectionText</text></section><text>PageText</text></page></x>";
private static final String TEST_OUTPUT_3 = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field var='testField1'><validate xmlns='http://jabber.org/protocol/xdata-validate' datatype='xs:integer'><range min='1111' max='9999'/></validate></field></x>";
@Test
public void test() throws XmlPullParserException, IOException, SmackException {
//Build a Form
DataForm df = new DataForm("SUBMIT");
DataForm df = new DataForm(DataForm.Type.submit);
String instruction = "InstructionTest1";
df.addInstruction(instruction);
FormField field = new FormField("testField1");
@ -80,7 +80,7 @@ public class DataFormTest {
@Test
public void testLayout() throws XmlPullParserException, IOException, SmackException {
//Build a Form
DataForm df = new DataForm("SUBMIT");
DataForm df = new DataForm(DataForm.Type.submit);
String instruction = "InstructionTest1";
df.addInstruction(instruction);
FormField field = new FormField("testField1");
@ -124,7 +124,7 @@ public class DataFormTest {
@Test
public void testValidation() throws XmlPullParserException, IOException, SmackException {
//Build a Form
DataForm df = new DataForm("SUBMIT");
DataForm df = new DataForm(DataForm.Type.submit);
String instruction = "InstructionTest1";
df.addInstruction(instruction);
FormField field = new FormField("testField1");