KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > traits > BorderPropsTestCase


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 /* $Id$ */
19
20 package org.apache.fop.traits;
21
22 import java.awt.Color JavaDoc;
23
24 import junit.framework.TestCase;
25
26 import org.apache.fop.fo.Constants;
27 import org.apache.fop.util.ColorUtil;
28
29 /**
30  * Tests the BorderProps class.
31  */

32 public class BorderPropsTestCase extends TestCase {
33
34     /**
35      * Test serialization and deserialization to/from String.
36      * @throws Exception if an error occurs
37      */

38     public void testSerialization() throws Exception JavaDoc {
39         Color JavaDoc col = new Color JavaDoc(1.0f, 1.0f, 0.5f, 1.0f);
40         //Normalize: Avoid false alarms due to color conversion (rounding)
41
col = ColorUtil.parseColorString(null, ColorUtil.colorToString(col));
42         
43         BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250,
44                 col, BorderProps.COLLAPSE_OUTER);
45         String JavaDoc ser = b1.toString();
46         BorderProps b2 = BorderProps.valueOf(null, ser);
47         assertEquals(b1, b2);
48
49         b1 = new BorderProps(Constants.EN_INSET, 9999,
50                 col, BorderProps.SEPARATE);
51         ser = b1.toString();
52         b2 = BorderProps.valueOf(null, ser);
53         assertEquals(b1, b2);
54     }
55     
56 }
57
Popular Tags