diff --git a/.github/workflows/manualRelease.yml b/.github/workflows/manualRelease.yml new file mode 100755 index 0000000..ffba127 --- /dev/null +++ b/.github/workflows/manualRelease.yml @@ -0,0 +1,35 @@ +name: Release and Publish +on: + workflow_dispatch: +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check-out + uses: actions/checkout@v4 + - name: Set up Java for publishing to Maven Central Packages + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + server-id: central + server-username: SONATYPE_USERNAME + server-password: SONATYPE_TOKEN + - name: Release with Maven + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + mvn -B -ntp -Dstyle.color=always release:prepare + VERSION=`cat release.properties | grep scm.tag= | cut -d'=' -f2` + mvn -B -ntp -Dstyle.color=always release:perform + echo "Released ${VERSION} 🚀" >> $GITHUB_STEP_SUMMARY + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }} + SONATYPE_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffba127..03edc8c 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ -name: Release and Publish +name: Publish package to GitHub Packages on: - workflow_dispatch: + release: + types: [created] jobs: publish: runs-on: ubuntu-latest @@ -8,28 +9,13 @@ jobs: contents: read packages: write steps: - - name: Check-out - uses: actions/checkout@v4 - - name: Set up Java for publishing to Maven Central Packages + - uses: actions/checkout@v4 + - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - cache: maven - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - server-id: central - server-username: SONATYPE_USERNAME - server-password: SONATYPE_TOKEN - - name: Release with Maven - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - mvn -B -ntp -Dstyle.color=always release:prepare - VERSION=`cat release.properties | grep scm.tag= | cut -d'=' -f2` - mvn -B -ntp -Dstyle.color=always release:perform - echo "Released ${VERSION} 🚀" >> $GITHUB_STEP_SUMMARY + - name: Publish to GitHub Packages + run: mvn --batch-mode deploy env: - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }} - SONATYPE_TOKEN: ${{ secrets.OSSRH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/commons-kernel/pom.xml b/commons-kernel/pom.xml index 24459d5..c4022a8 100755 --- a/commons-kernel/pom.xml +++ b/commons-kernel/pom.xml @@ -10,6 +10,8 @@ commons-kernel + https://github.com/sddevelopment-be/coding-utils + 21 21 diff --git a/commons-testing/pom.xml b/commons-testing/pom.xml index d74c129..9b1d5d6 100755 --- a/commons-testing/pom.xml +++ b/commons-testing/pom.xml @@ -11,6 +11,13 @@ commons-testing + + This module contains testing utilities included in the sddevelopment.be commons projects. + It is intended to simplify the testing of other modules in java projects. + + + https://github.com/sddevelopment-be/coding-utils + 21 21 diff --git a/commons-testing/src/main/java/be/sddevelopment/commons/testing/BaseTest.java b/commons-testing/src/main/java/be/sddevelopment/commons/testing/BaseTest.java new file mode 100644 index 0000000..b2777d1 --- /dev/null +++ b/commons-testing/src/main/java/be/sddevelopment/commons/testing/BaseTest.java @@ -0,0 +1,34 @@ +/*- + * #%L + * commons-testing + * %% + * Copyright (C) 2020 - 2024 SD Development + * %% + * Licensed under the EUPL, Version 1.1 or – as soon they will be + * approved by the European Commission - subsequent versions of the + * EUPL (the "Licence"); + * + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * #L% + */ + +package be.sddevelopment.commons.testing; + + +import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing; +import org.assertj.core.api.WithAssertions; +import org.junit.jupiter.api.DisplayNameGeneration; + +@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class) +public interface BaseTest extends WithAssertions { + +} diff --git a/commons-testing/src/main/java/be/sddevelopment/commons/testing/TextualAssertions.java b/commons-testing/src/main/java/be/sddevelopment/commons/testing/TextualAssertions.java index 2d1281d..c82b48f 100755 --- a/commons-testing/src/main/java/be/sddevelopment/commons/testing/TextualAssertions.java +++ b/commons-testing/src/main/java/be/sddevelopment/commons/testing/TextualAssertions.java @@ -36,8 +36,6 @@ *

Description of file/class

* * @author Stijn Dejongh - * @version $Id: $Id - * @created 18.10.20, Sunday */ public final class TextualAssertions { diff --git a/commons-testing/src/main/java/be/sddevelopment/commons/testing/annotations/WIP.java b/commons-testing/src/main/java/be/sddevelopment/commons/testing/annotations/WIP.java new file mode 100644 index 0000000..3f3b3e9 --- /dev/null +++ b/commons-testing/src/main/java/be/sddevelopment/commons/testing/annotations/WIP.java @@ -0,0 +1,37 @@ +/*- + * #%L + * commons-testing + * %% + * Copyright (C) 2020 - 2024 SD Development + * %% + * Licensed under the EUPL, Version 1.1 or – as soon they will be + * approved by the European Commission - subsequent versions of the + * EUPL (the "Licence"); + * + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * #L% + */ + +package be.sddevelopment.commons.testing.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.junit.jupiter.api.Disabled; + +@Disabled("Disabled: Work In Progress") +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface WIP { + +} diff --git a/commons-testing/src/main/java/be/sddevelopment/commons/testing/package-info.java b/commons-testing/src/main/java/be/sddevelopment/commons/testing/package-info.java index bc1b2c4..aafd4a2 100755 --- a/commons-testing/src/main/java/be/sddevelopment/commons/testing/package-info.java +++ b/commons-testing/src/main/java/be/sddevelopment/commons/testing/package-info.java @@ -22,9 +22,11 @@ */ /** - *

Description of file/class

+ *

+ * This module contains testing utilities included in the sddevelopment.be commons projects. + * It is intended to simplify the testing of other modules in java projects. + *

* * @author Stijn Dejongh - * @created 22.10.20, Thursday **/ package be.sddevelopment.commons.testing; diff --git a/commons-testing/src/test/java/be/sddevelopment/commons/testing/ReflectionAssertionUtilsTest.java b/commons-testing/src/test/java/be/sddevelopment/commons/testing/ReflectionAssertionUtilsTest.java index 4934eae..dd45ba3 100755 --- a/commons-testing/src/test/java/be/sddevelopment/commons/testing/ReflectionAssertionUtilsTest.java +++ b/commons-testing/src/test/java/be/sddevelopment/commons/testing/ReflectionAssertionUtilsTest.java @@ -7,12 +7,12 @@ * Licensed under the EUPL, Version 1.1 or – as soon they will be * approved by the European Commission - subsequent versions of the * EUPL (the "Licence"); - * + * * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: - * + * * http://ec.europa.eu/idabc/eupl5 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,18 +26,14 @@ import static be.sddevelopment.commons.testing.ReflectionAssertionUtils.assertPrivateMember; import static be.sddevelopment.commons.testing.ReflectionAssertionUtils.assertPrivateMemberReflectionProtection; -import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; import org.assertj.core.api.ThrowableAssert.ThrowingCallable; -import org.assertj.core.api.WithAssertions; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class) -class ReflectionAssertionUtilsTest implements WithAssertions { +class ReflectionAssertionUtilsTest implements BaseTest { @Test void constructorIsPrivate() throws NoSuchMethodException { @@ -46,16 +42,21 @@ void constructorIsPrivate() throws NoSuchMethodException { @Test void constructorIsReflectionSafe() throws NoSuchMethodException { - assertPrivateMemberReflectionProtection(ReflectionAssertionUtils.class.getDeclaredConstructor()); + assertPrivateMemberReflectionProtection( + ReflectionAssertionUtils.class.getDeclaredConstructor()); } @Nested @DisplayName("Method: assertPrivateMember") class AssertPrivateMember { + @Test void passesWhenConstructorIsPrivate() throws NoSuchMethodException { var constructorToTest = ClassWithPrivateConstructor.class.getDeclaredConstructor(); - assertThat(constructorToTest).isNotNull().extracting(Constructor::getModifiers).matches(Modifier::isPrivate); + assertThat(constructorToTest) + .isNotNull() + .extracting(Constructor::getModifiers) + .matches(Modifier::isPrivate); ThrowingCallable assertion = () -> assertPrivateMember(constructorToTest); @@ -65,43 +66,61 @@ void passesWhenConstructorIsPrivate() throws NoSuchMethodException { @Test void failsWhenConstructorIsPublic() throws NoSuchMethodException { var constructorToTest = ClassWithPublicConstructor.class.getDeclaredConstructor(); - assertThat(constructorToTest).isNotNull().extracting(Constructor::getModifiers).matches(Modifier::isPublic); + assertThat(constructorToTest) + .isNotNull() + .extracting(Constructor::getModifiers) + .matches(Modifier::isPublic); ThrowingCallable assertion = () -> assertPrivateMember(constructorToTest); - assertThatCode(assertion).isInstanceOf(AssertionError.class).hasMessageContaining("is expected to be protected from illegal access"); + assertThatCode(assertion) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("is expected to be protected from illegal access"); } } @Nested @DisplayName("Method: assertPrivateMemberReflectionProtection") class AssertPrivateMemberReflectionProtection { + @Test void failsWhenConstructorIsPublic() throws NoSuchMethodException { var constructorToTest = ClassWithPublicConstructor.class.getDeclaredConstructor(); - assertThat(constructorToTest).isNotNull().extracting(Constructor::getModifiers).matches(Modifier::isPublic); + assertThat(constructorToTest) + .isNotNull() + .extracting(Constructor::getModifiers) + .matches(Modifier::isPublic); ThrowingCallable assertion = () -> assertPrivateMemberReflectionProtection(constructorToTest); - assertThatCode(assertion).isInstanceOf(AssertionError.class) - .hasMessageContaining("is expected to be protected from illegal access"); + assertThatCode(assertion) + .isInstanceOf(AssertionError.class) + .hasMessageContaining("is expected to be protected from illegal access"); } @Test void failsWhenConstructorIsPrivateButNotReflectionSafe() throws NoSuchMethodException { var constructorToTest = ClassWithPrivateConstructor.class.getDeclaredConstructor(); - assertThat(constructorToTest).isNotNull().extracting(Constructor::getModifiers).matches(Modifier::isPrivate); + assertThat(constructorToTest) + .isNotNull() + .extracting(Constructor::getModifiers) + .matches(Modifier::isPrivate); ThrowingCallable assertion = () -> assertPrivateMemberReflectionProtection(constructorToTest); - assertThatCode(assertion).isNotNull().isInstanceOf(AssertionError.class) - .hasMessageContaining("is expected to be protected from illegal access"); + assertThatCode(assertion) + .isNotNull() + .isInstanceOf(AssertionError.class) + .hasMessageContaining("is expected to be protected from illegal access"); } @Test void passesWhenConstructorIsPrivateAndReflectionSafe() throws NoSuchMethodException { var constructorToTest = ClassWithReflectionSafeConstructor.class.getDeclaredConstructor(); - assertThat(constructorToTest).isNotNull().extracting(Constructor::getModifiers).matches(Modifier::isPrivate); + assertThat(constructorToTest) + .isNotNull() + .extracting(Constructor::getModifiers) + .matches(Modifier::isPrivate); ThrowingCallable assertion = () -> assertPrivateMemberReflectionProtection(constructorToTest); @@ -110,17 +129,21 @@ void passesWhenConstructorIsPrivateAndReflectionSafe() throws NoSuchMethodExcept } static final class ClassWithReflectionSafeConstructor { + private ClassWithReflectionSafeConstructor() { - throw new UnsupportedOperationException("Utility classes should not have a public or default constructor"); + throw new UnsupportedOperationException( + "Utility classes should not have a public or default constructor"); } } static final class ClassWithPrivateConstructor { + private ClassWithPrivateConstructor() { } } static final class ClassWithPublicConstructor { + public ClassWithPublicConstructor() { // Intentionally left empty to test the assertion } diff --git a/commons-testing/src/test/java/be/sddevelopment/commons/testing/TextualAssertionsTest.java b/commons-testing/src/test/java/be/sddevelopment/commons/testing/TextualAssertionsTest.java index 97ddaa1..67a30f7 100755 --- a/commons-testing/src/test/java/be/sddevelopment/commons/testing/TextualAssertionsTest.java +++ b/commons-testing/src/test/java/be/sddevelopment/commons/testing/TextualAssertionsTest.java @@ -41,8 +41,7 @@ * @version $Id: $Id */ @DisplayName("Test for AssertionUtils") -@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class) -class TextualAssertionsTest { +class TextualAssertionsTest implements BaseTest{ @Nested @DisplayName("Test with empty input") diff --git a/commons/pom.xml b/commons/pom.xml index 61a6d79..54d5fbc 100755 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -10,6 +10,12 @@ commons + + This module contains utilities, shared exceptions, and constants, included in the sddevelopment.be commons projects. + + + https://github.com/sddevelopment-be/coding-utils + 21 21 diff --git a/pom.xml b/pom.xml index 75e46ce..535ea62 100755 --- a/pom.xml +++ b/pom.xml @@ -14,11 +14,21 @@ useful design patterns. + https://github.com/sddevelopment-be/coding-utils + SD Development https://www.sddevelopment.be + + + EUPL v.1.2 + https://github.com/sddevelopment-be/coding-utils/blob/main/LICENSE + repo + + + Stijn Dejongh @@ -35,6 +45,11 @@ commons-testing commons-kernel + + scm:git:ssh://git@github.com/sddevelopment-be/coding-utils.git + ${project.url} + HEAD + @@ -44,23 +59,6 @@ - https://github.com/sddevelopment-be/coding-utils - - - EUPL v.1.2 - https://github.com/sddevelopment-be/coding-utils/blob/main/LICENSE - repo - - - - - scm:git:ssh://git@github.com/sddevelopment-be/coding-utils.git - ${project.url} - HEAD - - - - sddevelopment-be https://sonarcloud.io