aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2010-01-14 14:18:15 -0800
committerRaphael <raphael@google.com>2010-01-14 14:20:40 -0800
commit902280200956f077a0ef571435091b4b9a9e5306 (patch)
treef1265e6b4ba9e4a14b543f848d562330701ab681
parente31f9169faa105960bcf2a6eb2adf56c05c1ec71 (diff)
downloadsdk-902280200956f077a0ef571435091b4b9a9e5306.zip
sdk-902280200956f077a0ef571435091b4b9a9e5306.tar.gz
sdk-902280200956f077a0ef571435091b4b9a9e5306.tar.bz2
Cleanup mock class, don't use NotImplementedException.
It has a non-java namespace we don't want to use. Change-Id: I67f247b38df16e1a62957e84ce9e03c449ffae5a
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockNamedNodeMap.java32
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockXmlNode.java76
2 files changed, 51 insertions, 57 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockNamedNodeMap.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockNamedNodeMap.java
index cf05b2a..19682a1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockNamedNodeMap.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockNamedNodeMap.java
@@ -20,41 +20,39 @@ import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
import java.util.ArrayList;
import java.util.HashMap;
class MockNamedNodeMap implements NamedNodeMap {
-
+
/** map for access by namespace/name */
private final HashMap<String, HashMap<String, Node>> mNodeMap =
new HashMap<String, HashMap<String, Node>>();
-
+
/** list for access by index */
private final ArrayList<Node> mNodeList = new ArrayList<Node>();
-
+
public MockXmlNode addAttribute(String namespace, String localName, String value) {
MockXmlNode node = new MockXmlNode(namespace, localName, value);
if (namespace == null) {
namespace = ""; // no namespace
}
-
+
// get the map for the namespace
HashMap<String, Node> map = mNodeMap.get(namespace);
if (map == null) {
map = new HashMap<String, Node>();
mNodeMap.put(namespace, map);
}
-
-
+
+
map.put(localName, node);
mNodeList.add(node);
-
+
return node;
}
-
+
// --------- NamedNodeMap -------
public int getLength() {
@@ -66,7 +64,7 @@ class MockNamedNodeMap implements NamedNodeMap {
if (map != null) {
return map.get(name);
}
-
+
return null;
}
@@ -74,12 +72,12 @@ class MockNamedNodeMap implements NamedNodeMap {
if (namespaceURI == null) {
namespaceURI = ""; //no namespace
}
-
+
HashMap<String, Node> map = mNodeMap.get(namespaceURI);
if (map != null) {
return map.get(localName);
}
-
+
return null;
}
@@ -88,19 +86,19 @@ class MockNamedNodeMap implements NamedNodeMap {
}
public Node removeNamedItem(String name) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node setNamedItem(Node arg) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node setNamedItemNS(Node arg) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockXmlNode.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockXmlNode.java
index 1ad7543..49acaca 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockXmlNode.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/mock/MockXmlNode.java
@@ -25,14 +25,12 @@ import org.w3c.dom.UserDataHandler;
import java.util.HashMap;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
/**
* A mock XML node with only a minimal set of information.
*/
public class MockXmlNode implements Node {
-
+
MockNodeList mNodeList;
private String mLocalName;
private String mNamespace;
@@ -42,14 +40,14 @@ public class MockXmlNode implements Node {
private MockXmlNode mNextSibling;
private String mAttrValue;
private MockNamedNodeMap mAttributes;
-
+
// namespace stuff only set in the root node
/** map from namespace to prefix. */
private HashMap<String, String> mNsMap = null;
-
+
/**
* Constructs a node from a given children list.
- *
+ *
* @param namespace The namespace of the node or null if none
* @param localName The XML local node name.
* @param node_type One of Node.xxx_NODE constants, e.g. Node.ELEMENT_NODE
@@ -66,7 +64,7 @@ public class MockXmlNode implements Node {
/**
* Constructs an attribute node
- *
+ *
* @param namespace The namespace of the node or null if none
* @param localName The XML local node name.
* @param value the value of the attribute
@@ -92,16 +90,16 @@ public class MockXmlNode implements Node {
prev = n;
}
}
-
+
public void addAttributes(String namespaceURI, String localName, String value) {
if (mAttributes == null) {
mAttributes = new MockNamedNodeMap();
}
-
+
MockXmlNode node = mAttributes.addAttribute(namespaceURI, localName, value);
node.mParent = this;
}
-
+
public void setPrefix(String namespace, String prefix) {
if (mNsMap == null) {
mNsMap = new HashMap<String, String>();
@@ -109,16 +107,16 @@ public class MockXmlNode implements Node {
mNsMap.put(namespace, prefix);
}
-
+
public String getPrefix(String namespace) {
if (mNsMap != null) {
return mNsMap.get(namespace);
}
-
+
return mParent.getPrefix(namespace);
}
-
+
// ----------- Node methods
public Node appendChild(Node newChild) throws DOMException {
@@ -155,7 +153,7 @@ public class MockXmlNode implements Node {
public String getNodeName() {
return mLocalName;
}
-
+
public String getLocalName() {
return mLocalName;
}
@@ -177,19 +175,17 @@ public class MockXmlNode implements Node {
}
public boolean hasAttributes() {
- // TODO Auto-generated method stub
- throw new NotImplementedException();
- //return false;
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public boolean isSameNode(Node other) {
return this == other;
}
-
+
public String getNodeValue() throws DOMException {
return mAttrValue;
}
-
+
public String getPrefix() {
return getPrefix(getNamespaceURI());
}
@@ -200,87 +196,87 @@ public class MockXmlNode implements Node {
// --- methods not implemented ---
-
+
public Node cloneNode(boolean deep) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public short compareDocumentPosition(Node other) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public String getBaseURI() {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Object getFeature(String feature, String version) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Document getOwnerDocument() {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public String getTextContent() throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Object getUserData(String key) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node insertBefore(Node newChild, Node refChild)
throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public boolean isDefaultNamespace(String namespaceURI) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public boolean isEqualNode(Node arg) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public boolean isSupported(String feature, String version) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public String lookupNamespaceURI(String prefix) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public String lookupPrefix(String namespaceURI) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public void normalize() {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node removeChild(Node oldChild) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Node replaceChild(Node newChild, Node oldChild)
throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public void setNodeValue(String nodeValue) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public void setPrefix(String prefix) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public void setTextContent(String textContent) throws DOMException {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
public Object setUserData(String key, Object data,
UserDataHandler handler) {
- throw new NotImplementedException();
+ throw new UnsupportedOperationException("Operation not implemented."); //$NON-NLS-1$
}
}