You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/04/12 17:17:12 UTC

[camel] 03/10: CAMEL-17763: cleaned up unused exceptions in camel-jmx

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1a3ea952f3ade7952f51d98b314e8e2814988bc4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Apr 12 16:16:36 2022 +0200

    CAMEL-17763: cleaned up unused exceptions in camel-jmx
---
 ...sumerObserveAttributeMatchStringDifferTest.java |  4 ++--
 ...JmxConsumerObserveAttributeMatchStringTest.java |  4 ++--
 .../jmx/CamelJmxConsumerObserveAttributeTest.java  |  4 ++--
 .../camel/component/jmx/CamelJmxConsumerTest.java  |  4 ++--
 .../camel/component/jmx/JMXComponentTest.java      | 10 +++++-----
 .../camel/component/jmx/JMXConsumerTest.java       |  2 +-
 .../camel/component/jmx/JMXEndpointTest.java       | 14 +++++++-------
 .../camel/component/jmx/JMXUriBuilderTest.java     | 22 +++++++++++-----------
 .../camel/component/jmx/SimpleBeanFixture.java     |  4 ++--
 .../org/apache/camel/component/jmx/XmlFixture.java | 10 ++++------
 10 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
index f1244415ef2..9125724fa4c 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringDifferTest.java
@@ -56,10 +56,10 @@ public class CamelJmxConsumerObserveAttributeMatchStringDifferTest extends Camel
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 String id = getContext().getName();
 
                 fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing&stringToCompare=true&notifyDiffer=true",
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
index 62c14ed0add..77349ac6b97 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeMatchStringTest.java
@@ -56,10 +56,10 @@ public class CamelJmxConsumerObserveAttributeMatchStringTest extends CamelTestSu
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 String id = getContext().getName();
 
                 fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing&stringToCompare=false",
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
index 83615265504..9b8dbf97aab 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerObserveAttributeTest.java
@@ -48,10 +48,10 @@ public class CamelJmxConsumerObserveAttributeTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 String id = getContext().getName();
 
                 fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"&observedAttribute=Tracing",
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
index 72f1cfd082d..9f926aae839 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/CamelJmxConsumerTest.java
@@ -43,10 +43,10 @@ public class CamelJmxConsumerTest extends CamelTestSupport {
     }
 
     @Override
-    protected RoutesBuilder createRouteBuilder() throws Exception {
+    protected RoutesBuilder createRouteBuilder() {
         return new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 String id = getContext().getName();
 
                 fromF("jmx:platform?objectDomain=org.apache.camel&key.context=%s&key.type=routes&key.name=\"foo\"", id)
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
index 848add5ad4a..d158f2a81bf 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
@@ -37,7 +37,7 @@ public class JMXComponentTest {
     DefaultCamelContext context = new DefaultCamelContext();
 
     @Test
-    public void withObjectProperties() throws Exception {
+    public void withObjectProperties() {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&key.propOne=prop1&key.propTwo=prop2",
                 JMXEndpoint.class);
         assertNotNull(ep);
@@ -51,7 +51,7 @@ public class JMXComponentTest {
     }
 
     @Test
-    public void withObjectName() throws Exception {
+    public void withObjectName() {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&objectName=theObjectName", JMXEndpoint.class);
         assertNotNull(ep);
 
@@ -62,7 +62,7 @@ public class JMXComponentTest {
     }
 
     @Test
-    public void withObjectNameAndObjectProperties() throws Exception {
+    public void withObjectNameAndObjectProperties() {
         try {
             context.getEndpoint("jmx:platform?objectDomain=FooDomain&objectName=theObjectName&key.propOne=prop1");
             fail("expected exception");
@@ -72,7 +72,7 @@ public class JMXComponentTest {
     }
 
     @Test
-    public void withoutDomain() throws Exception {
+    public void withoutDomain() {
         try {
             context.getEndpoint("jmx:platform?objectName=theObjectName");
             fail("missing domain should have caused failure");
@@ -82,7 +82,7 @@ public class JMXComponentTest {
     }
 
     @Test
-    public void withoutObjectNameAndObjectProperties() throws Exception {
+    public void withoutObjectNameAndObjectProperties() {
         try {
             context.getEndpoint("jmx:platform?objectDomain=theObjectDomain");
             fail("missing name should have caused failure");
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
index de2b59c6801..346ac3c0177 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXConsumerTest.java
@@ -89,7 +89,7 @@ public class JMXConsumerTest extends SimpleBeanFixture {
         waitAndAssertMessageReceived("src/test/resources/consumer-test/timerNotification.xml");
     }
 
-    private void waitAndAssertMessageReceived(String aExpectedFilePath) throws InterruptedException, Exception {
+    private void waitAndAssertMessageReceived(String aExpectedFilePath) throws Exception {
         getMockFixture().waitForMessages();
         getMockFixture().assertMessageReceived(new File(aExpectedFilePath));
     }
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
index 85aeccfcc58..a03e873b9be 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java
@@ -40,12 +40,12 @@ public class JMXEndpointTest {
     DefaultCamelContext context;
 
     @BeforeEach
-    public void setUp() throws Exception {
+    public void setUp() {
         context = new DefaultCamelContext();
     }
 
     @Test
-    public void setObjectNameThrowsWhenObjectPropertiesIsSet() throws Exception {
+    public void setObjectNameThrowsWhenObjectPropertiesIsSet() {
         JMXEndpoint ep = new JMXEndpoint("urn:ignored", new JMXComponent());
         ep.setObjectProperties(new Hashtable<String, String>());
         try {
@@ -58,13 +58,13 @@ public class JMXEndpointTest {
     }
 
     @Test
-    public void defaultsToXml() throws Exception {
+    public void defaultsToXml() {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&objectName=theObjectName", JMXEndpoint.class);
         assertTrue(ep.isXML());
     }
 
     @Test
-    public void formatRaw() throws Exception {
+    public void formatRaw() {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&objectName=theObjectName&format=raw",
                 JMXEndpoint.class);
         assertFalse(ep.isXML());
@@ -96,14 +96,14 @@ public class JMXEndpointTest {
     }
 
     @Test
-    public void platformServer() throws Exception {
+    public void platformServer() {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&key.name=theObjectName", JMXEndpoint.class);
         assertTrue(ep.isPlatformServer());
         assertEquals("platform", ep.getServerURL());
     }
 
     @Test
-    public void remoteServer() throws Exception {
+    public void remoteServer() {
         JMXEndpoint ep = context.getEndpoint(
                 "jmx:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi?objectDomain=FooDomain&key.name=theObjectName",
                 JMXEndpoint.class);
@@ -128,7 +128,7 @@ public class JMXEndpointTest {
     }
 
     @Test
-    public void credentials() throws Exception {
+    public void credentials() {
         JMXEndpoint ep = context.getEndpoint(
                 "jmx:platform?objectDomain=FooDomain&key.name=theObjectName&user=user1&password=1234", JMXEndpoint.class);
         assertEquals("user1", ep.getUser());
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
index 5ec9f12d5e9..c270608ca4d 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXUriBuilderTest.java
@@ -28,50 +28,50 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 public class JMXUriBuilderTest {
 
     @Test
-    public void defaultsToPlatform() throws Exception {
+    public void defaultsToPlatform() {
         assertEquals("jmx:platform", new JMXUriBuilder().toString());
     }
 
     @Test
-    public void remote() throws Exception {
+    public void remote() {
         assertEquals("jmx:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
                 new JMXUriBuilder("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi").toString());
     }
 
     @Test
-    public void withServerName() throws Exception {
+    public void withServerName() {
         assertEquals("jmx:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
                 new JMXUriBuilder().withServerName("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi").toString());
     }
 
     @Test
-    public void format() throws Exception {
+    public void format() {
         assertEquals("jmx:platform?format=raw", new JMXUriBuilder().withFormat("raw").toString());
     }
 
     @Test
-    public void credentials() throws Exception {
+    public void credentials() {
         assertEquals("jmx:platform?user=me&password=pass", new JMXUriBuilder().withUser("me").withPassword("pass").toString());
     }
 
     @Test
-    public void objectName() throws Exception {
+    public void objectName() {
         assertEquals("jmx:platform?objectDomain=myDomain&objectName=oname",
                 new JMXUriBuilder().withObjectDomain("myDomain").withObjectName("oname").toString());
     }
 
     @Test
-    public void notificationFilter() throws Exception {
+    public void notificationFilter() {
         assertEquals("jmx:platform?notificationFilter=#foo", new JMXUriBuilder().withNotificationFilter("#foo").toString());
     }
 
     @Test
-    public void handback() throws Exception {
+    public void handback() {
         assertEquals("jmx:platform?handback=#hb", new JMXUriBuilder().withHandback("#hb").toString());
     }
 
     @Test
-    public void objectProperties() throws Exception {
+    public void objectProperties() {
         LinkedHashMap<String, String> map = new LinkedHashMap<>();
         map.put("one", "1");
         map.put("two", "2");
@@ -79,12 +79,12 @@ public class JMXUriBuilderTest {
     }
 
     @Test
-    public void withObjectPropertiesReference() throws Exception {
+    public void withObjectPropertiesReference() {
         assertEquals("jmx:platform?objectProperties=#op", new JMXUriBuilder().withObjectPropertiesReference("#op").toString());
     }
 
     @Test
-    public void withObjectPropertiesReferenceSansHashmark() throws Exception {
+    public void withObjectPropertiesReferenceSansHashmark() {
         assertEquals("jmx:platform?objectProperties=#op", new JMXUriBuilder().withObjectPropertiesReference("op").toString());
     }
 }
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
index 57e56e11c1e..e4e4e58fecf 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/SimpleBeanFixture.java
@@ -76,7 +76,7 @@ public class SimpleBeanFixture {
         startContext();
     }
 
-    protected void startContext() throws Exception {
+    protected void startContext() {
         mContext.start();
     }
 
@@ -162,7 +162,7 @@ public class SimpleBeanFixture {
         mContext.setRegistry(getRegistry());
         mContext.addRoutes(new RouteBuilder() {
             @Override
-            public void configure() throws Exception {
+            public void configure() {
                 from(buildFromURI().toString()).to(mock);
             }
         });
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
index 1efb187b9c0..f6099341364 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java
@@ -21,7 +21,6 @@ import java.io.File;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamResult;
@@ -38,11 +37,11 @@ public final class XmlFixture {
     private XmlFixture() {
     }
 
-    public static Source toSource(String aXmlString) throws Exception {
+    public static Source toSource(String aXmlString) {
         return Input.fromString(aXmlString).build();
     }
 
-    public static Source toSource(File aFile) throws Exception {
+    public static Source toSource(File aFile) {
         return Input.fromFile(aFile).build();
     }
 
@@ -59,8 +58,7 @@ public final class XmlFixture {
     }
 
     public static void dump(Source aActual)
-            throws TransformerConfigurationException,
-            TransformerException {
+            throws TransformerException {
         TransformerFactory tf = TransformerFactory.newInstance();
         Transformer transformer = tf.newTransformer();
         transformer.setOutputProperty(OutputKeys.INDENT, "yes");
@@ -77,7 +75,7 @@ public final class XmlFixture {
         return transform(aSource, resourcePath);
     }
 
-    protected static Source transform(Source aSource, String aResourcePath) throws Exception {
+    protected static Source transform(Source aSource, String aResourcePath) {
         Source stylesheet = new StreamSource(XmlFixture.class.getResourceAsStream(aResourcePath));
         stylesheet.setSystemId(XmlFixture.class.getResource(aResourcePath).toExternalForm());
         return Input.byTransforming(aSource).withStylesheet(stylesheet).build();