diff options
Diffstat (limited to 'tests/org.eclipse.wst.sse.core.tests/src/org')
26 files changed, 0 insertions, 2016 deletions
diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/ExistenceTest.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/ExistenceTest.java deleted file mode 100644 index b19ccdca5..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/ExistenceTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.eclipse.wst.sse.core.tests; - - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.SSECorePlugin; - - -public class ExistenceTest extends TestCase { - - public void testPluginExists(){ - assertNotNull(SSECorePlugin.getDefault()); - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/Logger.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/Logger.java deleted file mode 100644 index e2d6efc82..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/Logger.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests; - -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -/** - * Small convenience class to log messages to plugin's log file and also, if desired, - * the console. This class should only be used by classes in this plugin. Other - * plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.sse.core.tests"; //$NON-NLS-1$ - - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - - public static final int OK = IStatus.OK; // 0 - public static final int INFO = IStatus.INFO; // 1 - public static final int WARNING = IStatus.WARNING; // 2 - public static final int ERROR = IStatus.ERROR; // 4 - - public static final int OK_DEBUG = 200 + OK; - public static final int INFO_DEBUG = 200 + INFO; - public static final int WARNING_DEBUG = 200 + WARNING; - public static final int ERROR_DEBUG = 200 + ERROR; - - /** - * Adds message to log. - * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message text to add to the log - * @param exception exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) - return; - } - - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG : - case INFO : - severity = IStatus.INFO; - break; - case WARNING_DEBUG : - case WARNING : - severity = IStatus.WARNING; - break; - case ERROR_DEBUG : - case ERROR : - severity = IStatus.ERROR; - } - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * @param message text to print - * @param category category of the message, to be compared with /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - /** - * Determines if currently tracing a category - * @param category - * @return true if tracing category, false otherwise - */ - public static boolean isTracing(String category) { - if (!isDebugging()) - return false; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - return true; - } - } - } - return false; - } - - public static void log(int level, String message) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestSuite.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestSuite.java deleted file mode 100644 index 843cb4040..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestSuite.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.wst.sse.core.tests.events.TestAboutToBeChangedEvent; -import org.eclipse.wst.sse.core.tests.events.TestNewDocumentContentEvent; -import org.eclipse.wst.sse.core.tests.events.TestNewDocumentEvent; -import org.eclipse.wst.sse.core.tests.events.TestNoChangeEvent; -import org.eclipse.wst.sse.core.tests.events.TestRegionChangedEvent; -import org.eclipse.wst.sse.core.tests.events.TestRegionsReplacedEvent; -import org.eclipse.wst.sse.core.tests.events.TestStructuredDocumentRegionsReplacedEvent; - - -public class SSEModelTestSuite extends TestSuite { - - /** - * to get picked up by BVT - * - * @return - */ - public static Test suite() { - return new SSEModelTestSuite(); - } - - // not ready for threaded tests, yet. - // private static Class[] classes = new - // Class[]{TestOfThreadLocalImprovement.class, - // TestOfThreadLocalWithChanges.class, TestCreation.class}; - - // private static Class[] classes = new Class[]{TestCreation.class, - // TestDocumentReader.class}; - // private static Class[] classes = new Class[]{TestCreation.class, - // TestDocumentReader.class, TestCharSequenceReader.class, - // TestRegionMatches.class}; - - private static Class[] classes = new Class[]{ExistenceTest.class, TestNewDocumentContentEvent.class, TestAboutToBeChangedEvent.class, TestNewDocumentEvent.class, TestNoChangeEvent.class, TestRegionChangedEvent.class,TestRegionsReplacedEvent.class,TestStructuredDocumentRegionsReplacedEvent.class}; - - public SSEModelTestSuite() { - super("SSE Model Basic Test Suite"); - for (int i = 0; i < classes.length; i++) { - addTest(new TestSuite(classes[i], classes[i].getName())); - } - } - - public SSEModelTestSuite(Class theClass, String name) { - super(theClass, name); - } - - public SSEModelTestSuite(Class theClass) { - super(theClass); - } - - public SSEModelTestSuite(String name) { - super(name); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestsPlugin.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestsPlugin.java deleted file mode 100644 index bbd670d4c..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/SSEModelTestsPlugin.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Plugin; - -/** - * The main plugin class to be used in the desktop. - */ -public class SSEModelTestsPlugin extends Plugin { - //The shared instance. - private static SSEModelTestsPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public SSEModelTestsPlugin() { - super(); - plugin = this; - try { - resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.sse.core.tests.TestsPluginResources"); - } - catch (MissingResourceException x) { - resourceBundle = null; - } - } - - /** - * Returns the shared instance. - */ - public static SSEModelTestsPlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = SSEModelTestsPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null ? bundle.getString(key) : key); - } - catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/TestAbstractAdapterFactory.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/TestAbstractAdapterFactory.java deleted file mode 100644 index ee942f041..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/TestAbstractAdapterFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.eclipse.wst.sse.core.tests; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; - -/** - * - * @author pavery - */ -public class TestAbstractAdapterFactory extends TestCase { - - private AbstractAdapterFactory fFactory = null; - - class MyClass implements INodeAdapter { - public boolean isAdapterForType(Object type) { - return type instanceof MyClass; - } - public void notifyChanged(INodeNotifier notifier,int eventType,Object changedFeature,Object oldValue,Object newValue,int pos) { - // noop - } - } - - protected void setUp() throws Exception { - super.setUp(); - setUpAdapterFactory(); - } - - private void setUpAdapterFactory() { - fFactory = new AbstractAdapterFactory(TestAbstractAdapterFactory.MyClass.class, false) { - protected INodeAdapter createAdapter(INodeNotifier target) { - return new MyClass(); - } - }; - } - - public void testAdapt() { - fFactory.adapt(null); - } - -// public void testAdaptNew() { -// fFactory.adaptNew(null); -// } - -// public void testCopy() { -// AdapterFactory f = fFactory.copy(); -// assertNotNull(f); -// } - - public void testCreate() { - // TODO: create unit test - - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterFactoryTestOnly.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterFactoryTestOnly.java deleted file mode 100644 index a8c3993a8..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterFactoryTestOnly.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.adaptdom; - -import java.util.Iterator; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - - -/** - * This class exists only to satisfy some of the unit tests. - * - * To test, use following line in client, such as when it intitialized. - * FactoryRegistry.getFactoryRegistry().addFactory(new - * AdapterFactoryTestOnly()); - * - * Creation date: (11/14/00 7:08:18 PM) - * - * @author: David Williams - */ -public class AdapterFactoryTestOnly implements INodeAdapterFactory { - // This factory deals with three adapters - java.util.List adapters = new java.util.ArrayList(); - - /** - * CAAdapterFactory constructor. - */ - public AdapterFactoryTestOnly() { - super(); - adapters.add(new AdapterForDocumentTestOnly()); - adapters.add(new AdapterForElementTestOnly()); - adapters.add(new AdapterForAttrTestOnly()); - } - - /** - * Method that returns the adapter associated with the this factory and - * the given object, and "sets up" the adaptable object to use the - * adapter. - * - * The adapter may be a singleton or not ... depending on the needs of the - * INodeAdapter ... but in general it is recommended for an adapter to be - * stateless, so the efficiencies of a singleton can be gained. - * - * The implementation of this method should call addAdapter on the adapted - * object with the correct instance of the adapter. - */ - public INodeAdapter adapt(INodeNotifier target) { - // object.addAdapter(adapterInstance); - // return adapterInstance; - INodeAdapter result = null; - - Iterator adaptersList = adapters.iterator(); - while (adaptersList.hasNext()) { - INodeAdapter adapter = (INodeAdapter) adaptersList.next(); - if (adapter.isAdapterForType(target)) { - INodeAdapter existingAdapter = target.getExistingAdapter(adapter); - if (existingAdapter == null) { - target.addAdapter(adapter); - result = adapter; - } - } - } - - return result; - - } - - /** - * isFactoryForType method comment. - */ - public boolean isFactoryForType(java.lang.Object type) { - boolean result = false; - - // for now, one adapter for documents, elements, and attr. - // - if (type instanceof Document) { - result = true; - } - else { - if (type instanceof Element) { - result = true; - } - else { - if (type instanceof Attr) { - result = true; - } - } - } - - return result; - } - - /** - * - */ - public void release() { - // TODO: create unit test - - } - - public INodeAdapterFactory copy() { - return new AdapterFactoryTestOnly(); - } - -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForAttrTestOnly.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForAttrTestOnly.java deleted file mode 100644 index e86b84cc0..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForAttrTestOnly.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.adaptdom; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.w3c.dom.Attr; - - -/** - * Insert the type's description here. Creation date: (1/9/01 3:37:01 PM) - * - * @author: David Williams - */ -public class AdapterForAttrTestOnly implements INodeAdapter { - /** - * CAAdapterTestOnly constructor comment. - */ - public AdapterForAttrTestOnly() { - super(); - } - - /** - * Allowing the INodeAdapter to compare itself against the type allows it - * to return true in more than one case. - */ - public boolean isAdapterForType(Object type) { - boolean result = false; - if (type instanceof Attr) { - result = true; - } - return result; - } - - /** - */ - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { - System.out.println("INodeAdapter AdapterForAttrTestOnly " + this.hashCode() + " has been notified of " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " (when " + notifier + " notified it)"); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForDocumentTestOnly.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForDocumentTestOnly.java deleted file mode 100644 index f8875c927..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForDocumentTestOnly.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.adaptdom; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.w3c.dom.Document; - - -/** - * Insert the type's description here. Creation date: (1/9/01 3:37:01 PM) - * - * @author: David Williams - */ -public class AdapterForDocumentTestOnly implements INodeAdapter { - /** - * CAAdapterTestOnly constructor comment. - */ - public AdapterForDocumentTestOnly() { - super(); - } - - /** - * Allowing the INodeAdapter to compare itself against the type allows it - * to return true in more than one case. - */ - public boolean isAdapterForType(Object type) { - boolean result = false; - if (type instanceof Document) { - result = true; - } - return result; - } - - /** - */ - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { - System.out.println("INodeAdapter AdapterForDocumentTestOnly " + this.hashCode() + " has been notified of " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " (when " + notifier + " notified it)"); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForElementTestOnly.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForElementTestOnly.java deleted file mode 100644 index 0781564f6..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/adaptdom/AdapterForElementTestOnly.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.adaptdom; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.w3c.dom.Element; - - -/** - * Insert the type's description here. Creation date: (1/9/01 3:37:01 PM) - * - * @author: David Williams - */ -public class AdapterForElementTestOnly implements INodeAdapter { - /** - * CAAdapterTestOnly constructor comment. - */ - public AdapterForElementTestOnly() { - super(); - } - - /** - * Allowing the INodeAdapter to compare itself against the type allows it - * to return true in more than one case. - */ - public boolean isAdapterForType(Object type) { - boolean result = false; - if (type instanceof Element) { - result = true; - } - return result; - } - - /** - */ - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { - System.out.println("INodeAdapter AdapterForElementTestOnly " + this.hashCode() + " has been notified of " + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " (when " + notifier + " notified it)"); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestCharSequenceReader.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestCharSequenceReader.java deleted file mode 100644 index 1a585c143..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestCharSequenceReader.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.document; - -import java.io.IOException; - -import org.eclipse.wst.sse.core.internal.text.CharSequenceReader; - -import junit.framework.TestCase; - - - -public class TestCharSequenceReader extends TestCase { - - - public TestCharSequenceReader() { - super(); - } - - - public TestCharSequenceReader(String name) { - super(name); - } - - String fStandardString = "test123"; - - public void testStandardBeginning() { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3); - char char1 = (char) reader.read(); - assertTrue(char1 == 't'); - char char2 = (char) reader.read(); - assertTrue(char2 == 'e'); - char char3 = (char) reader.read(); - assertTrue(char3 == 's'); - int eof = reader.read(); - assertTrue(eof == -1); - } - - public void testStandardMiddle() { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 2, 3); - char char1 = (char) reader.read(); - assertTrue(char1 == 's'); - char char2 = (char) reader.read(); - assertTrue(char2 == 't'); - char char3 = (char) reader.read(); - assertTrue(char3 == '1'); - int eof = reader.read(); - assertTrue(eof == -1); - } - - public void testStandardEnd() { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 4, 3); - char char1 = (char) reader.read(); - assertTrue(char1 == '1'); - char char2 = (char) reader.read(); - assertTrue(char2 == '2'); - char char3 = (char) reader.read(); - assertTrue(char3 == '3'); - int eof = reader.read(); - assertTrue(eof == -1); - } - - public void testStandardOutOfRange() { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 50, 3); - int eof = reader.read(); - assertTrue(eof == -1); - } - - public void testStandardPartiallyOutOfRange() { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 5, 3); - char char1 = (char) reader.read(); - assertTrue(char1 == '2'); - char char2 = (char) reader.read(); - assertTrue(char2 == '3'); - int eof = reader.read(); - assertTrue(eof == -1); - } - - public void testBufferBegining() throws IOException { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3); - String targetString = "tes"; - - // intentionally small sized buffer - char[] charbuffer = new char[2]; - StringBuffer stringBuffer = new StringBuffer(); - int nRead = 0; - while (nRead != -1) { - nRead = reader.read(charbuffer); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - } - String testString = stringBuffer.toString(); - - assertEquals(targetString, testString); - - } - public void testBufferEnd() throws IOException { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 4, 3); - String targetString = "123"; - - // intentionally small sized buffer - char[] charbuffer = new char[2]; - StringBuffer stringBuffer = new StringBuffer(); - int nRead = 0; - while (nRead != -1) { - nRead = reader.read(charbuffer); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - } - String testString = stringBuffer.toString(); - - assertEquals(targetString, testString); - - } public void testBufferEndEnlarged() throws IOException { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 4, 3); - String targetString = "123"; - - // intentionally small sized buffer - char[] charbuffer = new char[200]; - StringBuffer stringBuffer = new StringBuffer(); - int nRead = 0; - while (nRead != -1) { - nRead = reader.read(charbuffer); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - } - String testString = stringBuffer.toString(); - - assertEquals(targetString, testString); - - } - public void testBufferBeginingEnlarged() throws IOException { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3); - String targetString = "tes"; - - // intentionally small sized buffer - char[] charbuffer = new char[200]; - StringBuffer stringBuffer = new StringBuffer(); - int nRead = 0; - while (nRead != -1) { - nRead = reader.read(charbuffer); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - } - String testString = stringBuffer.toString(); - - assertEquals(targetString, testString); - - } - public void testBufferBeginingReduced() throws IOException { - CharSequenceReader reader = new CharSequenceReader(fStandardString, 0, 3); - String targetString = "te"; - - // intentionally small sized buffer - char[] charbuffer = new char[2]; - StringBuffer stringBuffer = new StringBuffer(); - int nRead = 0; - //while (nRead != -1) { - nRead = reader.read(charbuffer, 0, 2); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - //} - String testString = stringBuffer.toString(); - - assertEquals(targetString, testString); - /// now continue reading same reader - targetString = "s"; - stringBuffer = new StringBuffer(); - nRead = 0; - //while (nRead != -1) { - nRead = reader.read(charbuffer, 0, 2); - if (nRead > 0) { - stringBuffer.append(charbuffer, 0, nRead); - } - //} - testString = stringBuffer.toString(); - assertEquals(targetString, testString); - - } - -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestRegionMatches.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestRegionMatches.java deleted file mode 100644 index c93d1aa97..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/document/TestRegionMatches.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.document; - -import org.eclipse.wst.sse.core.internal.text.StructuredDocumentTextStore; - -import junit.framework.TestCase; - - - -public class TestRegionMatches extends TestCase { - - /** - * - */ - public TestRegionMatches() { - super(); - - } - - /** - * @param name - */ - public TestRegionMatches(String name) { - super(name); - - } - - public void testRegionMatches1() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - structuredDocumentTextStore.set("testing123"); - boolean result = structuredDocumentTextStore.regionMatches(0, 1, "t"); - assertEquals(true, result); - } - - public void testRegionMatches2() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - structuredDocumentTextStore.set("testing123"); - boolean result = structuredDocumentTextStore.regionMatches(0, 2, "t"); - assertEquals(false, result); - } - public void testRegionMatches3() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - structuredDocumentTextStore.set("testing123"); - boolean result = structuredDocumentTextStore.regionMatches(7, 3, "123"); - assertEquals(true, result); - } - public void testRegionMatches4() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - structuredDocumentTextStore.set("testing123"); - boolean result = structuredDocumentTextStore.regionMatches(8, 3, "234"); - assertEquals(false, result); - } - - public void testRegionMatchesIgnoreCase() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - String test = "testing123"; - String compare = "TeSting123"; - structuredDocumentTextStore.set(test); - boolean result = structuredDocumentTextStore.regionMatches(0, test.length(), compare); - assertEquals(false, result); - result = structuredDocumentTextStore.regionMatchesIgnoreCase(0, test.length(), compare); - assertEquals(true, result); - } - public void testRegionMatchesIgnoreCase2() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - String test = "test\u0130ng123"; - String compare = "TeStIng123"; - structuredDocumentTextStore.set(test); - boolean result = structuredDocumentTextStore.regionMatches(0, test.length(), compare); - assertEquals(false, result); - result = structuredDocumentTextStore.regionMatchesIgnoreCase(0, test.length(), compare); - assertEquals(true, result); - } - public void testRegionMatchesIgnoreCase3() { - StructuredDocumentTextStore structuredDocumentTextStore = new StructuredDocumentTextStore(); - String test = "testing123"; - String compare = "TeSt\u0131ng123"; - structuredDocumentTextStore.set(test); - boolean result = structuredDocumentTextStore.regionMatches(0, test.length(), compare); - assertEquals(false, result); - result = structuredDocumentTextStore.regionMatchesIgnoreCase(0, test.length(), compare); - assertEquals(true, result); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/NullParser.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/NullParser.java deleted file mode 100644 index 46ab20bf5..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/NullParser.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import java.io.Reader; -import java.util.List; - -import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - -public class NullParser implements RegionParser { - - public IStructuredDocumentRegion getDocumentRegions() { - - return null; - } - - public List getRegions() { - - return null; - } - - public RegionParser newInstance() { - - return this; - } - - public void reset(Reader reader) { - // do nothing - - } - - public void reset(Reader reader, int offset) { - // do nothing - - } - - public void reset(String input) { - // do nothing - - } - - public void reset(String input, int offset) { - // do nothing - } - -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestAboutToBeChangedEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestAboutToBeChangedEvent.java deleted file mode 100644 index 79f84da98..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestAboutToBeChangedEvent.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.AboutToBeChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestAboutToBeChangedEvent extends TestCase { - - public void testAboutToBeChangedEvent() { - AboutToBeChangedEvent event = getBasicEvent(); - assertNotNull(event); - } - - public void testGetDeletedText() { - AboutToBeChangedEvent event = getBasicEvent(); - String d = event.getDeletedText(); - assertEquals(d, null); - } - - public void testGetOriginalRequester() { - AboutToBeChangedEvent event = getBasicEvent(); - Object r = event.getOriginalRequester(); - assertEquals(this, r); - } - - public void testGetStructuredDocument() { - AboutToBeChangedEvent event = getBasicEvent(); - IStructuredDocument d = event.getStructuredDocument(); - assertNotNull(d); - } - - public void testSetDeletedText() { - AboutToBeChangedEvent event = getBasicEvent(); - event.setDeletedText("junkyNothing"); - // assume ok if no exception - assertTrue(true); - } - - private AboutToBeChangedEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - AboutToBeChangedEvent event = new AboutToBeChangedEvent(document, this, "test", 0, 0); - return event; - - } - -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentContentEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentContentEvent.java deleted file mode 100644 index ce2637838..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentContentEvent.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentContentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestNewDocumentContentEvent extends TestCase { - final private static String testString = "testing"; - - public void testNewDocumentContentEvent() { - NewDocumentContentEvent event = getBasicEvent(); - assertNotNull(event); - } - - public void testGetOffset() { - NewDocumentContentEvent event = getBasicEvent(); - int o = event.getOffset(); - assertEquals(0, o); - } - - public void testGetLength() { - NewDocumentContentEvent event = getBasicEvent(); - int i = event.getLength(); - assertEquals(testString.length(), i); - } - - /* - * Class under test for String getText() - */ - public void testGetText() { - NewDocumentContentEvent event = getBasicEvent(); - String text = event.getText(); - assertEquals(testString, text); - } - - private NewDocumentContentEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - NewDocumentContentEvent event = new NewDocumentContentEvent(document, this); - return event; - - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentEvent.java deleted file mode 100644 index 8f8ae731d..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNewDocumentEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestNewDocumentEvent extends TestCase { - final private static String testString = "testing"; - - public void testGetOffset() { - NewDocumentEvent event = getBasicEvent(); - int o = event.getOffset(); - assertEquals(0, o); - } - - public void testGetLength() { - NewDocumentEvent event = getBasicEvent(); - int i = event.getLength(); - assertEquals(testString.length(), i); - } - - public void testNewDocumentEvent() { - NewDocumentEvent event = getBasicEvent(); - assertNotNull(event); - } - - - public void testGetText() { - NewDocumentEvent event = getBasicEvent(); - String text = event.getText(); - assertEquals(testString, text); - } - - private NewDocumentEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - NewDocumentEvent event = new NewDocumentEvent(document, this); - return event; - - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNoChangeEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNoChangeEvent.java deleted file mode 100644 index 134fc93fc..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestNoChangeEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestNoChangeEvent extends TestCase { - final private static String testString = "testing"; - - public void testNoChangeEvent() { - NoChangeEvent event = getBasicEvent(); - assertNotNull(event); - assertEquals(NoChangeEvent.NO_CONTENT_CHANGE, event.reason); - } - - private NoChangeEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - NoChangeEvent event = new NoChangeEvent(document, this, "", 0, 0); - event.reason = NoChangeEvent.NO_CONTENT_CHANGE; - return event; - } - -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionChangedEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionChangedEvent.java deleted file mode 100644 index e7cb82f92..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionChangedEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - -public class TestRegionChangedEvent extends TestCase { - final private static String testString = "testing"; - - public void testRegionChangedEvent() { - RegionChangedEvent event = getBasicEvent(); - assertNotNull(event); - } - - public void testGetRegion() { - RegionChangedEvent event = getBasicEvent(); - IStructuredDocumentRegion structuredDocumentRegion = event.getStructuredDocumentRegion(); - assertEquals(null, structuredDocumentRegion); - } - - public void testGetStructuredDocumentRegion() { - RegionChangedEvent event = getBasicEvent(); - ITextRegion region = event.getRegion(); - assertEquals(null, region); - } - - private RegionChangedEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - RegionChangedEvent event = new RegionChangedEvent(document, this, null, null, "", 0, 0); - return event; - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionsReplacedEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionsReplacedEvent.java deleted file mode 100644 index b7b116818..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestRegionsReplacedEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestRegionsReplacedEvent extends TestCase { - - final private static String testString = "testing"; - - public void testRegionsReplacedEvent() { - RegionsReplacedEvent event = getBasicEvent(); - assertNotNull(event); - } - - public void testGetNewRegions() { - RegionsReplacedEvent event = getBasicEvent(); - assertNull(event.getNewRegions()); - } - - public void testGetOldRegions() { - RegionsReplacedEvent event = getBasicEvent(); - assertNull(event.getOldRegions()); - } - - public void testGetStructuredDocumentRegion() { - RegionsReplacedEvent event = getBasicEvent(); - assertNull(event.getStructuredDocumentRegion()); - } - - private RegionsReplacedEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - RegionsReplacedEvent event = new RegionsReplacedEvent(document, this, null, null, null, "", 0, 0); - return event; - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestStructuredDocumentRegionsReplacedEvent.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestStructuredDocumentRegionsReplacedEvent.java deleted file mode 100644 index 735b3583c..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/events/TestStructuredDocumentRegionsReplacedEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.events; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; - -public class TestStructuredDocumentRegionsReplacedEvent extends TestCase { - final private static String testString = "testing"; - - public void testStructuredDocumentRegionsReplacedEvent() { - StructuredDocumentRegionsReplacedEvent event = getBasicEvent(); - assertNotNull(event); - } - - public void testGetNewStructuredDocumentRegions() { - StructuredDocumentRegionsReplacedEvent event = getBasicEvent(); - assertNull(event.getNewStructuredDocumentRegions()); - } - - public void testGetOldStructuredDocumentRegions() { - StructuredDocumentRegionsReplacedEvent event = getBasicEvent(); - assertNull(event.getOldStructuredDocumentRegions()); - } - - private StructuredDocumentRegionsReplacedEvent getBasicEvent() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(new NullParser()); - document.setText(this, testString); - StructuredDocumentRegionsReplacedEvent event = new StructuredDocumentRegionsReplacedEvent(document, this, null, null, "", 0, 0); - return event; - } -} diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/examples/TestAtSign.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/examples/TestAtSign.java deleted file mode 100644 index 9d9100030..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/examples/TestAtSign.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.examples; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - - -public class TestAtSign { - - public TestAtSign() { - super(); - } - - public static void main(String[] args) throws IOException { - Properties properties = new Properties(); //System.getProperties(); - properties.put("at sign", "this is an \u0040 sign"); - properties.list(System.out); - FileOutputStream outputStream = new FileOutputStream("testAt.txt"); - properties.store(outputStream, "tests"); - outputStream.close(); - InputStream inStream = new FileInputStream("testAt.txt"); - Properties readProperties = new Properties(); - readProperties.load(inStream); - String atSign = (String) readProperties.get("at sign"); - System.out.println("at sign from read: " + atSign); - - - - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/EmptyModelForTests.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/EmptyModelForTests.java deleted file mode 100644 index 52b95d8a5..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/EmptyModelForTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.life; - -import org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; - - - -public class EmptyModelForTests extends AbstractStructuredModel { - - public EmptyModelForTests() { - - super(); - // TODO Auto-generated constructor stub - } - - public IndexedRegion getIndexedRegion(int offset) { - - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/TestCreation.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/TestCreation.java deleted file mode 100644 index 18112c5f9..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/life/TestCreation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.life; - -import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; - -import junit.framework.TestCase; - - - - -public class TestCreation extends TestCase { - private boolean DEBUG = false; - - public void testCreation() { - IStructuredModel structuredModel = new EmptyModelForTests(); - ModelLifecycleEvent event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_RELEASED); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_DIRTY_STATE); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED); - if (DEBUG) { - System.out.println(event); - } - /* event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_REINITIALIZED); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.ADAPTERS_NOTIFIED); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_RELOADED); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_RESOURCE_DELETED); - if (DEBUG) { - System.out.println(event); - } - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_RESOURCE_MOVED); - if (DEBUG) { - System.out.println(event); - } - */ - event = new ModelLifecycleEvent(structuredModel, ModelLifecycleEvent.MODEL_SAVED); - if (DEBUG) { - System.out.println(event); - } - - - // if gets to here without exception, assume ok. - assertTrue(true); - - - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalImprovement.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalImprovement.java deleted file mode 100644 index a193ad50d..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalImprovement.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.threading; - -import java.io.IOException; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; - - -/** - * To print out timings, set DEBUG_TEST to true, other wise, this test passes - * if no exceptions thrown. - */ -public class TestOfThreadLocalImprovement extends TestCase { - // number of times a pair of tests (with and without) thread local are - // repeated (for more accurate averages). - int nTrials = 3; - IStructuredDocument fDocument = null; - private static final boolean DEBUG_TEST = false; - private static final boolean DEBUG_TEST_DETAIL = false; - // tests from 1 to MAX_TREADS-1 threads - private int MAX_THREADS = 5; - private long SLEEP_TIME = 0; - - public TestOfThreadLocalImprovement() throws IOException { - super(); - } - - private final String getContent() { - return "<test>" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "</test>"; - } - - private IStructuredDocument getDocument(String content) throws IOException { - if (fDocument == null) { - IModelManager modelManager = StructuredModelManager.getModelManager(); - fDocument = modelManager.createStructuredDocumentFor("testPerf.xml", content, null); - } - return fDocument; - } - - void linkRunner(final Boolean direction, IStructuredDocument document) { - IStructuredDocument structuredDocument = document; - IStructuredDocumentRegion previousDocumentRegion = null; - long startTime = System.currentTimeMillis(); - int start = 0; - int length = structuredDocument.getLength(); - int nRegions = 0; - for (int i = start; i < length; i++) { - int index = i; - if (!direction.booleanValue()) { - index = (length - 1) - i; - } - IStructuredDocumentRegion currentDocumentRegion = structuredDocument.getRegionAtCharacterOffset(index); - if (currentDocumentRegion != previousDocumentRegion) { - nRegions++; - previousDocumentRegion = currentDocumentRegion; - } - Thread.yield(); - try { - Thread.sleep(SLEEP_TIME); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - long endTime = System.currentTimeMillis(); - if (DEBUG_TEST_DETAIL) { - System.out.println("Thread: " + Thread.currentThread() + " from " + length + " characters, found " + nRegions + " regions in " + (endTime - startTime) + " msecs."); - } - } - - private long dotestDocumentWalkingWithThreadLocal(int nThreads) throws IOException { - BasicStructuredDocument.setUSE_LOCAL_THREAD(true); - fDocument = getDocument(getContent()); - long startTimeOverall = System.currentTimeMillis(); - doDocumentWalking(nThreads); - long endTimeOverall = System.currentTimeMillis(); - long finalOverall = endTimeOverall - startTimeOverall; - if (DEBUG_TEST_DETAIL) { - System.out.println("Overall time using Local_Thread: " + finalOverall); - } - return finalOverall; - } - - private long dotestDocumentWalkingWithoutThreadLocal(int nThreads) throws IOException { - BasicStructuredDocument.setUSE_LOCAL_THREAD(false); - fDocument = getDocument(getContent()); - long startTimeOverall = System.currentTimeMillis(); - doDocumentWalking(nThreads); - long endTimeOverall = System.currentTimeMillis(); - long finalOverall = endTimeOverall - startTimeOverall; - if (DEBUG_TEST_DETAIL) { - System.out.println("Overall time NOT using Local_Thread: " + finalOverall); - } - return finalOverall; - } - - private void doDocumentWalking(int nThreads) throws IOException { - Thread[] threads = new Thread[nThreads]; - boolean toggle = true; - for (int i = 0; i < threads.length; i++) { - final Boolean direction = new Boolean(toggle); - toggle = !toggle; - ThreadGroup threadGroup = new ThreadGroup("sse unit tests"); - Thread thread = new Thread(threadGroup, new Runnable() { - public void run() { - linkRunner(direction, fDocument); - } - }, ("sse unit test thread " + i)); - // I used MIN_PRIORITY since that makes it easier to "see" in debugger list of threads - thread.setPriority(Thread.MIN_PRIORITY); - threads[i] = thread; - } - for (int i = 0; i < threads.length; i++) { - threads[i].start(); - } - try { - for (int i = 0; i < threads.length; i++) { - threads[i].join(); - - } - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void testNThreads() throws IOException { - for (int i = 1; i < MAX_THREADS; i++) { - int nThreads = i; - if (DEBUG_TEST_DETAIL) { - System.out.println(" >>>>---- N Threads: " + i); - } - float woCumm = 0; - float wCumm = 0; - - for (int j = 0; j < nTrials; j++) { - woCumm = woCumm + dotestDocumentWalkingWithoutThreadLocal(nThreads); - wCumm = wCumm + dotestDocumentWalkingWithThreadLocal(nThreads); - } - float averageWO = woCumm / nTrials; - float averageW = wCumm / nTrials; - float perThreadWO = averageWO / nThreads; - float perThreadW = averageW / nThreads; - int roundedWO = new Float(perThreadWO).intValue(); - int roundedW = new Float(perThreadW).intValue(); - if (DEBUG_TEST) { - System.out.println("Average per thread: without: " + roundedWO + " with: " + roundedW); - System.out.println(" <<<<<---- N Threads: " + i); - } - } - // if gets to here (with no exceptions) all is ok. - assertTrue(0 == 0); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalWithChanges.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalWithChanges.java deleted file mode 100644 index 23c643dc7..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/TestOfThreadLocalWithChanges.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.threading; - -import java.io.IOException; -import java.util.Random; - -import junit.framework.TestCase; - -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; - - -/** - * This class started off as copy of TestOfThreadLocalImprovements, and I just - * added another thread with modifies the document. - */ -public class TestOfThreadLocalWithChanges extends TestCase { - // number of times a pair of tests (with and without) thread local are - // repeated (for more accurate averages). - int nTrials = 3; - IStructuredDocument fDocument = null; - private static final boolean DEBUG_TEST_DETAIL = false; - // tests from 1 to MAX_TREADS-1 threads - private int MAX_THREADS = 14; - private long SLEEP_TIME = 2; - private int N_CHANGES = 10000; - - public TestOfThreadLocalWithChanges() throws IOException { - super(); - } - - private final String getContent() { - return "<test>" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" - + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "<extra> <junk> to make a <large/> file (over <1000> chars)" + "</test>"; - } - - private IStructuredDocument getDocument(String content) throws IOException { - if (fDocument == null) { - IModelManager modelManager = StructuredModelManager.getModelManager(); - fDocument = modelManager.createStructuredDocumentFor("testPerf.xml", content, null); - } - return fDocument; - } - - void linkRunner(final Boolean direction, IStructuredDocument document) { - IStructuredDocument structuredDocument = document; - IStructuredDocumentRegion previousDocumentRegion = null; - long startTime = System.currentTimeMillis(); - int start = 0; - int length = structuredDocument.getLength(); - int nRegions = 0; - // I made length "dynamic" after adding modification thread - for (int i = start; i < structuredDocument.getLength(); i++) { - int index = i; - if (!direction.booleanValue()) { - int currentLength = structuredDocument.getLength(); - index = (currentLength - 1) - i; - } - IStructuredDocumentRegion currentDocumentRegion = structuredDocument.getRegionAtCharacterOffset(index); - if (currentDocumentRegion != previousDocumentRegion) { - nRegions++; - previousDocumentRegion = currentDocumentRegion; - } - Thread.yield(); - try { - Thread.sleep(SLEEP_TIME); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - long endTime = System.currentTimeMillis(); - if (DEBUG_TEST_DETAIL) { - System.out.println("Thread: " + Thread.currentThread() + " from " + length + " characters, found " + nRegions + " regions in " + (endTime - startTime) + " msecs."); - } - } - - private long dotestDocumentWalkingWithThreadLocal(int nThreads) throws IOException { - BasicStructuredDocument.setUSE_LOCAL_THREAD(true); - fDocument = getDocument(getContent()); - long startTimeOverall = System.currentTimeMillis(); - doDocumentWalking(nThreads); - long endTimeOverall = System.currentTimeMillis(); - long finalOverall = endTimeOverall - startTimeOverall; - if (DEBUG_TEST_DETAIL) { - System.out.println("Overall time using Local_Thread: " + finalOverall); - } - return finalOverall; - } - - private void doDocumentWalking(int nThreads) throws IOException { - Thread[] threads = new Thread[nThreads]; - boolean toggle = true; - for (int i = 0; i < threads.length; i++) { - final Boolean direction = new Boolean(toggle); - // toggle controls whether moves from start to end, or end to start - // of document. - toggle = !toggle; - ThreadGroup threadGroup = new ThreadGroup("unit tests"); - Thread thread = new Thread(threadGroup, new Runnable() { - public void run() { - linkRunner(direction, fDocument); - } - }, ("sse unit test thread " + i)); - // I used MIN_PRIORITY since that makes it easier to "see" in - // debugger list of threads - thread.setPriority(Thread.MIN_PRIORITY); - threads[i] = thread; - } - for (int i = 0; i < threads.length; i++) { - threads[i].start(); - } - // now that "readers" have started, we'll start a modification thread - // too - Thread modifyingThread = new Thread(new Runnable() { - public void run() { - modifiyDocument(fDocument); - } - }, ("sse unit test modification thread ")); - // I used MAX_PRIORITY to be sure lots of modifications take place - modifyingThread.setPriority(Thread.MIN_PRIORITY); - modifyingThread.start(); - try { - for (int i = 0; i < threads.length; i++) { - threads[i].join(); - } - modifyingThread.join(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - void modifiyDocument(IStructuredDocument document) { - Random random = new Random(); - for (int i = 0; i < N_CHANGES + 1; i++) { - int randomOffset = random.nextInt(document.getLength()); - // 100 just seems like a good maximum length to replace - // (could play with in future). - int randomLength = random.nextInt(100); - // if we "accidently" get more than the length, just skipit - if (randomOffset + randomLength < document.getLength()) { - document.replaceText(this, randomOffset, randomLength, "testingtext"); - } - } - } - - public void testNThreads() throws IOException { - for (int i = 1; i < MAX_THREADS; i++) { - int nThreads = i; - if (DEBUG_TEST_DETAIL) { - System.out.println(" >>>>---- N Threads: " + i); - } - float wCumm = 0; - for (int j = 0; j < nTrials; j++) { - wCumm = wCumm + dotestDocumentWalkingWithThreadLocal(nThreads); - } - } - // if gets to here (with no exceptions) all is ok. - assertTrue(0 == 0); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalExample.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalExample.java deleted file mode 100644 index 747d01f87..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalExample.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.threading; - -import java.util.Random; - -/** - * See http://java.sun.com/developer/JDCTechTips/2003/tt1208.html#2 for - * informative article. - */ -public class ThreadLocalExample { - - // Create thread local class - // Initial value is a random number from 0-999 - private static class MyThreadLocal extends ThreadLocal { - private Random innerRandom = new Random(); - - protected Object initialValue() { - return new Integer(innerRandom.nextInt(1000)); - } - } - - // Create class variable - static volatile int counter = 0; - - // Define/create thread local variable - static ThreadLocal threadLocal = new MyThreadLocal(); - - // For random number generation - // static Random random = new Random(); - - // Displays thread local variable, counter, - // and thread name - static void displayValues() { - System.out.println(threadLocal.get() + "\t" + counter + "\t" + Thread.currentThread().getName()); - } - - public static void main(String args[]) { - - // Each thread increments counter - // Displays variable info - // And sleeps for the random amount of time - // Before displaying info again - Runnable runner = new Runnable() { - public void run() { - synchronized (ThreadLocalExample.class) { - counter++; - } - displayValues(); - try { - Thread.sleep(((Integer) threadLocal.get()).intValue()); - displayValues(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - }; - - // Another instance of class created - // and values displayed - displayValues(); - - // Here's where the other threads - // are actually created - for (int i = 0; i < 5; i++) { - Thread t = new Thread(runner); - t.start(); - } - } - - /** - * - */ - public ThreadLocalExample() { - super(); - } -}
\ No newline at end of file diff --git a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalInstanceExample.java b/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalInstanceExample.java deleted file mode 100644 index 5d08f5940..000000000 --- a/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/threading/ThreadLocalInstanceExample.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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.sse.core.tests.threading; - -import java.util.Random; - -/** - * See http://java.sun.com/developer/JDCTechTips/2003/tt1208.html#2 for - * informative article. - */ -public class ThreadLocalInstanceExample { - - // Create thread local class - // Initial value is a random number from 0-999 - private class MyThreadLocal extends ThreadLocal { - private Random innerRandom = new Random(); - - protected Object initialValue() { - return new Integer(innerRandom.nextInt(1000)); - } - } - - // Create class variable - static volatile int counter = 0; - - // Define/create thread local variable - ThreadLocal threadLocal = new MyThreadLocal(); - - // For random number generation - // static Random random = new Random(); - - // Displays thread local variable, counter, - // and thread name - void displayValues() { - System.out.println(threadLocal.get() + "\t" + counter + "\t" + Thread.currentThread().getName()); - } - - public static void main(String args[]) { - new ThreadLocalInstanceExample().startRun(); - } - - private void startRun() { - - // Each thread increments counter - // Displays variable info - // And sleeps for the random amount of time - // Before displaying info again - Runnable runner = new Runnable() { - public void run() { - synchronized (this) { - counter++; - } - displayValues(); - try { - Thread.sleep(((Integer) threadLocal.get()).intValue()); - displayValues(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - }; - - // Another instance of class created - // and values displayed - displayValues(); - - // Here's where the other threads - // are actually created - for (int i = 0; i < 5; i++) { - Thread t = new Thread(runner); - t.start(); - } - } - - /** - * - */ - public ThreadLocalInstanceExample() { - super(); - } -}
\ No newline at end of file |