From 5c93e22814d3bcf99a8973efb9c526e1d33ceb14 Mon Sep 17 00:00:00 2001 From: indroneel Date: Sat, 19 Sep 2026 22:55:06 +0530 Subject: [PATCH] the first commit --- .editorconfig | 9 + .gitignore | 62 ++++++ README.md | 59 ++++- build.gradle | 77 +++++++ settings.gradle | 15 ++ .../v1/test/scenario/s1/InheritanceTests.java | 67 ++++++ .../v1/test/scenario/s1/NonDescend.java | 22 ++ .../v1/test/scenario/s1/S1BaseClass.java | 22 ++ .../v1/test/scenario/s1/S1BaseFace.java | 24 +++ .../v1/test/scenario/s1/S1Descend01.java | 22 ++ .../v1/test/scenario/s1/S1Descend02.java | 22 ++ .../v1/test/scenario/s1/S1Descend03.java | 22 ++ .../v1/test/scenario/s1/S1Descend04.java | 22 ++ .../v1/test/scenario/s2/InheritanceTests.java | 65 ++++++ .../v1/test/scenario/s2/S2BaseClass.java | 22 ++ .../v1/test/scenario/s2/S2BaseFace.java | 22 ++ .../v1/test/scenario/s2/S2ChildClass.java | 22 ++ .../v1/test/scenario/s2/S2ChildFace.java | 22 ++ .../v1/test/scenario/s2/S2Descend01.java | 22 ++ .../v1/test/scenario/s2/S2Descend02.java | 22 ++ .../v1/test/scenario/s2/S2Descend03.java | 22 ++ .../v1/test/scenario/s2/S2Descend04.java | 22 ++ .../scenario/s3/ClassAnnotationTests.java | 95 ++++++++ .../v1/test/scenario/s3/S3BaseClass.java | 23 ++ .../v1/test/scenario/s3/S3BaseFace1.java | 23 ++ .../v1/test/scenario/s3/S3BaseFace2.java | 23 ++ .../v1/test/scenario/s3/S3ClsAnn01.java | 29 +++ .../v1/test/scenario/s3/S3ClsAnn02.java | 29 +++ .../v1/test/scenario/s3/S3ClsAnn03.java | 29 +++ .../v1/test/scenario/s3/S3ClsAnn04.java | 29 +++ .../v1/test/scenario/s3/S3DerivedFace.java | 22 ++ .../v1/test/scenario/s3/S3Target01.java | 23 ++ .../v1/test/scenario/s3/S3Target02.java | 23 ++ .../v1/test/scenario/s3/S3Target03.java | 22 ++ .../v1/test/scenario/s3/S3Target04.java | 22 ++ .../v1/test/scenario/s3/S3Target05.java | 22 ++ .../scenario/s4/MethodAnnotationTests.java | 79 +++++++ .../test/scenario/s4/S4BaseContainer01.java | 25 +++ .../test/scenario/s4/S4BaseContainer02.java | 25 +++ .../v1/test/scenario/s4/S4Container01.java | 28 +++ .../v1/test/scenario/s4/S4Container02.java | 24 +++ .../v1/test/scenario/s4/S4Container03.java | 25 +++ .../v1/test/scenario/s4/S4Container04.java | 24 +++ .../v1/test/scenario/s4/S4MthdAnn01.java | 29 +++ .../v1/test/scenario/s4/S4MthdAnn02.java | 29 +++ .../v1/test/scenario/s4/S4MthdAnn03.java | 29 +++ .../scenario/s5/FieldAnnotationTests.java | 133 ++++++++++++ .../test/scenario/s5/S5BaseContainer01.java | 25 +++ .../test/scenario/s5/S5BaseContainer02.java | 25 +++ .../test/scenario/s5/S5BaseContainer03.java | 25 +++ .../v1/test/scenario/s5/S5Container01.java | 25 +++ .../v1/test/scenario/s5/S5Container02.java | 25 +++ .../v1/test/scenario/s5/S5Container03.java | 25 +++ .../v1/test/scenario/s5/S5Container04.java | 24 +++ .../v1/test/scenario/s5/S5Container05.java | 24 +++ .../v1/test/scenario/s5/S5Container06.java | 24 +++ .../v1/test/scenario/s5/S5FldAnn01.java | 29 +++ .../v1/test/scenario/s5/S5FldAnn02.java | 29 +++ .../v1/test/scenario/s5/S5FldAnn03.java | 29 +++ .../v1/test/scenario/s5/S5FldAnn04.java | 29 +++ .../v1/test/scenario/s5/S5FldAnn05.java | 29 +++ .../v1/test/scenario/s5/S5FldAnn06.java | 29 +++ .../v1/test/scenario/s6/FilterScopeTests.java | 204 ++++++++++++++++++ .../v1/test/scenario/s6/S6ClsAnn01.java | 29 +++ .../v1/test/scenario/s6/S6Target01.java | 23 ++ .../v1/test/scenario/s6/S6Target02.java | 23 ++ .../v1/test/scenario/s6/S6Target03.java | 23 ++ .../v1/test/scenario/s6/SXTarget01.java | 23 ++ .../test/scenario/s7/DuplicateScopeTests.java | 114 ++++++++++ .../v1/test/scenario/s7/S7ClsAnn01.java | 29 +++ .../v1/test/scenario/s7/S7Target01.java | 23 ++ .../v1/test/scenario/s7/S7Target02.java | 23 ++ .../v1/test/scenario/s7/S7Target03.java | 23 ++ .../scanpath/v1/test/setup/AbstractTests.java | 55 +++++ .../v1/test/setup/LauncherSessionHandler.java | 43 ++++ ....platform.launcher.LauncherSessionListener | 15 ++ src/test/resources/logback.xml | 52 +++++ 77 files changed, 2646 insertions(+), 2 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 settings.gradle create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/InheritanceTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/NonDescend.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseClass.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseFace.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/InheritanceTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseClass.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseFace.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildClass.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildFace.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/ClassAnnotationTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseClass.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace1.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace2.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3DerivedFace.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target05.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/MethodAnnotationTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/FieldAnnotationTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container05.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container06.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn04.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn05.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn06.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/FilterScopeTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/S6ClsAnn01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target03.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s6/SXTarget01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s7/DuplicateScopeTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s7/S7ClsAnn01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target01.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target02.java create mode 100644 src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target03.java create mode 100644 src/test/java/dux/scanpath/v1/test/setup/AbstractTests.java create mode 100644 src/test/java/dux/scanpath/v1/test/setup/LauncherSessionHandler.java create mode 100644 src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener create mode 100644 src/test/resources/logback.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..94e001b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +indent_style = tab +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fdc9df --- /dev/null +++ b/.gitignore @@ -0,0 +1,62 @@ +## OS Generated + +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +Desktop.ini + +## Eclipse IDE + +.project +.classpath +.settings/ +.metadata +bin/ +*.tmp +*.bak +*.swp +local.properties +.externalToolBuilders/ +*.launch +.pmd +.eclipse-pmd + +# Intellij Idea +.idea +*.iml + +# Maven +target/ + +# Gradle +.gradle +/build/ +/gradle/ +/gradlew +/gradlew.bat + +## Project specific +deploy + +# Default by github for Java projects + +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Maven versionsBackup + +*.versionsBackup diff --git a/README.md b/README.md index ac5a643..3f324aa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,58 @@ -# scanpath-v1-tests +# Scanpath v1 Tests -Unit tests for the Scanpath v1 library \ No newline at end of file +> Integration and unit tests for the Javassist-backed Scanpath v1 library. + +This project exercises the public scanning API provided by +[Scanpath v1](https://rprime.indroneel.co/libzero/scanpath-v1). The suite uses small, purpose-built +type hierarchies and annotations to verify discovery behavior without relying on +application-specific classes. + +## Coverage + +The test scenarios cover: + +- Direct and indirect inheritance and interface implementations +- Class-level annotation discovery +- Field-level annotation discovery +- Method-level annotation discovery +- Package and class filtering +- Duplicate scope handling +- Positive and negative discovery cases + +Tests are organized under +[`src/test/java/dux/scanpath/v1/test`](src/test/java/dux/scanpath/v1/test), with scenarios grouped +by discovery behavior. + +## Requirements + +- Java 17 or newer +- Gradle 9.x +- A locally installed or reachable `dux.scanpath:dux.scanpath:v1-SNAPSHOT` dependency + +The build resolves dependencies from `mavenLocal()`, Maven Central, and the DuxTechnica snapshot +repository. Build and install the sibling Scanpath v1 project first when the snapshot is not +already available: + +```bash +cd ../scanpath-v1 +mvn install +``` + +## Run the tests + +From this directory, run the complete JUnit Platform test suite: + +```bash +gradle clean build test +``` + +The reports are written to the following locations: + +- `build/reports/tests/test/index.html` - JUnit test report +- `build/reports/jacoco/test/html/index.html` - JaCoCo coverage report + +## License + +This project is distributed under the +[DuxTechnica Limited Use Source Code License Agreement](LICENSE). Review the license before +using or redistributing the source code. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..d9f27c6 --- /dev/null +++ b/build.gradle @@ -0,0 +1,77 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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. + */ + +plugins { + id "java" + id "jacoco" +} + +version = "v1-SNAPSHOT" + +repositories { + mavenLocal() + mavenCentral() + maven { + url "https://maven.indroneel.co/repo/snapshots" + } +} + +dependencies { + implementation "dux.scanpath:dux.scanpath:v1-SNAPSHOT" + + implementation "org.junit.jupiter:junit-jupiter:5.10.2" + implementation "org.junit.platform:junit-platform-launcher:1.10.2" + + implementation "org.slf4j:jul-to-slf4j:2.0.7" + implementation "ch.qos.logback:logback-classic:1.4.6" + implementation "org.codehaus.janino:janino:3.1.9" +} + +tasks.named("test", Test) { + useJUnitPlatform() + systemProperty "junit.jupiter.extensions.autodetection.enabled", "true" + + /* + filter { + includeTestsMatching("fully.qualified.package.*") + } + */ + + testLogging { + events "started", "passed", "failed", "skipped" + showStandardStreams = true + displayGranularity 2 + reports + finalizedBy jacocoTestReport + } +} + +jacocoTestReport { + dependsOn test + reports { + xml.required = true + csv.required = false + //html.outputLocation = layout.buildDirectory.dir('jacocoHtml') + } + + afterEvaluate { + def classDir = file("${projectDir}/../scanpath-v1/target/classes") + def sourceDir = file("${projectDir}/../scanpath-v1/src/main/java") + + sourceDirectories.setFrom(files(sourceDir)) + classDirectories.setFrom(files( + fileTree(dir: classDir) + )) + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..c8bce23 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,15 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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. + */ + +rootProject.name = "scanpath-v1-tests" diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/InheritanceTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/InheritanceTests.java new file mode 100644 index 0000000..e25010a --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/InheritanceTests.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class InheritanceTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(InheritanceTests.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(S1BaseClass.class.getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.setClassLoader(null); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(S1BaseFace.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S1Descend01.class)); + Assertions.assertTrue(clsList.contains(S1Descend02.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(S1BaseClass.class.getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(S1BaseClass.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S1Descend03.class)); + Assertions.assertTrue(clsList.contains(S1Descend04.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/NonDescend.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/NonDescend.java new file mode 100644 index 0000000..1fe0ee8 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/NonDescend.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class NonDescend { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseClass.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseClass.java new file mode 100644 index 0000000..730d462 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseClass.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class S1BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseFace.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseFace.java new file mode 100644 index 0000000..2a433f7 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1BaseFace.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * This is a marker interface that is used to scan for classes that implement this interface. + * + * @author indroneel + */ + +public interface S1BaseFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend01.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend01.java new file mode 100644 index 0000000..ccb8f2e --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend01.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class S1Descend01 implements S1BaseFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend02.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend02.java new file mode 100644 index 0000000..dfcedd0 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend02.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class S1Descend02 implements S1BaseFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend03.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend03.java new file mode 100644 index 0000000..fb68831 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend03.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class S1Descend03 extends S1BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend04.java b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend04.java new file mode 100644 index 0000000..a939a50 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s1/S1Descend04.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s1; + +/** + * @author indroneel + */ + +public class S1Descend04 extends S1BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/InheritanceTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/InheritanceTests.java new file mode 100644 index 0000000..8ac20ec --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/InheritanceTests.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class InheritanceTests { + + private static final Logger _L = Logger.getLogger(InheritanceTests.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(S2BaseClass.class.getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(S2BaseFace.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S2Descend01.class)); + Assertions.assertTrue(clsList.contains(S2Descend02.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(S2BaseClass.class.getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(S2BaseClass.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S2Descend03.class)); + Assertions.assertTrue(clsList.contains(S2Descend04.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseClass.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseClass.java new file mode 100644 index 0000000..f1f69a4 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseClass.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseFace.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseFace.java new file mode 100644 index 0000000..596ff73 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2BaseFace.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public interface S2BaseFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildClass.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildClass.java new file mode 100644 index 0000000..94727ea --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildClass.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2ChildClass extends S2BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildFace.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildFace.java new file mode 100644 index 0000000..e119604 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2ChildFace.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public interface S2ChildFace extends S2BaseFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend01.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend01.java new file mode 100644 index 0000000..9aafac3 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend01.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2Descend01 implements S2ChildFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend02.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend02.java new file mode 100644 index 0000000..d25df73 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend02.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2Descend02 implements S2ChildFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend03.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend03.java new file mode 100644 index 0000000..667ff89 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend03.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2Descend03 extends S2BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend04.java b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend04.java new file mode 100644 index 0000000..e5e5b27 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s2/S2Descend04.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s2; + +/** + * @author indroneel + */ + +public class S2Descend04 extends S2BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/ClassAnnotationTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/ClassAnnotationTests.java new file mode 100644 index 0000000..efdbc8d --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/ClassAnnotationTests.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class ClassAnnotationTests extends AbstractTests { + + private static final Logger _L = Logger.getLogger(ClassAnnotationTests.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S3ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S3Target01.class)); + Assertions.assertTrue(clsList.contains(S3Target02.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S3ClsAnn02.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S3Target03.class)); + } + + @Test + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S3ClsAnn03.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S3Target04.class)); + } + + @Test + @Order(4) + public void test04() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S3ClsAnn04.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S3Target05.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseClass.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseClass.java new file mode 100644 index 0000000..2ddf02c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseClass.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/**' + * @author indroneel + */ + +@S3ClsAnn02 +public class S3BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace1.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace1.java new file mode 100644 index 0000000..a877190 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace1.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +@S3ClsAnn03 +public interface S3BaseFace1 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace2.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace2.java new file mode 100644 index 0000000..2635168 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3BaseFace2.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +@S3ClsAnn04 +public interface S3BaseFace2 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn01.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn01.java new file mode 100644 index 0000000..bd01c47 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S3ClsAnn01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn02.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn02.java new file mode 100644 index 0000000..5460344 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn02.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S3ClsAnn02 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn03.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn03.java new file mode 100644 index 0000000..17fbc8c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn03.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S3ClsAnn03 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn04.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn04.java new file mode 100644 index 0000000..2e368fc --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3ClsAnn04.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S3ClsAnn04 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3DerivedFace.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3DerivedFace.java new file mode 100644 index 0000000..dc89bb7 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3DerivedFace.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +public interface S3DerivedFace extends S3BaseFace2 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target01.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target01.java new file mode 100644 index 0000000..f82deb6 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target01.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +@S3ClsAnn01 +public class S3Target01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target02.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target02.java new file mode 100644 index 0000000..1c6c12d --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target02.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +@S3ClsAnn01 +public class S3Target02 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target03.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target03.java new file mode 100644 index 0000000..4097628 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target03.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +public class S3Target03 extends S3BaseClass { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target04.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target04.java new file mode 100644 index 0000000..b539595 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target04.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +public class S3Target04 implements S3BaseFace1 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target05.java b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target05.java new file mode 100644 index 0000000..47773f7 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s3/S3Target05.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s3; + +/** + * @author indroneel + */ + +public class S3Target05 implements S3DerivedFace { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/MethodAnnotationTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/MethodAnnotationTests.java new file mode 100644 index 0000000..744f542 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/MethodAnnotationTests.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class MethodAnnotationTests extends AbstractTests { + + private static final Logger _L = Logger.getLogger(MethodAnnotationTests.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedMethods(S4MthdAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S4Container01.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedMethods(S4MthdAnn02.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S4Container02.class)); + } + + @Test + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedMethods(S4MthdAnn03.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S4BaseContainer02.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer01.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer01.java new file mode 100644 index 0000000..f6910e3 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer01.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4BaseContainer01 { + + @S4MthdAnn02 + public void method01() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer02.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer02.java new file mode 100644 index 0000000..2dd270f --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4BaseContainer02.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4BaseContainer02 { + + @S4MthdAnn03 + private void method01() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container01.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container01.java new file mode 100644 index 0000000..86e5435 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container01.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4Container01 { + + @S4MthdAnn01 + public void method01() {} + + @S4MthdAnn01 + public void method02() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container02.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container02.java new file mode 100644 index 0000000..a054ac4 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container02.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4Container02 extends S4BaseContainer01 { + + public void method02() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container03.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container03.java new file mode 100644 index 0000000..6cd015a --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container03.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4Container03 { + + @S4MthdAnn03 + private void method01() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container04.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container04.java new file mode 100644 index 0000000..ad6b21c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4Container04.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +/** + * @author indroneel + */ + +public class S4Container04 extends S4BaseContainer02 { + + public void method02() {} +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn01.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn01.java new file mode 100644 index 0000000..7cb1382 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S4MthdAnn01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn02.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn02.java new file mode 100644 index 0000000..8783dde --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn02.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S4MthdAnn02 { +} \ No newline at end of file diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn03.java b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn03.java new file mode 100644 index 0000000..1af7ee2 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s4/S4MthdAnn03.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s4; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S4MthdAnn03 { +} \ No newline at end of file diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/FieldAnnotationTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/FieldAnnotationTests.java new file mode 100644 index 0000000..5d63203 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/FieldAnnotationTests.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("Classes can be found using field-level annotations") +public class FieldAnnotationTests extends AbstractTests { + + private static final Logger _L = Logger.getLogger(FieldAnnotationTests.class.getName()); + + @Test + @DisplayName("Annotation on a public field can be used to find a class") + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container01.class)); + } + + @Test + @DisplayName("Annotation on a private field can be used to find a class") + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn02.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container02.class)); + } + + @Test + @DisplayName("Annotation on a protected field can be used to find a class") + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn03.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container03.class)); + } + + + @Test + @DisplayName("Annotation on a public field can be used to find a derived class") + @Order(4) + public void test04() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn04.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container04.class)); + } + + @Test + @DisplayName("Annotation on a private field can be used to find a derived class") + @Order(5) + public void test05() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn05.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container05.class)); + } + + @Test + @DisplayName("Annotation on a protected field can be used to find a derived class") + @Order(6) + public void test06() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listClassesWithAnnotatedFields(S5FldAnn06.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(S5Container06.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer01.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer01.java new file mode 100644 index 0000000..2c1887b --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer01.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public abstract class S5BaseContainer01 { + + @S5FldAnn04 + public String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer02.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer02.java new file mode 100644 index 0000000..fd8693c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer02.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public abstract class S5BaseContainer02 { + + @S5FldAnn05 + private String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer03.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer03.java new file mode 100644 index 0000000..1833890 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5BaseContainer03.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public abstract class S5BaseContainer03 { + + @S5FldAnn06 + protected String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container01.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container01.java new file mode 100644 index 0000000..db27aef --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container01.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container01 { + + @S5FldAnn01 + public String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container02.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container02.java new file mode 100644 index 0000000..62af3f2 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container02.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container02 { + + @S5FldAnn02 + private String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container03.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container03.java new file mode 100644 index 0000000..55cd2c5 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container03.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container03 { + + @S5FldAnn03 + protected String value01; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container04.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container04.java new file mode 100644 index 0000000..67eb341 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container04.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container04 extends S5BaseContainer01 { + + public String value02; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container05.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container05.java new file mode 100644 index 0000000..b773d17 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container05.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container05 extends S5BaseContainer02 { + + private String value02; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container06.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container06.java new file mode 100644 index 0000000..529ff21 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5Container06.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +/** + * @author indroneel + */ + +public class S5Container06 extends S5BaseContainer03 { + + protected String value02; +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn01.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn01.java new file mode 100644 index 0000000..b0495f6 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn02.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn02.java new file mode 100644 index 0000000..aacebba --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn02.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn02 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn03.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn03.java new file mode 100644 index 0000000..bf4bb27 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn03.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn03 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn04.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn04.java new file mode 100644 index 0000000..4d8bbdb --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn04.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn04 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn05.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn05.java new file mode 100644 index 0000000..b7d9947 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn05.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn05 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn06.java b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn06.java new file mode 100644 index 0000000..d61a9d4 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s5/S5FldAnn06.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S5FldAnn06 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/FilterScopeTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/FilterScopeTests.java new file mode 100644 index 0000000..400e66c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/FilterScopeTests.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.support.ClassAnnotationVisitor; +import dux.scanpath.v1.support.ClassVisitor; +import dux.scanpath.v1.support.FieldAnnotationVisitor; +import dux.scanpath.v1.support.InheritanceVisitor; +import dux.scanpath.v1.support.MethodAnnotationVisitor; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("Test for the filtering capabilities of scan scope") +public class FilterScopeTests extends AbstractTests { + + private static final Logger _L = Logger.getLogger(FilterScopeTests.class.getName()); + + @Test + @DisplayName("Classes can be explicitly included in scan scope") + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + //ss.includePackage(getClass().getPackageName()); + ss.includeClass(S6Target01.class.getName()); + ss.includeClass(S6Target02.class.getName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(S6Target01.class)); + Assertions.assertTrue(clsList.contains(S6Target02.class)); + } + + @Test + @DisplayName("Classes can be explicitly excluded in scan scope") + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClass(S6Target01.class.getName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(3, clsList.size()); + Assertions.assertTrue(clsList.contains(S6Target02.class)); + Assertions.assertTrue(clsList.contains(S6Target03.class)); + Assertions.assertTrue(clsList.contains(SXTarget01.class)); + } + + @Test + @DisplayName("Classes on the classpath are included in scan scope") + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includePackage("dux.scanpath"); + ss.excludePackage("dux.scanpath.test"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listInheritingClasses(ClassVisitor.class); + _L.info(clsList1.toString()); + + Assertions.assertTrue(clsList1.contains(InheritanceVisitor.class)); + Assertions.assertTrue(clsList1.contains(ClassAnnotationVisitor.class)); + Assertions.assertTrue(clsList1.contains(MethodAnnotationVisitor.class)); + Assertions.assertTrue(clsList1.contains(FieldAnnotationVisitor.class)); + } + + @Test + @DisplayName("Classes on the classpath can be excluded from scan scope") + @Order(4) + public void test04() { + File cwd = new File(System.getProperty("user.dir")); + ScanScope ss = new ScanScope(); + ss.excludeSystemClassPath(); + ss.addClassPath(new File(cwd, "/build/classes/java/test").getAbsolutePath()); + ss.addClassPath(new File(cwd, "/build/resources/test").getAbsolutePath()); + + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listInheritingClasses(ClassVisitor.class); + _L.info(clsList1.toString()); + + Assertions.assertTrue(clsList1.isEmpty()); + + List> clsList2 = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList2.toString()); + + Assertions.assertTrue(clsList2.contains(S6Target01.class)); + Assertions.assertTrue(clsList2.contains(S6Target02.class)); + Assertions.assertTrue(clsList2.contains(S6Target03.class)); + } + + @Test + @DisplayName("Classes are included in scan scope using regular expression") + @Order(5) + public void test05() { + ScanScope ss = new ScanScope(); + ss.includeClassesByPattern(".+01\\z"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(S6Target01.class)); + Assertions.assertTrue(clsList.contains(SXTarget01.class)); + } + + @Test + @DisplayName("Classes are excluded from scan scope using regular expression") + @Order(6) + public void test06() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClassesByPattern(".+01\\z"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(S6Target02.class)); + Assertions.assertTrue(clsList.contains(S6Target03.class)); + } + + @Test + @DisplayName("Invalid include patterns in scan scope are ignored") + @Order(7) + public void test07() { + ScanScope ss = new ScanScope(); + ss.includeClassesByPattern("[0-"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertTrue(clsList.isEmpty()); + } + + @Test + @DisplayName("Invalid exclude patterns in scan scope are ignored") + @Order(8) + public void test08() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClassesByPattern("[0-"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listAnnotatedClasses(S6ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(4, clsList.size()); + Assertions.assertTrue(clsList.contains(S6Target01.class)); + Assertions.assertTrue(clsList.contains(S6Target02.class)); + Assertions.assertTrue(clsList.contains(S6Target03.class)); + Assertions.assertTrue(clsList.contains(SXTarget01.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/S6ClsAnn01.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6ClsAnn01.java new file mode 100644 index 0000000..5a99227 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6ClsAnn01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S6ClsAnn01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target01.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target01.java new file mode 100644 index 0000000..c93e865 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target01.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +/** + * @author indroneel + */ + +@S6ClsAnn01 +public class S6Target01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target02.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target02.java new file mode 100644 index 0000000..a31b239 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target02.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +/** + * @author indroneel + */ + +@S6ClsAnn01 +public class S6Target02 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target03.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target03.java new file mode 100644 index 0000000..90ed40f --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/S6Target03.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +/** + * @author indroneel + */ + +@S6ClsAnn01 +public class S6Target03 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s6/SXTarget01.java b/src/test/java/dux/scanpath/v1/test/scenario/s6/SXTarget01.java new file mode 100644 index 0000000..b05399a --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s6/SXTarget01.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s6; + +/** + * @author indroneel + */ + +@S6ClsAnn01 +public class SXTarget01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s7/DuplicateScopeTests.java b/src/test/java/dux/scanpath/v1/test/scenario/s7/DuplicateScopeTests.java new file mode 100644 index 0000000..5ae64a7 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s7/DuplicateScopeTests.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s7; + +import dux.scanpath.v1.ClasspathScanner; +import dux.scanpath.v1.ScanScope; +import dux.scanpath.v1.test.setup.AbstractTests; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@DisplayName("Tests that scan scope can be duplicated correctly") +public class DuplicateScopeTests extends AbstractTests { + + private static final Logger _L = Logger.getLogger(DuplicateScopeTests.class.getName()); + + @Test + @DisplayName("Packages included in duplicate scan scope") + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ScanScope dss = ss.duplicate(); + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(dss); + + List> clsList = scanner.listAnnotatedClasses(S7ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(3, clsList.size()); + Assertions.assertTrue(clsList.contains(S7Target01.class)); + Assertions.assertTrue(clsList.contains(S7Target02.class)); + Assertions.assertTrue(clsList.contains(S7Target03.class)); + } + + @Test + @DisplayName("Classes included in duplicate scan scope") + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includeClass(S7Target01.class.getName()); + ss.includeClass(S7Target02.class.getName()); + + ScanScope dss = ss.duplicate(); + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(dss); + + List> clsList = scanner.listAnnotatedClasses(S7ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(S7Target01.class)); + Assertions.assertTrue(clsList.contains(S7Target02.class)); + } + + @Test + @DisplayName("Classes are included in duplicate scan scope using regular expression") + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includeClassesByPattern(".+01\\z"); + + ScanScope dss = ss.duplicate(); + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(dss); + + List> clsList = scanner.listAnnotatedClasses(S7ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(1, clsList.size()); + Assertions.assertTrue(clsList.contains(S7Target01.class)); + } + + @Test + @DisplayName("Classes are excluded from duplicate scan scope using regular expression") + @Order(4) + public void test04() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClassesByPattern(".+01\\z"); + + ScanScope dss = ss.duplicate(); + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(dss); + + List> clsList = scanner.listAnnotatedClasses(S7ClsAnn01.class); + _L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(S7Target02.class)); + Assertions.assertTrue(clsList.contains(S7Target03.class)); + } +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s7/S7ClsAnn01.java b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7ClsAnn01.java new file mode 100644 index 0000000..618eb80 --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7ClsAnn01.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s7; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author indroneel + */ + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface S7ClsAnn01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target01.java b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target01.java new file mode 100644 index 0000000..27ed17d --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target01.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s7; + +/** + * @author indroneel + */ + +@S7ClsAnn01 +public class S7Target01 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target02.java b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target02.java new file mode 100644 index 0000000..155efab --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target02.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s7; + +/** + * @author indroneel + */ + +@S7ClsAnn01 +public class S7Target02 { +} diff --git a/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target03.java b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target03.java new file mode 100644 index 0000000..f96128c --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/scenario/s7/S7Target03.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.scenario.s7; + +/** + * @author indroneel + */ + +@S7ClsAnn01 +public class S7Target03 { +} diff --git a/src/test/java/dux/scanpath/v1/test/setup/AbstractTests.java b/src/test/java/dux/scanpath/v1/test/setup/AbstractTests.java new file mode 100644 index 0000000..240840a --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/setup/AbstractTests.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.setup; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestMethodOrder; + +import java.util.Locale; +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public abstract class AbstractTests { + + private static final Logger L = Logger.getLogger(AbstractTests.class.getName()); + + @BeforeEach + public void beforeEach(TestInfo info) { + String clsName = "UnknownClass"; + String mthdName = "unknownMethod"; + if(info.getTestClass().isPresent()) { + clsName = info.getTestClass().get().getSimpleName(); + } + if(info.getTestMethod().isPresent()) { + mthdName = info.getTestMethod().get().getName(); + } + + L.info("%s.%s(): %s".formatted( + clsName, mthdName, info.getDisplayName().toUpperCase(Locale.getDefault()))); + } + + protected final void logMultiLines(Logger logger, String logout) { + String[] lines = logout.split("\n"); + for(String line : lines) { + logger.info(line); + } + } +} diff --git a/src/test/java/dux/scanpath/v1/test/setup/LauncherSessionHandler.java b/src/test/java/dux/scanpath/v1/test/setup/LauncherSessionHandler.java new file mode 100644 index 0000000..104ec6a --- /dev/null +++ b/src/test/java/dux/scanpath/v1/test/setup/LauncherSessionHandler.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) DuxTechnica + * + * Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not + * use this file except in compliance with the License. You may obtain a copy of the License by + * contacting: + * + * Dux Technica, contact@duxtechnica.com + * + * This file 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 dux.scanpath.v1.test.setup; + +import org.junit.platform.launcher.LauncherSession; +import org.junit.platform.launcher.LauncherSessionListener; +import org.slf4j.bridge.SLF4JBridgeHandler; + +import java.util.logging.Logger; + +/** + * @author indroneel + */ + +public class LauncherSessionHandler implements LauncherSessionListener { + + private static final Logger L = Logger.getLogger(LauncherSessionHandler.class.getName()); + + @Override + public void launcherSessionOpened(LauncherSession session) { + SLF4JBridgeHandler.removeHandlersForRootLogger(); + SLF4JBridgeHandler.install(); + + L.info("launcher session opened"); + } + + @Override + public void launcherSessionClosed(LauncherSession session) { + L.info("launcher session closed"); + } +} diff --git a/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener b/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener new file mode 100644 index 0000000..4bc7c58 --- /dev/null +++ b/src/test/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener @@ -0,0 +1,15 @@ +# +# Copyright (c) DuxTechnica +# +# Licensed under the DuxTechnica Limited Use Source Code License Agreement (DT-LUSCL); you may not +# use this file except in compliance with the License. You may obtain a copy of the License by +# contacting: +# +# Dux Technica, contact@duxtechnica.com +# +# This file 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. +# + +dux.scanpath.v1.test.setup.LauncherSessionHandler \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml new file mode 100644 index 0000000..94d2b37 --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,52 @@ + + + + + + + + + true + + + + + + + + %4line: %msg%n + + + + + + + + %n%msg%n + + + + + + + + + + + + + + + \ No newline at end of file