From 9b13b14d9d640318a9376c13605aaaf4867106f8 Mon Sep 17 00:00:00 2001 From: clouless <12599965+clouless@users.noreply.github.com> Date: Sat, 14 Feb 2026 17:35:02 +0100 Subject: [PATCH 1/2] maven build with ci --- .github/workflows/build-on-pull-request.yml | 21 ++++ .github/workflows/build-on-release.yml | 26 +++++ .github/workflows/scan-malware.yml | 14 +++ .github/workflows/scan-semgrep.yml | 19 ++++ BUILD | 38 -------- WORKSPACE | 78 --------------- deprecated_pom.xml | 70 -------------- pom.xml | 95 +++++++++++++++++++ .../io/codeclou/java/xml/grepper/Main.java | 3 +- .../codeclou/java/xml/grepper/XmlGrepper.java | 11 ++- .../xml/grepper/GetterSetterValidator.java | 43 --------- .../codeclou/java/xml/grepper/MainTest.java | 52 ---------- .../java/xml/grepper/PreventExitTestRule.java | 69 -------------- .../io/codeclou/java/xml/grepper/TestAll.java | 32 ------- .../java/xml/grepper/XmlGrepperTest.java | 30 +++--- 15 files changed, 194 insertions(+), 407 deletions(-) create mode 100644 .github/workflows/build-on-pull-request.yml create mode 100644 .github/workflows/build-on-release.yml create mode 100644 .github/workflows/scan-malware.yml create mode 100644 .github/workflows/scan-semgrep.yml delete mode 100644 BUILD delete mode 100644 WORKSPACE delete mode 100644 deprecated_pom.xml create mode 100644 pom.xml delete mode 100644 src/test/java/io/codeclou/java/xml/grepper/GetterSetterValidator.java delete mode 100644 src/test/java/io/codeclou/java/xml/grepper/MainTest.java delete mode 100644 src/test/java/io/codeclou/java/xml/grepper/PreventExitTestRule.java delete mode 100644 src/test/java/io/codeclou/java/xml/grepper/TestAll.java diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml new file mode 100644 index 0000000..928ac87 --- /dev/null +++ b/.github/workflows/build-on-pull-request.yml @@ -0,0 +1,21 @@ +name: build and test on pull request +on: + pull_request: + branches: [main] +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Malware Scanner # https://github.com/dell/common-github-actions/blob/main/malware-scanner/README.md + uses: dell/common-github-actions/malware-scanner@main + with: + directories: . + options: -ri + - name: Set up JDK 21 for x64 + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "temurin" + architecture: x64 + - run: mvn package -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true diff --git a/.github/workflows/build-on-release.yml b/.github/workflows/build-on-release.yml new file mode 100644 index 0000000..3131316 --- /dev/null +++ b/.github/workflows/build-on-release.yml @@ -0,0 +1,26 @@ +name: build and test on release +on: + push: + tags: + - "*" +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up JDK 21 for x64 + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "temurin" + architecture: x64 + - run: mvn package -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true + - name: "upload release assets" + uses: softprops/action-gh-release@cd28b0f5ee8571b76cfdaa62a30d51d752317477 #https://github.com/softprops/action-gh-release/issues/216 + if: github.ref_type == 'tag' + with: + body: | + :closed_book: File 1 of 1 uploaded: java-xml-grepper.jar + files: | + target/java-xml-grepper.jar + append_body: true diff --git a/.github/workflows/scan-malware.yml b/.github/workflows/scan-malware.yml new file mode 100644 index 0000000..651e9d3 --- /dev/null +++ b/.github/workflows/scan-malware.yml @@ -0,0 +1,14 @@ +name: scan-malware +on: + pull_request: + branches: [main] +jobs: + scan-malware: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Malware Scanner # https://github.com/dell/common-github-actions/blob/main/malware-scanner/README.md + uses: dell/common-github-actions/malware-scanner@main + with: + directories: . + options: -ri diff --git a/.github/workflows/scan-semgrep.yml b/.github/workflows/scan-semgrep.yml new file mode 100644 index 0000000..73b5615 --- /dev/null +++ b/.github/workflows/scan-semgrep.yml @@ -0,0 +1,19 @@ +name: scan-semgrep +on: + pull_request: {} + workflow_dispatch: {} + merge_group: + types: [checks_requested] +jobs: + scan-semgrep: + name: semgrep/ci + runs-on: ubuntu-latest + container: + image: semgrep/semgrep + # Skip any PR created by dependabot and any check triggered by merge group + if: (github.actor != 'dependabot[bot]') && (github.event != 'merge_group') + steps: + - uses: actions/checkout@v4 + - run: semgrep ci + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} diff --git a/BUILD b/BUILD deleted file mode 100644 index 2bc5f0a..0000000 --- a/BUILD +++ /dev/null @@ -1,38 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -java_library( - name = "java-xml-grepper-lib", - srcs = glob(["src/main/java/io/codeclou/java/xml/grepper/*.java"]), - deps = [ - "@commons_cli//jar", - ], -) - -java_binary( - name = "java-xml-grepper", - main_class = "io.codeclou.java.xml.grepper.Main", - runtime_deps = [":java-xml-grepper-lib"], -) - -java_test( - name = "tests", - srcs = glob(["src/test/java/io/codeclou/java/xml/grepper/*.java"]), - test_class = "io.codeclou.java.xml.grepper.TestAll", - resources=glob(['src/test/resources/**/*']), - deps = [ - ":java-xml-grepper-lib", - # TEST SCOPE - "@openpojo//jar", - "@commons_io//jar", - "@junit//jar", - "@powermock_api_support//jar", - "@powermock_core//jar", - "@powermock_module_junit4//jar", - "@powermock_module_junit4_common//jar", - "@powermock_api_mockito//jar", - "@powermock_api_mockito_common//jar", - "@powermock_reflect//jar", - "@mockito_all//jar", - "@javassist//jar", - ], -) diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index ffe8585..0000000 --- a/WORKSPACE +++ /dev/null @@ -1,78 +0,0 @@ -# -# COMPILE SCOPE -# -maven_jar( - name = "commons_cli", - artifact = "commons-cli:commons-cli:1.4", - server = "maven_central_server", -) -# -# TEST SCOPE -# -maven_jar( - name = "openpojo", - artifact = "com.openpojo:openpojo:0.8.6", - server = "maven_central_server", -) -maven_jar( - name = "commons_io", - artifact = "commons-io:commons-io:jar:2.6", - server = "maven_central_server", -) -maven_jar( - name = "junit", - artifact = "junit:junit:4.12", - server = "maven_central_server", -) -maven_jar( - name = "powermock_api_support", - artifact = "org.powermock:powermock-api-support:jar:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_core", - artifact = "org.powermock:powermock-core:jar:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_module_junit4", - artifact = "org.powermock:powermock-module-junit4:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_module_junit4_common", - artifact = "org.powermock:powermock-module-junit4-common:jar:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_api_mockito", - artifact = "org.powermock:powermock-api-mockito:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_api_mockito_common", - artifact = "org.powermock:powermock-api-mockito-common:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "powermock_reflect", - artifact = "org.powermock:powermock-reflect:jar:1.7.0", - server = "maven_central_server", -) -maven_jar( - name = "mockito_all", - artifact = "org.mockito:mockito-all:1.10.19", - server = "maven_central_server", -) -maven_jar( - name = "javassist", - artifact = "javassist:javassist:3.12.0.GA", - server = "maven_central_server", -) -# -# REPOS -# -maven_server( - name = "maven_central_server", - url = "https://repo1.maven.org/maven2/", -) diff --git a/deprecated_pom.xml b/deprecated_pom.xml deleted file mode 100644 index e1fc49d..0000000 --- a/deprecated_pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - 4.0.0 - io.codeclou - java-xml-grepper - 1.0.0 - - codeclou.io - http://codeclou.io/ - - - - MIT - https://github.com/codeclou/java-xml-grepper/blob/master/LICENSE - - - java-xml-grepper - java-xml-grepper - jar - - - commons-cli - commons-cli - 1.4 - - - junit - junit - 4.12 - test - - - com.openpojo - openpojo - 0.8.6 - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito - ${powermock.version} - test - - - org.mockito - mockito-all - 1.10.19 - test - - - org.powermock - powermock-api-mockito-common - 1.7.0 - test - - - - 1.7.0 - UTF-8 - 1.8 - 1.8 - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c0c6444 --- /dev/null +++ b/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + io.codeclou + java-xml-grepper + 1.1.0 + + codeclou.io + http://codeclou.io/ + + + + MIT + https://github.com/codeclou/java-xml-grepper/blob/main/LICENSE + + + java-xml-grepper + java-xml-grepper + jar + + + commons-cli + commons-cli + 1.11.0 + compile + + + org.junit.jupiter + junit-jupiter-engine + 5.11.0-M2 + test + + + commons-io + commons-io + 2.21.0 + test + + + com.openpojo + openpojo + 0.9.1 + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 0 + true + -Xmx1024m -XX:MaxPermSize=256m + + + + org.openclover + clover-maven-plugin + 4.5.2 + + + maven-assembly-plugin + 3.1.0 + + java-xml-grepper + + + io.codeclou.java.xml.grepper.Main + + + + jar-with-dependencies + + false + + + + make-assembly + package + + single + + + + + + + + UTF-8 + 21 + 21 + + diff --git a/src/main/java/io/codeclou/java/xml/grepper/Main.java b/src/main/java/io/codeclou/java/xml/grepper/Main.java index 04db71b..3b8aa3f 100644 --- a/src/main/java/io/codeclou/java/xml/grepper/Main.java +++ b/src/main/java/io/codeclou/java/xml/grepper/Main.java @@ -27,7 +27,8 @@ public class Main { public static void main(String [] args) throws Exception { XmlGrepper xmlGrepper = new XmlGrepper(); - xmlGrepper.run(args); + Boolean hasErrors = xmlGrepper.run(args); + System.exit(hasErrors ? 1 : 0); } } diff --git a/src/main/java/io/codeclou/java/xml/grepper/XmlGrepper.java b/src/main/java/io/codeclou/java/xml/grepper/XmlGrepper.java index 53344a6..c75d6a8 100644 --- a/src/main/java/io/codeclou/java/xml/grepper/XmlGrepper.java +++ b/src/main/java/io/codeclou/java/xml/grepper/XmlGrepper.java @@ -45,9 +45,9 @@ public class XmlGrepper { private CommandLineParser parser = new DefaultParser(); - private Options options = new Options(); - private Boolean hasCmdLineParameterErrors = false; - private Boolean hasFileNotFoundErrors = false; + protected Options options = new Options(); + protected Boolean hasCmdLineParameterErrors = false; + protected Boolean hasFileNotFoundErrors = false; protected String parseXml(String xpathExpression, File xmlFile) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, XPathExpressionException { FileInputStream fileIS = new FileInputStream(xmlFile); @@ -58,7 +58,7 @@ protected String parseXml(String xpathExpression, File xmlFile) throws FileNotFo return (String) xPath.compile(xpathExpression).evaluate(xmlDocument, XPathConstants.STRING); } - protected void run(String[] args) throws Exception { + protected boolean run(String[] args) throws Exception { // // ONLY OUTPUT STUFF ON ERROR! // @@ -87,9 +87,10 @@ protected void run(String[] args) throws Exception { } catch (Exception e) { System.out.println("\033[31;1mError >> Parse Exception\033[0m"); System.out.println(e.getMessage()); - System.exit(1); + return true; } } } + return false; } } diff --git a/src/test/java/io/codeclou/java/xml/grepper/GetterSetterValidator.java b/src/test/java/io/codeclou/java/xml/grepper/GetterSetterValidator.java deleted file mode 100644 index 756aa32..0000000 --- a/src/test/java/io/codeclou/java/xml/grepper/GetterSetterValidator.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Bernhard Grünewaldt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.codeclou.java.xml.grepper; - -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class GetterSetterValidator { - - private static final Validator ACCESSOR_VALIDATOR = ValidatorBuilder.create() - .with(new GetterTester()) - .with(new SetterTester()) - .build(); - - public static void validateAccessors(final Class clazz) { - ACCESSOR_VALIDATOR.validate(PojoClassFactory.getPojoClass(clazz)); - } - -} diff --git a/src/test/java/io/codeclou/java/xml/grepper/MainTest.java b/src/test/java/io/codeclou/java/xml/grepper/MainTest.java deleted file mode 100644 index b8bde99..0000000 --- a/src/test/java/io/codeclou/java/xml/grepper/MainTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Bernhard Grünewaldt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.codeclou.java.xml.grepper; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import static org.powermock.api.mockito.PowerMockito.whenNew; - -@RunWith(PowerMockRunner.class) -public class MainTest { - - @Mock - private XmlGrepper xmlGrepper; - - @Before - public void init() throws Exception { - whenNew(XmlGrepper.class).withNoArguments().thenReturn(xmlGrepper); - } - - @Test - @PrepareForTest({Main.class}) - public void testMergerValidInput() throws Exception { - String[] args = {"-f foo.xml", "-x aaa"}; - Main.main(args); - } -} diff --git a/src/test/java/io/codeclou/java/xml/grepper/PreventExitTestRule.java b/src/test/java/io/codeclou/java/xml/grepper/PreventExitTestRule.java deleted file mode 100644 index 2851944..0000000 --- a/src/test/java/io/codeclou/java/xml/grepper/PreventExitTestRule.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Bernhard Grünewaldt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.codeclou.java.xml.grepper; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -import java.security.Permission; - -public class PreventExitTestRule implements TestRule { - - private SecurityManager securityManager; - - @Override - public Statement apply(Statement statement, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - securityManager = System.getSecurityManager(); - System.setSecurityManager(new PreventExitSecurityManager()); - } - }; - } - - class PreventExitSecurityManager extends SecurityManager { - @Override - public void checkPermission(Permission perm) { - if (securityManager != null) { - securityManager.checkPermission(perm); - } - } - - @Override - public void checkPermission(Permission perm, Object context) { - if (securityManager != null) { - securityManager.checkPermission(perm, context); - } - } - - @Override - public void checkExit(int status) { - if (status != 0) { - throw new SecurityException("Prevented System.exit(" + status + ")"); - } - } - } -} diff --git a/src/test/java/io/codeclou/java/xml/grepper/TestAll.java b/src/test/java/io/codeclou/java/xml/grepper/TestAll.java deleted file mode 100644 index 7aa095a..0000000 --- a/src/test/java/io/codeclou/java/xml/grepper/TestAll.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Bernhard Grünewaldt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package io.codeclou.java.xml.grepper; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({MainTest.class, XmlGrepperTest.class}) -public class TestAll { } diff --git a/src/test/java/io/codeclou/java/xml/grepper/XmlGrepperTest.java b/src/test/java/io/codeclou/java/xml/grepper/XmlGrepperTest.java index 6c3c8ff..d282a44 100644 --- a/src/test/java/io/codeclou/java/xml/grepper/XmlGrepperTest.java +++ b/src/test/java/io/codeclou/java/xml/grepper/XmlGrepperTest.java @@ -23,30 +23,22 @@ */ package io.codeclou.java.xml.grepper; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.internal.util.reflection.Whitebox; +import org.junit.jupiter.api.Test; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; -import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class XmlGrepperTest { - // NOTE: Bazel has its own GoogleSecurityManager that prevents System.exit() - //@Rule - //public PreventExitTestRule preventExit = new PreventExitTestRule(); - private File getTestFile(String filename) throws IOException { // Since Bazel creates a test.jar somewhere we need to extract the testfile // out of the jar and put it accessible on the Filesystem somewhere to e.g. /tmp/ @@ -75,7 +67,7 @@ public void testRunInvalidInput1() throws Exception { String[] args = {}; XmlGrepper grepper = new XmlGrepper(); grepper.run(args); - Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(grepper, "hasCmdLineParameterErrors"); + Boolean hasCmdLineParameterErrors = grepper.hasCmdLineParameterErrors; assertTrue(hasCmdLineParameterErrors); } @@ -84,7 +76,7 @@ public void testRunInvalidInput2() throws Exception { String[] args = {"-x=foo"}; XmlGrepper grepper = new XmlGrepper(); grepper.run(args); - Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(grepper, "hasCmdLineParameterErrors"); + Boolean hasCmdLineParameterErrors = grepper.hasCmdLineParameterErrors; assertTrue(hasCmdLineParameterErrors); } @@ -93,7 +85,7 @@ public void testRunValidInputWithInvalidFolders() throws Exception { String[] args = {"-x=foo", "-f=?x/bar.xml"}; XmlGrepper grepper = new XmlGrepper(); grepper.run(args); - Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(grepper, "hasFileNotFoundErrors"); + Boolean hasFileNotFoundErrors = grepper.hasFileNotFoundErrors; assertTrue(hasFileNotFoundErrors); } @@ -103,9 +95,9 @@ public void testRunValidInputWithValidXpath() throws Exception { String[] args = {"-f=" + pomXMl.getAbsolutePath(), "-x=foo"}; XmlGrepper grepper = new XmlGrepper(); grepper.run(args); - Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(grepper, "hasCmdLineParameterErrors"); + Boolean hasCmdLineParameterErrors = grepper.hasCmdLineParameterErrors; assertFalse(hasCmdLineParameterErrors); - Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(grepper, "hasFileNotFoundErrors"); + Boolean hasFileNotFoundErrors = grepper.hasFileNotFoundErrors; assertFalse(hasFileNotFoundErrors); } @@ -119,9 +111,9 @@ public void testRunValidInputWithInValidXpath() throws Exception { } catch (SecurityException e) { // expected } - Boolean hasCmdLineParameterErrors = (Boolean) Whitebox.getInternalState(grepper, "hasCmdLineParameterErrors"); + Boolean hasCmdLineParameterErrors = grepper.hasCmdLineParameterErrors; assertFalse(hasCmdLineParameterErrors); - Boolean hasFileNotFoundErrors = (Boolean) Whitebox.getInternalState(grepper, "hasFileNotFoundErrors"); + Boolean hasFileNotFoundErrors = grepper.hasFileNotFoundErrors; assertFalse(hasFileNotFoundErrors); } From 912d86a3f4c404fb0b24230da765e12f8c86c736 Mon Sep 17 00:00:00 2001 From: clouless <12599965+clouless@users.noreply.github.com> Date: Sat, 14 Feb 2026 17:37:53 +0100 Subject: [PATCH 2/2] cleanup --- DEVELOPMENT.md | 54 -------------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index b4d5ed6..0000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,54 +0,0 @@ -# Development - -### Doc - -We build with bazel: - - * https://docs.bazel.build/versions/master/tutorial/java.html - * https://github.com/bazelbuild/examples/tree/master/java-maven - * https://github.com/johnynek/bazel-deps - -"Fat-Jar": - - * https://docs.bazel.build/versions/master/tutorial/java.html#package-a-java-target-for-deployment - - -### Run Tests - -``` -bazel test :tests -``` - -Use Bazel Watcher for tests: https://github.com/bazelbuild/bazel-watcher - -Install -``` -cd ~/git -git clone https://github.com/bazelbuild/bazel-watcher.git -cd bazel-watcher -bazel build //ibazel - -# Add to .bash_profile -echo 'export PATH="$PATH:$HOME/git/bazel-watcher/bazel-bin/ibazel/darwin_amd64_pure_stripped/"' >> ~/.bash_profile -``` - -Test with watcher - -``` -ibazel test :tests -``` - -### Build - -``` -# JAR / BINARY -bazel build //:java-xml-grepper - -./bazel-bin/java-xml-grepper - - -# FAT JAR -bazel build //:java-xml-grepper_deploy.jar - -java -jar bazel-bin/java-xml-grepper_deploy.jar -```