Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom')
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/AttrImplTests.java80
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/ElementImplTests.java73
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NameValidatorTests.java65
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeContainerTests.java89
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeListImplTests.java184
-rw-r--r--tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/RegionChangedAdapterNotificationTests.java784
6 files changed, 0 insertions, 1275 deletions
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/AttrImplTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/AttrImplTests.java
deleted file mode 100644
index 1694e263e..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/AttrImplTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.tests.dom;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-public class AttrImplTests extends TestCase {
-
- private static final String contents = "<elementName attrPrefix:local='lorem' />"; //$NON-NLS-1$
-
- public AttrImplTests() {
- }
-
- public AttrImplTests(String name) {
- super(name);
- }
-
- public void testAttrImplPrefix() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element documentElement = model.getDocument().getDocumentElement();
- assertNotNull("no document element found", documentElement);
- NamedNodeMap attributes = documentElement.getAttributes();
- assertTrue("no attributes found", attributes.getLength() > 0);
- Attr attribute = (Attr) attributes.item(0);
- assertEquals("attribute prefix was not as expected", "attrPrefix", attribute.getPrefix());
- }
-
- public void testAttrImplLocalName() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element documentElement = model.getDocument().getDocumentElement();
- assertNotNull("no document element found", documentElement);
- NamedNodeMap attributes = documentElement.getAttributes();
- assertTrue("no attributes found", attributes.getLength() > 0);
- Attr attribute = (Attr) attributes.item(0);
- assertEquals("attribute local name was not as expected", "local", attribute.getLocalName());
- }
-
- public void testNamespaceURIOnCreation() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Attr attr = model.getDocument().createAttribute("simple");
- assertNull("namespace was found", attr.getNamespaceURI());
-
- Attr attr2 = model.getDocument().createAttributeNS("http://lorem.ipsum", "complex");
- assertEquals("attribute namespace URI was not as expected", "http://lorem.ipsum", attr2.getNamespaceURI());
- Attr attr3 = model.getDocument().createAttributeNS(null, "complex");
- assertEquals("attribute namespace URI was not as expected", null, attr3.getNamespaceURI());
- }
-
- public void testNullAttributeValue() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Attr attribute = model.getDocument().createAttribute("attr");
- try {
- attribute.setNodeValue(null);
- } catch (NullPointerException npe) {
- fail("Setting a null node value caused a NullPointerException.");
- }
- }
-}
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/ElementImplTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/ElementImplTests.java
deleted file mode 100644
index a36fccb8d..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/ElementImplTests.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.tests.dom;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Element;
-
-public class ElementImplTests extends TestCase {
-
- private static final String contents = "<elementPrefix:localName attrPrefix:local='lorem' xmlns:elementPrefix='urn:prefix' xmlns:attributePrefix='urn:attribute:prefix' />"; //$NON-NLS-1$
-
- public ElementImplTests() {
- }
-
- public ElementImplTests(String name) {
- super(name);
- }
-
- public void testElementImplPrefix() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element documentElement = model.getDocument().getDocumentElement();
- assertNotNull("no document element found", documentElement);
- assertEquals("attribute prefix was not as expected", "elementPrefix", documentElement.getPrefix());
- }
-
- public void testElementImplLocalName() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element documentElement = model.getDocument().getDocumentElement();
- assertNotNull("no document element found", documentElement);
- assertEquals("attribute local name was not as expected", "localName", documentElement.getLocalName());
- }
-
- public void testAttrBasedElementNamespace() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element documentElement = model.getDocument().getDocumentElement();
- assertNotNull("no document element found", documentElement);
- assertNotNull("Namespace was not found.", documentElement.getNamespaceURI());
- String namespace = documentElement.getNamespaceURI();
- assertEquals("attribute local name was not as expected", "urn:prefix", namespace);
- }
-
- public void testNamespaceURIOnCreation() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(contents);
-
- Element element = model.getDocument().createElement("simple");
- assertNull("namespace was found", element.getNamespaceURI());
-
- Element element2 = model.getDocument().createElementNS("http://lorem.ipsum", "complex");
- assertEquals("attribute namespace URI was not as expected", "http://lorem.ipsum", element2.getNamespaceURI());
- Element element3 = model.getDocument().createElementNS(null, "complex");
- assertEquals("attribute namespace URI was not as expected", null, element3.getNamespaceURI());
- }
-}
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NameValidatorTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NameValidatorTests.java
deleted file mode 100644
index 0e28c6781..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NameValidatorTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.tests.dom;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-
-public class NameValidatorTests extends TestCase {
-
- private int nTrials = 100;
-
- public NameValidatorTests(String name) {
- super(name);
- }
-
- private void doTest(int testNumber, String testString, Boolean expectedValidity) {
-// System.out.println();
- boolean isValid = NameValidator.isValid(testString);
- assertEquals("testNumber: " + testNumber, expectedValidity.booleanValue(), isValid);
-// System.out.println();
- }
-
- public void testIsValid() {
- Object[][] testees = new Object[][]{
- {"initial",Boolean.TRUE}, //0
- {"foo",Boolean.TRUE}, //1
- {"4",Boolean.FALSE}, //2
- {"9999", Boolean.FALSE}, //3
- {"f9999", Boolean.TRUE}, //4
- {"", Boolean.FALSE}, //5
- {"got space", Boolean.FALSE}, //6
- {" spacebefore", Boolean.FALSE}, //7
- {"spaceafter ", Boolean.FALSE}, //8
- {"ns:namespace", Boolean.TRUE}, //9
- {":funnyns", Boolean.TRUE}, //10
- /* ISSUE: is "endns:" really valid name */
- {"endns:", Boolean.TRUE}, //11
- {"us_underscore", Boolean.TRUE}, //12
- {"_underscore", Boolean.TRUE}, //13
- {"underscore_", Boolean.TRUE}, //14
- {"averylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersizeaverylongnamethatshouldgooverbuffersize", Boolean.TRUE}, //15
- {"<bracket", Boolean.FALSE}, //16
- {"bracket<", Boolean.FALSE}, //17
- {"bracket", Boolean.TRUE}, //18
- {"per.iod", Boolean.TRUE}, //19
- };
- for (int i = 0; i < testees.length; i++) {
- for (int j = 0; j < nTrials; j++) {
- doTest(i, (String)testees[i][0], (Boolean) testees[i][1]);
- }
- }
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeContainerTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeContainerTests.java
deleted file mode 100644
index 94509573c..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeContainerTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.tests.dom;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class NodeContainerTests extends TestCase {
-
- private static final String CONTENT_1 = "<root><a id='a'></a></root>";
- private static final String CONTENT_2 = "<root><a id='a'><b id='b'></b></a></root>";
-
- /**
- * Default Constructor
- */
- public NodeContainerTests() {
- super("Test NodeContainer");
- }
-
- /**
- * Constructor
- *
- * @param name the name of this test run
- */
- public NodeContainerTests(String name) {
- super(name);
- }
-
- public void testAppendValidChild() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(CONTENT_1);
-
- IDOMDocument doc = model.getDocument();
-
- Element a = doc.getElementById("a");
- assertNotNull("Could not find element with id 'a' in " + CONTENT_1, a);
-
- Element b = doc.createElement("b");
- b.setAttribute("id", "b");
-
- try {
- a.appendChild(b);
- } catch (DOMException e) {
- fail("Should have been able to append " + b + " as a child of " + a);
- }
- }
-
- public void testAppendParentAsChildOfChild() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- model.getStructuredDocument().set(CONTENT_2);
-
- IDOMDocument doc = model.getDocument();
-
- Element a = doc.getElementById("a");
- assertNotNull("Could not find element with id 'a' in " + CONTENT_2, a);
-
- Element b = doc.getElementById("b");
- assertNotNull("Could not find element with id 'b' in " + CONTENT_2, b);
-
- boolean threwException = false;
- try {
- b.appendChild(a);
- } catch (DOMException e) {
- assertEquals("Wrong type of exception was thrown: " + e, DOMException.HIERARCHY_REQUEST_ERR, e.code);
- threwException = true;
- }
-
- assertTrue("A DOMException with code HIERARCHY_REQUEST_ERR should have been thrown when appending a parent to its own child", threwException);
- }
-
-}
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeListImplTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeListImplTests.java
deleted file mode 100644
index 9fec6ca9d..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/NodeListImplTests.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.core.tests.dom;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.document.NodeListImpl;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public class NodeListImplTests extends TestCase {
-
- private static class AccessorNodeList extends NodeListImpl {
- public Node appendNode(Node node) {
- return super.appendNode(node);
- }
-
- public Node insertNode(Node node, int index) {
- return super.insertNode(node, index);
- }
-
- public Node removeNode(int index) {
- return super.removeNode(index);
- }
-
- }
-
- public NodeListImplTests() {
- }
-
- public NodeListImplTests(String name) {
- super(name);
- }
-
- public void testInsertAtIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- assertEquals("non-zero length at start", 0, list.getLength());
-
- list.appendNode(document.createElement("test0"));
- list.appendNode(document.createElement("test1"));
- list.appendNode(document.createElement("test2"));
- list.appendNode(document.createElement("test3"));
- list.appendNode(document.createElement("test4"));
- list.appendNode(document.createElement("test5"));
- list.appendNode(document.createElement("test6"));
-
- list.insertNode(document.createElement("test"), 3);
-
- assertEquals("list size did not increment", 8, list.getLength());
-
- assertEquals("test0 was not at expected index", "test0", list.item(0).getLocalName());
- assertEquals("test1 was not at expected index", "test1", list.item(1).getLocalName());
- assertEquals("test2 was not at expected index", "test2", list.item(2).getLocalName());
- assertEquals("test was not at expected index", "test", list.item(3).getLocalName());
- assertEquals("test3 was not at expected index", "test3", list.item(4).getLocalName());
- assertEquals("test4 was not at expected index", "test4", list.item(5).getLocalName());
- assertEquals("test5 was not at expected index", "test5", list.item(6).getLocalName());
- assertEquals("test6 was not at expected index", "test6", list.item(7).getLocalName());
- }
-
- public void testRemoveFromIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- list.appendNode(document.createElement("test0"));
- list.appendNode(document.createElement("test1"));
- list.appendNode(document.createElement("test2"));
- list.appendNode(document.createElement("test3"));
- list.appendNode(document.createElement("test4"));
- list.appendNode(document.createElement("test5"));
- list.appendNode(document.createElement("test6"));
- assertEquals("wrong length after setup", 7, list.getLength());
-
- Node excised = list.removeNode(3);
- assertEquals("test3 was not the one removed", "test3", excised.getLocalName());
-
- assertEquals("wrong length after removal", 6, list.getLength());
- assertEquals("test0 was not at expected index", "test0", list.item(0).getLocalName());
- assertEquals("test1 was not at expected index", "test1", list.item(1).getLocalName());
- assertEquals("test2 was not at expected index", "test2", list.item(2).getLocalName());
- assertEquals("test4 was not at expected index", "test4", list.item(3).getLocalName());
- assertEquals("test5 was not at expected index", "test5", list.item(4).getLocalName());
- assertEquals("test6 was not at expected index", "test6", list.item(5).getLocalName());
- }
-
- public void testInsertAtNegativeIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- // appends on bad value
- list.insertNode(document.createElement("test-1"),-1);
- assertEquals("wrong length after insert at negative index", 1, list.getLength());
- }
-
- public void testRemoveFromNegativeIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- list.appendNode(document.createElement("test-1"));
- // ignores bad index
- list.removeNode(-1);
- assertEquals("wrong length after removal at negative index", 1, list.getLength());
- }
-
- public void testInsertAtExcessiveIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- // appends on bad value
- list.insertNode(document.createElement("test3"), 3);
- assertEquals("wrong length after insert at out of bounds index", 1, list.getLength());
- }
-
- public void testRemoveFromExcessiveIndex() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- list.appendNode(document.createElement("test0"));
- // ignores bad index
- list.removeNode(3);
- assertEquals("wrong length after removal at nonexistent index", 1, list.getLength());
- }
-
- public void testAppend() {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
- Document document = model.getDocument();
-
- AccessorNodeList list = new AccessorNodeList();
-
- assertEquals("non-zero length at start", 0, list.getLength());
-
- list.appendNode(document.createElement("test1"));
- assertEquals("list size did not increment", 1, list.getLength());
-
- list.appendNode(document.createElement("test2"));
- assertEquals("list size did not increment", 2, list.getLength());
-
- list.appendNode(document.createElement("test3"));
- assertEquals("list size did not increment", 3, list.getLength());
-
- Node element4 = list.appendNode(document.createElement("test4"));
- assertEquals("list size did not increment", 4, list.getLength());
- assertEquals("test4 not returned from append", "test4", element4.getLocalName());
-
- Node element5 = list.appendNode(document.createElement("test5"));
- assertEquals("list size did not increment", 5, list.getLength());
- assertEquals("test5 not returned from append", "test5", element5.getLocalName());
-
- Node element6 = list.appendNode(document.createElement("test6"));
- assertEquals("list size did not increment", 6, list.getLength());
- assertEquals("test6 not returned from append", "test6", element6.getLocalName());
-
- Node element7 = list.appendNode(document.createElement("test7"));
- assertEquals("list size did not increment", 7, list.getLength());
- assertEquals("test7 not returned from append", "test7", element7.getLocalName());
-
- }
-}
diff --git a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/RegionChangedAdapterNotificationTests.java b/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/RegionChangedAdapterNotificationTests.java
deleted file mode 100644
index f5a26f138..000000000
--- a/tests/org.eclipse.wst.xml.core.tests/src/org/eclipse/wst/xml/core/tests/dom/RegionChangedAdapterNotificationTests.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.core.tests.dom;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.encoding.util.NullInputStream;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * Tests performance minimization of adapter notifications for RegionChanged
- * events, which would affect areas like formatting performance
- */
-public class RegionChangedAdapterNotificationTests extends TestCase {
- public RegionChangedAdapterNotificationTests() {
- this("RegionChanged Adapter Notification tests");
- }
-
- /**
- * Constructor for UpdaterTestRegionChanged.
- *
- * @param name
- */
- public RegionChangedAdapterNotificationTests(String name) {
- super(name);
- }
-
- public void testAppendWhitespaceToAttributeName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 4, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b = c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testAppendWhitespaceToEqualSign() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 5, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testAppendWhitespaceToTagName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
- ((INodeNotifier) document).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 2, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testAppendWhitespaceToAttributeValue() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 7, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c ></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testChangeAttributeName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 4, 0, "d");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("Property Changed Adapter Notification event not sent " + changed[0] + " " +structuredDocument.get(), INodeNotifier.CHANGE, changed[0]);
-
- assertEquals("unexpected document content", "<a bd= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
- public void testChangeAttributeValue() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 6, 0, "d");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("Property Changed Adapter Notification event not sent " + changed[0] + " " +structuredDocument.get(), INodeNotifier.CHANGE, changed[0]);
-
- assertEquals("unexpected document content", "<a b= dc></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
- public void testChangeTagName1() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) document).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 1, 0, "d");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertNotSame("DOM Node not replaced", before, after);
-
- assertEquals("Structure Changed notification not sent to adapter " + changed[0] + " to parent " +structuredDocument.get(), INodeNotifier.STRUCTURE_CHANGED, changed[0]);
-
- assertEquals("unexpected document content", "<da b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testChangeTagName2() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) document).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 2, 0, "d");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertNotSame("DOM Node not replaced", before, after);
-
- assertEquals("Structure Changed notification not sent to adapter " + changed[0] + " to parent " +structuredDocument.get(), INodeNotifier.STRUCTURE_CHANGED, changed[0]);
-
- assertEquals("unexpected document content", "<ad b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testChangeQuotedAttributeValue() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= \"c\"></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 7, 0, "d");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("Property Changed Adapter Notification event not sent " + changed[0] + " " +structuredDocument.get(), INodeNotifier.CHANGE, changed[0]);
-
- assertEquals("unexpected document content", "<a b= \"dc\"></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testPrependSpaceToAttributeName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 3, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testPrependSpaceToEqualSign() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 4, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b = c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testPrependSpaceToAttributeValue() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 6, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testRemoveTrailingSpaceFromEqualSign() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 5, 1, "");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b=c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
- public void testRemoveTrailingSpaceFromAttributeName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b = c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 4, 1, "");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testRemoveTrailingSpaceFromAttributeValue() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b = c ></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 8, 1, "");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b = c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testRemoveTrailingSpaceFromTagName() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
- ((INodeNotifier) document).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 2, 1, "");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testRemoveTrailingSpaceFromTagName2() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
- ((INodeNotifier) document).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 3, 1, "");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-
- public void testReplaceTrailingSpaceofEqualSignWithTwoSpaces() throws IOException {
- IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(getName() + ".xml", new NullInputStream(), null);
-
- try {
- Document document = model.getDocument();
- IStructuredDocument structuredDocument = model.getStructuredDocument();
-
- structuredDocument.setText(this, "<a b= c></a>");
-
- Node before = document.getFirstChild();
- final int[] changed = new int[]{-1};
- INodeAdapter adapter = new INodeAdapter() {
- public boolean isAdapterForType(Object type) {
- return type.equals(RegionChangedAdapterNotificationTests.class);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- changed[0] = eventType;
- }
- };
- ((INodeNotifier) before).addAdapter(adapter);
-
- Object[] originalRegions = structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray();
- StructuredDocumentEvent fmEvent = structuredDocument.replaceText(null, 5, 0, " ");
- assertTrue("Region instances changed", Arrays.equals(originalRegions, structuredDocument.getFirstStructuredDocumentRegion().getRegions().toArray()));
-
- assertTrue(fmEvent instanceof RegionChangedEvent);
-
- Node after = document.getFirstChild();
-
- assertEquals("Node replaced", before, after);
-
- assertEquals("unexpected adapter notification event sent " + structuredDocument.get(), -1, changed[0]);
-
- assertEquals("unexpected document content", "<a b= c></a>", structuredDocument.get());
- }
- finally {
- model.releaseFromEdit();
- }
- }
-}

Back to the top