/*
* Copyright (c) 2015 Tarun Gupta.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
package com.isode.stroke.parser.payloadparsers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.isode.stroke.elements.InBandRegistrationPayload;
import com.isode.stroke.elements.Form;
import com.isode.stroke.parser.payloadparsers.InBandRegistrationPayloadParser;
import com.isode.stroke.parser.payloadparsers.PayloadsParserTester;
import com.isode.stroke.eventloop.DummyEventLoop;
public class InBandRegistrationPayloadParserTest {
public InBandRegistrationPayloadParserTest() {
}
@Test
public void testParse() {
DummyEventLoop eventLoop = new DummyEventLoop();
PayloadsParserTester parser = new PayloadsParserTester(eventLoop);
assertNotNull(parser.parse("" +
"" +
""));
InBandRegistrationPayload payload = (InBandRegistrationPayload)parser.getPayload();
assertNotNull(payload);
assertTrue(payload.isRegistered());
}
@Test
public void testParse_Form() {
DummyEventLoop eventLoop = new DummyEventLoop();
PayloadsParserTester parser = new PayloadsParserTester(eventLoop);
assertNotNull(parser.parse("" +
"Use the enclosed form to register." +
"" +
"Contest Registration" +
"" +
"jabber:iq:register" +
"" +
"" +
""));
InBandRegistrationPayload payload = (InBandRegistrationPayload)parser.getPayload();
assertNotNull(payload);
assertEquals("Use the enclosed form to register.", payload.getInstructions());
Form form = payload.getForm();
assertNotNull(form);
assertEquals("Contest Registration", form.getTitle());
assertEquals(Form.Type.FORM_TYPE, form.getType());
assertEquals("jabber:iq:register", form.getFormType());
}
}