try {
// Create the room
muc.create("testbot1");
// Get the the room's configuration form
Form form = muc.getConfigurationForm();
assertNotNull("No room configuration form", form);
// Create a new form to submit based on the original form
Form submitForm = form.createAnswerForm();
// Add default answers to the form to submit
for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
FormField field = fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType())
&& field.getVariable() != null) {
// Sets the default value as the answer
submitForm.setDefaultAnswer(field.getVariable());
}
}
List<String> owners = new ArrayList<String>();
owners.add(getBareJID(0));
submitForm.setAnswer("muc#roomconfig_roomowners", owners);
// Update the new room's configuration
muc.sendConfigurationForm(submitForm);
// Destroy the new room