View Javadoc

1   /*
2    * $Id: HttpHeadersTestCase.java 22518 2011-07-22 07:00:22Z 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.transport.http.functional;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import org.mule.api.MuleMessage;
17  import org.mule.module.client.MuleClient;
18  import org.mule.tck.AbstractServiceAndFlowTestCase;
19  import org.mule.tck.junit4.rule.DynamicPort;
20  import org.mule.transport.http.HttpConstants;
21  
22  import java.util.Arrays;
23  import java.util.Collection;
24  
25  import org.junit.Rule;
26  import org.junit.Test;
27  import org.junit.runners.Parameterized.Parameters;
28  
29  public class HttpHeadersTestCase extends AbstractServiceAndFlowTestCase
30  {
31  
32      @Rule
33      public DynamicPort dynamicPort1 = new DynamicPort("port1");
34  
35      @Rule
36      public DynamicPort dynamicPort2 = new DynamicPort("port2");
37  
38      public HttpHeadersTestCase(ConfigVariant variant, String configResources)
39      {
40          super(variant, configResources);
41      }
42  
43      @Parameters
44      public static Collection<Object[]> parameters()
45      {
46          return Arrays.asList(new Object[][]{
47              {ConfigVariant.SERVICE, "http-headers-config-service.xml"},
48              {ConfigVariant.FLOW, "http-headers-config-flow.xml"}
49          });
50      }      
51      
52      @Test
53      public void testJettyHeaders() throws Exception 
54      {
55          MuleClient client = new MuleClient(muleContext);
56          MuleMessage result = client.send("clientEndpoint", null, null);
57  
58          String contentTypeProperty = result.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE);
59          assertNotNull(contentTypeProperty); 
60          assertEquals("application/x-download", contentTypeProperty);
61  
62          String contentDispositionProperty = result.getInboundProperty(HttpConstants.HEADER_CONTENT_DISPOSITION);
63          assertNotNull(contentDispositionProperty);
64          assertEquals("attachment; filename=foo.zip", contentDispositionProperty);
65      }
66  
67  }