1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.util;
12
13 import org.mule.api.endpoint.ImmutableEndpoint;
14 import org.mule.tck.junit4.AbstractMuleContextTestCase;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertEquals;
19
20 public class ObjectNameHelperTestCase extends AbstractMuleContextTestCase
21 {
22
23 @Test
24 public void testEndpointAutomaticNames() throws Exception
25 {
26 ImmutableEndpoint ep = muleContext.getEndpointFactory().getInboundEndpoint(
27 "test://cn=foo,name=queue");
28 muleContext.getRegistry().registerEndpoint(ep);
29 assertEquals("endpoint.test.cn.foo.name.queue", ep.getName());
30
31 ep = muleContext.getEndpointFactory().getInboundEndpoint("test://cn=foo,name=queue");
32 assertEquals("endpoint.test.cn.foo.name.queue.1", ep.getName());
33
34
35 ep = muleContext.getEndpointFactory().getInboundEndpoint("vm://my.queue");
36 assertEquals("endpoint.vm.my.queue", ep.getName());
37 ep = muleContext.getEndpointFactory().getInboundEndpoint(
38 "pop3://ross:secret@mail.mycompany.com?subject=foo");
39 assertEquals("endpoint.pop3.ross.mycompany.com", ep.getName());
40 }
41
42 @Test
43 public void testEndpointNames() throws Exception
44 {
45 ImmutableEndpoint ep = muleContext.getEndpointFactory().getInboundEndpoint(
46 "test://cn=foo,name=queue?endpointName=foo");
47 muleContext.getRegistry().registerEndpoint(ep);
48 assertEquals("endpoint.test.cn.foo.name.queue", ep.getName());
49
50 ep = muleContext.getEndpointFactory().getInboundEndpoint(
51 "test://cn=foo,name=queue?endpointName=this_is@aWierd-Name:x");
52 assertEquals("this.is.aWierd.Name.x", ep.getName());
53 muleContext.getRegistry().registerEndpoint(ep);
54
55
56 ep = muleContext.getEndpointFactory().getInboundEndpoint(
57 "test://cn=foo,name=queue?endpointName=this_is@aWierd-Name:x");
58 assertEquals("this.is.aWierd.Name.x", ep.getName());
59 ep = muleContext.getEndpointFactory().getInboundEndpoint(
60 "test://cn=foo,name=queue?endpointName=this____is+another=@Wierd----Name:x:::");
61 assertEquals("this.is.another.Wierd.Name.x", ep.getName());
62 }
63
64 @Test
65 public void testTestEndpoint() throws Exception
66 {
67 ImmutableEndpoint ep = muleContext.getEndpointFactory().getInboundEndpoint(
68 "test://exception.listener");
69 muleContext.getRegistry().registerEndpoint(ep);
70 assertEquals("endpoint.test.exception.listener", ep.getName());
71 }
72
73 }