|
Minor issue: MuleMessageToHttpResponseTestCase must extend AbstractMuleTestCase
Pablo On Mon, Jul 30, 2012 at 6:23 PM, <[hidden email]> wrote:
- Revision
- 24698
- Author
- svacas
- Date
- 2012-07-30 16:23:24 -0500 (Mon, 30 Jul 2012)
Log Message
MULE-6365: Set-Cookie OutboundProperty not working for more than one Cookie
Modified Paths
Added Paths
Diff
Modified: branches/mule-3.3.x/transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java (24697 => 24698)
--- branches/mule-3.3.x/transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java 2012-07-30 14:31:39 UTC (rev 24697)
+++ branches/mule-3.3.x/transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java 2012-07-30 21:23:24 UTC (rev 24698)
@@ -285,6 +285,11 @@
//attach the outbound properties to the message
for (String headerName : msg.getOutboundPropertyNames())
{
+ if (response.getFirstHeader(headerName) != null)
+ {
+ //keep headers already set
+ continue;
+ }
Object v = msg.getOutboundProperty(headerName);
if (v != null)
{
Added: branches/mule-3.3.x/transports/http/src/test/java/org/mule/transport/http/transformers/MuleMessageToHttpResponseTestCase.java (0 => 24698)
--- branches/mule-3.3.x/transports/http/src/test/java/org/mule/transport/http/transformers/MuleMessageToHttpResponseTestCase.java (rev 0)
+++ branches/mule-3.3.x/transports/http/src/test/java/org/mule/transport/http/transformers/MuleMessageToHttpResponseTestCase.java 2012-07-30 21:23:24 UTC (rev 24698)
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ * --------------------------------------------------------------------------------------
+ * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
+ *
+ * The software in this package is published under the terms of the CPAL v1.0
+ * license, a copy of which has been included with this distribution in the
+ * LICENSE.txt file.
+ */
+
+package org.mule.transport.http.transformers;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.mule.api.MuleMessage;
+import org.mule.tck.size.SmallTest;
+import org.mule.transport.http.HttpResponse;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.Header;
+import org.junit.Assert;
+import org.junit.Test;
+
+@SmallTest
+public class MuleMessageToHttpResponseTestCase
+{
+
+ @Test
+ public void testSetCookieOnOutbound() throws Exception
+ {
+ MuleMessageToHttpResponse transformer = new MuleMessageToHttpResponse();
+ MuleMessage msg = mock(MuleMessage.class);
+
+ Cookie[] cookiesOutbound = new Cookie[2];
+ cookiesOutbound[0] = new Cookie("domain", "name-out-1", "value-out-1");
+ cookiesOutbound[1] = new Cookie("domain", "name-out-2", "value-out-2");
+
+ when(msg.getOutboundProperty("Set-Cookie")).thenReturn(cookiesOutbound);
+ Set props = new HashSet();
+ props.add("Set-Cookie");
+ when(msg.getOutboundPropertyNames()).thenReturn(props);
+
+ HttpResponse response = transformer.createResponse(null, "UTF-8", msg);
+ Header[] headers = response.getHeaders();
+ int cookiesSet = 0;
+ for(Header header : headers)
+ {
+ if ("Set-Cookie".equals(header.getName()))
+ {
+ cookiesSet++;
+ }
+ }
+ Assert.assertEquals(cookiesOutbound.length, cookiesSet);
+ }
+}
Property changes on: branches/mule-3.3.x/transports/http/src/test/java/org/mule/transport/http/transformers/MuleMessageToHttpResponseTestCase.java
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
|