/**
 * 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.activemq.camel;

import static org.junit.Assert.*;

import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AMQ2240Test {

    private static final Logger LOG = LoggerFactory.getLogger(AMQ2240Test.class);

    @Test
    public void testBadVMTransportOptionsJMSPrefix() throws Exception {

        try{
            final String vmUri = "vm://localhost?" +
                "jms.redeliveryPolicy.maximumRedeliveries=0&" +
                "jms.redeliveryPolicy.initialRedeliveryDelay=500&" +
                "jms.useAsyncSend=false&jms.sendTimeout=ABC&" +
                "jms.maxXXXXReconnectAttempts=1&jms.timeout=3000";

            LOG.info("creating context with bad URI: " + vmUri);
            ActiveMQComponent.activeMQComponent(vmUri);

            fail("Should have received an exception from the bad URI.");
        } catch(Exception e) {
            // Expected
        }
    }

    @Test
    public void testBadVMTransportOptionsBrokerPrefix() throws Exception {
        try{
            final String vmUri = "vm://localhost?" +
                "broker.XXX=foo&broker.persistent=XXX&broker.useJmx=false";

            LOG.info("creating context with bad URI: " + vmUri);
            ActiveMQComponent.activeMQComponent(vmUri).start();

            fail("Should have received an exception from the bad URI.");
        } catch(Exception e) {
            // Expected
        }
    }
}

@@ -859,17 +859,20 @@
 .Assert.
-*
+fail
 ;%0A%0Aimpor
@@ -897,28 +897,34 @@
 emq.
-broker.BrokerService
+camel.AMQ2611Test.Consumer
 ;%0Aim
@@ -1013,32 +1013,74 @@
 l.CamelContext;%0A
+import org.apache.camel.ProducerTemplate;%0A
 import org.apach
@@ -1187,33 +1187,8 @@
 er;%0A
-import org.junit.Before;%0A
 impo
@@ -1371,24 +1371,258 @@
 st.class);%0A%0A
+    private CamelContext camelContext = null;%0A%0A    @After%0A    public void destroyCamelContext() throws Exception %7B%0A        if (camelContext != null) %7B%0A            camelContext.stop();%0A            camelContext = null;%0A        %7D%0A    %7D%0A%0A
     @Test%0A  
@@ -2378,33 +2378,35 @@
 on %7B%0A        try
-%7B
+ %7B%0A
 %0A            fin
@@ -2588,32 +2588,56 @@
 ri);%0A           
+ ActiveMQComponent amq =
  ActiveMQCompone
@@ -2667,15 +2667,640 @@
 Uri)
-.start(
+;%0A%0A            camelContext = new DefaultCamelContext();%0A            camelContext.addComponent(%22activemq%22, amq);%0A            final String queueEndpointName = %22activemq:queuetest.Queue%22;%0A            camelContext.addRoutes(new RouteBuilder() %7B%0A                @Override%0A                public void configure() throws Exception %7B%0A                    from(queueEndpointName).bean(Consumer.class, %22consume%22);%0A                %7D%0A            %7D);%0A%0A            camelContext.start();%0A            final ProducerTemplate producerTemplate = camelContext.createProducerTemplate();%0A            producerTemplate.sendBody(queueEndpointName, %22message%22
 );%0A%0A

Fix failing test case, things are more lazily loaded now so we must actually invoke the route before the URI will get used and the exception fired.