hillion 02/03/20 02:42:26
Modified: sources/org/apache/batik/css/engine CSSEngine.java
sources/org/apache/batik/dom AbstractElement.java
test-resources/org/apache/batik/dom unitTesting.xml
Added: test-sources/org/apache/batik/dom RemoveAttributeTest.java
Log:
- Fixed Element.removeAttribute().
Revision Changes Path
1.2 +10 -4 xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java
Index: CSSEngine.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CSSEngine.java 18 Mar 2002 10:28:21 -0000 1.1
+++ CSSEngine.java 20 Mar 2002 10:42:26 -0000 1.2
@@ -58,7 +58,7 @@
* This is the base class for all the CSS engines.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: CSSEngine.java,v 1.1 2002/03/18 10:28:21 hillion Exp $
+ * @version $Id: CSSEngine.java,v 1.2 2002/03/20 10:42:26 hillion Exp $
*/
public abstract class CSSEngine {
@@ -992,7 +992,9 @@
i = getShorthandIndex(name);
if (i == -1) {
String s = Messages.formatMessage("invalid.property",
- new Object[] { name });
+ new Object[] {
+ documentURI,
+ name });
throw new DOMException(DOMException.SYNTAX_ERR, s);
}
shorthandManagers[i].setValues(CSSEngine.this,
@@ -1142,7 +1144,9 @@
i = getShorthandIndex(name);
if (i == -1) {
String s = Messages.formatMessage("invalid.property",
- new Object[] { name });
+ new Object[] {
+ documentURI,
+ name });
throw new DOMException(DOMException.SYNTAX_ERR, s);
}
shorthandManagers[i].setValues(CSSEngine.this,
@@ -1578,7 +1582,9 @@
i = getShorthandIndex(name);
if (i == -1) {
String s = Messages.formatMessage("invalid.property",
- new Object[] { name });
+ new Object[] {
+ documentURI,
+ name });
throw new DOMException(DOMException.SYNTAX_ERR, s);
}
shorthandManagers[i].setValues(CSSEngine.this,
1.16 +5 -9 xml-batik/sources/org/apache/batik/dom/AbstractElement.java
Index: AbstractElement.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- AbstractElement.java 19 Mar 2002 09:25:40 -0000 1.15
+++ AbstractElement.java 20 Mar 2002 10:42:26 -0000 1.16
@@ -29,7 +29,7 @@
* This class implements the {@link org.w3c.dom.Element} interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: AbstractElement.java,v 1.15 2002/03/19 09:25:40 hillion Exp $
+ * @version $Id: AbstractElement.java,v 1.16 2002/03/20 10:42:26 hillion Exp $
*/
public abstract class AbstractElement
extends AbstractParentChildNode
@@ -135,10 +135,8 @@
* org.w3c.dom.Element#removeAttribute(String)}.
*/
public void removeAttribute(String name) throws DOMException {
- if (attributes == null) {
- throw createDOMException(DOMException.NOT_FOUND_ERR,
- "attribute.missing",
- new Object[] { name });
+ if (!hasAttribute(name)) {
+ return;
}
attributes.removeNamedItem(name);
}
@@ -245,10 +243,8 @@
*/
public void removeAttributeNS(String namespaceURI,
String localName) throws DOMException {
- if (attributes == null) {
- throw createDOMException(DOMException.NOT_FOUND_ERR,
- "attribute.missing",
- new Object[] { localName });
+ if (!hasAttributeNS(namespaceURI, localName)) {
+ return;
}
attributes.removeNamedItemNS(namespaceURI, localName);
}
1.5 +22 -1 xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml
Index: unitTesting.xml
===================================================================
RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- unitTesting.xml 19 Mar 2002 13:43:54 -0000 1.4
+++ unitTesting.xml 20 Mar 2002 10:42:26 -0000 1.5
@@ -9,7 +9,7 @@
<!-- ========================================================================= -->
<!-- @author [EMAIL PROTECTED] -->
<!-- @author [EMAIL PROTECTED] -->
-<!-- @version $Id: unitTesting.xml,v 1.4 2002/03/19 13:43:54 hillion Exp $ -->
+<!-- @version $Id: unitTesting.xml,v 1.5 2002/03/20 10:42:26 hillion Exp $ -->
<!-- ========================================================================= -->
<testSuite id="dom.unitTesting" name="org.apache.batik.dom package - Unit Testing">
@@ -63,6 +63,27 @@
value="test-resources/org/apache/batik/dom/dummyXML3.xml" />
<arg class="java.lang.String" value="doc" />
<arg class="java.lang.String" value="root" />
+ </test>
+
+ <!-- ==========================================================================
-->
+ <!-- removeAttribute test
-->
+ <!-- ==========================================================================
-->
+ <test id="removeAttribute1"
+ class="org.apache.batik.dom.RemoveAttributeTest" >
+ <arg class="java.lang.String"
+ value="test-resources/org/apache/batik/dom/dummyXML3.xml" />
+ <arg class="java.lang.String" value="doc" />
+ <arg class="java.lang.String" value="root" />
+ <arg class="java.lang.String" value="attr" />
+ </test>
+
+ <test id="removeAttribute2"
+ class="org.apache.batik.dom.RemoveAttributeTest" >
+ <arg class="java.lang.String"
+ value="test-resources/org/apache/batik/dom/dummyXML3.xml" />
+ <arg class="java.lang.String" value="doc" />
+ <arg class="java.lang.String" value="root" />
+ <arg class="java.lang.String" value="attr2" />
</test>
<!-- ==========================================================================
-->
1.1
xml-batik/test-sources/org/apache/batik/dom/RemoveAttributeTest.java
Index: RemoveAttributeTest.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.dom;
import org.w3c.dom.*;
import java.io.*;
import java.net.*;
import org.apache.batik.dom.util.*;
import org.apache.batik.util.*;
import org.apache.batik.test.*;
/**
* This class tests the removeAttribute method.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
* @version $Id: RemoveAttributeTest.java,v 1.1 2002/03/20 10:42:26 hillion Exp $
*/
public class RemoveAttributeTest extends AbstractTest {
public static String ERROR_GET_ELEMENT_BY_ID_FAILED
= "error.get.element.by.id.failed";
public static String ENTRY_KEY_ID
= "entry.key.id";
protected String testFileName;
protected String rootTag;
protected String targetId;
protected String targetAttr;
public RemoveAttributeTest(String file,
String root,
String id,
String attr) {
testFileName = file;
rootTag = root;
targetId = id;
targetAttr = attr;
}
public TestReport runImpl() throws Exception {
String parser =
XMLResourceDescriptor.getXMLParserClassName();
DocumentFactory df
= new SAXDocumentFactory
(GenericDOMImplementation.getDOMImplementation(), parser);
File f = (new File(testFileName));
URL url = f.toURL();
Document doc = df.createDocument(null,
rootTag,
url.toString(),
url.openStream());
Element e = doc.getElementById(targetId);
if (e == null){
DefaultTestReport report = new DefaultTestReport(this);
report.setErrorCode(ERROR_GET_ELEMENT_BY_ID_FAILED);
report.addDescriptionEntry(ENTRY_KEY_ID,
targetId);
report.setPassed(false);
return report;
}
try {
e.removeAttribute(targetAttr);
} catch (DOMException ex) {
DefaultTestReport report = new DefaultTestReport(this);
report.setErrorCode(report.ERROR_TEST_FAILED);
report.addDescriptionEntry("exception.message",
ex.getMessage());
report.setPassed(false);
return report;
}
return reportSuccess();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]