Skip to content

Commit

Permalink
CAMEL-9672: ClassCastException with interceptFrom and using when with…
Browse files Browse the repository at this point in the history
… JMX. Thanks to Stephan Siano for the patch.
  • Loading branch information
davsclaus committed Mar 7, 2016
1 parent 7944093 commit 8492269
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
Expand Up @@ -96,6 +96,7 @@
import org.apache.camel.management.mbean.ManagedValidate; import org.apache.camel.management.mbean.ManagedValidate;
import org.apache.camel.management.mbean.ManagedWeightedLoadBalancer; import org.apache.camel.management.mbean.ManagedWeightedLoadBalancer;
import org.apache.camel.management.mbean.ManagedWireTapProcessor; import org.apache.camel.management.mbean.ManagedWireTapProcessor;
import org.apache.camel.model.ExpressionNode;
import org.apache.camel.model.LoadBalanceDefinition; import org.apache.camel.model.LoadBalanceDefinition;
import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.model.ProcessDefinition; import org.apache.camel.model.ProcessDefinition;
Expand Down Expand Up @@ -307,7 +308,7 @@ public Object getManagedObjectForProcessor(CamelContext context, Processor proce
} else if (target instanceof RoutingSlip) { } else if (target instanceof RoutingSlip) {
answer = new ManagedRoutingSlip(context, (RoutingSlip) target, (org.apache.camel.model.RoutingSlipDefinition) definition); answer = new ManagedRoutingSlip(context, (RoutingSlip) target, (org.apache.camel.model.RoutingSlipDefinition) definition);
} else if (target instanceof FilterProcessor) { } else if (target instanceof FilterProcessor) {
answer = new ManagedFilter(context, (FilterProcessor) target, (org.apache.camel.model.FilterDefinition) definition); answer = new ManagedFilter(context, (FilterProcessor) target, (ExpressionNode)definition);
} else if (target instanceof LogProcessor) { } else if (target instanceof LogProcessor) {
answer = new ManagedLog(context, (LogProcessor) target, definition); answer = new ManagedLog(context, (LogProcessor) target, definition);
} else if (target instanceof LoopProcessor) { } else if (target instanceof LoopProcessor) {
Expand Down
Expand Up @@ -19,7 +19,7 @@
import org.apache.camel.CamelContext; import org.apache.camel.CamelContext;
import org.apache.camel.api.management.ManagedResource; import org.apache.camel.api.management.ManagedResource;
import org.apache.camel.api.management.mbean.ManagedFilterMBean; import org.apache.camel.api.management.mbean.ManagedFilterMBean;
import org.apache.camel.model.FilterDefinition; import org.apache.camel.model.ExpressionNode;
import org.apache.camel.processor.FilterProcessor; import org.apache.camel.processor.FilterProcessor;


/** /**
Expand All @@ -29,14 +29,14 @@
public class ManagedFilter extends ManagedProcessor implements ManagedFilterMBean { public class ManagedFilter extends ManagedProcessor implements ManagedFilterMBean {
private final FilterProcessor processor; private final FilterProcessor processor;


public ManagedFilter(CamelContext context, FilterProcessor processor, FilterDefinition definition) { public ManagedFilter(CamelContext context, FilterProcessor processor, ExpressionNode definition) {
super(context, processor, definition); super(context, processor, definition);
this.processor = processor; this.processor = processor;
} }


@Override @Override
public FilterDefinition getDefinition() { public ExpressionNode getDefinition() {
return (FilterDefinition) super.getDefinition(); return (ExpressionNode) super.getDefinition();
} }


@Override @Override
Expand Down
@@ -0,0 +1,54 @@
/**
* 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.management;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;

/**
* @version
*/
public class ManagedInterceptFromTest extends ManagementTestSupport {

public void testManageWithInterceptFrom() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}

MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(1);
MockEndpoint intercepted = getMockEndpoint("mock:intercepted");
intercepted.setExpectedMessageCount(1);

template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");

assertMockEndpointsSatisfied();
}

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
interceptFrom().when(simple("${header.foo} == '123'")).to("mock:intercepted");
from("direct:start").to("mock:foo");
}
};
}

}

0 comments on commit 8492269

Please sign in to comment.