Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/imageio/plugins/gif/EndWriteSequenceTest.java
41154 views
1
/*
2
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 6275366 6275369
27
* @summary Verifies that behaviour of GIFImageWriter.endWriteSequence() is
28
* consistent with specification
29
*/
30
31
import java.io.ByteArrayOutputStream;
32
import java.io.IOException;
33
34
import javax.imageio.ImageIO;
35
import javax.imageio.ImageWriter;
36
import javax.imageio.stream.ImageOutputStream;
37
38
public class EndWriteSequenceTest {
39
public static void main(String[] args) throws IOException {
40
ImageWriter w =
41
ImageIO.getImageWritersByFormatName("GIF").next();
42
43
boolean gotCorrectException = false;
44
45
/**
46
* check statement: "Throws: IllegalStateException -
47
* if the output has not been set ...."
48
*/
49
try {
50
w.reset(); // to be shure that output is null
51
w.endWriteSequence();
52
} catch (IllegalStateException e) {
53
gotCorrectException = true;
54
} catch (Throwable e) {
55
throw new RuntimeException("Test failed.", e);
56
}
57
if (!gotCorrectException) {
58
throw new RuntimeException("Test failed.");
59
}
60
61
/**
62
* set up output stream
63
*/
64
ByteArrayOutputStream baos =
65
new ByteArrayOutputStream();
66
67
ImageOutputStream ios =
68
ImageIO.createImageOutputStream(baos);
69
70
w.setOutput(ios);
71
72
/**
73
* check statement: "Throws: IllegalStateException -
74
* if .... prepareWriteSequence has not been called.
75
*/
76
gotCorrectException = false;
77
try {
78
w.endWriteSequence();
79
} catch (IllegalStateException e) {
80
gotCorrectException = true;
81
} catch (Throwable e) {
82
throw new RuntimeException("Test failed.", e);
83
}
84
if (!gotCorrectException) {
85
throw new RuntimeException("Test failed.");
86
}
87
88
System.out.println("Test passed.");
89
}
90
}
91
92