HHH-12828 Make ScannerTests more stable

In a shared containerized environment like Travis, it's not obvious that
the second read will be faster than the first one.

And indeed, the test often fails.

There's no real value in testing that, we are just testing I/O, and the OS
cache.
This commit is contained in:
Guillaume Smet 2018-07-19 09:57:57 +02:00
parent 3fe7d6e13e
commit ac11b7fd8c
1 changed files with 0 additions and 8 deletions

View File

@ -7,7 +7,6 @@
package org.jboss.as.jpa.hibernate5.scan; package org.jboss.as.jpa.hibernate5.scan;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -23,14 +22,12 @@ import java.nio.file.Paths;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import org.hibernate.boot.archive.internal.ArchiveHelper; import org.hibernate.boot.archive.internal.ArchiveHelper;
import org.jboss.shrinkwrap.api.ArchivePath; import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths; import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ZipExporter; import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.vfs.TempFileProvider; import org.jboss.vfs.TempFileProvider;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -128,21 +125,16 @@ public class ScannerTests {
public void testGetBytesFromInputStream() throws Exception { public void testGetBytesFromInputStream() throws Exception {
File file = buildLargeJar(); File file = buildLargeJar();
long start = System.currentTimeMillis();
InputStream stream = new BufferedInputStream( InputStream stream = new BufferedInputStream(
new FileInputStream( file ) ); new FileInputStream( file ) );
int oldLength = getBytesFromInputStream( stream ).length; int oldLength = getBytesFromInputStream( stream ).length;
stream.close(); stream.close();
long oldTime = System.currentTimeMillis() - start;
start = System.currentTimeMillis();
stream = new BufferedInputStream( new FileInputStream( file ) ); stream = new BufferedInputStream( new FileInputStream( file ) );
int newLength = ArchiveHelper.getBytesFromInputStream( stream ).length; int newLength = ArchiveHelper.getBytesFromInputStream( stream ).length;
stream.close(); stream.close();
long newTime = System.currentTimeMillis() - start;
assertEquals( oldLength, newLength ); assertEquals( oldLength, newLength );
assertTrue( oldTime > newTime );
} }
// This is the old getBytesFromInputStream from JarVisitorFactory before // This is the old getBytesFromInputStream from JarVisitorFactory before