diff --git a/CHANGELOG.md b/CHANGELOG.md
index c34bb95..3eb6b7e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 1.2.1 - (12/03/2024)
+- **[BUGFIX]**: plugin: fix ColdFusion detection on Windows [#116](https://github.com/intergral/deep/pull/116) [@LMarkie](https://github.com/LMarkie)
+
# 1.2.0 - (06/02/2024)
- **[CHANGE]**: change log config to allow better control of logging [#103](https://github.com/intergral/deep/pull/103) [@Umaaz](https://github.com/Umaaz)
- **[CHANGE]**: change tracepoint logger to be a plugin [#106](https://github.com/intergral/deep/pull/106) [@Umaaz](https://github.com/Umaaz)
diff --git a/plugins/cf-plugin/pom.xml b/plugins/cf-plugin/pom.xml
index 40a9f6b..ac23616 100644
--- a/plugins/cf-plugin/pom.xml
+++ b/plugins/cf-plugin/pom.xml
@@ -41,6 +41,15 @@
1.0-SNAPSHOT
compile
+
+
+
+ org.junit-pioneer
+ junit-pioneer
+ 2.2.0
+ test
+
+
\ No newline at end of file
diff --git a/plugins/cf-plugin/src/main/java/com/intergral/deep/plugin/cf/Utils.java b/plugins/cf-plugin/src/main/java/com/intergral/deep/plugin/cf/Utils.java
index aa8e426..4fd8095 100644
--- a/plugins/cf-plugin/src/main/java/com/intergral/deep/plugin/cf/Utils.java
+++ b/plugins/cf-plugin/src/main/java/com/intergral/deep/plugin/cf/Utils.java
@@ -28,12 +28,22 @@ private Utils() {
/**
* Are we running on a CF server.
*
- * By looking at the java start up command we can tell if this is a CF server.
+ * By checking that the {@code coldfusion.home} system property exists, or by looking at the java start up command,
+ * we can tell if this is a CF server.
*
* @return {@code true} if we are on a coldfusion server.
*/
public static boolean isCFServer() {
- return System.getProperty("sun.java.command").contains("coldfusion");
+ if (System.getProperty("coldfusion.home") != null) {
+ return true;
+ }
+
+ final String javaCommand = System.getProperty("sun.java.command");
+ // has the potential to not exist on Windows services
+ if (javaCommand == null) {
+ return false;
+ }
+ return javaCommand.contains("coldfusion");
}
/**
diff --git a/plugins/cf-plugin/src/test/java/coldfusion/Version.java b/plugins/cf-plugin/src/test/java/coldfusion/Version.java
new file mode 100644
index 0000000..a5c378d
--- /dev/null
+++ b/plugins/cf-plugin/src/test/java/coldfusion/Version.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2024 Intergral GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package coldfusion;
+
+public class Version {
+ public static int getMajor() {
+ if (System.getProperty("cf.test.error") != null) {
+ throw new RuntimeException("failed to load version");
+ }
+ return 10;
+ }
+}
diff --git a/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/CFPluginTest.java b/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/CFPluginTest.java
new file mode 100644
index 0000000..ee18ac5
--- /dev/null
+++ b/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/CFPluginTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2024 Intergral GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.intergral.deep.plugin.cf;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import com.intergral.deep.agent.api.plugin.EvaluationException;
+import com.intergral.deep.agent.api.plugin.ISnapshotContext;
+import com.intergral.deep.agent.api.resource.Resource;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+class CFPluginTest {
+
+ @Test
+ void canDecorate() throws EvaluationException {
+ final CFPlugin cfPlugin = new CFPlugin();
+ final ISnapshotContext mock = Mockito.mock(ISnapshotContext.class);
+
+ final Resource decorate = cfPlugin.decorate(null, mock);
+ assertNotNull(decorate);
+ assertEquals("10", decorate.getAttributes().get("cf_version"));
+ assertNull(decorate.getAttributes().get("app_name"));
+
+ Mockito.verify(mock).evaluateExpression("APPLICATION.applicationname");
+ }
+
+ @Test
+ void canHandleEvaluateDecorate() throws EvaluationException {
+ final CFPlugin cfPlugin = new CFPlugin();
+
+ final ISnapshotContext mock = Mockito.mock(ISnapshotContext.class);
+
+ Mockito.when(mock.evaluateExpression("APPLICATION.applicationname")).thenReturn("app_name");
+
+ final Resource decorate = cfPlugin.decorate(null, mock);
+ assertNotNull(decorate);
+ assertEquals("10", decorate.getAttributes().get("cf_version"));
+ assertEquals("app_name", decorate.getAttributes().get("app_name"));
+
+ Mockito.verify(mock).evaluateExpression("APPLICATION.applicationname");
+ }
+
+ @Test
+ void canHandleEvaluateFailedDecorate() throws EvaluationException {
+ final CFPlugin cfPlugin = new CFPlugin();
+
+ final ISnapshotContext mock = Mockito.mock(ISnapshotContext.class);
+
+ Mockito.when(mock.evaluateExpression("APPLICATION.applicationname")).thenThrow(new RuntimeException("test exception"));
+
+ final Resource decorate = cfPlugin.decorate(null, mock);
+ assertNotNull(decorate);
+ assertEquals("10", decorate.getAttributes().get("cf_version"));
+ assertNull(decorate.getAttributes().get("app_name"));
+
+ Mockito.verify(mock).evaluateExpression("APPLICATION.applicationname");
+ }
+
+ @Test
+ void isActive() {
+ assertFalse(new CFPlugin().isActive());
+ }
+}
\ No newline at end of file
diff --git a/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/UtilsTest.java b/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/UtilsTest.java
new file mode 100644
index 0000000..4392e78
--- /dev/null
+++ b/plugins/cf-plugin/src/test/java/com/intergral/deep/plugin/cf/UtilsTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2024 Intergral GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.intergral.deep.plugin.cf;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ClearSystemProperty;
+import org.junitpioneer.jupiter.SetSystemProperty;
+
+class UtilsTest {
+
+ @Test
+ void canDetectNotCF() {
+ assertFalse(Utils.isCFServer());
+ }
+
+ @Test
+ @ClearSystemProperty(key = "sun.java.command")
+ void canHandleNoSunCommand() {
+ assertFalse(Utils.isCFServer());
+ }
+
+ @Test
+ @SetSystemProperty(key = "coldfusion.home", value = "doesn't matter")
+ void canDetectCFHome() {
+ assertTrue(Utils.isCFServer());
+ }
+
+ @Test
+ @SetSystemProperty(key = "sun.java.command", value = "/some/coldfusion")
+ void canUseSunCommand() {
+ assertTrue(Utils.isCFServer());
+ }
+
+ @Test
+ void loadCFVersion() {
+ assertEquals("10", Utils.loadCFVersion());
+ }
+
+ @Test
+ @SetSystemProperty(key = "cf.test.error", value = "anything")
+ void failLoadCFVersion() {
+ assertNull(Utils.loadCFVersion());
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4b69fc3..fdbfd3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -553,7 +553,8 @@
org.junit.jupiter
junit-jupiter
- 5.10.1
+
+ 5.9.3
org.mockito