use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassFileImporterSlowTest method imports_jars.
@Test
public void imports_jars() throws Exception {
JavaClasses classes = new ClassFileImporter().importJar(jarFileOf(Rule.class));
assertThatTypes(classes).contain(Rule.class);
assertThatTypes(classes).doNotContain(Object.class, ImmutableList.class);
classes = new ClassFileImporter().importJars(jarFileOf(Rule.class), jarFileOf(ImmutableList.class));
assertThatTypes(classes).contain(Rule.class, ImmutableList.class);
assertThatTypes(classes).doNotContain(Object.class);
classes = new ClassFileImporter().importJars(ImmutableList.of(jarFileOf(Rule.class), jarFileOf(ImmutableList.class)));
assertThatTypes(classes).contain(Rule.class, ImmutableList.class);
assertThatTypes(classes).doNotContain(Object.class);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassFileImporterSlowTest method imports_packages.
@Test
public void imports_packages() {
JavaClasses classes = new ClassFileImporter().importPackages(getClass().getPackage().getName(), Rule.class.getPackage().getName());
assertThatTypes(classes).contain(ImmutableSet.of(getClass(), Rule.class));
classes = new ClassFileImporter().importPackages(ImmutableSet.of(getClass().getPackage().getName(), Rule.class.getPackage().getName()));
assertThatTypes(classes).contain(ImmutableSet.of(getClass(), Rule.class));
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassFileImporterSlowTest method creates_JavaPackages.
@Test
public void creates_JavaPackages() {
JavaClasses javaClasses = importJavaBase();
JavaPackage defaultPackage = javaClasses.getDefaultPackage();
assertThat(defaultPackage.containsPackage("java")).as("Created default package contains 'java'").isTrue();
JavaPackage javaPackage = defaultPackage.getPackage("java.lang");
assertThatTypes(javaPackage.getClasses()).contain(Object.class, String.class, Integer.class);
assertThatTypes(javaPackage.getAllClasses()).contain(Object.class, Annotation.class, Field.class);
assertThat(javaClasses.containPackage("java.util")).as("Classes contain package 'java.util'").isTrue();
assertThatTypes(javaClasses.getPackage("java.util").getClasses()).contain(List.class);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassFileImporterSlowTest method imports_the_classpath.
@Test
public void imports_the_classpath() {
JavaClasses classes = new ClassFileImporter().importClasspath();
assertThatTypes(classes).contain(ClassFileImporter.class, getClass());
// Default does not import jars
assertThatTypes(classes).doNotContain(Rule.class);
// Default does not import JDK classes
assertThatTypes(classes).doNotContain(File.class);
classes = new ClassFileImporter().importClasspath(new ImportOptions().with(importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath()));
assertThatTypes(classes).contain(ClassFileImporter.class, getClass(), Rule.class, File.class);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ClassFileImporterSlowTest method imports_packages_of_classes.
@Test
public void imports_packages_of_classes() {
JavaClasses classes = new ClassFileImporter().importPackagesOf(getClass(), Rule.class);
assertThatTypes(classes).contain(ImmutableSet.of(getClass(), Rule.class));
classes = new ClassFileImporter().importPackagesOf(ImmutableSet.of(getClass(), Rule.class));
assertThatTypes(classes).contain(ImmutableSet.of(getClass(), Rule.class));
}
Aggregations