1
2
3
4
5
6
7 package org.mule.module.rss;
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.module.rss.endpoint.RssInboundEndpoint;
13 import org.mule.tck.junit4.AbstractMuleContextTestCase;
14 import org.mule.transport.file.FileConnector;
15 import org.mule.transport.http.HttpPollingConnector;
16
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.fail;
23
24 public class RssEndpointTestCase extends AbstractMuleContextTestCase
25 {
26
27 @Test
28 public void testHttpInboundEndpointCreation() throws Exception
29 {
30 String uri = "rss:http://blog.com/rss";
31 EndpointFactory factory = muleContext.getEndpointFactory();
32 InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
33 assertNotNull(in);
34 assertEquals("rss:http", in.getEndpointURI().getFullScheme());
35 assertEquals("http", in.getProtocol());
36 assertTrue(in.getConnector() instanceof HttpPollingConnector);
37 assertTrue(in instanceof RssInboundEndpoint);
38 }
39
40 @Test(expected = UnsupportedOperationException.class)
41 public void testHttpOutboundEndpointCreation() throws Exception
42 {
43 String uri = "rss:http://blog.com/rss";
44 EndpointFactory factory = muleContext.getEndpointFactory();
45
46 factory.getEndpointBuilder(uri).buildOutboundEndpoint();
47 }
48
49 @Test
50 public void testFileInboundEndpointCreation() throws Exception
51 {
52 String uri = "rss:file://./src/foo";
53 EndpointFactory factory = muleContext.getEndpointFactory();
54 InboundEndpoint in = factory.getEndpointBuilder(uri).buildInboundEndpoint();
55 assertNotNull(in);
56 assertEquals("rss:file", in.getEndpointURI().getFullScheme());
57 assertEquals("file", in.getProtocol());
58 assertTrue(in.getConnector() instanceof FileConnector);
59 assertTrue(in instanceof RssInboundEndpoint);
60 }
61
62 @Test(expected = UnsupportedOperationException.class)
63 public void testFileOutboundEndpointCreation() throws Exception
64 {
65 String uri = "rss:file://./src/foo";
66 EndpointFactory factory = muleContext.getEndpointFactory();
67
68 factory.getEndpointBuilder(uri).buildOutboundEndpoint();
69 }
70
71 @Test(expected = ServiceException.class)
72 public void testXXInboundEndpointCreation() throws Exception
73 {
74 String uri = "rss:xxx://./src/foo";
75 EndpointFactory factory = muleContext.getEndpointFactory();
76
77 factory.getEndpointBuilder(uri).buildInboundEndpoint();
78 }
79 }