1
2
3
4
5
6
7 package org.mule.module.atom.endpoint;
8
9 import org.mule.api.endpoint.EndpointFactory;
10 import org.mule.api.endpoint.InboundEndpoint;
11 import org.mule.api.registry.ServiceException;
12 import org.mule.tck.junit4.AbstractMuleContextTestCase;
13 import org.mule.transport.file.FileConnector;
14 import org.mule.transport.http.HttpPollingConnector;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21 import static org.junit.Assert.fail;
22
23
24
25
26 public class AtomEndpointTestCase extends AbstractMuleContextTestCase
27 {
28
29 @Test
30 public void testHttpInboundEndpointCreation() throws Exception
31 {
32 String uri = "atom:http://blog.com/atom";
33 EndpointFactory factory = muleContext.getEndpointFactory();
34 InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
35 assertNotNull(in);
36 assertEquals("atom:http", in.getEndpointURI().getFullScheme());
37 assertEquals("http", in.getProtocol());
38 assertTrue(in.getConnector() instanceof HttpPollingConnector);
39 assertTrue(in instanceof AtomInboundEndpoint);
40 }
41
42 @Test
43 public void testHttpOutboundEndpointCreation() throws Exception
44 {
45 String uri = "atom:http://blog.com/atom";
46 EndpointFactory factory = muleContext.getEndpointFactory();
47 try
48 {
49 factory.getEndpointBuilder(uri).buildOutboundEndpoint();
50 fail("ATOM outbound endpoints are not supported");
51 }
52 catch (UnsupportedOperationException e)
53 {
54
55 }
56 }
57
58 @Test
59 public void testFileInboundEndpointCreation() throws Exception
60 {
61 String uri = "atom:file://./src/foo";
62 EndpointFactory factory = muleContext.getEndpointFactory();
63 InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
64 assertNotNull(in);
65 assertEquals("atom:file", in.getEndpointURI().getFullScheme());
66 assertEquals("file", in.getProtocol());
67 assertTrue(in.getConnector() instanceof FileConnector);
68 assertTrue(in instanceof AtomInboundEndpoint);
69 }
70
71 @Test
72 public void testFileOutboundEndpointCreation() throws Exception
73 {
74 String uri = "atom:file://./src/foo";
75 EndpointFactory factory = muleContext.getEndpointFactory();
76 try
77 {
78 factory.getEndpointBuilder(uri).buildOutboundEndpoint();
79 fail("ATOM outbound endpoints are not supported");
80 }
81 catch (UnsupportedOperationException e)
82 {
83
84 }
85 }
86
87 @Test
88 public void testXXInboundEndpointCreation() throws Exception
89 {
90 String uri = "atom:xxx://./src/foo";
91 EndpointFactory factory = muleContext.getEndpointFactory();
92 try
93 {
94 factory.getEndpointBuilder(uri).buildInboundEndpoint();
95 fail("xxx is not a valid transport");
96 }
97 catch (ServiceException e)
98 {
99
100 }
101 }
102 }