Search in sources :

Example 1 with ClassDescriptorImpl

use of org.hibernate.jpa.boot.internal.ClassDescriptorImpl in project wildfly by wildfly.

the class ScannerTest method validateResults.

private void validateResults(AbstractScannerImpl.ResultCollector resultCollector, Class... expectedClasses) throws IOException {
    assertEquals(3, resultCollector.getClassDescriptorSet().size());
    for (Class expectedClass : expectedClasses) {
        assertTrue(resultCollector.getClassDescriptorSet().contains(new ClassDescriptorImpl(expectedClass.getName(), null)));
    }
    assertEquals(2, resultCollector.getMappingFileSet().size());
    for (MappingFileDescriptor mappingFileDescriptor : resultCollector.getMappingFileSet()) {
        assertNotNull(mappingFileDescriptor.getStreamAccess());
        final InputStream stream = mappingFileDescriptor.getStreamAccess().accessInputStream();
        assertNotNull(stream);
        stream.close();
    }
}
Also used : MappingFileDescriptor(org.hibernate.jpa.boot.spi.MappingFileDescriptor) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ClassDescriptorImpl(org.hibernate.jpa.boot.internal.ClassDescriptorImpl)

Example 2 with ClassDescriptorImpl

use of org.hibernate.jpa.boot.internal.ClassDescriptorImpl in project wildfly by wildfly.

the class ScannerTest method testExplodedJar.

@Test
public void testExplodedJar() throws Exception {
    File explodedPar = buildExplodedPar();
    addPackageToClasspath(explodedPar);
    String dirPath = explodedPar.getAbsolutePath();
    if (dirPath.endsWith("/")) {
        dirPath = dirPath.substring(0, dirPath.length() - 1);
    }
    final VirtualFile virtualFile = VFS.getChild(dirPath);
    ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(virtualFile.toURL());
    AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
    archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
    assertEquals(1, resultCollector.getClassDescriptorSet().size());
    assertEquals(1, resultCollector.getPackageDescriptorSet().size());
    assertEquals(1, resultCollector.getMappingFileSet().size());
    assertTrue(resultCollector.getClassDescriptorSet().contains(new ClassDescriptorImpl(Carpet.class.getName(), null)));
    for (MappingFileDescriptor mappingFileDescriptor : resultCollector.getMappingFileSet()) {
        assertNotNull(mappingFileDescriptor.getStreamAccess());
        final InputStream stream = mappingFileDescriptor.getStreamAccess().accessInputStream();
        assertNotNull(stream);
        stream.close();
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) MappingFileDescriptor(org.hibernate.jpa.boot.spi.MappingFileDescriptor) AbstractScannerImpl(org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ClassDescriptorImpl(org.hibernate.jpa.boot.internal.ClassDescriptorImpl) ArchiveDescriptor(org.hibernate.jpa.boot.archive.spi.ArchiveDescriptor) Carpet(org.hibernate.jpa.test.pack.explodedpar.Carpet) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File) StandardScanOptions(org.hibernate.jpa.boot.scan.internal.StandardScanOptions) Test(org.junit.Test)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ClassDescriptorImpl (org.hibernate.jpa.boot.internal.ClassDescriptorImpl)2 MappingFileDescriptor (org.hibernate.jpa.boot.spi.MappingFileDescriptor)2 File (java.io.File)1 ArchiveDescriptor (org.hibernate.jpa.boot.archive.spi.ArchiveDescriptor)1 StandardScanOptions (org.hibernate.jpa.boot.scan.internal.StandardScanOptions)1 AbstractScannerImpl (org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl)1 Carpet (org.hibernate.jpa.test.pack.explodedpar.Carpet)1 VirtualFile (org.jboss.vfs.VirtualFile)1 Test (org.junit.Test)1