View Javadoc

1   /*
2    * $Id: EndpointContentTypeTestCase.java 22460 2011-07-20 07:44:33Z claude.mamo $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.endpoints;
12  
13  import static org.junit.Assert.assertEquals;
14  
15  import org.mule.api.endpoint.EndpointBuilder;
16  import org.mule.api.endpoint.InboundEndpoint;
17  import org.mule.api.endpoint.OutboundEndpoint;
18  import org.mule.tck.AbstractServiceAndFlowTestCase;
19  
20  import java.util.Arrays;
21  import java.util.Collection;
22  
23  import org.junit.Test;
24  import org.junit.runners.Parameterized.Parameters;
25  
26  /** Test configuration of content-type in various endpoints */
27  public class EndpointContentTypeTestCase  extends AbstractServiceAndFlowTestCase
28  {   
29      public EndpointContentTypeTestCase(ConfigVariant variant, String configResources)
30      {
31          super(variant, configResources);
32      }
33  
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{
38              {ConfigVariant.SERVICE, "content-type-setting-endpoint-configs-service.xml"},
39              {ConfigVariant.FLOW, "content-type-setting-endpoint-configs-flow.xml"}
40          });
41      }      
42      
43      @Test
44      public void testContentType()  throws Exception
45      {
46          InboundEndpoint inbound = muleContext.getRegistry().lookupObject("inbound");
47          assertEquals("text/xml", inbound.getMimeType());
48          assertEquals("utf-8", inbound.getEncoding());
49          OutboundEndpoint outbound = muleContext.getRegistry().lookupObject("outbound");
50          assertEquals("application/json", outbound.getMimeType());
51          assertEquals("iso-8859-2", outbound.getEncoding());
52          EndpointBuilder global = muleContext.getRegistry().lookupEndpointBuilder("global");
53          InboundEndpoint created = global.buildInboundEndpoint();
54          assertEquals("application/xml", created.getMimeType());
55          assertEquals("iso-8859-1", created.getEncoding());
56      }
57  }