use of org.hibernate.jpa.boot.scan.internal.StandardScanOptions in project wildfly by wildfly.
the class ScannerTest method testZippedJar.
@Test
public void testZippedJar() throws Exception {
File defaultPar = buildDefaultPar();
addPackageToClasspath(defaultPar);
final VirtualFile virtualFile = VFS.getChild(defaultPar.getAbsolutePath());
Closeable closeable = VFS.mountZip(virtualFile, virtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(virtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable.close();
}
}
use of org.hibernate.jpa.boot.scan.internal.StandardScanOptions in project wildfly by wildfly.
the class ScannerTest method testHttp.
@Test
public void testHttp() throws Exception {
URL url = ArchiveHelper.getJarURLFromURLEntry(new URL("jar:http://www.ibiblio.org/maven/hibernate/jars/hibernate-annotations-3.0beta1.jar!/META-INF/persistence.xml"), "/META-INF/persistence.xml");
try {
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
} catch (IOException ie) {
//fail silently
return;
}
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(url);
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
assertEquals(0, resultCollector.getClassDescriptorSet().size());
assertEquals(0, resultCollector.getPackageDescriptorSet().size());
assertEquals(0, resultCollector.getMappingFileSet().size());
}
use of org.hibernate.jpa.boot.scan.internal.StandardScanOptions in project wildfly by wildfly.
the class ScannerTest method testNestedJarProtocol.
@Test
public void testNestedJarProtocol() throws Exception {
File defaultPar = buildDefaultPar();
File nestedEar = buildNestedEar(defaultPar);
addPackageToClasspath(nestedEar);
final VirtualFile nestedEarVirtualFile = VFS.getChild(nestedEar.getAbsolutePath());
Closeable closeable = VFS.mountZip(nestedEarVirtualFile, nestedEarVirtualFile, tempFileProvider);
try {
VirtualFile parVirtualFile = nestedEarVirtualFile.getChild("defaultpar.par");
Closeable closeable2 = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable2.close();
}
} finally {
closeable.close();
}
File nestedEarDir = buildNestedEarDir(defaultPar);
final VirtualFile nestedEarDirVirtualFile = VFS.getChild(nestedEarDir.getAbsolutePath());
try {
VirtualFile parVirtualFile = nestedEarDirVirtualFile.getChild("defaultpar.par");
closeable = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable.close();
}
} finally {
closeable.close();
}
}
use of org.hibernate.jpa.boot.scan.internal.StandardScanOptions 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();
}
}
use of org.hibernate.jpa.boot.scan.internal.StandardScanOptions in project wildfly by wildfly.
the class ScannerTest method testInputStreamZippedJar.
@Test
public void testInputStreamZippedJar() throws Exception {
File defaultPar = buildDefaultPar();
addPackageToClasspath(defaultPar);
final VirtualFile virtualFile = VFS.getChild(defaultPar.getAbsolutePath());
Closeable closeable = VFS.mountZip(virtualFile, virtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(defaultPar.toURI().toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable.close();
}
}
Aggregations