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