diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-02-07 15:42:03 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-02-07 15:42:03 +0000 |
commit | b3c8c500256e67344c6b4cc91c045a04e8e65e36 (patch) | |
tree | b7610339c8f2f627d88c9b5f520fe623948b6443 /test | |
parent | 575826b283fa659929204c63905e05fe2e2cf5f5 (diff) | |
download | xmlgraphics-fop-b3c8c500256e67344c6b4cc91c045a04e8e65e36.tar.gz xmlgraphics-fop-b3c8c500256e67344c6b4cc91c045a04e8e65e36.zip |
Bugfix for date formatting with negative time zones in the PDF's Info object.
Update of xmlgraphics-commons-1.3.jar because of a similar bug with formatting dates in XMP.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@619461 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r-- | test/java/org/apache/fop/UtilityCodeTestSuite.java | 8 | ||||
-rw-r--r-- | test/java/org/apache/fop/pdf/PDFObjectTestCase.java | 59 |
2 files changed, 64 insertions, 3 deletions
diff --git a/test/java/org/apache/fop/UtilityCodeTestSuite.java b/test/java/org/apache/fop/UtilityCodeTestSuite.java index 679e16ce7..19d7d0266 100644 --- a/test/java/org/apache/fop/UtilityCodeTestSuite.java +++ b/test/java/org/apache/fop/UtilityCodeTestSuite.java @@ -19,6 +19,10 @@ package org.apache.fop; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.fop.pdf.PDFObjectTestCase; import org.apache.fop.traits.BorderPropsTestCase; import org.apache.fop.traits.TraitColorTestCase; import org.apache.fop.util.DataURIResolverTestCase; @@ -26,9 +30,6 @@ import org.apache.fop.util.ElementListUtilsTestCase; import org.apache.fop.util.PDFNumberTestCase; import org.apache.fop.util.UnitConvTestCase; -import junit.framework.Test; -import junit.framework.TestSuite; - /** * Test suite for FOP's utility classes. */ @@ -43,6 +44,7 @@ public class UtilityCodeTestSuite { "Test suite for FOP's utility classes"); //$JUnit-BEGIN$ suite.addTest(new TestSuite(PDFNumberTestCase.class)); + suite.addTest(new TestSuite(PDFObjectTestCase.class)); suite.addTest(new TestSuite(UnitConvTestCase.class)); suite.addTest(new TestSuite(TraitColorTestCase.class)); suite.addTest(new TestSuite(BorderPropsTestCase.class)); diff --git a/test/java/org/apache/fop/pdf/PDFObjectTestCase.java b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java new file mode 100644 index 000000000..96ac728bd --- /dev/null +++ b/test/java/org/apache/fop/pdf/PDFObjectTestCase.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.pdf; + +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import junit.framework.TestCase; + +/** + * Tests the PDFObject class. + */ +public class PDFObjectTestCase extends TestCase { + + /** + * Tests date/time formatting in PDFObject. + * @throws Exception if an error occurs + */ + public void testDateFormatting() throws Exception { + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); + cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07); + cal.set(Calendar.MILLISECOND, 0); + Date dt = cal.getTime(); + + MyPDFObject obj = new MyPDFObject(); + String s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT")); + assertEquals("D:20080207151107Z", s); + s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT+02:00")); + assertEquals("D:20080207171107+02'00'", s); + s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT+02:30")); + assertEquals("D:20080207174107+02'30'", s); + s = obj.formatDateTime(dt, TimeZone.getTimeZone("GMT-08:00")); + assertEquals("D:20080207071107-08'00'", s); + } + + private class MyPDFObject extends PDFObject { + + } + +} |