Skip to content

Commit

Permalink
Merge pull request #13650 from scottmarlow/WFLY-13970_fixintermittent…
Browse files Browse the repository at this point in the history
…fail

[WFLY-13970] ScannerTests.testGetBytesFromInputStream fail intermittently
  • Loading branch information
kabir committed Oct 19, 2020
2 parents b89f073 + 1a2ee0a commit dd11521
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.jboss.as.jpa.hibernate5.scan;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.BufferedInputStream;
Expand Down Expand Up @@ -130,21 +129,16 @@ protected File buildLargeJar()throws Exception {
public void testGetBytesFromInputStream() throws Exception {
File file = buildLargeJar();

long start = System.currentTimeMillis();
InputStream stream = new BufferedInputStream(
new FileInputStream(file));
int oldLength = getBytesFromInputStream(stream).length;
stream.close();
long oldTime = System.currentTimeMillis() - start;

start = System.currentTimeMillis();
stream = new BufferedInputStream(new FileInputStream(file));
int newLength = ArchiveHelper.getBytesFromInputStream(stream).length;
stream.close();
long newTime = System.currentTimeMillis() - start;

assertEquals(oldLength, newLength);
assertTrue(oldTime > newTime);
}

// This is the old getBytesFromInputStream from JarVisitorFactory before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.jboss.as.jpa.hibernate5.scan;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.BufferedInputStream;
Expand Down Expand Up @@ -130,21 +129,16 @@ protected File buildLargeJar()throws Exception {
public void testGetBytesFromInputStream() throws Exception {
File file = buildLargeJar();

long start = System.currentTimeMillis();
InputStream stream = new BufferedInputStream(
new FileInputStream(file));
int oldLength = getBytesFromInputStream(stream).length;
stream.close();
long oldTime = System.currentTimeMillis() - start;

start = System.currentTimeMillis();
stream = new BufferedInputStream(new FileInputStream(file));
int newLength = ArchiveHelper.getBytesFromInputStream(stream).length;
stream.close();
long newTime = System.currentTimeMillis() - start;

assertEquals(oldLength, newLength);
assertTrue(oldTime > newTime);
}

// This is the old getBytesFromInputStream from JarVisitorFactory before
Expand Down

0 comments on commit dd11521

Please sign in to comment.