View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.http.functional;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  import org.mule.transport.http.HttpConstants;
14  
15  import org.junit.Rule;
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  
21  public class HttpHeadersTestCase extends FunctionalTestCase
22  {
23  
24      @Rule
25      public DynamicPort dynamicPort1 = new DynamicPort("port1");
26  
27      @Rule
28      public DynamicPort dynamicPort2 = new DynamicPort("port2");
29  
30      @Override
31      protected String getConfigResources()
32      {
33          return "http-headers-config.xml";
34      }
35  
36      @Test
37      public void testJettyHeaders() throws Exception 
38      {
39          MuleClient client = new MuleClient(muleContext);
40          MuleMessage result = client.send("clientEndpoint", null, null);
41  
42          String contentTypeProperty = result.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE);
43          assertNotNull(contentTypeProperty); 
44          assertEquals("application/x-download", contentTypeProperty);
45  
46          String contentDispositionProperty = result.getInboundProperty(HttpConstants.HEADER_CONTENT_DISPOSITION);
47          assertNotNull(contentDispositionProperty);
48          assertEquals("attachment; filename=foo.zip", contentDispositionProperty);
49      }
50  
51  }