Added: 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java?rev=1205935&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java
 (added)
+++ 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java
 Thu Nov 24 17:15:28 2011
@@ -0,0 +1,131 @@
+/*
+ * 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.render.intermediate;
+
+
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import 
org.apache.fop.render.intermediate.IFStructureTreeBuilder.SAXEventRecorder;
+import org.apache.fop.util.XMLUtil;
+
+/**
+ * Tests {@link SAXEventRecorder}.
+ */
+public class SAXEventRecorderTestCase {
+
+    private static final String URI = "http://www.example.com/";;
+
+    private SAXEventRecorder sut;
+
+    @Before
+    public void setUp() {
+        sut = new SAXEventRecorder();
+    }
+
+    @Test
+    public void testStartEvent() throws SAXException {
+        final String localName = "element";
+        final String qName = "prefix:" + localName;
+        final Attributes attributes = new AttributesImpl();
+
+        sut.startElement(URI, localName, qName, attributes);
+        ContentHandler handler = mock(ContentHandler.class);
+        sut.replay(handler);
+        verify(handler).startElement(URI, localName, qName, attributes);
+    }
+
+    @Test
+    public void testEndEvent() throws SAXException {
+        final String localName = "element";
+        final String qName = "prefix:" + localName;
+        sut.endElement(URI, localName, qName);
+        ContentHandler handler = mock(ContentHandler.class);
+        sut.replay(handler);
+        verify(handler).endElement(URI, localName, qName);
+    }
+
+    @Test
+    public void testStartPrefixMapping() throws SAXException {
+        final String prefix = "prefix";
+
+        sut.startPrefixMapping(URI, prefix);
+        ContentHandler handler = mock(ContentHandler.class);
+        sut.replay(handler);
+        verify(handler).startPrefixMapping(URI, prefix);
+    }
+
+    @Test
+    public void testEndPrefixMapping() throws SAXException {
+        final String prefix = "prefix";
+
+        sut.endPrefixMapping(prefix);
+        ContentHandler handler = mock(ContentHandler.class);
+        sut.replay(handler);
+        verify(handler).endPrefixMapping(prefix);
+    }
+
+    @Test
+    public void completeTest() throws SAXException {
+        final String localName1 = "element";
+        final String qName1 = "prefix:" + localName1;
+        final Attributes attributes1 = createAttributes(URI, localName1, 
qName1, "value-1");
+        final String localName2 = "element2";
+        final String qName2 = "prefix:" + localName2;
+        final Attributes attributes2 = createAttributes(URI, localName2, 
qName2, "value-2");
+        final ContentHandler handler = mock(ContentHandler.class);
+        final String extensionUrl = "http://www.example.com/extension";;
+        final String extensionPrefix = "ext";
+
+        sut.startPrefixMapping(extensionPrefix, extensionUrl);
+        sut.startElement(URI, localName1, qName1, attributes1);
+        sut.startElement(URI, localName2, qName2, attributes2);
+        sut.endElement(URI, localName2, qName2);
+        sut.endElement(URI, localName1, qName1);
+        sut.endPrefixMapping(extensionPrefix);
+
+        sut.replay(handler);
+
+        InOrder inOrder = inOrder(handler);
+        inOrder.verify(handler).startPrefixMapping(extensionPrefix, 
extensionUrl);
+        inOrder.verify(handler).startElement(URI, localName1, qName1, 
attributes1);
+        inOrder.verify(handler).startElement(URI, localName2, qName2, 
attributes2);
+        inOrder.verify(handler).endElement(URI, localName2, qName2);
+        inOrder.verify(handler).endElement(URI, localName1, qName1);
+        inOrder.verify(handler).endPrefixMapping(extensionPrefix);
+    }
+
+    private static Attributes createAttributes(String uri, String localName,
+            String qName, String value) {
+        final AttributesImpl atts = new AttributesImpl();
+        atts.addAttribute(uri, localName, qName, XMLUtil.CDATA, value);
+        return atts;
+    }
+
+}

Propchange: 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/render/intermediate/SAXEventRecorderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Copied: 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/LanguageTagsTestCase.java
 (from r1187300, 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/XMLUtilTestCase.java)
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/LanguageTagsTestCase.java?p2=xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/LanguageTagsTestCase.java&p1=xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/XMLUtilTestCase.java&r1=1187300&r2=1205935&rev=1205935&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/XMLUtilTestCase.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/java/org/apache/fop/util/LanguageTagsTestCase.java
 Thu Nov 24 17:15:28 2011
@@ -20,31 +20,39 @@
 package org.apache.fop.util;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 
 import java.util.Locale;
 
 import org.junit.Test;
 
 /**
- * Tests {@link XMLUtil}.
+ * Tests {@link LanguageTags}.
  */
-public class XMLUtilTestCase {
+public class LanguageTagsTestCase {
+
+    @Test(expected = NullPointerException.class)
+    public void toLanguageTagRejectsNull() {
+        LanguageTags.toLanguageTag(null);
+    }
 
     @Test
-    public void testLocaleToRFC3066() throws Exception {
-        assertNull(XMLUtil.toRFC3066(null));
-        assertEquals("en", XMLUtil.toRFC3066(new Locale("en")));
-        assertEquals("en-US", XMLUtil.toRFC3066(new Locale("en", "US")));
-        assertEquals("en-US", XMLUtil.toRFC3066(new Locale("EN", "us")));
+    public void testToLanguageTag() throws Exception {
+        assertEquals("", LanguageTags.toLanguageTag(new Locale("")));
+        assertEquals("en", LanguageTags.toLanguageTag(new Locale("en")));
+        assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("en", 
"US")));
+        assertEquals("en-US", LanguageTags.toLanguageTag(new Locale("EN", 
"us")));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void toLocaleRejectsNull() {
+        LanguageTags.toLocale(null);
     }
 
     @Test
     public void testRFC3066ToLocale() throws Exception {
-        assertNull(XMLUtil.convertRFC3066ToLocale(null));
-        assertNull(XMLUtil.convertRFC3066ToLocale(""));
-        assertEquals(new Locale("en"), XMLUtil.convertRFC3066ToLocale("en"));
-        assertEquals(new Locale("en", "US"), 
XMLUtil.convertRFC3066ToLocale("en-US"));
-        assertEquals(new Locale("en", "US"), 
XMLUtil.convertRFC3066ToLocale("EN-us"));
+        assertEquals(new Locale(""), LanguageTags.toLocale(""));
+        assertEquals(new Locale("en"), LanguageTags.toLocale("en"));
+        assertEquals(new Locale("en", "US"), LanguageTags.toLocale("en-US"));
+        assertEquals(new Locale("en", "US"), LanguageTags.toLocale("EN-us"));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to