1 52 package org.jivesoftware.smackx.muc; 53 54 import java.util.*; 55 56 import org.jivesoftware.smack.*; 57 import org.jivesoftware.smack.test.SmackTestCase; 58 import org.jivesoftware.smackx.*; 59 60 65 public class MultiUserChatCreationTest extends SmackTestCase { 66 67 private String room; 68 69 73 public MultiUserChatCreationTest(String arg0) { 74 super(arg0); 75 } 76 77 80 public void testCreateReservedRoom() { 81 MultiUserChat muc = new MultiUserChat(getConnection(0), room); 82 83 try { 84 muc.create("testbot1"); 86 87 Form form = muc.getConfigurationForm(); 89 assertNotNull("No room configuration form", form); 90 Form submitForm = form.createAnswerForm(); 92 for (Iterator fields = form.getFields(); fields.hasNext();) { 94 FormField field = (FormField) fields.next(); 95 if (!FormField.TYPE_HIDDEN.equals(field.getType()) 96 && field.getVariable() != null) { 97 submitForm.setDefaultAnswer(field.getVariable()); 99 } 100 } 101 List owners = new ArrayList(); 102 owners.add(getBareJID(0)); 103 submitForm.setAnswer("muc#roomconfig_roomowners", owners); 104 105 muc.sendConfigurationForm(submitForm); 107 108 muc.destroy("The room has almost no activity...", null); 110 111 } 112 catch (XMPPException e) { 113 e.printStackTrace(); 114 fail(e.getMessage()); 115 } 116 } 117 118 121 public void testCreateInstantRoom() { 122 MultiUserChat muc = new MultiUserChat(getConnection(0), room); 123 124 try { 125 muc.create("testbot"); 127 128 muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT)); 131 132 muc.destroy("The room has almost no activity...", null); 134 } 135 catch (XMPPException e) { 136 e.printStackTrace(); 137 fail(e.getMessage()); 138 } 139 } 140 141 protected int getMaxConnections() { 142 return 2; 143 } 144 145 protected void setUp() throws Exception { 146 super.setUp(); 147 room = "fruta124@" + getMUCDomain(); 148 } 149 } 150 | Popular Tags |