use of com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.AbstractFileResource 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();
}
use of com.buschmais.jqassistant.plugin.common.api.scanner.filesystem.AbstractFileResource in project jqa-java-plugin by buschmais.
the class ClassTypeScannerPlugin method scan.
@Override
public ClassFileDescriptor scan(final Class<?> item, String path, Scope scope, Scanner scanner) throws IOException {
final String fileName = "/" + item.getName().replace('.', '/') + ".class";
AbstractFileResource fileResource = new AbstractFileResource() {
@Override
public InputStream createStream() throws IOException {
return item.getResourceAsStream(fileName);
}
};
return scanner.scan(fileResource, fileName, scope);
}
Aggregations