first commit with all tests passed

This commit is contained in:
2026-09-20 18:37:08 +05:30
parent d8e8a64f20
commit 4757248928
91 changed files with 2837 additions and 0 deletions
+9
View File
@@ -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
+62
View File
@@ -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
+77
View File
@@ -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, [email protected]
*
* 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)
))
}
}
+15
View File
@@ -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, [email protected]
*
* 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"
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> clsList = scanner.listInheritingClasses(Base02.class);
L.info(clsList.toString());
Assertions.assertTrue(clsList.contains(Derived02.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> clsList = scanner.listInheritingClasses(Base02.class);
L.info(clsList.toString());
Assertions.assertTrue(clsList.contains(Derived02.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> 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<Class<?>> clsList1 = scanner.listInheritingClasses(Iface03.class);
L.info(clsList1.toString());
Assertions.assertTrue(clsList1.contains(Base02.class));
Assertions.assertTrue(clsList1.contains(Derived03.class));
List<Class<?>> clsList2 = scanner.listInheritingClasses(Iface04.class);
L.info(clsList2.toString());
Assertions.assertTrue(clsList2.contains(Base02.class));
Assertions.assertTrue(clsList2.contains(Derived03.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> clsList = scanner.listInheritingClasses(Sample01.class);
L.info(clsList.toString());
Assertions.assertEquals(0, clsList.size());
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> clsList = scanner.listInheritingClasses(Iface01.class);
L.info(clsList.toString());
Assertions.assertTrue(clsList.contains(Iface02.class));
Assertions.assertTrue(clsList.contains(Sample01.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> clsList = scanner.listAnnotatedClasses(Annotation04.class);
L.info(clsList.toString());
Assertions.assertEquals(1, clsList.size());
Assertions.assertTrue(clsList.contains(Derived02.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> clsList1 = scanner.listAnnotatedClasses(Annotation01.class);
L.info(clsList1.toString());
List<Class<?>> clsList2 = scanner.listAnnotatedClasses(Annotation02.class);
L.info(clsList2.toString());
Assertions.assertEquals(1, clsList1.size());
Assertions.assertEquals(0, clsList2.size());
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> clsList = scanner.listInheritingClasses(Base.class);
L.info(clsList.toString());
Assertions.assertEquals(5, clsList.size());
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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;
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> clsList = scanner.listAnnotatedClasses(Annotation04.class);
L.info(clsList.toString());
Assertions.assertEquals(1, clsList.size());
Assertions.assertTrue(clsList.contains(Derived02.class));
}
*/
}
@@ -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, [email protected]
*
* 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;
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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;
}
@@ -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, [email protected]
*
* 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;
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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;
}
@@ -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, [email protected]
*
* 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<Class<?>> clsList1 = scanner.listClassesWithAnnotatedFields(Annotation01.class);
L.info(clsList1.toString());
List<Class<?>> clsList2 = scanner.listClassesWithAnnotatedFields(Annotation02.class);
L.info(clsList2.toString());
Assertions.assertEquals(1, clsList1.size());
Assertions.assertEquals(0, clsList2.size());
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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!";
}
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> 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<Class<?>> 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<Class<?>> clsList = scanner.listAnnotatedClasses(Annotation04.class);
L.info(clsList.toString());
Assertions.assertEquals(1, clsList.size());
Assertions.assertTrue(clsList.contains(Derived02.class));
}
*/
}
@@ -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, [email protected]
*
* 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!";
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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!";
}
}
@@ -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, [email protected]
*
* 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();
}
@@ -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, [email protected]
*
* 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!";
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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!";
}
}
@@ -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, [email protected]
*
* 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<Class<?>> clsList1 = scanner.listClassesWithAnnotatedMethods(Annotation01.class);
L.info(clsList1.toString());
List<Class<?>> clsList2 = scanner.listClassesWithAnnotatedMethods(Annotation02.class);
L.info(clsList2.toString());
Assertions.assertEquals(1, clsList1.size());
Assertions.assertEquals(0, clsList2.size());
}
}
@@ -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, [email protected]
*
* 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<Class<?>> 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<Class<?>> clsList = scanner.listInheritingClasses(Base01.class);
L.info(clsList.toString());
Assertions.assertTrue(clsList.contains(Derived01.class));
}
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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 {
}
@@ -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, [email protected]
*
* 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);
}
}
}
@@ -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, [email protected]
*
* 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");
}
}
@@ -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, [email protected]
#
# 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
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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, [email protected]
~
~ 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.
-->
<!DOCTYPE configuration>
<configuration debug="false">
<import class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<contextListener class="LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%logger{0}.%method [%4line]: %msg%n
</pattern>
</encoder>
</appender>
<appender name="STDOUT_TEST" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
[%4line]: %msg%n
</pattern>
</encoder>
</appender>
<appender name="STDOUT_MIN" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%n%msg%n
</pattern>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>
<logger name="dux.scanpath.v2.test.setup" level="TRACE" additivity="false">
<appender-ref ref="STDOUT_MIN"/>
</logger>
<logger name="dux.scanpath.v2.test" level="TRACE" additivity="false">
<appender-ref ref="STDOUT_TEST"/>
</logger>
<logger name="dux.scanpath.v2" level="TRACE" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
</configuration>
+1
View File
@@ -0,0 +1 @@
This is a bad jar file for the purpose of testing.
Binary file not shown.