01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Denis M. Kishenko
19: * @version $Revision$
20: */package java.awt.geom;
21:
22: import java.awt.Rectangle;
23:
24: import junit.framework.TestCase;
25:
26: public class FlatteningPathIteratorTest extends TestCase {
27:
28: PathIterator p;
29: FlatteningPathIterator fp;
30:
31: public FlatteningPathIteratorTest(String name) {
32: super (name);
33: }
34:
35: @Override
36: protected void setUp() throws Exception {
37: super .setUp();
38: p = new Rectangle(1, 2, 3, 4).getPathIterator(null);
39: fp = new FlatteningPathIterator(p, 10, 5);
40: }
41:
42: @Override
43: protected void tearDown() throws Exception {
44: fp = null;
45: super .tearDown();
46: }
47:
48: public void testCreateInvalid() {
49: try {
50: new FlatteningPathIterator(p, -1, 5);
51: fail("expected IllegalArgumentException");
52: } catch (IllegalArgumentException e) {
53: // expected
54: }
55:
56: try {
57: new FlatteningPathIterator(p, 1, -5);
58: fail("expected IllegalArgumentException");
59: } catch (IllegalArgumentException e) {
60: // expected
61: }
62:
63: // Regression test HARMONY-1419
64: try {
65: new FlatteningPathIterator(null, -1, 5);
66: fail("expected IllegalArgumentException");
67: } catch (IllegalArgumentException e) {
68: // expected
69: }
70:
71: try {
72: new FlatteningPathIterator(null, 1, 5);
73: fail("expected NPE");
74: } catch (NullPointerException e) {
75: // expected
76: }
77:
78: }
79:
80: public void testGetFlatness() {
81: assertEquals("Flatness", 10, fp.getFlatness(), 0.0);
82: }
83:
84: public void testGetRecursionLimit() {
85: assertEquals("Limit", 5, fp.getRecursionLimit(), 0.0);
86: }
87:
88: public void testGetWindingRule() {
89: assertEquals("Rule", p.getWindingRule(), fp.getWindingRule());
90: }
91:
92: public static void main(String[] args) {
93: junit.textui.TestRunner.run(FlatteningPathIteratorTest.class);
94: }
95:
96: }
|