|
6 | 6 | import com.tngtech.archunit.core.importer.ClassFileImporter;
|
7 | 7 | import com.tngtech.archunit.core.importer.ImportOption;
|
8 | 8 | import com.tngtech.archunit.core.importer.ImportOptions;
|
| 9 | +import com.tngtech.archunit.lang.ArchRule; |
9 | 10 | import com.tngtech.archunit.lang.syntax.elements.GivenClassesConjunction;
|
10 | 11 |
|
11 | 12 | import nl.jqno.equalsverifier.EqualsVerifier;
|
12 | 13 |
|
| 14 | +import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage; |
| 15 | +import static com.tngtech.archunit.lang.conditions.ArchConditions.dependOnClassesThat; |
| 16 | +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; |
13 | 17 | import static com.tngtech.archunit.library.GeneralCodingRules.*;
|
14 | 18 | import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
15 | 19 | import static org.junit.Assert.assertTrue;
|
@@ -45,6 +49,14 @@ public void noClassesShouldUseJavaUtilLogging() {
|
45 | 49 | NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING.check(twilioClasses);
|
46 | 50 | }
|
47 | 51 |
|
| 52 | + @Test |
| 53 | + public void noClassesShouldUseLog4j() { |
| 54 | + // disallow Log4j version 1.x |
| 55 | + disallowPackage("org.apache.log4j").check(twilioClasses); |
| 56 | + // disallow Log4j version 2.x |
| 57 | + disallowPackage("org.apache.logging.log4j").check(twilioClasses); |
| 58 | + } |
| 59 | + |
48 | 60 | @Test
|
49 | 61 | public void noClassesShouldUseJodaTime() {
|
50 | 62 | NO_CLASSES_SHOULD_USE_JODATIME.check(twilioClasses);
|
@@ -73,4 +85,9 @@ private static List<Class> getResourceClasses(final JavaClasses jclasses) {
|
73 | 85 | }
|
74 | 86 | return Collections.unmodifiableList(builder);
|
75 | 87 | }
|
| 88 | + |
| 89 | + private static ArchRule disallowPackage(final String packageIdentifier) { |
| 90 | + return noClasses() |
| 91 | + .should(dependOnClassesThat(resideInAPackage(packageIdentifier))); |
| 92 | + } |
76 | 93 | }
|
0 commit comments