You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gg...@apache.org on 2016/02/24 18:20:34 UTC
[2/2] camel git commit: [CAMEL-9636] Fail fast in case of empty
cm:property-placeholder + test
[CAMEL-9636] Fail fast in case of empty cm:property-placeholder + test
(cherry picked from commit e15603a977b825a89fcad20b8da0a8ba59d982d3)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a1acec61
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a1acec61
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a1acec61
Branch: refs/heads/camel-2.16.x
Commit: a1acec615e400a008d6d083d6a84ad68ebb7ab43
Parents: ed5790b
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Wed Feb 24 14:27:25 2016 +0100
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Wed Feb 24 18:20:03 2016 +0100
----------------------------------------------------------------------
.../test/blueprint/CamelBlueprintHelper.java | 19 ++++++++++---
.../blueprint/CamelBlueprintTestSupport.java | 6 ++--
...minNoDefaultValuesBlueprintCreationTest.java | 29 ++++++++------------
3 files changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a1acec61/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index b99814c..9f811a2 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -314,13 +314,20 @@ public final class CamelBlueprintHelper {
final String symbolicName, final int bpEvent, final Runnable runAndWait)
throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
+ final Throwable[] pThrowable = new Throwable[] {null};
ServiceRegistration<BlueprintListener> registration = context.registerService(BlueprintListener.class, new BlueprintListener() {
@Override
public void blueprintEvent(BlueprintEvent event) {
- if (event.getType() == bpEvent && event.getBundle().getSymbolicName().equals(symbolicName)) {
- // we skip events that we've already seen
- // it works with BP container reloads if next CREATE state is at least 1ms after previous one
- if (eventHistory == null || eventHistory.add(event.getTimestamp())) {
+ if (event.getBundle().getSymbolicName().equals(symbolicName)) {
+ if (event.getType() == bpEvent) {
+ // we skip events that we've already seen
+ // it works with BP container reloads if next CREATE state is at least 1ms after previous one
+ if (eventHistory == null || eventHistory.add(event.getTimestamp())) {
+ latch.countDown();
+ }
+ } else if (event.getType() == BlueprintEvent.FAILURE) {
+ // we didn't wait for FAILURE, but we got it - fail fast then
+ pThrowable[0] = event.getCause();
latch.countDown();
}
}
@@ -331,6 +338,10 @@ public final class CamelBlueprintHelper {
}
latch.await(CamelBlueprintHelper.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
registration.unregister();
+
+ if (pThrowable[0] != null) {
+ throw new RuntimeException(pThrowable[0].getMessage(), pThrowable[0]);
+ }
}
protected static TinyBundle createTestBundle(String name, String version, String descriptors, String[] ... configAdminPidFiles) throws IOException {
http://git-wip-us.apache.org/repos/asf/camel/blob/a1acec61/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
index 928d257..1340218 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
@@ -154,10 +154,8 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport {
// to the same state of BP container
Set<Long> bpEvents = new HashSet<>();
- if (!expectReload) {
- CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, null);
- }
-
+ CamelBlueprintHelper.waitForBlueprintContainer(bpEvents, answer, symbolicName, BlueprintEvent.CREATED, null);
+
// must reuse props as we can do both load from .cfg file and override afterwards
final Dictionary props = new Properties();
http://git-wip-us.apache.org/repos/asf/camel/blob/a1acec61/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoDefaultValuesBlueprintCreationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoDefaultValuesBlueprintCreationTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoDefaultValuesBlueprintCreationTest.java
index 8ace8c9..260d2e1 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoDefaultValuesBlueprintCreationTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminNoDefaultValuesBlueprintCreationTest.java
@@ -16,18 +16,23 @@
*/
package org.apache.camel.test.blueprint;
-import java.util.Dictionary;
-
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+
/**
- *
+ * A test showing that if Blueprint XML contains property placeholders, some property source has to be defined.
*/
public class ConfigAdminNoDefaultValuesBlueprintCreationTest extends CamelBlueprintTestSupport {
@Override
- protected boolean expectBlueprintContainerReloadOnConfigAdminUpdate() {
- return true;
+ public void setUp() throws Exception {
+ try {
+ super.setUp();
+ fail("Should fail, because Blueprint XML uses property placeholders, but we didn't define any property sources");
+ } catch (Exception e) {
+ assertThat(e.getCause().getCause().getMessage(), equalTo("Property placeholder key: destination not found"));
+ }
}
@Override
@@ -35,20 +40,8 @@ public class ConfigAdminNoDefaultValuesBlueprintCreationTest extends CamelBluepr
return "org/apache/camel/test/blueprint/configadmin-endpoint-no-defaults.xml";
}
- @Override
- protected String useOverridePropertiesWithConfigAdmin(Dictionary props) throws Exception {
- props.put("greeting", "Bye");
- props.put("destination", "mock:result");
- return "my-placeholders";
- }
-
@Test
- public void testConfigAdmin() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- template.sendBody("direct:start", "World");
-
- assertMockEndpointsSatisfied();
+ public void test() throws Exception {
}
}