You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/03/01 13:12:27 UTC
incubator-freemarker git commit: (Renamed configuration related
setting related exception classes to be some more conventional)
Repository: incubator-freemarker
Updated Branches:
refs/heads/3 5932e29b4 -> ff186d0ee
(Renamed configuration related setting related exception classes to be some more conventional)
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/ff186d0e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/ff186d0e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/ff186d0e
Branch: refs/heads/3
Commit: ff186d0ee20cf21b976fc92be864f5f64f0b7fb3
Parents: 5932e29
Author: ddekany <dd...@apache.org>
Authored: Wed Mar 1 14:02:33 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Wed Mar 1 14:12:16 2017 +0100
----------------------------------------------------------------------
.../apache/freemarker/core/Configurable.java | 50 +++-----------------
...onfigurationSettingValueStringException.java | 38 +++++++++++++++
.../UnknownConfigurationSettingException.java | 39 +++++++++++++++
.../freemarker/core/ConfigurationTest.java | 12 ++---
4 files changed, 89 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ff186d0e/src/main/java/org/apache/freemarker/core/Configurable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Configurable.java b/src/main/java/org/apache/freemarker/core/Configurable.java
index c1252d5..ed632e6 100644
--- a/src/main/java/org/apache/freemarker/core/Configurable.java
+++ b/src/main/java/org/apache/freemarker/core/Configurable.java
@@ -2133,8 +2133,8 @@ public class Configurable {
* @param name the name of the setting.
* @param value the string that describes the new value of the setting.
*
- * @throws UnknownSettingException if the name is wrong.
- * @throws SettingValueAssignmentException if the new value of the setting can't be set for any other reasons.
+ * @throws UnknownConfigurationSettingException if the name is wrong.
+ * @throws ConfigurationSettingValueStringException if the new value of the setting can't be set for any other reasons.
*/
public void setSetting(String name, String value) throws ConfigurationException {
boolean unknown = false;
@@ -2338,11 +2338,11 @@ public class Configurable {
/**
* Creates the exception that should be thrown when a setting name isn't recognized.
*/
- protected final UnknownSettingException unknownSettingException(String name) {
+ protected final UnknownConfigurationSettingException unknownSettingException(String name) {
Version removalVersion = getRemovalVersionForUnknownSetting(name);
return removalVersion != null
- ? new UnknownSettingException(name, removalVersion)
- : new UnknownSettingException(name, getCorrectedNameForUnknownSetting(name));
+ ? new UnknownConfigurationSettingException(name, removalVersion)
+ : new UnknownConfigurationSettingException(name, getCorrectedNameForUnknownSetting(name));
}
/**
@@ -2365,9 +2365,9 @@ public class Configurable {
return null;
}
- protected final SettingValueAssignmentException settingValueAssignmentException(
+ protected final ConfigurationSettingValueStringException settingValueAssignmentException(
String name, String value, Throwable cause) {
- return new SettingValueAssignmentException(name, value, cause);
+ return new ConfigurationSettingValueStringException(name, value, cause);
}
protected final TemplateException invalidSettingValueException(String name, String value) {
@@ -2379,44 +2379,8 @@ public class Configurable {
"Invalid value for setting ", new _DelayedJQuote(name), ": ", new _DelayedJQuote(value),
(reason != null ? ": " : null), (reason != null ? reason : null));
}
-
- /**
- * Thrown by {@link Configuration#setSetting(String, String)}; The setting name was not recognized.
- */
- @SuppressWarnings("serial")
- public static class UnknownSettingException extends ConfigurationException {
-
- private UnknownSettingException(String name, String correctedName) {
- super("Unknown FreeMarker configuration setting: " + _StringUtil.jQuote(name)
- + (correctedName == null ? "" : ". You may meant: " + _StringUtil.jQuote(correctedName)));
- }
-
- private UnknownSettingException(String name, Version removedInVersion) {
- super("Unknown FreeMarker configuration setting: " + _StringUtil.jQuote(name)
- + (removedInVersion == null ? "" : ". This setting was removed in version " + removedInVersion));
- }
-
- }
/**
- * Thrown by {@link Configuration#setSetting(String, String)}; The setting name was recognized, but its value
- * couldn't be parsed or the setting couldn't be set for some other reason. This exception should always have a
- * cause exception.
- *
- * @since 2.3.21
- */
- @SuppressWarnings("serial")
- public static class SettingValueAssignmentException extends ConfigurationException {
-
- private SettingValueAssignmentException(String name, String value, Throwable cause) {
- super("Failed to set FreeMarker configuration setting " + _StringUtil.jQuote(name)
- + " to value " + _StringUtil.jQuote(value) + "; see cause exception.", cause);
- _NullArgumentException.check("cause", cause);
- }
-
- }
-
- /**
* Set the settings stored in a <code>Properties</code> object.
*
* @throws ConfigurationException if the <code>Properties</code> object contains
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ff186d0e/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueStringException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueStringException.java b/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueStringException.java
new file mode 100644
index 0000000..558bfbb
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/ConfigurationSettingValueStringException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.freemarker.core;
+
+import org.apache.freemarker.core.util._NullArgumentException;
+import org.apache.freemarker.core.util._StringUtil;
+
+/**
+ * Thrown by {@link Configuration#setSetting(String, String)}; The setting name was recognized, but its value
+ * couldn't be parsed or the setting couldn't be set for some other reason. This exception should always have a
+ * cause exception.
+ */
+@SuppressWarnings("serial")
+public class ConfigurationSettingValueStringException extends ConfigurationException {
+
+ ConfigurationSettingValueStringException(String name, String value, Throwable cause) {
+ super("Failed to set FreeMarker configuration setting " + _StringUtil.jQuote(name)
+ + " to value " + _StringUtil.jQuote(value) + "; see cause exception.", cause);
+ _NullArgumentException.check("cause", cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ff186d0e/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java b/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
new file mode 100644
index 0000000..245e951
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/UnknownConfigurationSettingException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.freemarker.core;
+
+import org.apache.freemarker.core.util._StringUtil;
+
+/**
+ * Thrown by {@link Configuration#setSetting(String, String)}; The setting name was not recognized.
+ */
+@SuppressWarnings("serial")
+public class UnknownConfigurationSettingException extends ConfigurationException {
+
+ UnknownConfigurationSettingException(String name, String correctedName) {
+ super("Unknown FreeMarker configuration setting: " + _StringUtil.jQuote(name)
+ + (correctedName == null ? "" : ". You may meant: " + _StringUtil.jQuote(correctedName)));
+ }
+
+ UnknownConfigurationSettingException(String name, Version removedInVersion) {
+ super("Unknown FreeMarker configuration setting: " + _StringUtil.jQuote(name)
+ + (removedInVersion == null ? "" : ". This setting was removed in version " + removedInVersion));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ff186d0e/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
index ee4bcbd..0f3ed0a 100644
--- a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
+++ b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
@@ -37,8 +37,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
-import org.apache.freemarker.core.Configurable.SettingValueAssignmentException;
-import org.apache.freemarker.core.Configurable.UnknownSettingException;
import org.apache.freemarker.core.model.TemplateModelException;
import org.apache.freemarker.core.model.TemplateScalarModel;
import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
@@ -819,7 +817,7 @@ public class ConfigurationTest extends TestCase {
try {
cfg.setSetting(Configuration.OUTPUT_FORMAT_KEY, "null");
- } catch (SettingValueAssignmentException e) {
+ } catch (ConfigurationSettingValueStringException e) {
assertThat(e.getCause().getMessage(), containsString(UndefinedOutputFormat.class.getSimpleName()));
}
}
@@ -1128,7 +1126,7 @@ public class ConfigurationTest extends TestCase {
try {
cfg.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, "5");
assertEquals(5000L, cfg.getTemplateUpdateDelayMilliseconds());
- } catch (SettingValueAssignmentException e) {
+ } catch (ConfigurationSettingValueStringException e) {
assertThat(e.getCause().getMessage(), containsStringIgnoringCase("unit must be specified"));
}
cfg.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, "0");
@@ -1136,7 +1134,7 @@ public class ConfigurationTest extends TestCase {
try {
cfg.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, "5 foo");
assertEquals(5000L, cfg.getTemplateUpdateDelayMilliseconds());
- } catch (SettingValueAssignmentException e) {
+ } catch (ConfigurationSettingValueStringException e) {
assertThat(e.getCause().getMessage(), containsStringIgnoringCase("\"foo\""));
}
@@ -1554,7 +1552,7 @@ public class ConfigurationTest extends TestCase {
try {
cfg.setSetting(nameCC, value);
} catch (Exception e) {
- assertThat(e, not(instanceOf(UnknownSettingException.class)));
+ assertThat(e, not(instanceOf(UnknownConfigurationSettingException.class)));
resultCC = e;
}
@@ -1563,7 +1561,7 @@ public class ConfigurationTest extends TestCase {
try {
cfg.setSetting(nameSC, value);
} catch (Exception e) {
- assertThat(e, not(instanceOf(UnknownSettingException.class)));
+ assertThat(e, not(instanceOf(UnknownConfigurationSettingException.class)));
resultSC = e;
}