Search in sources :

Example 1 with FileResource

use of com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.FileResource in project jqa-java-plugin by buschmais.

the class InvalidClassFileIT method classFileWithHeaderOnly.

@Test
public void classFileWithHeaderOnly() throws IOException {
    final String path = "/com.buschmais.Test.class";
    final FileResource fileResource = new AbstractFileResource() {

        @Override
        public InputStream createStream() throws IOException {
            return new ByteArrayInputStream(ClassFileScannerPlugin.CAFEBABE);
        }
    };
    List<? extends FileDescriptor> fileDescriptors = execute(ARTIFACT_ID, new ScanClassPathOperation() {

        @Override
        public List<FileDescriptor> scan(JavaArtifactFileDescriptor artifact, Scanner scanner) {
            FileDescriptor fileDescriptor = scanner.scan(fileResource, path, JavaScope.CLASSPATH);
            return Collections.singletonList(fileDescriptor);
        }
    });
    store.beginTransaction();
    assertThat(fileDescriptors.size(), equalTo(1));
    FileDescriptor fileDescriptor = fileDescriptors.get(0);
    assertThat(fileDescriptor, instanceOf(ClassFileDescriptor.class));
    ClassFileDescriptor classFileDescriptor = (ClassFileDescriptor) fileDescriptor;
    assertThat(classFileDescriptor.getFileName(), equalTo(path));
    assertThat(classFileDescriptor.isValid(), equalTo(false));
    store.commitTransaction();
}
Also used : Scanner(com.buschmais.jqassistant.core.scanner.api.Scanner) ByteArrayInputStream(java.io.ByteArrayInputStream) FileResource(com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.FileResource) AbstractFileResource(com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.AbstractFileResource) List(java.util.List) AbstractFileResource(com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.AbstractFileResource) JavaArtifactFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaArtifactFileDescriptor) ClassFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor) JavaArtifactFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaArtifactFileDescriptor) FileDescriptor(com.buschmais.jqassistant.plugin.common.api.model.FileDescriptor) ClassFileDescriptor(com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor) Test(org.junit.Test)

Aggregations

Scanner (com.buschmais.jqassistant.core.scanner.api.Scanner)1 FileDescriptor (com.buschmais.jqassistant.plugin.common.api.model.FileDescriptor)1 AbstractFileResource (com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.AbstractFileResource)1 FileResource (com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.FileResource)1 ClassFileDescriptor (com.buschmais.jqassistant.plugin.java.api.model.ClassFileDescriptor)1 JavaArtifactFileDescriptor (com.buschmais.jqassistant.plugin.java.api.model.JavaArtifactFileDescriptor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 List (java.util.List)1 Test (org.junit.Test)1