Repository: camel Updated Branches: refs/heads/camel-2.15.x 9ff5aadd0 -> 23fc3a530
[camel-test-blueprint] Ensure loadConfigAdminConfigurationFile() provided file is valid (cherry picked from commit 7fba34a9a5de8ece63e0fae23eccc64090f8491a) Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/65700051 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/65700051 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/65700051 Branch: refs/heads/camel-2.15.x Commit: 65700051482bc75e611732926c2a8efa80120c32 Parents: b6fba46 Author: Grzegorz Grzybek <gr.grzy...@gmail.com> Authored: Fri Jul 10 15:01:24 2015 +0200 Committer: Grzegorz Grzybek <gr.grzy...@gmail.com> Committed: Tue Jul 21 09:43:27 2015 +0200 ---------------------------------------------------------------------- .../blueprint/CamelBlueprintTestSupport.java | 4 ++ ...gAdminLoadConfigurationFileNotFoundTest.java | 57 ++++++++++++++++++++ 2 files changed, 61 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/65700051/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 f69e157..71e5864 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 @@ -16,6 +16,7 @@ */ package org.apache.camel.test.blueprint; +import java.io.File; import java.util.Dictionary; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -101,6 +102,9 @@ public abstract class CamelBlueprintTestSupport extends CamelTestSupport { } if (file != null) { + if (!new File(file[0]).exists()) { + throw new IllegalArgumentException("The provided file \"" + file[0] + "\" from loadConfigAdminConfigurationFile doesn't exist"); + } CamelBlueprintHelper.setPersistentFileForConfigAdmin(answer, file[1], file[0], props); } http://git-wip-us.apache.org/repos/asf/camel/blob/65700051/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java new file mode 100644 index 0000000..2f6d465 --- /dev/null +++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ConfigAdminLoadConfigurationFileNotFoundTest.java @@ -0,0 +1,57 @@ +/** + * 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.test.blueprint; + +import org.junit.Test; +import org.osgi.framework.BundleContext; + +/** + * + */ +public class ConfigAdminLoadConfigurationFileNotFoundTest extends CamelBlueprintTestSupport { + + @Override + protected String getBlueprintDescriptor() { + return "org/apache/camel/test/blueprint/configadmin-loadfile.xml"; + } + + @Override + public void setUp() throws Exception { + try { + super.setUp(); + fail("Should throw IllegalArgumentException, because the config file wasn't found"); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().contains("../../src/test/resources/etc/stuff.cfg")); + } + } + + // START SNIPPET: e1 + @Override + protected String[] loadConfigAdminConfigurationFile() { + // String[0] = tell Camel the path of the .cfg file to use for OSGi ConfigAdmin in the blueprint XML file + // this file should exist + // String[1] = tell Camel the persistence-id of the cm:property-placeholder in the blueprint XML file + return new String[]{"../../src/test/resources/etc/stuff.cfg", "stuff"}; + } + // END SNIPPET: e1 + + @Test + public void test() throws Exception { + // irrelevant + } + +}