From 18418f2bf7c29ccf52a9a37dfe83286638ba1aab Mon Sep 17 00:00:00 2001 From: Fabrizio Spataro Date: Wed, 14 Sep 2016 17:34:53 +0200 Subject: [PATCH 1/6] CAMEL-10319, SNMP Producer --- .../src/main/docs/snmp-component.adoc | 13 +- .../camel/component/snmp/SnmpEndpoint.java | 2 +- .../camel/component/snmp/SnmpProducer.java | 125 ++++++++++++++++++ .../camel/component/snmp/ProducerTest.java | 54 ++++++++ 4 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java create mode 100644 components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java diff --git a/components/camel-snmp/src/main/docs/snmp-component.adoc b/components/camel-snmp/src/main/docs/snmp-component.adoc index e6d24d35488d5..ba6edbdad7bbd 100644 --- a/components/camel-snmp/src/main/docs/snmp-component.adoc +++ b/components/camel-snmp/src/main/docs/snmp-component.adoc @@ -5,7 +5,7 @@ SNMP Component *Available as of Camel 2.1* The *snmp:* component gives you the ability to poll SNMP capable devices -or receiving traps. +or receiving traps Maven users will need to add the following dependency to their `pom.xml` for this component: @@ -35,6 +35,16 @@ and receiving traps. You can append query options to the URI in the following format, `?option=value&option=value&...` +[[SNMP-Producer]] +Snmp Producer +^^^^^^^^^^^^^ + +*Available from 2.18 release* + +It can also be used to request information using GET method. + +The response body type is org.apache.camel.component.snmp.SnmpMessage + [[SNMP-Options]] Options ^^^^^^^ @@ -93,7 +103,6 @@ The SNMP component supports 36 endpoint options which are listed below: {% endraw %} // endpoint options: END - [[SNMP-Theresultofapoll]] The result of a poll ^^^^^^^^^^^^^^^^^^^^ diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpEndpoint.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpEndpoint.java index ebb2f63189338..005e6350774b1 100644 --- a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpEndpoint.java +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpEndpoint.java @@ -111,7 +111,7 @@ public Consumer createConsumer(Processor processor) throws Exception { } public Producer createProducer() throws Exception { - throw new UnsupportedOperationException("SnmpProducer is not implemented"); + return new SnmpProducer(this); } public boolean isSingleton() { diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java new file mode 100644 index 0000000000000..1db66960677e5 --- /dev/null +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java @@ -0,0 +1,125 @@ +/** + * 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.component.snmp; + +import org.apache.camel.Exchange; +import org.apache.camel.impl.DefaultProducer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.snmp4j.CommunityTarget; +import org.snmp4j.PDU; +import org.snmp4j.Snmp; +import org.snmp4j.TransportMapping; +import org.snmp4j.event.ResponseEvent; +import org.snmp4j.mp.MPv3; +import org.snmp4j.security.SecurityModels; +import org.snmp4j.security.SecurityProtocols; +import org.snmp4j.security.USM; +import org.snmp4j.smi.Address; +import org.snmp4j.smi.GenericAddress; +import org.snmp4j.smi.OID; +import org.snmp4j.smi.OctetString; +import org.snmp4j.smi.VariableBinding; +import org.snmp4j.transport.DefaultTcpTransportMapping; +import org.snmp4j.transport.DefaultUdpTransportMapping; + +/** + * A snmp producer + * + * + */ +public class SnmpProducer extends DefaultProducer { + + private static final Logger LOG = LoggerFactory.getLogger(SnmpProducer.class); + + private SnmpEndpoint endpoint; + + public SnmpProducer(SnmpEndpoint endpoint) { + super(endpoint); + this.endpoint = endpoint; + } + + @Override + public void process(final Exchange exchange) throws Exception { + // load connection data only if the endpoint is enabled + Snmp snmp = null; + USM usm; + TransportMapping transport = null; + CommunityTarget target = null; + PDU pdu = null; + Address targetAddress = null; + + try { + LOG.debug("Starting SNMP producer on {}", endpoint.getAddress()); + + targetAddress = GenericAddress.parse(endpoint.getAddress()); + + LOG.debug("targetAddress: " + targetAddress); + + // either tcp or udp + if ("tcp".equals(endpoint.getProtocol())) { + transport = new DefaultTcpTransportMapping(); + } else if ("udp".equals(endpoint.getProtocol())) { + transport = new DefaultUdpTransportMapping(); + } else { + throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol()); + } + + snmp = new Snmp(transport); + usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); + + SecurityModels.getInstance().addSecurityModel(usm); + + // setting up target + target = new CommunityTarget(); + target.setCommunity(new OctetString(endpoint.getSnmpCommunity())); + target.setAddress(targetAddress); + target.setRetries(this.endpoint.getRetries()); + target.setTimeout(this.endpoint.getTimeout()); + target.setVersion(this.endpoint.getSnmpVersion()); + + pdu = new PDU(); + for (OID oid : endpoint.getOids()) { + pdu.add(new VariableBinding(oid)); + } + pdu.setErrorIndex(0); + pdu.setErrorStatus(0); + pdu.setMaxRepetitions(0); + pdu.setType(PDU.GET); + + LOG.debug("Snmp: i am sending"); + + snmp.listen(); + ResponseEvent responseEvent = snmp.send(pdu, target); + + LOG.debug("Snmp: sended"); + + if (responseEvent.getResponse() != null) { + exchange.getIn().setBody(new SnmpMessage(responseEvent.getResponse())); + } else { + throw new Exception("SNMP Producer Timeout"); + } + } finally { + try { + transport.close(); + } catch (Exception e) { } + try { + snmp.close(); + } catch (Exception e) { } + } + } //end process +} \ No newline at end of file diff --git a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java new file mode 100644 index 0000000000000..d667f364a788b --- /dev/null +++ b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java @@ -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.component.snmp; + +import java.util.concurrent.TimeUnit; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class ProducerTest extends CamelTestSupport { + + private String host = "192.168.0.254"; + private String port = "161"; + private String oids = "1.3.6.1.2.1.1.3.0,1.3.6.1.2.1.25.3.2.1.5.1,1.3.6.1.2.1.25.3.5.1.1.1,1.3.6.1.2.1.43.5.1.1.11.1"; + + @Test + public void testSnmpProducer() throws Exception { + template.sendBody("direct:in", ""); + + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMinimumMessageCount(1); + + assertMockEndpointsSatisfied(60, TimeUnit.SECONDS); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() { + from("direct:in") + .to("snmp://" + host + ":" + port + "?oids=" + oids) + .log("${body}") + .to("mock:result"); + } + }; + } +} + From fef64b2d3396d1d12baf8898167728929ce1194d Mon Sep 17 00:00:00 2001 From: Fabrizio Spataro Date: Wed, 14 Sep 2016 17:37:22 +0200 Subject: [PATCH 2/6] CAMEL-10319, SNMP Producer --- .../apache/camel/component/snmp/SnmpProducer.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java index 1db66960677e5..43cfe0c6b11c8 100644 --- a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java @@ -57,16 +57,12 @@ public SnmpProducer(SnmpEndpoint endpoint) { public void process(final Exchange exchange) throws Exception { // load connection data only if the endpoint is enabled Snmp snmp = null; - USM usm; TransportMapping transport = null; - CommunityTarget target = null; - PDU pdu = null; - Address targetAddress = null; try { LOG.debug("Starting SNMP producer on {}", endpoint.getAddress()); - targetAddress = GenericAddress.parse(endpoint.getAddress()); + Address targetAddress = GenericAddress.parse(endpoint.getAddress()); LOG.debug("targetAddress: " + targetAddress); @@ -80,19 +76,19 @@ public void process(final Exchange exchange) throws Exception { } snmp = new Snmp(transport); - usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); + USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); // setting up target - target = new CommunityTarget(); + CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString(endpoint.getSnmpCommunity())); target.setAddress(targetAddress); target.setRetries(this.endpoint.getRetries()); target.setTimeout(this.endpoint.getTimeout()); target.setVersion(this.endpoint.getSnmpVersion()); - pdu = new PDU(); + PDU pdu = new PDU(); for (OID oid : endpoint.getOids()) { pdu.add(new VariableBinding(oid)); } From 6a0a3386d3eb3cb7fa842eb19d6e0064c25ce874 Mon Sep 17 00:00:00 2001 From: Fabrizio Spataro Date: Wed, 14 Sep 2016 18:02:15 +0200 Subject: [PATCH 3/6] CAMEL-10319, SNMP Producer --- .../camel/component/snmp/SnmpProducer.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java index 43cfe0c6b11c8..0da0b008a71c8 100644 --- a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.snmp; +import java.util.concurrent.TimeoutException; + import org.apache.camel.Exchange; import org.apache.camel.impl.DefaultProducer; import org.slf4j.Logger; @@ -48,11 +50,33 @@ public class SnmpProducer extends DefaultProducer { private SnmpEndpoint endpoint; + private Address targetAddress; + private USM usm; + public SnmpProducer(SnmpEndpoint endpoint) { super(endpoint); this.endpoint = endpoint; } + @Override + public void start() throws Exception { + super.start(); + + this.targetAddress = GenericAddress.parse(endpoint.getAddress()); + LOG.debug("targetAddress: {}", targetAddress); + + this.usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); + SecurityModels.getInstance().addSecurityModel(this.usm); + } + + @Override + public void stop() throws Exception { + super.stop(); + + this.targetAddress = null; + this.usm = null; + } + @Override public void process(final Exchange exchange) throws Exception { // load connection data only if the endpoint is enabled @@ -61,10 +85,6 @@ public void process(final Exchange exchange) throws Exception { try { LOG.debug("Starting SNMP producer on {}", endpoint.getAddress()); - - Address targetAddress = GenericAddress.parse(endpoint.getAddress()); - - LOG.debug("targetAddress: " + targetAddress); // either tcp or udp if ("tcp".equals(endpoint.getProtocol())) { @@ -72,14 +92,11 @@ public void process(final Exchange exchange) throws Exception { } else if ("udp".equals(endpoint.getProtocol())) { transport = new DefaultUdpTransportMapping(); } else { - throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol()); + throw new IllegalArgumentException("Unknown protocol: {} " + endpoint.getProtocol()); } snmp = new Snmp(transport); - USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); - SecurityModels.getInstance().addSecurityModel(usm); - // setting up target CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString(endpoint.getSnmpCommunity())); @@ -107,7 +124,7 @@ public void process(final Exchange exchange) throws Exception { if (responseEvent.getResponse() != null) { exchange.getIn().setBody(new SnmpMessage(responseEvent.getResponse())); } else { - throw new Exception("SNMP Producer Timeout"); + throw new TimeoutException("SNMP Producer Timeout"); } } finally { try { From 41fdd09004fb3a49680887cd6b1d32dec3f4479d Mon Sep 17 00:00:00 2001 From: Fabryprog Date: Wed, 14 Sep 2016 19:47:05 +0200 Subject: [PATCH 4/6] CAMEL-10319, SNMP Producer --- .../org/apache/camel/component/snmp/SnmpProducer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java index 0da0b008a71c8..9f69ff93f5e3e 100644 --- a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java @@ -33,6 +33,7 @@ import org.snmp4j.security.USM; import org.snmp4j.smi.Address; import org.snmp4j.smi.GenericAddress; +import org.snmp4j.smi.Integer32; import org.snmp4j.smi.OID; import org.snmp4j.smi.OctetString; import org.snmp4j.smi.VariableBinding; @@ -73,8 +74,12 @@ public void start() throws Exception { public void stop() throws Exception { super.stop(); - this.targetAddress = null; - this.usm = null; + try { + SecurityModels.getInstance().removeSecurityModel(new Integer32(this.usm.getID())); + } finally { + this.targetAddress = null; + this.usm = null; + } } @Override From ff597f5c0472b0dc9789841c58fb8a49f68a91ac Mon Sep 17 00:00:00 2001 From: Fabryprog Date: Thu, 15 Sep 2016 07:32:32 +0200 Subject: [PATCH 5/6] CAMEL-10319, SNMP Producer (fix test) --- .../camel/component/snmp/ProducerTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java index d667f364a788b..45d8ff451434d 100644 --- a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java +++ b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java @@ -18,25 +18,35 @@ import java.util.concurrent.TimeUnit; +import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; public class ProducerTest extends CamelTestSupport { + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private String host = "192.168.0.254"; private String port = "161"; private String oids = "1.3.6.1.2.1.1.3.0,1.3.6.1.2.1.25.3.2.1.5.1,1.3.6.1.2.1.25.3.5.1.1.1,1.3.6.1.2.1.43.5.1.1.11.1"; - + private Integer timeout = 5; // 5ms + @Test public void testSnmpProducer() throws Exception { - template.sendBody("direct:in", ""); + thrown.expect(CamelExecutionException.class); + template.sendBody("direct:in", ""); + MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); - assertMockEndpointsSatisfied(60, TimeUnit.SECONDS); + assertMockEndpointsSatisfied(5, TimeUnit.SECONDS); } @Override @@ -44,7 +54,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:in") - .to("snmp://" + host + ":" + port + "?oids=" + oids) + .to("snmp://" + host + ":" + port + "?oids=" + oids + "&timeout=" + timeout) .log("${body}") .to("mock:result"); } From 17b7e9d00fb65e4d531b8f47d2840657e5eb51b8 Mon Sep 17 00:00:00 2001 From: Fabrizio Spataro Date: Thu, 15 Sep 2016 10:40:01 +0200 Subject: [PATCH 6/6] CAMEL-10319, SNMP Producer (fix onStart/onStop) --- .../camel/component/snmp/SnmpProducer.java | 61 ++++++++++--------- .../camel/component/snmp/ProducerTest.java | 14 +---- 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java index 9f69ff93f5e3e..6b6d2c8a6dc17 100644 --- a/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java +++ b/components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java @@ -53,32 +53,54 @@ public class SnmpProducer extends DefaultProducer { private Address targetAddress; private USM usm; - + private CommunityTarget target; + private PDU pdu; + public SnmpProducer(SnmpEndpoint endpoint) { super(endpoint); this.endpoint = endpoint; } @Override - public void start() throws Exception { - super.start(); + protected void doStart() throws Exception { + super.doStart(); - this.targetAddress = GenericAddress.parse(endpoint.getAddress()); + this.targetAddress = GenericAddress.parse(this.endpoint.getAddress()); LOG.debug("targetAddress: {}", targetAddress); this.usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(this.usm); + + // setting up target + this.target = new CommunityTarget(); + this.target.setCommunity(new OctetString(endpoint.getSnmpCommunity())); + this.target.setAddress(this.targetAddress); + this.target.setRetries(this.endpoint.getRetries()); + this.target.setTimeout(this.endpoint.getTimeout()); + this.target.setVersion(this.endpoint.getSnmpVersion()); + + this.pdu = new PDU(); + for (OID oid : this.endpoint.getOids()) { + this.pdu.add(new VariableBinding(oid)); + } + this.pdu.setErrorIndex(0); + this.pdu.setErrorStatus(0); + this.pdu.setMaxRepetitions(0); + this.pdu.setType(PDU.GET); + } @Override - public void stop() throws Exception { - super.stop(); + protected void doStop() throws Exception { + super.doStop(); try { SecurityModels.getInstance().removeSecurityModel(new Integer32(this.usm.getID())); } finally { this.targetAddress = null; this.usm = null; + this.target = null; + this.pdu = null; } } @@ -89,40 +111,23 @@ public void process(final Exchange exchange) throws Exception { TransportMapping transport = null; try { - LOG.debug("Starting SNMP producer on {}", endpoint.getAddress()); + LOG.debug("Starting SNMP producer on {}", this.endpoint.getAddress()); // either tcp or udp - if ("tcp".equals(endpoint.getProtocol())) { + if ("tcp".equals(this.endpoint.getProtocol())) { transport = new DefaultTcpTransportMapping(); - } else if ("udp".equals(endpoint.getProtocol())) { + } else if ("udp".equals(this.endpoint.getProtocol())) { transport = new DefaultUdpTransportMapping(); } else { - throw new IllegalArgumentException("Unknown protocol: {} " + endpoint.getProtocol()); + throw new IllegalArgumentException("Unknown protocol: {} " + this.endpoint.getProtocol()); } snmp = new Snmp(transport); - // setting up target - CommunityTarget target = new CommunityTarget(); - target.setCommunity(new OctetString(endpoint.getSnmpCommunity())); - target.setAddress(targetAddress); - target.setRetries(this.endpoint.getRetries()); - target.setTimeout(this.endpoint.getTimeout()); - target.setVersion(this.endpoint.getSnmpVersion()); - - PDU pdu = new PDU(); - for (OID oid : endpoint.getOids()) { - pdu.add(new VariableBinding(oid)); - } - pdu.setErrorIndex(0); - pdu.setErrorStatus(0); - pdu.setMaxRepetitions(0); - pdu.setType(PDU.GET); - LOG.debug("Snmp: i am sending"); snmp.listen(); - ResponseEvent responseEvent = snmp.send(pdu, target); + ResponseEvent responseEvent = snmp.send(this.pdu, this.target); LOG.debug("Snmp: sended"); diff --git a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java index 45d8ff451434d..2532eac272acd 100644 --- a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java +++ b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ProducerTest.java @@ -18,29 +18,21 @@ import java.util.concurrent.TimeUnit; -import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Rule; +import org.junit.Ignore; import org.junit.Test; -import org.junit.rules.ExpectedException; +@Ignore("CAMEL-10319: Set host, port and oids to test snmp producer.") public class ProducerTest extends CamelTestSupport { - @Rule - public ExpectedException thrown = ExpectedException.none(); - - private String host = "192.168.0.254"; private String port = "161"; private String oids = "1.3.6.1.2.1.1.3.0,1.3.6.1.2.1.25.3.2.1.5.1,1.3.6.1.2.1.25.3.5.1.1.1,1.3.6.1.2.1.43.5.1.1.11.1"; - private Integer timeout = 5; // 5ms @Test public void testSnmpProducer() throws Exception { - thrown.expect(CamelExecutionException.class); - template.sendBody("direct:in", ""); MockEndpoint mock = getMockEndpoint("mock:result"); @@ -54,7 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() { from("direct:in") - .to("snmp://" + host + ":" + port + "?oids=" + oids + "&timeout=" + timeout) + .to("snmp://" + host + ":" + port + "?oids=" + oids) .log("${body}") .to("mock:result"); }