camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] 02/11: CAMEL-13755: camel3 - Remove fault from camel-core/message and let it be component specific for camel-cxf and camel-spring-ws as its only used by SOAP-WS
Date Sun, 21 Jul 2019 18:18:43 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch CAMEL-13755
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 374fe43ea9a27745273339610a8c0bdb0a468ce1
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Fri Jul 19 10:12:03 2019 +0200

    CAMEL-13755: camel3 - Remove fault from camel-core/message and let it be component specific
for camel-cxf and camel-spring-ws as its only used by SOAP-WS
---
 .../org/apache/camel/reifier/ProcessorReifier.java |  1 -
 .../apache/camel/reifier/SetFaultBodyReifier.java  | 41 ---------
 .../camel/builder/FluentProducerTemplateTest.java  | 15 ----
 .../camel/impl/DefaultProducerTemplateTest.java    | 12 ---
 .../org/apache/camel/processor/PipelineTest.java   | 19 -----
 .../RedeliverWithExceptionAndFaultTest.java        | 98 ----------------------
 ...deliveryWithExceptionAndFaultDelayInHeader.java | 97 ---------------------
 .../UnitOfWorkSynchronizationAdapterTest.java      |  6 +-
 .../org/apache/camel/processor/UnitOfWorkTest.java | 19 +----
 .../camel/processor/enricher/EnricherTest.java     | 34 +-------
 .../camel/processor/enricher/FailureProcessor.java | 18 +---
 11 files changed, 5 insertions(+), 355 deletions(-)

diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
index c8685ec..c84b4c3 100644
--- a/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
+++ b/core/camel-core/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
@@ -161,7 +161,6 @@ public abstract class ProcessorReifier<T extends ProcessorDefinition<?>>
{
         map.put(ServiceCallDefinition.class, ServiceCallReifier::new);
         map.put(SetBodyDefinition.class, SetBodyReifier::new);
         map.put(SetExchangePatternDefinition.class, SetExchangePatternReifier::new);
-        map.put(SetFaultBodyDefinition.class, SetFaultBodyReifier::new);
         map.put(SetHeaderDefinition.class, SetHeaderReifier::new);
         map.put(SetPropertyDefinition.class, SetPropertyReifier::new);
         map.put(SortDefinition.class, SortReifier::new);
diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java
b/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java
deleted file mode 100644
index c948c7e..0000000
--- a/core/camel-core/src/main/java/org/apache/camel/reifier/SetFaultBodyReifier.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.reifier;
-
-import org.apache.camel.Expression;
-import org.apache.camel.Processor;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.SetFaultBodyDefinition;
-import org.apache.camel.spi.RouteContext;
-
-@Deprecated
-public class SetFaultBodyReifier extends ExpressionReifier<SetFaultBodyDefinition>
{
-
-    SetFaultBodyReifier(ProcessorDefinition<?> definition) {
-        super((SetFaultBodyDefinition) definition);
-    }
-
-    @Override
-    public Processor createProcessor(RouteContext routeContext) throws Exception {
-        final Expression expr = definition.getExpression().createExpression(routeContext);
-        return exchange -> {
-            Object body = expr.evaluate(exchange, Object.class);
-            exchange.getMessage().setFault(true);
-            exchange.getMessage().setBody(body);
-        };
-    }
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java
b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java
index 2cb75ad..c35b5fd 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java
@@ -153,21 +153,6 @@ public class FluentProducerTemplateTest extends ContextTestSupport {
     }
 
     @Test
-    public void testFault() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(0);
-
-        Object result = DefaultFluentProducerTemplate.on(context)
-            .withBody("Hello World")
-            .to("direct:fault")
-            .request();
-
-        assertMockEndpointsSatisfied();
-
-        assertEquals("Faulty World", result);
-    }
-
-    @Test
     public void testExceptionUsingBody() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
index 6050156..c1a63ce 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
@@ -63,18 +63,6 @@ public class DefaultProducerTemplateTest extends ContextTestSupport {
     }
 
     @Test
-    public void testFault() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(0);
-
-        Object result = template.requestBody("direct:fault", "Hello World");
-
-        assertMockEndpointsSatisfied();
-
-        assertEquals("Faulty World", result);
-    }
-
-    @Test
     public void testExceptionUsingBody() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
index 16454bf..14e1030 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
@@ -76,25 +76,6 @@ public class PipelineTest extends ContextTestSupport {
         assertEquals(3, exchange.getOut().getHeader("copy-counter"));        
     }
 
-    /**
-     * Disabled for now until we figure out fault processing in the pipeline.
-     * 
-     * @throws Exception
-     */
-    @Test
-    public void testFaultStopsPipeline() throws Exception {
-        Exchange exchange = template.request("direct:c", new Processor() {
-            public void process(Exchange exchange) {
-                exchange.getIn().setBody("Fault Message");
-            }
-        });
-        
-        // Check the fault..
-        assertTrue(exchange.getOut() != null && exchange.getOut().isFault());
-        assertEquals("Fault Message", exchange.getOut().getBody());
-        assertEquals(2, exchange.getOut().getHeader("copy-counter"));        
-    }
-
     @Test
     public void testOnlyProperties() {
         Exchange exchange = template.request("direct:b", new Processor() {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RedeliverWithExceptionAndFaultTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/RedeliverWithExceptionAndFaultTest.java
deleted file mode 100644
index ac5ce17..0000000
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RedeliverWithExceptionAndFaultTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.processor;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
-
-public class RedeliverWithExceptionAndFaultTest extends ContextTestSupport {
-
-    private static int counter;
-
-    @Test
-    public void testOk() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-
-        String out = template.requestBody("direct:start", "Hello World", String.class);
-        assertEquals("Bye World", out);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    @Test
-    public void testTransientAndPersistentError() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(0);
-
-        String out = template.requestBody("direct:start", "Boom", String.class);
-        assertEquals("Persistent error", out);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    @Test
-    public void testTransientAndPersistentErrorWithExchange() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(0);
-
-        Exchange out = template.request("direct:start", new Processor() {
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("Boom");
-            }
-        });
-        assertTrue("Should be failed", out.isFailed());
-        assertNull("No exception", out.getException());
-        assertTrue(out.getOut() != null && out.getOut().isFault());
-        assertEquals("Persistent error", out.getOut().getBody());
-
-        assertMockEndpointsSatisfied();
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                errorHandler(defaultErrorHandler().maximumRedeliveries(5).redeliveryDelay(0));
-
-                from("direct:start")
-                    .process(new Processor() {
-                        public void process(Exchange exchange) throws Exception {
-                            counter++;
-                            if (counter < 3) {
-                                throw new IllegalArgumentException("Try again");
-                            }
-
-                            if (exchange.getIn().getBody().equals("Boom")) {
-                                exchange.getOut().setFault(true);
-                                exchange.getOut().setBody("Persistent error");
-                            } else {
-                                exchange.getOut().setBody("Bye World");
-                            }
-                        }
-                    }).to("mock:result");
-            }
-        };
-    }
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RedeliveryWithExceptionAndFaultDelayInHeader.java
b/core/camel-core/src/test/java/org/apache/camel/processor/RedeliveryWithExceptionAndFaultDelayInHeader.java
deleted file mode 100644
index fd00b97..0000000
--- a/core/camel-core/src/test/java/org/apache/camel/processor/RedeliveryWithExceptionAndFaultDelayInHeader.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.processor;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-
-public class RedeliveryWithExceptionAndFaultDelayInHeader extends ContextTestSupport {
-
-    private static int counter;
-
-    public void testOk() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(1);
-
-        String out = template.requestBody("direct:start", "Hello World", String.class);
-        assertEquals("Bye World", out);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testTransientAndPersistentError() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(0);
-
-        String out = template.requestBody("direct:start", "Boom", String.class);
-        assertEquals("Persistent error", out);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testTransientAndPersistentErrorWithExchange() throws Exception {
-        counter = 0;
-
-        getMockEndpoint("mock:result").expectedMessageCount(0);
-
-        Exchange out = template.request("direct:start", new Processor() {
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setBody("Boom");
-            }
-        });
-        assertTrue("Should be failed", out.isFailed());
-        assertNull("No exception", out.getException());
-        assertTrue(out.getOut() != null && out.getOut().isFault());
-        assertEquals("Persistent error", out.getOut().getBody());
-
-        assertMockEndpointsSatisfied();
-
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                errorHandler(defaultErrorHandler().maximumRedeliveries(5));
-
-                from("direct:start")
-
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws Exception {
-                                exchange.getIn().setHeader(Exchange.REDELIVERY_DELAY, 100);
-                                counter++;
-                                if (counter < 3) {
-                                    throw new IllegalArgumentException("Try again");
-                                }
-
-                                if (exchange.getIn().getBody().equals("Boom")) {
-                                    exchange.getOut().setFault(true);
-                                    exchange.getOut().setBody("Persistent error");
-                                } else {
-                                    exchange.getOut().setBody("Bye World");
-                                }
-                            }
-                        }).to("mock:result");
-            }
-        };
-    }
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkSynchronizationAdapterTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkSynchronizationAdapterTest.java
index a8f02a4..1925514 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkSynchronizationAdapterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkSynchronizationAdapterTest.java
@@ -50,11 +50,7 @@ public class UnitOfWorkSynchronizationAdapterTest extends UnitOfWorkTest
{
                         });
 
                         String name = getName();
-                        if (name.equals("testFail")) {
-                            log.info("Failing test!");
-                            exchange.getOut().setFault(true);
-                            exchange.getOut().setBody("testFail() should always fail with
a fault!");
-                        } else if (name.equals("testException")) {
+                        if (name.equals("testException")) {
                             log.info("Throwing exception!");
                             throw new Exception("Failing test!");
                         }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkTest.java
index 1df1ef0..5235b16 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/UnitOfWorkTest.java
@@ -49,19 +49,6 @@ public class UnitOfWorkTest extends ContextTestSupport {
     }
 
     @Test
-    public void testFail() throws Exception {
-        sendMessage();
-
-        assertTrue("Exchange did not complete.", doneLatch.await(5, TimeUnit.SECONDS));
-        assertNull("Should not have completed", completed);
-        assertNotNull("Should have received failed notification", failed);
-        assertEquals("Should have propagated the header inside the Synchronization.onFailure()
callback", "bat", baz);
-        assertNull("The Synchronization.onComplete() callback should have not been invoked",
foo);
-
-        log.info("Received fail: " + failed);
-    }
-
-    @Test
     public void testException() throws Exception {
         sendMessage();
 
@@ -115,11 +102,7 @@ public class UnitOfWorkTest extends ContextTestSupport {
                         exchange.getUnitOfWork().addSynchronization(synchronization);
 
                         String name = getName();
-                        if (name.equals("testFail")) {
-                            log.info("Failing test!");
-                            exchange.getOut().setFault(true);
-                            exchange.getOut().setBody("testFail() should always fail with
a fault!");
-                        } else if (name.equals("testException")) {
+                        if (name.equals("testException")) {
                             log.info("Throwing exception!");
                             throw new Exception("Failing test!");
                         }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherTest.java
index ad251ba..9449fe2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherTest.java
@@ -50,22 +50,6 @@ public class EnricherTest extends ContextTestSupport {
     }
 
     @Test
-    public void testEnrichFaultInOnly() throws InterruptedException {
-        mock.expectedMessageCount(0);
-        Exchange exchange = template.send("direct:enricher-test-3", new Processor() {
-            public void process(Exchange exchange) {
-                exchange.getIn().setBody("test");
-            }
-        });
-        mock.assertIsSatisfied();
-        assertEquals("test", exchange.getIn().getBody());
-        assertTrue(exchange.getOut() != null && exchange.getOut().isFault());
-        assertEquals("failed", exchange.getOut().getBody());
-        assertEquals("direct://enricher-fault-resource", exchange.getProperty(Exchange.TO_ENDPOINT));
-        assertNull(exchange.getException());
-    }
-
-    @Test
     public void testEnrichErrorInOnly() throws InterruptedException {
         mock.expectedMessageCount(0);
         Exchange exchange = template.send("direct:enricher-test-4", new Processor() {
@@ -104,19 +88,6 @@ public class EnricherTest extends ContextTestSupport {
     }
 
     @Test
-    public void testEnrichFaultInOut() throws InterruptedException {
-        Exchange exchange = template.send("direct:enricher-test-7", ExchangePattern.InOut,
new Processor() {
-            public void process(Exchange exchange) {
-                exchange.getIn().setBody("test");
-            }
-        });
-        assertEquals("test", exchange.getIn().getBody());
-        assertTrue(exchange.getOut() != null && exchange.getOut().isFault());
-        assertEquals("failed", exchange.getOut().getBody());
-        assertNull(exchange.getException());
-    }
-
-    @Test
     public void testEnrichErrorInOut() throws InterruptedException {
         Exchange exchange = template.send("direct:enricher-test-8", ExchangePattern.InOut,
new Processor() {
             public void process(Exchange exchange) {
@@ -164,9 +135,8 @@ public class EnricherTest extends ContextTestSupport {
                 // -------------------------------------------------------------
 
                 from("direct:enricher-constant-resource").transform().constant("blah");
-                
-                from("direct:enricher-fault-resource").errorHandler(noErrorHandler()).process(new
FailureProcessor(false));
-                from("direct:enricher-error-resource").errorHandler(noErrorHandler()).process(new
FailureProcessor(true));
+
+                from("direct:enricher-error-resource").errorHandler(noErrorHandler()).process(new
FailureProcessor());
             }
         };
     }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java
b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java
index e263075..3654b6f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/FailureProcessor.java
@@ -19,26 +19,10 @@ package org.apache.camel.processor.enricher;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 
-@Deprecated
 public class FailureProcessor implements Processor {
 
-    private boolean error;
-    
-    public FailureProcessor() {
-        this(false);
-    }
-    
-    public FailureProcessor(boolean error) {
-        this.error = error;
-    }
-    
     public void process(Exchange exchange) throws Exception {
-        if (error) {
-            throw new RuntimeException("failed");
-        } else {
-            exchange.getOut().setFault(true);
-            exchange.getOut().setBody("failed");
-        }
+        throw new RuntimeException("failed");
     }
 
 }


Mime
View raw message