Author: dgolovin
Date: 2010-03-26 17:27:07 -0400 (Fri, 26 Mar 2010)
New Revision: 21071
Added:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ErrorHandlerImpl.java
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLEntityResolver.java
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLUtilities.java
Removed:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/META-INF/MANIFEST.MF
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescription.java
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescriptionFactory.java
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
Log:
remove deps from common
Modified: branches/modular_build/tests/plugins/org.jboss.tools.tests/META-INF/MANIFEST.MF
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/META-INF/MANIFEST.MF 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/META-INF/MANIFEST.MF 2010-03-26
21:27:07 UTC (rev 21071)
@@ -9,10 +9,8 @@
org.eclipse.core.resources,
org.junit,
org.eclipse.ui.ide,
- org.jboss.tools.jst.web.kb,
org.apache.xerces;bundle-version="[2.9.0,3.0.0)",
org.junit4;bundle-version="4.5.0",
- org.jboss.tools.common;bundle-version="2.0.0",
org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
org.eclipse.text;bundle-version="3.5.0"
Bundle-ActivationPolicy: lazy
Added:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ErrorHandlerImpl.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ErrorHandlerImpl.java
(rev 0)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ErrorHandlerImpl.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.test.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+class ErrorHandlerImpl implements ErrorHandler {
+ List<String> errors = new ArrayList<String>();
+
+ public void error(SAXParseException e) throws SAXException {
+ add(e);
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException {
+ add(e);
+ throw e;
+ }
+
+ public void warning(SAXParseException e) throws SAXException {
+ add(e);
+ }
+
+ private void add(SAXParseException e) {
+ errors.add("" + e.getMessage() + ":" + e.getLineNumber() +
":" + e.getColumnNumber()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ }
Property changes on:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/ErrorHandlerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescription.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescription.java 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescription.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -12,7 +12,6 @@
import java.util.Properties;
-import org.jboss.tools.common.xml.XMLUtilities;
import org.w3c.dom.Element;
/**
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescriptionFactory.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescriptionFactory.java 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestDescriptionFactory.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -18,8 +18,6 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
-import org.jboss.tools.common.xml.XMLEntityResolver;
-import org.jboss.tools.common.xml.XMLUtilities;
import org.w3c.dom.Element;
/**
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/TestProjectProvider.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -29,7 +29,6 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.jboss.tools.common.util.FileUtil;
/**
* Test plugins may define test projects to be added
Added:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLEntityResolver.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLEntityResolver.java
(rev 0)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLEntityResolver.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -0,0 +1,106 @@
+/*
+ * XMLEntityResolver.java
+ * Created on February 21, 2003, 9:38 AM
+ */
+
+package org.jboss.tools.test.util;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author valera
+ */
+public class XMLEntityResolver implements EntityResolver {
+
+ private static final Properties publicEntities = new Properties();
+ private static final Properties systemEntities = new Properties();
+
+ public static void registerPublicEntity(String publicId, String url) {
+ publicEntities.setProperty(publicId, url);
+ }
+
+ public static void registerPublicEntity(String publicId, Class<?> loader,
String resourceName) throws IOException {
+ URL url = resolve(loader, resourceName);
+ if(url != null) {
+ registerPublicEntity(publicId, url.toString());
+ }
+ }
+
+ public static void registerSystemEntity(String systemId, String url) {
+ systemEntities.setProperty(systemId, url);
+ }
+
+ public static void registerSystemEntity(String systemId, Class<?> loader,
String resourceName) throws IOException {
+ URL url = resolve(loader, resourceName);
+ if(url != null) {
+ registerSystemEntity(systemId, url.toString());
+ }
+ }
+
+ static URL resolve(Class<?> loader, String resourceName) throws IOException {
+ URL url = loader.getResource(resourceName);
+ return (url == null) ? null : FileLocator.resolve(url);
+ }
+
+ public static XMLEntityResolver getInstance() {
+ return new XMLEntityResolver();
+ }
+
+ boolean deactivate = true;
+
+ private XMLEntityResolver() {}
+
+ public void setDeactivate(boolean b) {
+ deactivate = b;
+ }
+
+ public boolean isResolved(String publicId, String systemId) {
+ if (publicId != null) {
+ String url = publicEntities.getProperty(publicId);
+ if (url != null) {
+ return true;
+ }
+ } else if (systemId != null) {
+ String url = systemEntities.getProperty(systemId);
+ if (url != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, java.io.IOException {
+ InputSource source = null;
+ boolean ok = false;
+ if (publicId != null) {
+ String url = publicEntities.getProperty(publicId);
+ if (url != null) {
+ source = new InputSource(url);
+ source.setPublicId(publicId);
+ ok = true;
+ }
+ }
+ if (!ok && systemId != null) {
+ String url = systemEntities.getProperty(systemId);
+ if (url != null) {
+ source = new InputSource(url);
+ source.setSystemId(systemId);
+ }
+ }
+
+ if(deactivate && (systemId != null) && (source == null) &&
(systemId.toLowerCase().endsWith(".dtd"))) { // this deactivates DTD
//$NON-NLS-1$
+ source = new InputSource(new ByteArrayInputStream("<?xml version='1.0'
encoding='UTF-8'?>".getBytes())); //$NON-NLS-1$
+ }
+
+ return source;
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLEntityResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLUtilities.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLUtilities.java
(rev 0)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLUtilities.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -0,0 +1,414 @@
+package org.jboss.tools.test.util;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xml.serialize.LineSeparator;
+import org.apache.xml.serialize.Method;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XMLUtilities {
+
+ public static boolean hasAttribute(Element e, String s) {
+ return e.getAttributes().getNamedItem(s) != null;
+ }
+
+ public static Element[] getChildren(Element parent, String name){
+ ArrayList<Element> al = new ArrayList<Element>();
+ NodeList nl = parent.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++){
+ Node n = nl.item(i);
+ if(n.getNodeType() == Node.ELEMENT_NODE &&
+ n.getNodeName().equals(name)) {
+ al.add((Element)n);
+ }
+ }
+ return al.toArray(new Element[0]);
+ }
+
+ public static Element getUniqueChild(Element parent, String name){
+ Element[] e = getChildren(parent, name);
+ return (e.length == 0) ? null : e[0];
+ }
+
+ public static Element getFirstChild(Element parent, String name) {
+ NodeList nl = parent.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++){
+ Node n = nl.item(i);
+ if(n.getNodeType() == Node.ELEMENT_NODE &&
+ n.getNodeName().equals(name)) {
+ return (Element)n;
+ }
+ }
+ return null;
+ }
+
+ public static Element getLastChild(Element parent, String name) {
+ Element child = null;
+ NodeList nl = parent.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++){
+ Node n = nl.item(i);
+ if(n.getNodeType() == Node.ELEMENT_NODE &&
+ n.getNodeName().equals(name)) {
+ child = (Element)n;
+ }
+ }
+ return child;
+ }
+
+ public static Element[] getAncestors(Element parent, String name) {
+ int i = name.indexOf('.');
+ if(i < 0) {
+ return getChildren(parent, name);
+ }
+ Element p = getUniqueChild(parent, name.substring(0, i));
+ return (p == null) ? new Element[0] : getAncestors(p, name.substring(i + 1));
+ }
+
+ public static Element createElement(Element parent, String path) {
+ int i = path.indexOf('.');
+ if(i < 0) {
+ Element element = parent.getOwnerDocument().createElement(path);
+ parent.appendChild(element);
+ return element;
+ }
+ String p = path.substring(0, i), c = path.substring(i + 1);
+ Element pe = getUniqueChild(parent, p);
+ if(pe == null) {
+ pe = parent.getOwnerDocument().createElement(p);
+ parent.appendChild(pe);
+ }
+ return createElement(pe, c);
+ }
+
+ public static DocumentBuilder createDocumentBuilder() {
+ return createDocumentBuilder(false);
+ }
+
+ public static DocumentBuilder createDocumentBuilder(boolean validate) {
+ try {
+ DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
+ if (validate) {
+ f.setValidating(validate);
+ }
+ // / f.setExpandEntityReferences(false);
+ DocumentBuilder d = f.newDocumentBuilder();
+ if (!validate) {
+ d.setEntityResolver(EMPTY_RESOLVER);
+ }
+ d.setErrorHandler(new ErrorHandlerImpl());
+ return d;
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static final EntityResolver EMPTY_RESOLVER = createEmptyEntityResolver();
+
+
+
+ public static Element createDocumentElement(String name) {
+ Document d = createDocumentBuilder().newDocument();
+ Element de = d.createElement(name);
+ d.appendChild(de);
+ return de;
+ }
+
+ public static EntityResolver createEmptyEntityResolver() {
+ return new EntityResolver() {
+ public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
throws SAXException, java.io.IOException {
+ if((systemId != null) && systemId.toLowerCase().endsWith(".dtd")) {
// this deactivates DTD //$NON-NLS-1$
+ return new InputSource(new ByteArrayInputStream("<?xml version='1.0'
encoding='UTF-8'?>".getBytes())); //$NON-NLS-1$
+ } else {
+ return null;
+ }
+ }
+ };
+ }
+
+ public static Element createDocumentElement(String name, String qName, String publicId,
String systemId, String namespaceURI) {
+ Document d = null;
+ try {
+ DOMImplementation domImpl = createDocumentBuilder().getDOMImplementation();
+ DocumentType docType = domImpl.createDocumentType(qName, publicId,
systemId);
+ d = domImpl.createDocument(namespaceURI, name, docType);
+ } catch (DOMException e) {
+ return null;
+ }
+ Element de = d.getDocumentElement();
+ if (de == null) {
+ de = d.createElement(name);
+ d.appendChild(de);
+ }
+ return de;
+ }
+
+ public static Element getElement(String filename, EntityResolver resolver) {
+ return getElement(new File(filename), resolver);
+ }
+
+ public static Element getElement(File file, EntityResolver resolver) {
+ if(file == null || !file.isFile()) {
+ return null;
+ }
+ java.io.FileReader fr = null;
+ try {
+ fr = new java.io.FileReader(file);
+ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(fr);
+ return getElement(inSource, resolver);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (fr != null) {
+ fr.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ public static Element getElement(Reader reader, EntityResolver resolver) {
+ Document d = getDocument(reader, resolver);
+ return (d == null) ? null : d.getDocumentElement();
+ }
+
+ public static Document getDocument(Reader reader, EntityResolver resolver) {
+ try {
+ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
+ return getDocument(inSource, resolver);
+ } catch (SAXException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public static Element getElement(InputStream is, EntityResolver resolver) {
+ try {
+ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(is);
+ return getElement(inSource, resolver);
+ } catch (SAXException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public static Element getElement(InputSource is, EntityResolver resolver) throws
SAXException, IOException {
+ return getDocument(is, resolver).getDocumentElement();
+ }
+
+ public static Document getDocument(InputSource is, EntityResolver resolver) throws
SAXException, IOException{
+ DocumentBuilder builder = createDocumentBuilder(false);
+ if(resolver != null) {
+ builder.setEntityResolver(resolver);
+ }
+ return builder.parse(is);
+ }
+
+ public static String[] getXMLErrors(Reader reader, EntityResolver resolver) {
+ return getXMLErrors(reader, true, resolver);
+ }
+
+ public static String[] getXMLErrors(Reader reader, boolean checkDTD, EntityResolver
resolver) {
+ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
+ return getXMLErrors(inSource, checkDTD, resolver);
+ }
+
+ public static String[] getXMLErrors(org.xml.sax.InputSource is, EntityResolver resolver)
{
+ return getXMLErrors(is, true, resolver);
+ }
+
+ public static String[] getXMLErrors(org.xml.sax.InputSource is, boolean checkDTD,
EntityResolver resolver) {
+ ErrorHandlerImpl h = new ErrorHandlerImpl();
+ try {
+ DocumentBuilder builder = createDocumentBuilder(checkDTD);
+ if(resolver != null) {
+ builder.setEntityResolver(resolver);
+ }
+ builder.setErrorHandler(h);
+ builder.parse(is);
+ } catch (IOException e) {
+ if(h.errors.isEmpty()) {
+ return new String[]{e.getMessage()+":0:0",e.toString()}; //$NON-NLS-1$
+ }
+ } catch (SAXException e) {
+ if(h.errors.isEmpty()) {
+ return new String[]{e.getMessage()+":0:0",e.toString()}; //$NON-NLS-1$
+ }
+ }
+ return h.errors.toArray(new String[0]);
+ }
+
+ public static final void serialize(Element element, String filename) throws
IOException {
+ File f = new File(filename);
+ if(f.exists() && !f.canWrite()) {
+ return;
+ }
+ if(!f.exists()) {
+ f.createNewFile();
+ }
+ FileWriter fw = new FileWriter(f);
+ serialize(element, new BufferedWriter(fw));
+ fw.close();
+ }
+ static final String ENCODING = "encoding=\""; //$NON-NLS-1$
+ static final String UTF8 = "UTF-8"; //$NON-NLS-1$
+
+ public static String getEncoding(String body) {
+ int i = body.indexOf(ENCODING);
+ if(i < 0) {
+ return UTF8;
+ }
+ i = i + ENCODING.length();
+ int j = body.indexOf('"', i);
+ if(j < 0) {
+ return UTF8;
+ }
+ return body.substring(i, j);
+
+ }
+ public static OutputFormat createOutputFormat(String encoding) {
+ OutputFormat format = new OutputFormat(Method.XML, encoding == null ||
encoding.length() == 0?null:encoding, true);
+ format.setLineSeparator(System.getProperty("line.separator",
LineSeparator.Web)); //$NON-NLS-1$
+ format.setIndent(1);
+ return format;
+ }
+
+ public static final boolean serialize(Element element, Writer w) throws IOException
{
+ if(element == null) {
+ return false;
+ }
+ serialize(element, new XMLSerializer(w, createOutputFormat(UTF8)));
+ w.close();
+ return true;
+ }
+
+ public static final boolean serialize(Element element, OutputStream w) throws
IOException {
+ if(element == null) {
+ return false;
+ }
+ serialize(element, new XMLSerializer(w, createOutputFormat(UTF8)));
+ w.close();
+ return true;
+ }
+
+ public static void serialize(Element element, XMLSerializer serial) throws
IOException {
+ serial.asDOMSerializer();
+ serial.serialize(element);
+ }
+
+ public static void serialize(Document document, XMLSerializer serial) throws
IOException {
+ if(serial == null || document == null) {
+ return;
+ }
+ serial.asDOMSerializer();
+ serial.serialize(document);
+ }
+
+ public static final boolean serialize(Document document, Writer w) throws IOException
{
+ return serialize(document, w, null);
+ }
+
+ public static final boolean serialize(Document document, Writer w, String encoding)
throws IOException {
+ if(document == null) {
+ return false;
+ }
+ serialize(document, new XMLSerializer(w, createOutputFormat(encoding)));
+ w.close();
+ return true;
+ }
+
+ public static final String getCDATA(Element elem) {
+ return getCDATA(elem, true);
+ }
+
+ public static final String getCDATA(Element elem, boolean trim) {
+ StringBuffer sb = new StringBuffer();
+ NodeList nl = elem.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node nc = nl.item(i);
+ if (nc.getNodeType() == Node.CDATA_SECTION_NODE) {
+ sb.append(((Text) nc).getData());
+ } else if (nc.getNodeType() == Node.TEXT_NODE) {
+ String txt = ((Text) nc).getData();
+ if(trim) {
+ txt = txt.trim();
+ }
+ sb.append(txt);
+ }
+ }
+ return sb.toString();
+ }
+
+ public static final String getComment(Element elem) {
+ StringBuffer sb = new StringBuffer();
+ Node node = elem.getPreviousSibling();
+ while (node != null) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ break;
+ }
+ if (node.getNodeType() == Node.COMMENT_NODE) {
+ if (sb.length() > 0) {
+ sb.insert(0, '\n');
+ sb.insert(0, ((Comment) node).getData());
+ } else {
+ sb.append(((Comment) node).getData());
+ }
+ }
+ node = node.getPreviousSibling();
+ }
+ return sb.toString();
+ }
+
+ public static final void setCDATA(Element element, String data) {
+ element.appendChild(element.getOwnerDocument().createCDATASection(
+ data!=null?data:"")); //$NON-NLS-1$
+ }
+
+ public static final void setText(Element element, String data) {
+ element.appendChild(element.getOwnerDocument().createTextNode(
+ data!=null?data:"")); //$NON-NLS-1$
+ }
+
+ public static final void setComment(Element element, String data) {
+ Comment comm = element.getOwnerDocument().createComment(
+ data!=null?data:""); //$NON-NLS-1$
+ element.getParentNode().insertBefore(comm, element);
+ }
+
+}
Property changes on:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/util/XMLUtilities.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractRefactorTest.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -1,144 +0,0 @@
-package org.jboss.tools.tests;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.test.util.JobUtils;
-
-public class AbstractRefactorTest extends TestCase{
-
- public AbstractRefactorTest(String name){
- super(name);
- }
-
- protected void checkRename(RenameProcessor processor, List<TestChangeStructure>
changeList) throws CoreException{
- JobUtils.waitForIdle(2000);
-
- // Test before renaming
- for(TestChangeStructure changeStructure : changeList){
- IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
- String content = null;
- try {
- content = FileUtil.readStream(file);
- } catch (CoreException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- for(TestTextChange change : changeStructure.getTextChanges()){
- assertNotSame(change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
- }
- }
-
- // Rename
- processor.checkInitialConditions(new NullProgressMonitor());
- processor.checkFinalConditions(new NullProgressMonitor(), null);
- CompositeChange rootChange = (CompositeChange)processor.createChange(new
NullProgressMonitor());
-
- assertEquals("There is unexpected number of changes",changeList.size(),
rootChange.getChildren().length);
-
- for(int i = 0; i < rootChange.getChildren().length;i++){
- TextFileChange fileChange = (TextFileChange)rootChange.getChildren()[i];
-
- MultiTextEdit edit = (MultiTextEdit)fileChange.getEdit();
-
- TestChangeStructure change = findChange(changeList, fileChange.getFile());
- if(change != null){
- assertEquals(change.size(), edit.getChildrenSize());
- }
- }
-
- rootChange.perform(new NullProgressMonitor());
- JobUtils.waitForIdle(2000);
-
-
- // Test results
- for(TestChangeStructure changeStructure : changeList){
- IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
- String content = null;
- content = FileUtil.readStream(file);
- for(TestTextChange change : changeStructure.getTextChanges()){
- assertEquals("There is unexpected change in resource -
"+file.getName(),change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
- }
- }
- }
-
-
- protected TestChangeStructure findChange(List<TestChangeStructure> changeList,
IFile file){
- for(TestChangeStructure tcs : changeList){
- if(tcs.getFileName().equals("/"+file.getFullPath().removeFirstSegments(1).toString()))
- return tcs;
- }
- return null;
- }
-
-
- public class TestChangeStructure{
- private IProject project;
- private String fileName;
- ArrayList<TestTextChange> textChanges = new ArrayList<TestTextChange>();
-
-
- public TestChangeStructure(IProject project, String fileName){
- this.project = project;
- this.fileName = fileName;
- }
-
- public IProject getProject(){
- return project;
- }
-
- public String getFileName(){
- return fileName;
- }
-
- public ArrayList<TestTextChange> getTextChanges(){
- return textChanges;
- }
-
- public void addTextChange(TestTextChange change){
- textChanges.add(change);
- }
-
- public int size(){
- return textChanges.size();
- }
-
- }
-
- public class TestTextChange{
- private int offset;
- private int length;
- private String text;
-
- public TestTextChange(int offset, int length, String text){
- this.offset = offset;
- this.length = length;
- this.text = text;
- }
-
- public int getOffset(){
- return offset;
- }
-
- public int getLength(){
- return length;
- }
-
- public String getText(){
- return text;
- }
- }
-
-}
Modified:
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
===================================================================
---
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2010-03-26
20:59:26 UTC (rev 21070)
+++
branches/modular_build/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2010-03-26
21:27:07 UTC (rev 21071)
@@ -18,7 +18,6 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.jboss.tools.jst.web.kb.validation.IValidator;
import org.jboss.tools.test.util.JUnitUtils;
/**
@@ -216,7 +215,7 @@
int length = markers.length;
for (int i = 0; i < markers.length; i++) {
String groupName = markers[i].getAttribute("groupName", null);
- if(groupName==null || (!groupName.equals(messageGroup) &&
!groupName.equals(IValidator.MARKED_RESOURCE_MESSAGE_GROUP))) {
+ if(groupName==null || (!groupName.equals(messageGroup) &&
!groupName.equals("markedKbResource"))) {
length--;
}
}