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 2015/07/20 14:52:03 UTC
[05/14] camel git commit: [camel-test-blueprint] Ensure
loadConfigAdminConfigurationFile() provided file is valid
[camel-test-blueprint] Ensure loadConfigAdminConfigurationFile() provided file is valid
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7fba34a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7fba34a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7fba34a9
Branch: refs/heads/master
Commit: 7fba34a9a5de8ece63e0fae23eccc64090f8491a
Parents: dc23d6a
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Jul 10 15:01:24 2015 +0200
Committer: Grzegorz Grzybek <gr...@gmail.com>
Committed: Mon Jul 20 14:51:37 2015 +0200
----------------------------------------------------------------------
.../blueprint/CamelBlueprintTestSupport.java | 4 ++
...gAdminLoadConfigurationFileNotFoundTest.java | 57 ++++++++++++++++++++
2 files changed, 61 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7fba34a9/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 d707370..a49b848 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;
@@ -111,6 +112,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/7fba34a9/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
+ }
+
+}