/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.issues;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;

/**
 * @version $Revision$
 */
public class TryCatchSetHeaderIssueTest extends ContextTestSupport {

    public void testTryCatchSetHeaderIssue() throws Exception {
        getMockEndpoint("mock:end").expectedBodiesReceived("Hello World");
        getMockEndpoint("mock:end").expectedHeaderReceived("foo", "error");

        template.sendBody("direct:start", "Hello World");

        assertMockEndpointsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                    .doTry()
                        .setHeader("foo", constant("try"))
                        .throwException(new IllegalArgumentException("Damn"))
                    .doCatch(Exception.class)
                        .setHeader("foo", constant("error"))
                    .end()
                    .to("mock:end");
            }
        };
    }
}

@@ -1079,32 +1079,582 @@
 ows Exception %7B%0A
+        context.addRoutes(new RouteBuilder() %7B%0A            @Override%0A            public void configure() throws Exception %7B%0A                from(%22direct:start%22)%0A                    .doTry()%0A                        .setHeader(%22foo%22, constant(%22try%22))%0A                        .throwException(new IllegalArgumentException(%22Damn%22))%0A                    .doCatch(Exception.class)%0A                        .setHeader(%22foo%22, constant(%22error%22))%0A                    .end()%0A                    .to(%22mock:end%22);%0A            %7D%0A        %7D);%0A        context.start();%0A%0A
         getMockE
@@ -1903,63 +1903,49 @@
     
-@Override%0A    protected RouteBuilder createRouteBuilder
+public void testTryCatchTwoSetHeaderIssue
 () t
@@ -1974,15 +1974,26 @@
     
-return 
+context.addRoutes(
 new 
@@ -2310,32 +2310,47 @@
        .doCatch(
+IllegalArgument
 Exception.class)
@@ -2436,50 +2436,744 @@
    .
-end()%0A                    .to(%22mock:end%22);
+doCatch(Exception.class)%0A                        .setHeader(%22foo%22, constant(%22damn%22))%0A                    .end()%0A                    .to(%22mock:end%22);%0A            %7D%0A        %7D);%0A        context.start();%0A%0A        getMockEndpoint(%22mock:end%22).expectedBodiesReceived(%22Hello World%22);%0A        getMockEndpoint(%22mock:end%22).expectedHeaderReceived(%22foo%22, %22error%22);%0A%0A        template.sendBody(%22direct:start%22, %22Hello World%22);%0A%0A        assertMockEndpointsSatisfied();%0A    %7D%0A%0A    @Override%0A    public boolean isUseRouteBuilder() %7B%0A        return false;%0A    %7D%0A%0A    @Override%0A    protected RouteBuilder createRouteBuilder() throws Exception %7B%0A        return new RouteBuilder() %7B%0A            @Override%0A            public void configure() throws Exception %7B
 %0A   

add try catch test with multiple catch blocks