1
2
3
4
5
6
7 package org.mule.transport.xmpp;
8
9 import org.mule.api.lifecycle.InitialisationException;
10 import org.mule.endpoint.MuleEndpointURI;
11 import org.mule.tck.junit4.AbstractMuleContextTestCase;
12
13 import org.junit.Test;
14
15 import static org.junit.Assert.assertEquals;
16
17 public class XmppEndpointTestCase extends AbstractMuleContextTestCase
18 {
19
20 @Test(expected = InitialisationException.class)
21 public void testEndpointWithoutMessageType() throws Exception
22 {
23 MuleEndpointURI uri = new MuleEndpointURI("xmpp://mule:secret@jabber.org", muleContext);
24 uri.initialise();
25 }
26
27 @Test
28 public void testValidMessageEndpoint() throws Exception
29 {
30 doTest("xmpp://MESSAGE/mule@jabber.org", "MESSAGE");
31 }
32
33 @Test
34 public void testValidChatEndpoint() throws Exception
35 {
36 doTest("xmpp://CHAT/mule@jabber.org", "CHAT");
37 }
38
39 @Test
40 public void testValidGroupchatEndpoint() throws Exception
41 {
42 doTest("xmpp://GROUPCHAT/mule@jabber.org", "GROUPCHAT");
43 }
44
45 private void doTest(String uriInput, String expectedMessageType) throws Exception
46 {
47 MuleEndpointURI uri = new MuleEndpointURI(uriInput, muleContext);
48 uri.initialise();
49
50 assertEquals("xmpp", uri.getScheme());
51 assertEquals(expectedMessageType, uri.getHost());
52 assertEquals("/mule@jabber.org", uri.getPath());
53 }
54
55 @Test(expected = InitialisationException.class)
56 public void testInvalidMessageTypeEndpoint() throws Exception
57 {
58 MuleEndpointURI uri = new MuleEndpointURI("xmpp://INVALID/mule@jabber.org", muleContext);
59 uri.initialise();
60 }
61 }