You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2006/11/15 14:42:01 UTC
svn commit: r475233 - in
/incubator/harmony/enhanced/classlib/trunk/modules/swing/src:
main/java/common/javax/swing/text/html/parser/
test/api/java/common/javax/swing/text/html/
test/api/java/common/javax/swing/text/html/parser/
Author: apetrenko
Date: Wed Nov 15 05:42:00 2006
New Revision: 475233
URL: http://svn.apache.org/viewvc?view=rev&rev=475233
Log:
Patch for HARMONY-2087 "[classlib][html] Compatibilty. j.s.t.h.p.DTD.getElement(int) returns null when the RI throws ArrayIndexOutOfBoundsException"
Added:
incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/
incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/
incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/DTDTest.java
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/DTD.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/DTD.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/DTD.java?view=diff&rev=475233&r1=475232&r2=475233
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/DTD.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/DTD.java Wed Nov 15 05:42:00 2006
@@ -325,13 +325,8 @@
return result;
}
- /**
- *
- * @return if index < 0 or elements.size() <= index returns null.
- */
public Element getElement(final int index) {
- return index >= 0 && index < elements.size() ? (Element)
- elements.get(index) : null;
+ return elements.elementAt(index);
}
public Element getElement(final String name) {
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/DTDTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/DTDTest.java?view=auto&rev=475233
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/DTDTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/html/parser/DTDTest.java Wed Nov 15 05:42:00 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package javax.swing.text.html.parser;
+
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.Element;
+
+import junit.framework.TestCase;
+
+public class DTDTest extends TestCase {
+
+ DTD dtd = null;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ dtd = DTD.getDTD("testDTD");
+ }
+
+ public void testGetElementLowerOutOfBounds(){
+ try{
+ Element e = dtd.getElement(-1);
+
+ fail("IndexOutOfBoundsException wasn't raised as RI, but method returned: "+ e);
+ }catch (IndexOutOfBoundsException e) {
+ }catch (Exception e) {
+ fail(e.getClass().getName() + " raised but IndexOutOfBoundsException had to be raised");
+ }
+ }
+
+ public void testGetElementUpperOutOfBounds(){
+ try{
+ Element e = dtd.getElement(dtd.elements.size());
+
+ fail("IndexOutOfBoundsException didn't raised as RI, but method returned: "+ e);
+ }catch (IndexOutOfBoundsException e) {
+ }catch (Exception e) {
+ fail(e.getClass().getName() + " raised but IndexOutOfBoundsException had to be raised");
+ }
+ }
+
+}