/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6557086 6547241
* another thread does not cause crash in jpeg library.
* @run main ReadingInterruptionTest
*/
t.doTest();
t = new ReadingInterruptionTest(new ResetAction());
t.doTest();
t = new ReadingInterruptionTest(new DisposeAction());
t.doTest();
}
}
public abstract void run();
}
public void run() {
try {
} catch (IllegalStateException e) {
} catch (Throwable e) {
throw new RuntimeException("Test FAILED.", e);
}
}
}
public void run() {
try {
} catch (IllegalStateException e) {
} catch (Throwable e) {
throw new RuntimeException("Test FAILED.", e);
}
}
}
public void run() {
try {
} catch (IllegalStateException e) {
} catch (Throwable e) {
throw new RuntimeException("Test FAILED.", e);
}
}
}
}
public void doTest() {
try {
reader.addIIOReadProgressListener(this);
} catch (Exception e) {
/*
* we do expect that concurrent attempt to dispose this
* instance of image reader will be blocked. So, this image
* should be read sucessfuly. Otherwise, something went wrong
* and we need to report test failure.
*/
throw new RuntimeException("Test FAILED", e);
} finally {
/*
* it would happen that concurrent invocation of dispose() method
* will be successful. Due to race condition it seems to be possible
* that dispose operation will be performed after than read() operation
* leaveled thread lock. In this case all subsequent calls for reader
* methods should results in IllegalStateException. So, we treat
* IllegalStateException as success. Everything else means test failure.
*/
try {
} catch (IllegalStateException e) {
} catch(Exception e) {
throw new RuntimeException("Test FAILED.", e);
}
}
}
// listener medthods
int imageIndex) {} ;
float percentageDone)
{
t.start();
}
};
int minIndex) {};
int imageIndex,
int thumbnailIndex) {};
float percentageDone) {};
private static void createTestFile() {
int w = 1280;
int h = 1024;
BufferedImage img = new
g.setPaint(p);
g.dispose();
try {
if (!b) {
throw new RuntimeException("Failed to create test image.");
}
} catch (IOException e) {
throw new RuntimeException("Test failed", e);
}
}
}