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/build.gradle b/build.gradle new file mode 100644 index 0000000..3ba823b --- /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 = "v2-SNAPSHOT" + +repositories { + mavenLocal() + mavenCentral() + maven { + url "https://maven.indroneel.co/repo/snapshots" + } +} + +dependencies { + implementation "dux.scanpath:dux.scanpath:v2-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-v2/target/classes") + def sourceDir = file("${projectDir}/../scanpath-v2/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..f93748a --- /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-v2-tests" diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/Base01.java new file mode 100644 index 0000000..3a69292 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/Base01.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.v2.test.scenario.s1; + +/** + * Test class for scan path tests. This is the absolute base class in the hierarchy. It is also + * abstract. + * + * @author indroneel + */ + +public abstract class Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/Base02.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/Base02.java new file mode 100644 index 0000000..9f322e2 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/Base02.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.v2.test.scenario.s1; + +/** + * Test class for scan path tests. This class extends BaseClass01, and is a base class in itself. + * It is also abstract. + * + * @author indroneel + */ + +public abstract class Base02 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived01.java new file mode 100644 index 0000000..bca93d5 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived01.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.v2.test.scenario.s1; + +/** + * Test class for scan path tests. This class extends BaseClass01. + * + * @author indroneel + */ + +public class Derived01 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived02.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived02.java new file mode 100644 index 0000000..331579f --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/Derived02.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.v2.test.scenario.s1; + +/** + * Test class for scan path tests. This class extends BaseClass02. + * + * @author indroneel + */ + +public class Derived02 extends Base02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/HierarchyTests01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/HierarchyTests01.java new file mode 100644 index 0000000..a812125 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/HierarchyTests01.java @@ -0,0 +1,66 @@ +/* + * 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.v2.test.scenario.s1; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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 HierarchyTests01 extends AbstractTests { + + private static final Logger L = Logger.getLogger(HierarchyTests01.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.listInheritingClasses(Base01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Base02.class)); + Assertions.assertTrue(clsList.contains(Derived01.class)); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } + + @Test + @Order(1) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base02.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Derived02.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1/Sample01.java new file mode 100644 index 0000000..778334e --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1/Sample01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s1; + +public class Sample01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base01.java new file mode 100644 index 0000000..1cfd615 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base01.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.v2.test.scenario.s1_dup; + +/** + * Test class for scan path tests. This is the absolute base class in the hierarchy. It is also + * abstract. + * + * @author indroneel + */ + +public abstract class Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base02.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base02.java new file mode 100644 index 0000000..f1536d6 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Base02.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.v2.test.scenario.s1_dup; + +/** + * Test class for scan path tests. This class extends BaseClass01, and is a base class in itself. + * It is also abstract. + * + * @author indroneel + */ + +public abstract class Base02 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived01.java new file mode 100644 index 0000000..c9cc3a3 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived01.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.v2.test.scenario.s1_dup; + +/** + * Test class for scan path tests. This class extends Base01. + * + * @author indroneel + */ + +public class Derived01 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived02.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived02.java new file mode 100644 index 0000000..6137169 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Derived02.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.v2.test.scenario.s1_dup; + +/** + * Test class for scan path tests. This class extends Base02. + * + * @author indroneel + */ + +public class Derived02 extends Base02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Sample01.java new file mode 100644 index 0000000..db3d8a7 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/Sample01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s1_dup; + +public class Sample01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/TestCases.java new file mode 100644 index 0000000..c076532 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s1_dup/TestCases.java @@ -0,0 +1,66 @@ +/* + * 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.v2.test.scenario.s1_dup; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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 TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss.duplicate()); // use a duplicate scanscope + + List> clsList = scanner.listInheritingClasses(Base01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Base02.class)); + Assertions.assertTrue(clsList.contains(Derived01.class)); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } + + @Test + @Order(1) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss.duplicate()); // use a duplicate scanscope + + List> clsList = scanner.listInheritingClasses(Base02.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Derived02.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Base01.java new file mode 100644 index 0000000..8af50c1 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Base01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public abstract class Base01 implements Iface02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Base02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Base02.java new file mode 100644 index 0000000..65f09c8 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Base02.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public abstract class Base02 implements Iface03, Iface04 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived01.java new file mode 100644 index 0000000..c9774bd --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public class Derived01 implements Iface01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived02.java new file mode 100644 index 0000000..d556a40 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived02.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public class Derived02 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived03.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived03.java new file mode 100644 index 0000000..c694b97 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Derived03.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public class Derived03 extends Base02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/HierarchyTests02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/HierarchyTests02.java new file mode 100644 index 0000000..b890b65 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/HierarchyTests02.java @@ -0,0 +1,90 @@ +/* + * 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.v2.test.scenario.s2; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test class for scan path tests. This class tests the ability of the scanner to find classes that + * inherit from a given interface or class. + * + * @author indroneel + */ + +public class HierarchyTests02 extends AbstractTests { + + private static final Logger L = Logger.getLogger(HierarchyTests02.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.listInheritingClasses(Iface01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Derived01.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.listInheritingClasses(Iface02.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Base01.class)); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } + + @Test + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listInheritingClasses(Iface03.class); + L.info(clsList1.toString()); + + Assertions.assertTrue(clsList1.contains(Base02.class)); + Assertions.assertTrue(clsList1.contains(Derived03.class)); + + List> clsList2 = scanner.listInheritingClasses(Iface04.class); + L.info(clsList2.toString()); + + Assertions.assertTrue(clsList2.contains(Base02.class)); + Assertions.assertTrue(clsList2.contains(Derived03.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface01.java new file mode 100644 index 0000000..a420d04 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public interface Iface01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface02.java new file mode 100644 index 0000000..7736bcb --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface02.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public interface Iface02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface03.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface03.java new file mode 100644 index 0000000..260e365 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface03.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public interface Iface03 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface04.java b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface04.java new file mode 100644 index 0000000..589c018 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2/Iface04.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2; + +public interface Iface04 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Iface01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Iface01.java new file mode 100644 index 0000000..c5f169c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Iface01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_1; + +public interface Iface01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample01.java new file mode 100644 index 0000000..8be31d8 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_1; + +public abstract class Sample01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample02.java new file mode 100644 index 0000000..77fe30d --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/Sample02.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_1; + +public class Sample02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_1/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/TestCases.java new file mode 100644 index 0000000..c773459 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_1/TestCases.java @@ -0,0 +1,66 @@ +/* + * 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.v2.test.scenario.s2_1; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test cases for scenario s2_1. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.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.listInheritingClasses(Iface01.class); + L.info(clsList.toString()); + + Assertions.assertEquals(0, clsList.size()); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Sample01.class); + L.info(clsList.toString()); + + Assertions.assertEquals(0, clsList.size()); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface01.java new file mode 100644 index 0000000..3774a89 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_2; + +public interface Iface01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface02.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface02.java new file mode 100644 index 0000000..2b92b69 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Iface02.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_2; + +public interface Iface02 extends Iface01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Sample01.java new file mode 100644 index 0000000..4da832e --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/Sample01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s2_2; + +public class Sample01 implements Iface02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s2_2/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/TestCases.java new file mode 100644 index 0000000..afdcb5b --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s2_2/TestCases.java @@ -0,0 +1,52 @@ +/* + * 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.v2.test.scenario.s2_2; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test cases for scenario s2_2. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.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.listInheritingClasses(Iface01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Iface02.class)); + Assertions.assertTrue(clsList.contains(Sample01.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation01.java new file mode 100644 index 0000000..29276f6 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation01.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.v2.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation02.java new file mode 100644 index 0000000..3810f86 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation02.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.v2.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation03.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation03.java new file mode 100644 index 0000000..accf678 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation03.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.v2.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation03 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation04.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation04.java new file mode 100644 index 0000000..1eb35b2 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Annotation04.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.v2.test.scenario.s3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation04 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Base01.java new file mode 100644 index 0000000..3893914 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Base01.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s3; + +@Annotation03 +public abstract class Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/ClassAnnotationTests.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/ClassAnnotationTests.java new file mode 100644 index 0000000..f695603 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/ClassAnnotationTests.java @@ -0,0 +1,97 @@ +/* + * 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.v2.test.scenario.s3; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +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(Annotation01.class); + L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample01.class)); + Assertions.assertTrue(clsList.contains(Sample02.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(Annotation02.class); + L.info(clsList.toString()); + + Assertions.assertEquals(1, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample02.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(Annotation03.class); + L.info(clsList.toString()); + + Assertions.assertEquals(3, clsList.size()); + Assertions.assertTrue(clsList.contains(Base01.class)); + Assertions.assertTrue(clsList.contains(Derived01.class)); + Assertions.assertTrue(clsList.contains(Derived02.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(Annotation04.class); + L.info(clsList.toString()); + + Assertions.assertEquals(1, clsList.size()); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived01.java new file mode 100644 index 0000000..6080f33 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived01.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s3; + +public class Derived01 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived02.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived02.java new file mode 100644 index 0000000..305cf72 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Derived02.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s3; + +@Annotation04 +public class Derived02 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample01.java new file mode 100644 index 0000000..3b6654a --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample01.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s3; + +@Annotation01 +public class Sample01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample02.java b/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample02.java new file mode 100644 index 0000000..f018917 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3/Sample02.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s3; + +@Annotation01 +@Annotation02 +public class Sample02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation01.java new file mode 100644 index 0000000..3f29d62 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation01.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.v2.test.scenario.s3_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation02.java new file mode 100644 index 0000000..c3be042 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Annotation02.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.v2.test.scenario.s3_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Sample01.java new file mode 100644 index 0000000..a32664c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/Sample01.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s3_1; + +@Annotation01 +public class Sample01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s3_1/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/TestCases.java new file mode 100644 index 0000000..bd3576d --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s3_1/TestCases.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.v2.test.scenario.s3_1; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test cases for scenario s3_1. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listAnnotatedClasses(Annotation01.class); + L.info(clsList1.toString()); + + List> clsList2 = scanner.listAnnotatedClasses(Annotation02.class); + L.info(clsList2.toString()); + + Assertions.assertEquals(1, clsList1.size()); + Assertions.assertEquals(0, clsList2.size()); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/Base.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/Base.java new file mode 100644 index 0000000..7385a63 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/Base.java @@ -0,0 +1,18 @@ +/* + * 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.v2.test.scenario.s4; + +public abstract class Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/TestCases.java new file mode 100644 index 0000000..6361caf --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/TestCases.java @@ -0,0 +1,163 @@ +/* + * 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.v2.test.scenario.s4; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.test.scenario.s4.pkg01.Sample011; +import dux.scanpath.v2.test.scenario.s4.pkg01.Sample012; +import dux.scanpath.v2.test.scenario.s4.pkg02.Sample02; +import dux.scanpath.v2.test.scenario.s4.pkg03.Sample031; +import dux.scanpath.v2.test.scenario.s4.pkg03.Sample032; +import dux.scanpath.v2.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; + +/** + * Test cases for the ClasspathScanner with various inclusion and exclusion scenarios. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludePackage(getClass().getPackageName() + ".pkg03"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(3, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample011.class)); + Assertions.assertTrue(clsList.contains(Sample012.class)); + Assertions.assertTrue(clsList.contains(Sample02.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClass(Sample02.class.getName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(4, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample011.class)); + Assertions.assertTrue(clsList.contains(Sample031.class)); + } + + @Test + @Order(3) + public void test03() { + ScanScope ss = new ScanScope(); + ss.includeClass(Sample012.class.getName()); + ss.includeClass(Sample032.class.getName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample012.class)); + Assertions.assertTrue(clsList.contains(Sample032.class)); + } + + @Test + @Order(4) + public void test04() { + ScanScope ss = new ScanScope(); + ss.includeClassesByPattern(".+\\.Sample01."); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(2, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample011.class)); + Assertions.assertTrue(clsList.contains(Sample012.class)); + } + + @Test + @Order(5) + public void test05() { + ScanScope ss = new ScanScope(); + ss.includeClassesByPattern("(*"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(0, clsList.size()); + } + + @Test + @Order(6) + public void test06() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClassesByPattern(".+\\.Sample01."); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(3, clsList.size()); + Assertions.assertTrue(clsList.contains(Sample02.class)); + Assertions.assertTrue(clsList.contains(Sample031.class)); + Assertions.assertTrue(clsList.contains(Sample032.class)); + } + + @Test + @Order(7) + public void test07() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + ss.excludeClassesByPattern("(*"); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base.class); + L.info(clsList.toString()); + + Assertions.assertEquals(5, clsList.size()); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample011.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample011.java new file mode 100644 index 0000000..201f605 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample011.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s4.pkg01; + +import dux.scanpath.v2.test.scenario.s4.Base; + +public class Sample011 extends Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample012.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample012.java new file mode 100644 index 0000000..36a976e --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg01/Sample012.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s4.pkg01; + +import dux.scanpath.v2.test.scenario.s4.Base; + +public class Sample012 extends Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg02/Sample02.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg02/Sample02.java new file mode 100644 index 0000000..f266c13 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg02/Sample02.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s4.pkg02; + +import dux.scanpath.v2.test.scenario.s4.Base; + +public class Sample02 extends Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample031.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample031.java new file mode 100644 index 0000000..db41d74 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample031.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s4.pkg03; + +import dux.scanpath.v2.test.scenario.s4.Base; + +public class Sample031 extends Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample032.java b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample032.java new file mode 100644 index 0000000..9a0d9d7 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s4/pkg03/Sample032.java @@ -0,0 +1,20 @@ +/* + * 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.v2.test.scenario.s4.pkg03; + +import dux.scanpath.v2.test.scenario.s4.Base; + +public class Sample032 extends Base { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation01.java new file mode 100644 index 0000000..ee5a785 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation01.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.v2.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation02.java new file mode 100644 index 0000000..1b8ea41 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation02.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.v2.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation03.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation03.java new file mode 100644 index 0000000..1edc801 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Annotation03.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.v2.test.scenario.s5; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation03 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Base01.java new file mode 100644 index 0000000..f8be279 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Base01.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s5; + +public abstract class Base01 { + + @Annotation02 + private String fld01; +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/FieldAnnotationTests.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/FieldAnnotationTests.java new file mode 100644 index 0000000..524ed1c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/FieldAnnotationTests.java @@ -0,0 +1,100 @@ +/* + * 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.v2.test.scenario.s5; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Tests for scanning classes with annotated fields. + * + * @author indroneel + */ + +public class FieldAnnotationTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(FieldAnnotationTests.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.listClassesWithAnnotatedFields(Annotation01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Sample01.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.listClassesWithAnnotatedFields(Annotation02.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Sample02.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.listClassesWithAnnotatedFields(Annotation03.class); + L.info(clsList.toString()); + + Assertions.assertFalse(clsList.contains(Sample03.class)); + Assertions.assertTrue(clsList.contains(Sample04.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(Annotation04.class); + L.info(clsList.toString()); + + Assertions.assertEquals(1, clsList.size()); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } + */ +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample01.java new file mode 100644 index 0000000..0707ba9 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample01.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s5; + +public class Sample01 { + + @Annotation01 + private String fld01; +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample02.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample02.java new file mode 100644 index 0000000..3ac8100 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample02.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s5; + +public class Sample02 extends Base01 { + +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample03.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample03.java new file mode 100644 index 0000000..ab23d03 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample03.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s5; + +public class Sample03 { + + @Annotation03 + private static String fld01; +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample04.java b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample04.java new file mode 100644 index 0000000..18bfbc0 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5/Sample04.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s5; + +public class Sample04 { + + @Annotation03 + private String fld01; +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation01.java new file mode 100644 index 0000000..a440d63 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation01.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.v2.test.scenario.s5_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation02.java new file mode 100644 index 0000000..44af62f --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Annotation02.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.v2.test.scenario.s5_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Sample01.java new file mode 100644 index 0000000..6d1cf21 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/Sample01.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s5_1; + +public class Sample01 { + + @Annotation01 + private String fld01; +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s5_1/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/TestCases.java new file mode 100644 index 0000000..6561029 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s5_1/TestCases.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.v2.test.scenario.s5_1; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test cases for scenario s5_1. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listClassesWithAnnotatedFields(Annotation01.class); + L.info(clsList1.toString()); + + List> clsList2 = scanner.listClassesWithAnnotatedFields(Annotation02.class); + L.info(clsList2.toString()); + + Assertions.assertEquals(1, clsList1.size()); + Assertions.assertEquals(0, clsList2.size()); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation01.java new file mode 100644 index 0000000..81c41ed --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation01.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.v2.test.scenario.s6; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation02.java new file mode 100644 index 0000000..980c16b --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation02.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.v2.test.scenario.s6; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation03.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation03.java new file mode 100644 index 0000000..720b23c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Annotation03.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.v2.test.scenario.s6; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation03 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Base01.java new file mode 100644 index 0000000..eed46cc --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Base01.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.v2.test.scenario.s6; + +public abstract class Base01 { + + @Annotation02 + private String mthd01() { + return "Hello, World!"; + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/MethodAnnotationTests.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/MethodAnnotationTests.java new file mode 100644 index 0000000..920af36 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/MethodAnnotationTests.java @@ -0,0 +1,101 @@ +/* + * 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.v2.test.scenario.s6; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Tests for scanning classes with annotated methods. + * + * @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(Annotation01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Sample01.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(Annotation02.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Sample02.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(Annotation03.class); + L.info(clsList.toString()); + + Assertions.assertFalse(clsList.contains(Sample03.class)); + Assertions.assertFalse(clsList.contains(Sample04.class)); + Assertions.assertTrue(clsList.contains(Sample05.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(Annotation04.class); + L.info(clsList.toString()); + + Assertions.assertEquals(1, clsList.size()); + Assertions.assertTrue(clsList.contains(Derived02.class)); + } + */ +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample01.java new file mode 100644 index 0000000..9d7dd85 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample01.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.v2.test.scenario.s6; + +public class Sample01 { + + @Annotation01 + private String mthd01() { + return "Hello, World!"; + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample02.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample02.java new file mode 100644 index 0000000..a70e6ab --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample02.java @@ -0,0 +1,19 @@ +/* + * 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.v2.test.scenario.s6; + +public class Sample02 extends Base01 { + +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample03.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample03.java new file mode 100644 index 0000000..2d24e12 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample03.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.v2.test.scenario.s6; + +public class Sample03 { + + @Annotation03 + public static String mthd01() { + return "Hello, World!"; + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample04.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample04.java new file mode 100644 index 0000000..cd3252c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample04.java @@ -0,0 +1,21 @@ +/* + * 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.v2.test.scenario.s6; + +public abstract class Sample04 { + + @Annotation03 + public abstract String mthd01(); +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample05.java b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample05.java new file mode 100644 index 0000000..8933bc1 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6/Sample05.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.v2.test.scenario.s6; + +public class Sample05 { + + @Annotation03 + public String mthd01() { + return "Hello, World!"; + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation01.java b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation01.java new file mode 100644 index 0000000..2683b0e --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation01.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.v2.test.scenario.s6_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation02.java b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation02.java new file mode 100644 index 0000000..b39a80e --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Annotation02.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.v2.test.scenario.s6_1; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Annotation02 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Sample01.java b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Sample01.java new file mode 100644 index 0000000..6f8d71c --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/Sample01.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.v2.test.scenario.s6_1; + +public class Sample01 { + + @Annotation01 + private String mthd01() { + return "Hello, World!"; + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s6_1/TestCases.java b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/TestCases.java new file mode 100644 index 0000000..e3c4f17 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s6_1/TestCases.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.v2.test.scenario.s6_1; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +/** + * Test cases for scenario s6_1. + * + * @author indroneel + */ + +public class TestCases extends AbstractTests { + + private static final Logger L = Logger.getLogger(TestCases.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList1 = scanner.listClassesWithAnnotatedMethods(Annotation01.class); + L.info(clsList1.toString()); + + List> clsList2 = scanner.listClassesWithAnnotatedMethods(Annotation02.class); + L.info(clsList2.toString()); + + Assertions.assertEquals(1, clsList1.size()); + Assertions.assertEquals(0, clsList2.size()); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s7/BadPathTests.java b/src/test/java/dux/scanpath/v2/test/scenario/s7/BadPathTests.java new file mode 100644 index 0000000..3ce79c5 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s7/BadPathTests.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.v2.test.scenario.s7; + +import dux.scanpath.v2.ClasspathScanner; +import dux.scanpath.v2.ScanScope; +import dux.scanpath.v2.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; + +public class BadPathTests extends AbstractTests { + + private static final Logger L = Logger.getLogger(BadPathTests.class.getName()); + + @Test + @Order(1) + public void test01() { + ScanScope ss = new ScanScope(); + ss.addClassPath("test-harness-1/bad.jar"); // jar file not found + ss.addClassPath("test-harness/bad.jar"); // error opening zip file + ss.addClassPath("not-a-real-path"); // path not found + ss.addClassPath("test-harness-1/bad.zip"); // zip file not found + ss.addClassPath("test-harness/bad.zip"); // error opening zip file + ss.includePackage(getClass().getPackageName()); + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Derived01.class)); + } + + @Test + @Order(2) + public void test02() { + ScanScope ss = new ScanScope(); + ss.addClassPath("test-harness/bad02.zip"); // error reading class file + ss.includePackage(getClass().getPackageName()); + ss.includePackage("mypkg"); //bad classes are present here + + ClasspathScanner scanner = new ClasspathScanner(); + scanner.load(ss); + + List> clsList = scanner.listInheritingClasses(Base01.class); + L.info(clsList.toString()); + + Assertions.assertTrue(clsList.contains(Derived01.class)); + } +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s7/Base01.java b/src/test/java/dux/scanpath/v2/test/scenario/s7/Base01.java new file mode 100644 index 0000000..178b9e2 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s7/Base01.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.v2.test.scenario.s7; + +/** + * Test class for scan path tests. This is the absolute base class in the hierarchy. It is also + * abstract. + * + * @author indroneel + */ + +public abstract class Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/scenario/s7/Derived01.java b/src/test/java/dux/scanpath/v2/test/scenario/s7/Derived01.java new file mode 100644 index 0000000..e0707ad --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/scenario/s7/Derived01.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.v2.test.scenario.s7; + +/** + * Test class for scan path tests. This class extends Base01. + * + * @author indroneel + */ + +public class Derived01 extends Base01 { +} diff --git a/src/test/java/dux/scanpath/v2/test/setup/AbstractTests.java b/src/test/java/dux/scanpath/v2/test/setup/AbstractTests.java new file mode 100644 index 0000000..c2605dc --- /dev/null +++ b/src/test/java/dux/scanpath/v2/test/setup/AbstractTests.java @@ -0,0 +1,57 @@ +/* + * 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.v2.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; + +/** + * Base class for all test suites. Provides common setup and utilities for tests. + * + * @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/v2/test/setup/LauncherSessionHandler.java b/src/test/java/dux/scanpath/v2/test/setup/LauncherSessionHandler.java new file mode 100644 index 0000000..f184f67 --- /dev/null +++ b/src/test/java/dux/scanpath/v2/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.v2.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..f12c3a7 --- /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.v2.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..49a601b --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,63 @@ + + + + + + + + + true + + + + + + + + %logger{0}.%method [%4line]: %msg%n + + + + + + + + [%4line]: %msg%n + + + + + + + + %n%msg%n + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test-harness/bad.zip b/test-harness/bad.zip new file mode 100644 index 0000000..8da869a --- /dev/null +++ b/test-harness/bad.zip @@ -0,0 +1 @@ +This is a bad jar file for the purpose of testing. diff --git a/test-harness/bad02.zip b/test-harness/bad02.zip new file mode 100644 index 0000000..97439ce Binary files /dev/null and b/test-harness/bad02.zip differ