This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jelly.git
The following commit(s) were added to refs/heads/master by this push:
new 9112756f Use SystemProperties instead of magic strings
9112756f is described below
commit 9112756f6363704706b8d00708c9fd24a16c3bcb
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Jul 20 15:06:28 2025 -0400
Use SystemProperties instead of magic strings
---
core/src/main/java/org/apache/commons/jelly/Jelly.java | 14 +++++---------
.../org/apache/commons/jelly/core/TestInvokeStaticTag.java | 3 ++-
.../main/java/org/apache/commons/jelly/task/JellyTask.java | 3 ++-
.../java/org/apache/commons/jelly/swing/TestSwingTags.java | 3 ++-
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/core/src/main/java/org/apache/commons/jelly/Jelly.java
b/core/src/main/java/org/apache/commons/jelly/Jelly.java
index 93ef73f1..63523886 100644
--- a/core/src/main/java/org/apache/commons/jelly/Jelly.java
+++ b/core/src/main/java/org/apache/commons/jelly/Jelly.java
@@ -29,6 +29,7 @@ import java.util.Properties;
import org.apache.commons.jelly.parser.XMLParser;
import org.apache.commons.jelly.util.ClassLoaderUtils;
import org.apache.commons.jelly.util.CommandLineParser;
+import org.apache.commons.lang3.SystemProperties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.SAXException;
@@ -185,7 +186,7 @@ public class Jelly {
*/
public URL getRootContext() throws MalformedURLException {
if (rootContext == null) {
- rootContext = new File(System.getProperty("user.dir")).toURL();
+ rootContext = new File(SystemProperties.getUserDir()).toURL();
}
return rootContext;
}
@@ -200,22 +201,17 @@ public class Jelly {
*/
protected void loadJellyProperties() {
InputStream is = null;
-
- final String userDir = System.getProperty("user.home");
+ final String userDir = SystemProperties.getUserHome();
File f = new File(userDir + File.separator + "jelly.properties");
loadProperties(f);
-
f = new File("jelly.properties");
loadProperties(f);
-
-
is =
ClassLoaderUtils.getClassLoader(getClass()).getResourceAsStream("jelly.properties");
if (is != null) {
try {
loadProperties(is);
- }
- catch (final Exception e) {
- log.error( "Caught exception while loading jelly.properties
from the classpath. Reason: " + e, e );
+ } catch (final Exception e) {
+ log.error("Caught exception while loading jelly.properties
from the classpath. Reason: " + e, e);
}
}
}
diff --git
a/core/src/test/java/org/apache/commons/jelly/core/TestInvokeStaticTag.java
b/core/src/test/java/org/apache/commons/jelly/core/TestInvokeStaticTag.java
index 237373ac..54be9299 100644
--- a/core/src/test/java/org/apache/commons/jelly/core/TestInvokeStaticTag.java
+++ b/core/src/test/java/org/apache/commons/jelly/core/TestInvokeStaticTag.java
@@ -19,6 +19,7 @@ package org.apache.commons.jelly.core;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.test.BaseJellyTest;
+import org.apache.commons.lang3.SystemProperties;
import junit.framework.TestSuite;
@@ -112,7 +113,7 @@ public class TestInvokeStaticTag extends BaseJellyTest {
getJellyContext().setVariable( "propertyName", "java.runtime.version"
);
script.run( getJellyContext(),getXMLOutput() );
- assertTrue( System.getProperty( "java.runtime.version" ).equals(
getJellyContext().getVariable("propertyName" ) ) );
+ assertTrue( SystemProperties.getJavaRuntimeVersion().equals(
getJellyContext().getVariable("propertyName" ) ) );
}
/**
diff --git
a/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java
b/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java
index e0f96140..d519a6c3 100644
--- a/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java
+++ b/jelly-tags/ant/src/main/java/org/apache/commons/jelly/task/JellyTask.java
@@ -30,6 +30,7 @@ import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.parser.XMLParser;
import org.apache.commons.jelly.tags.ant.AntTagLibrary;
+import org.apache.commons.lang3.SystemProperties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.BuildException;
@@ -134,7 +135,7 @@ public class JellyTask extends Task {
*/
public URL getRootContext() throws MalformedURLException {
if (rootContext == null) {
- rootContext = new File(System.getProperty("user.dir")).toURL();
+ rootContext = new File(SystemProperties.getUserDir()).toURL();
}
return rootContext;
}
diff --git
a/jelly-tags/swing/src/test/java/org/apache/commons/jelly/swing/TestSwingTags.java
b/jelly-tags/swing/src/test/java/org/apache/commons/jelly/swing/TestSwingTags.java
index 4bd8a330..bba35f27 100644
---
a/jelly-tags/swing/src/test/java/org/apache/commons/jelly/swing/TestSwingTags.java
+++
b/jelly-tags/swing/src/test/java/org/apache/commons/jelly/swing/TestSwingTags.java
@@ -37,6 +37,7 @@ import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.test.BaseJellyTest;
+import org.apache.commons.lang3.SystemProperties;
import junit.framework.TestSuite;
@@ -146,7 +147,7 @@ public class TestSwingTags extends BaseJellyTest {
if (!isAWTAvailable()) {
return;
}
- if (System.getProperty("java.version").startsWith("1.4")) {
+ if (SystemProperties.getJavaVersion().startsWith("1.4")) {
runSwingScript("test.gbc14");
final JellyContext context = getJellyContext();
final JFrame frame = (JFrame) context.getVariable("frame");