[58349] Handle class shape changes, pass #1
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/AllSuites.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/AllSuites.java
index 21849dd..abe8844 100644
--- a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/AllSuites.java
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/AllSuites.java
@@ -11,10 +11,11 @@
  *******************************************************************************/
 /*
  *  $RCSfile: AllSuites.java,v $
- *  $Revision: 1.2 $  $Date: 2003/10/27 17:32:36 $ 
+ *  $Revision: 1.3 $  $Date: 2004/06/09 22:47:00 $ 
  */
 import org.eclipse.jem.tests.beaninfo.BeanInfoSuite;
 import org.eclipse.jem.tests.instantiation.InstantiationSuite;
+import org.eclipse.jem.tests.modelListeners.ListenersSuite;
 import org.eclipse.jem.tests.proxy.ide.IDEProxySuite;
 import org.eclipse.jem.tests.proxy.initParser.InitParserSuite;
 import org.eclipse.jem.tests.proxy.remote.RemoteProxySuite;
@@ -30,6 +31,7 @@
 		IDEProxySuite.class,
 		BeanInfoSuite.class,
 		InstantiationSuite.class,
+		ListenersSuite.class,
 		                                 } ;
 	public static String pkgName = "Java EMF Model jUnit Test Suite" ;
     
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/IListenerTester.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/IListenerTester.java
new file mode 100644
index 0000000..2cb94ac
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/IListenerTester.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: IListenerTester.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import junit.framework.AssertionFailedError;
+ 
+
+/**
+ * For many of the listener tests, the actual Assert is done on a safe runnable so that it can't be 
+ * normally sent. So we will have a listener tester that will retrieve the exception and will
+ * be called to get it from the main thread.
+ * @since 1.0.0
+ */
+public interface IListenerTester {
+
+	public void isException() throws AssertionFailedError;
+	public void isComplete() throws AssertionFailedError;
+}
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/ListenersSuite.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/ListenersSuite.java
new file mode 100644
index 0000000..5e645f3
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/ListenersSuite.java
@@ -0,0 +1,92 @@
+package org.eclipse.jem.tests.modelListeners;
+/*******************************************************************************
+ * Copyright (c)  2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: ListenersSuite.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+import java.net.URL;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+import org.eclipse.jem.tests.JavaProjectUtil;
+import org.eclipse.jem.tests.JavaTestsPlugin;
+import org.eclipse.jem.tests.beaninfo.AbstractBeanInfoTestCase;
+
+/**
+ * @author richkulp
+ *
+ */
+public class ListenersSuite extends TestSetup {
+
+	// Test cases to be include in the suite
+	private static final Class testsList[] = { TestJEM.class, TestBeanInfo.class};
+
+	/**
+	 * 
+	 */
+	public ListenersSuite() {
+		this("Test Listeners Suite");
+	}
+
+	/**
+	 * @param name
+	 */
+	public ListenersSuite(String name) {
+		super(new TestSuite(name) {
+			{
+				for (int i = 0; i < testsList.length; i++) {
+					addTestSuite(testsList[i]);
+				}
+
+			}
+		});
+	}
+
+	public static Test suite() {
+		return new ListenersSuite();
+	}
+
+	private boolean oldAutoBuildingState; // autoBuilding state before we started.	
+	protected void setUp() throws Exception {
+		System.out.println("-- Initializing the Listeners test data --"); //$NON-NLS-1$
+		oldAutoBuildingState = JavaProjectUtil.setAutoBuild(true);
+		URL installURL = JavaTestsPlugin.getPlugin().getBundle().getEntry("/");
+		String[] zipPaths = new String[2];
+		zipPaths[0] = Platform.asLocalURL(new URL(installURL, "testdata/testbeaninfo.zip")).getFile();
+		zipPaths[1] = Platform.asLocalURL(new URL(installURL, "testdata/testbeaninfopreq.zip")).getFile();
+		IProject[] projects =
+			JavaProjectUtil.importProjects(
+				new String[] { AbstractBeanInfoTestCase.TEST_BEANINFO_PROJECT, AbstractBeanInfoTestCase.TEST_BEANINFO_PREREQ_PROJECT },
+				zipPaths);
+		assertNotNull(projects[0]);
+		assertNotNull(projects[1]);
+		System.out.println("-- Data initialized --"); //$NON-NLS-1$
+
+	}
+
+	protected void tearDown() throws Exception {
+		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+			public void run(IProgressMonitor monitor) throws CoreException {
+				JavaProjectUtil.deleteProject(JavaProjectUtil.getProject(AbstractBeanInfoTestCase.TEST_BEANINFO_PROJECT));
+				JavaProjectUtil.deleteProject(JavaProjectUtil.getProject(AbstractBeanInfoTestCase.TEST_BEANINFO_PREREQ_PROJECT));
+			}
+		}, ResourcesPlugin.getWorkspace().getRoot(), 0, null);
+
+		JavaProjectUtil.setAutoBuild(oldAutoBuildingState);
+	}
+
+}
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeanInfo.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeanInfo.java
new file mode 100644
index 0000000..15c41b1
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeanInfo.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: TestBeanInfo.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.JavaModelException;
+
+import org.eclipse.jem.internal.beaninfo.adapters.BeaninfoModelSynchronizer;
+import org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier;
+import org.eclipse.jem.internal.proxy.core.ProxyFactoryRegistry;
+ 
+
+/**
+ * This is for testing the JEM Reflection listeners
+ * @since 1.0.0
+ */
+public class TestBeanInfo extends TestListeners {
+	
+	BeaninfoModelSynchronizer sync;
+	TestBeaninfoAdapterFactory factory;
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		factory = new TestBeaninfoAdapterFactory(new IBeaninfoSupplier() {
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier#getRegistry()
+			 */
+			public ProxyFactoryRegistry getRegistry() {
+				return null;
+			}
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier#isRegistryCreated()
+			 */
+			public boolean isRegistryCreated() {
+				return false;
+			}
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier#closeRegistry()
+			 */
+			public void closeRegistry() {
+			}
+
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier#getProject()
+			 */
+			public IProject getProject() {
+				return jp.getProject();
+			}
+		});	// Needs to be set first so that super.setUP() calls to special setups will have a factory.
+		super.setUp();	// Called first so that any setup won't fire our synchronizer.
+		
+		// Basic for this is add our special listener. (Don't need full JEM model cluttering things up).		
+		sync = new BeaninfoModelSynchronizer(factory, jp);
+		setTester(factory);
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpClose()
+	 */
+	protected void setUpClose() throws JavaModelException {
+		super.setUpClose();
+		factory.setTestCases(new int[0], new Object[0]);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpOpen()
+	 */
+	protected void setUpOpen() {
+		super.setUpOpen();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpAddMethodInWorkingCopy()
+	 */
+	protected void setUpAddMethodInWorkingCopy() throws JavaModelException {
+		super.setUpAddMethodInWorkingCopy();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpSaveFromWorkingCopy()
+	 */
+	protected void setUpSaveFromWorkingCopy() throws JavaModelException {
+		super.setUpSaveFromWorkingCopy();
+		factory.setTestCases(new int[] {TestBeaninfoAdapterFactory.MARK_STALE_INTROSPECTION_PLUS_INNER}, new Object[] {new Object[] {"org.eclipse.jem.tests.beaninfo.Test1Class", Boolean.FALSE}}); 		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpRevert()
+	 */
+	protected void setUpRevert() throws JavaModelException {
+		super.setUpRevert();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupDeleteMethodNoWorkingCopy()
+	 */
+	protected void setupDeleteMethodNoWorkingCopy() throws JavaModelException {
+		super.setupDeleteMethodNoWorkingCopy();
+		factory.setTestCases(new int[] {TestBeaninfoAdapterFactory.MARK_STALE_INTROSPECTION_PLUS_INNER}, new Object[] {new Object[] {"org.eclipse.jem.tests.beaninfo.Test1Class", Boolean.FALSE}});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupAddClass()
+	 */
+	protected void setupAddClass() {
+		super.setupAddClass();
+		factory.setTestCases(new int[0], new Object[0]);				
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupDeleteClassWithWorkingCopy()
+	 */
+	protected void setupDeleteClassWithWorkingCopy() throws JavaModelException {
+		super.setupDeleteClassWithWorkingCopy();
+		factory.setTestCases(new int[] {TestBeaninfoAdapterFactory.MARK_STALE_INTROSPECTION_PLUS_INNER, TestBeaninfoAdapterFactory.MARK_STALE_INTROSPECTION_PLUS_INNER}, new Object[] {new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass", Boolean.FALSE}, new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass", Boolean.TRUE}});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpDeleteClassNoWorkingCopy()
+	 */
+	protected void setUpDeleteClassNoWorkingCopy() throws JavaModelException {
+		super.setUpDeleteClassNoWorkingCopy();
+		factory.setTestCases(new int[] {TestBeaninfoAdapterFactory.MARK_STALE_INTROSPECTION_PLUS_INNER}, new Object[] {new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass", Boolean.TRUE}});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpAddPackage()
+	 */
+	protected void setUpAddPackage() throws JavaModelException {
+		super.setUpAddPackage();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpDeletePackage()
+	 */
+	protected void setUpDeletePackage() throws JavaModelException {
+		super.setUpDeletePackage();
+		factory.setTestCases(new int[] {TestBeaninfoAdapterFactory.MARK_ALL_STALE}, new Object[] {null});
+	}
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		sync.stopSynchronizer(true);
+		super.tearDown();
+	}
+}
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeaninfoAdapterFactory.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeaninfoAdapterFactory.java
new file mode 100644
index 0000000..d3641bf
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestBeaninfoAdapterFactory.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: TestBeaninfoAdapterFactory.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.jem.internal.beaninfo.adapters.BeaninfoAdapterFactory;
+import org.eclipse.jem.internal.beaninfo.core.IBeaninfoSupplier;
+
+/**
+ * Test factory to handle the calls from the listener during our tests.
+ * 
+ * @since 1.0.0
+ */
+public class TestBeaninfoAdapterFactory extends BeaninfoAdapterFactory implements IListenerTester {
+
+	/**
+	 * @param supplier
+	 * 
+	 * @since 1.0.0
+	 */
+	public TestBeaninfoAdapterFactory(IBeaninfoSupplier supplier) {
+		super(supplier);
+	}
+	
+	int callIndex = -1; // Index of calls into control list.
+
+	AssertionFailedError exception; // Set if exception occured.
+
+	protected int[] callTypes; // Order of permitted calltypes. If any come out of order, then error.
+
+	protected Object[] callArgs; // Corresponding args for each call types. Each type specific.
+
+	public void setTestCases(int[] callTypes, Object[] callArgs) {
+		this.callTypes = callTypes;
+		this.callArgs = callArgs;
+	}
+
+	public void isException() throws AssertionFailedError {
+		if (exception != null)
+			throw exception;
+	}
+
+	public void isComplete() throws AssertionFailedError {
+		Assert.assertEquals("Did not complete all notifcations. ", callTypes.length, callIndex + 1);
+	}
+
+	public static final int MARK_ALL_STALE = 0, MARK_STALE_INTROSPECTION = 1, MARK_STALE_INTROSPECTION_PLUS_INNER = 2;
+
+	private static final String[] callTypeNames = new String[] { "MARK_ALL_STALE", "MARK_STALE_INTROSPECTION", "MARK_STALE_INTROSPECTION_PLUS_INNER",
+			"UNREGISTER_INTROSPECTION", "UNREGISTER_INTROSPECTION_PLUS_INNER"};
+
+	/*
+	 * Test the next call type, if not valid, return false.
+	 */
+	protected boolean testCallType(int callType) {
+		if (exception != null)
+			return false; // Already had an error
+		try {
+			if (++callIndex >= callTypes.length)
+				Assert.fail("An extra notification of type " + callTypeNames[callType] + " received.");
+			if (callTypes[callIndex] != callType)
+				Assert.assertEquals(callTypeNames[callTypes[callIndex]], callTypeNames[callType]);
+		} catch (AssertionFailedError e) {
+			exception = e;
+			return false;
+		}
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jem.internal.beaninfo.adapters.BeaninfoAdapterFactory#markAllStale()
+	 */
+	public void markAllStale() {
+		testCallType(MARK_ALL_STALE);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jem.internal.beaninfo.adapters.BeaninfoAdapterFactory#markStaleIntrospection(java.lang.String, boolean)
+	 */
+	public void markStaleIntrospection(String sourceName, boolean clearResults) {
+		if (testCallType(MARK_STALE_INTROSPECTION)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], sourceName);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), clearResults); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jem.internal.beaninfo.adapters.BeaninfoAdapterFactory#markStaleIntrospectionPlusInner(java.lang.String, boolean)
+	 */
+	public void markStaleIntrospectionPlusInner(String sourceName, boolean clearResults) {
+		if (testCallType(MARK_STALE_INTROSPECTION_PLUS_INNER)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], sourceName);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), clearResults); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+	}
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJEM.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJEM.java
new file mode 100644
index 0000000..966de1b
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJEM.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: TestJEM.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import org.eclipse.jdt.core.JavaModelException;
+
+import org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer;
+ 
+
+/**
+ * This is for testing the JEM Reflection listeners
+ * @since 1.0.0
+ */
+public class TestJEM extends TestListeners {
+	
+	JavaReflectionSynchronizer sync;
+	TestJavaJDOMAdapterFactory factory;
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		factory = new TestJavaJDOMAdapterFactory();	// Needs to be set first so that super.setUP() calls to special setups will have a factory.
+		super.setUp();	// Called first so that any setup won't fire our synchronizer.
+		
+		// Basic for this is add our special listener. (Don't need full JEM model cluttering things up).		
+		factory.setJavaProject(jp);
+		sync = factory.getSynchronizer();
+		setTester(factory);
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpClose()
+	 */
+	protected void setUpClose() throws JavaModelException {
+		super.setUpClose();
+		factory.setTestCases(new int[0], new Object[0]);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpOpen()
+	 */
+	protected void setUpOpen() {
+		super.setUpOpen();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpAddMethodInWorkingCopy()
+	 */
+	protected void setUpAddMethodInWorkingCopy() throws JavaModelException {
+		super.setUpAddMethodInWorkingCopy();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpSaveFromWorkingCopy()
+	 */
+	protected void setUpSaveFromWorkingCopy() throws JavaModelException {
+		super.setUpSaveFromWorkingCopy();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION}, new Object[] {"org.eclipse.jem.tests.beaninfo.Test1Class"}); 		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpRevert()
+	 */
+	protected void setUpRevert() throws JavaModelException {
+		super.setUpRevert();
+		factory.setTestCases(new int[0], new Object[0]);		
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupDeleteMethodNoWorkingCopy()
+	 */
+	protected void setupDeleteMethodNoWorkingCopy() throws JavaModelException {
+		super.setupDeleteMethodNoWorkingCopy();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION}, new Object[] {"org.eclipse.jem.tests.beaninfo.Test1Class"});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupAddClass()
+	 */
+	protected void setupAddClass() {
+		super.setupAddClass();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY}, new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass"});				
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setupDeleteClassWithWorkingCopy()
+	 */
+	protected void setupDeleteClassWithWorkingCopy() throws JavaModelException {
+		super.setupDeleteClassWithWorkingCopy();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION, TestJavaJDOMAdapterFactory.DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY}, new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass", "org.eclipse.jem.tests.beaninfo.NewClass"});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpDeleteClassNoWorkingCopy()
+	 */
+	protected void setUpDeleteClassNoWorkingCopy() throws JavaModelException {
+		super.setUpDeleteClassNoWorkingCopy();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY}, new Object[] {"org.eclipse.jem.tests.beaninfo.NewClass"});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpAddPackage()
+	 */
+	protected void setUpAddPackage() throws JavaModelException {
+		super.setUpAddPackage();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.FLUSH_PACKAGE_NO_NOTIFICATION}, new Object[] {new Object[] {"test", Boolean.TRUE}});		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.tests.modelListeners.TestListeners#setUpDeletePackage()
+	 */
+	protected void setUpDeletePackage() throws JavaModelException {
+		super.setUpDeletePackage();
+		factory.setTestCases(new int[] {TestJavaJDOMAdapterFactory.FLUSH_PACKAGE}, new Object[] {new Object[] {"test", Boolean.FALSE}});
+	}
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		sync.stopSynchronizer();
+		super.tearDown();
+	}
+}
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJavaJDOMAdapterFactory.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJavaJDOMAdapterFactory.java
new file mode 100644
index 0000000..e6b4fbb
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestJavaJDOMAdapterFactory.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: TestJavaJDOMAdapterFactory.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.jdt.core.ICompilationUnit;
+
+import org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory;
+import org.eclipse.jem.internal.adapters.jdom.JavaReflectionSynchronizer;
+ 
+
+/**
+ * A test version of this so that it works with our test cases without having fullblown JEM model up and running.
+ * @since 1.0.0
+ */
+public class TestJavaJDOMAdapterFactory extends JavaJDOMAdapterFactory implements IListenerTester {
+	
+	int callIndex = -1;	// Index of calls into control list.
+	AssertionFailedError exception; // Set if exception occured.
+	
+	protected int[] callTypes;	// Order of permitted calltypes. If any come out of order, then error.
+	protected Object[] callArgs;	// Corresponding args for each call types. Each type specific.
+	
+	public void setTestCases(int[] callTypes, Object[] callArgs) {
+		this.callTypes = callTypes;
+		this.callArgs = callArgs;
+	}
+	
+	public void isException() throws AssertionFailedError {
+		if (exception != null)
+			throw exception;
+	}
+		
+	public void isComplete() throws AssertionFailedError {
+		Assert.assertEquals("Did not complete all notifcations. ", callTypes.length, callIndex+1);
+	}
+
+	public static final int FLUSH_ALL = 0, FLUSH_ALL_NO_NOTIFICATION = 1, FLUSH_PACKAGE = 2, FLUSH_PACKAGE_NO_NOTIFICATION = 3, 
+		FLUSH_REFLECTION = 4, FLUSH_REFLECTION_NO_NOTIFICATION = 5, FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION = 6, NOTIFY_CONTENT_CHANGED = 7,
+		DISASSOCIATE_SOURCE_NOTIFY = 8, DISASSOCIATE_SOURCE = 9, DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY = 10, DISASSOCIATE_SOURCE_PLUS_INNER = 11; 
+	
+	private static final String[] callTypeNames = new String[] {"FLUSH_ALL", "FLUSH_ALL_NO_NOTIFICATION", "FLUSH_PACKAGE", "FLUSH_PACKAGE_NO_NOTIFICATION", 
+			"FLUSH_REFLECTION", "FLUSH_REFLECTION_NO_NOTIFICATION", "FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION", "NOTIFY_CONTENT_CHANGED",
+			"DISASSOCIATE_SOURCE_NOTIFY", "DISASSOCIATE_SOURCE", "DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY", "DISASSOCIATE_SOURCE_PLUS_INNER"};	
+	/*
+	 * Test the next call type, if not valid, return false.
+	 */
+	protected boolean testCallType(int callType) {
+		if (exception != null)
+			return false;	// Already had an error
+		try {
+			if (++callIndex >= callTypes.length)
+				Assert.fail("An extra notification of type " + callTypeNames[callType] + " received.");
+			if (callTypes[callIndex] != callType)
+				Assert.assertEquals(callTypeNames[callTypes[callIndex]], callTypeNames[callType]);
+		} catch (AssertionFailedError e) {
+			exception = e;
+			return false;
+		}
+		return true;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#flushAll()
+	 */
+	public void flushAll() {
+		testCallType(FLUSH_ALL);
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#flushAllNoNotification()
+	 */
+	public List flushAllNoNotification() {
+		testCallType(FLUSH_ALL_NO_NOTIFICATION);
+		return Collections.EMPTY_LIST;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#flushPackage(java.lang.String, boolean)
+	 */
+	public void flushPackage(String packageName, boolean noFlushIfSourceFound) {
+		if (testCallType(FLUSH_PACKAGE)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], packageName);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), noFlushIfSourceFound); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#flushPackageNoNotification(java.lang.String, boolean)
+	 */
+	public List flushPackageNoNotification(String packageName, boolean noFlushIfSourceFound) {
+		if (testCallType(FLUSH_PACKAGE_NO_NOTIFICATION)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], packageName);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), noFlushIfSourceFound); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+		return Collections.EMPTY_LIST;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#flushReflection(java.lang.String)
+	 */
+	public void flushReflection(String source) {
+		if (testCallType(FLUSH_REFLECTION)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], source); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#flushReflectionNoNotification(java.lang.String)
+	 */
+	public Notification flushReflectionNoNotification(String source) {
+		if (testCallType(FLUSH_REFLECTION_NO_NOTIFICATION)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], source); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}			
+		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#flushReflectionPlusInnerNoNotification(java.lang.String)
+	 */
+	public Notification flushReflectionPlusInnerNoNotification(String source) {
+		if (testCallType(FLUSH_REFLECTION_PLUS_INNER_NO_NOTIFICATION)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], source); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}
+		return null;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory#notifyContentChanged(org.eclipse.jdt.core.ICompilationUnit)
+	 */
+	public void notifyContentChanged(ICompilationUnit targetCU) {
+		if (testCallType(NOTIFY_CONTENT_CHANGED)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], targetCU.getElementName()); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}			
+	}
+	
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#disAssociateSource(java.lang.String, boolean)
+	 */
+	public Notification disAssociateSource(String source, boolean doNotify) {
+		if (testCallType(DISASSOCIATE_SOURCE_NOTIFY)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], source);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), doNotify); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#disAssociateSource(java.lang.String)
+	 */
+	public Notification disAssociateSource(String source) {
+		if (testCallType(DISASSOCIATE_SOURCE)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], source); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}
+		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#disAssociateSourcePlusInner(java.lang.String, boolean)
+	 */
+	public Notification disAssociateSourcePlusInner(String source, boolean doNotify) {
+		if (testCallType(DISASSOCIATE_SOURCE_PLUS_INNER_NOTIFY)) {
+			try {
+				Assert.assertEquals((String) ((Object[]) callArgs[callIndex])[0], source);
+				Assert.assertEquals(((Boolean) ((Object[]) callArgs[callIndex])[1]).booleanValue(), doNotify); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+		return null;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jem.internal.java.adapters.JavaReflectionAdapterFactory#disAssociateSourcePlusInner(java.lang.String)
+	 */
+	public void disAssociateSourcePlusInner(String source) {
+		if (testCallType(DISASSOCIATE_SOURCE_PLUS_INNER)) {
+			try {
+				Assert.assertEquals((String) callArgs[callIndex], source); 
+			} catch (AssertionFailedError e) {
+				exception = e;
+			}			
+		}		
+	}
+	
+	public JavaReflectionSynchronizer getSynchronizer() {
+		return synchronizer;
+	}
+}
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestListeners.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestListeners.java
new file mode 100644
index 0000000..d6cfe0c
--- /dev/null
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/modelListeners/TestListeners.java
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ *  $RCSfile: TestListeners.java,v $
+ *  $Revision: 1.1 $  $Date: 2004/06/09 22:47:00 $ 
+ */
+package org.eclipse.jem.tests.modelListeners;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+
+import org.eclipse.jem.tests.JavaProjectUtil;
+import org.eclipse.jem.tests.beaninfo.AbstractBeanInfoTestCase;
+ 
+
+/**
+ * 
+ * @since 1.0.0
+ */
+public abstract class TestListeners extends TestCase {
+	
+	protected IJavaProject jp;
+
+	// The indexes of these lookups are found in the setup and teardown methods. They must be kept in sync.
+	protected List setupSpecials = Arrays.asList(new String[] { "testOpen", "testClose", "testAddMethodInWorkcopy", "testSaveFromWorkingCopy",
+			"testRevert", "testDeleteMethodNoWorkingCopy", "testAddClass", "testDeleteClassWithWorkingCopy",
+			"testDeleteClassNoWorkingCopy", "testAddPackage", "testDeletePackage"});
+	
+	protected IListenerTester tester;
+		
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		jp = JavaCore.create(JavaProjectUtil.getProject(AbstractBeanInfoTestCase.TEST_BEANINFO_PROJECT));
+		String testname = getName();
+		int index = setupSpecials.indexOf(testname);
+		switch (index) {
+			case 0:
+				setUpOpen();
+				break;
+			case 1:
+				setUpClose();
+				break;
+			case 2:
+				setUpAddMethodInWorkingCopy();
+				break;
+			case 3:
+				setUpSaveFromWorkingCopy();
+				break;
+			case 4:
+				setUpRevert();
+				break;
+			case 5:
+				setupDeleteMethodNoWorkingCopy();
+				break;
+			case 6:
+				setupAddClass();
+				break;
+			case 7:
+				setupDeleteClassWithWorkingCopy();
+				break;
+			case 8:
+				setUpDeleteClassNoWorkingCopy();
+				break;
+			case 9:
+				setUpAddPackage();
+				break;
+			case 10:
+				setUpDeletePackage();
+				break;
+			default:
+				break;
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		String testname = getName();
+		int index = setupSpecials.indexOf(testname);
+		switch (index) {
+			case 0:
+				tearDownOpen();
+				break;
+			case 1:
+				tearDownClose();
+				break;
+			case 2:
+				tearDownAddMethodInWorkingCopy();
+				break;
+			case 3:
+				tearDownSaveFromWorkingCopy();
+				break;
+			case 4:
+				tearDownRevert();
+				break;
+			case 5:
+				tearDownDeleteMethodNoWorkingCopy();
+				break;
+			case 6:
+				tearDownAddClass();
+				break;
+			case 7:
+				tearDownDeleteClassWithWorkingCopy();
+				break;
+			case 8:
+				tearDownDeleteClassNoWorkingCopy();
+				break;
+			case 9:
+				tearDownAddPackage();
+				break;
+			case 10:
+				tearDownDeletePackage();
+				break;
+			default:
+				break;
+		}		
+		super.tearDown();
+	}	
+
+
+	protected void setTester(IListenerTester tester) {
+		this.tester = tester;
+	}
+	
+	protected void setUpOpen() {	
+	}	
+	public void testOpen() throws JavaModelException {
+		// Test open a working copy.
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		testCU.becomeWorkingCopy(null, null);
+		tester.isException();
+		tester.isComplete();	// It should of been complete.
+	}
+	protected void tearDownOpen() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();		
+	}
+	
+	
+	protected ICompilationUnit testCU;
+	protected void setUpClose() throws JavaModelException {
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		testCU.becomeWorkingCopy(null, null);		
+	}	
+	public void testClose() throws JavaModelException {
+		// Test close a working copy.
+		testCU.discardWorkingCopy();
+		tester.isException();
+		tester.isComplete();	// It should of been complete.
+	}
+	protected void tearDownClose() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();
+	}
+	
+	
+	protected void setUpAddMethodInWorkingCopy() throws JavaModelException {
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		testCU.becomeWorkingCopy(null, null);		
+	}	
+	public void testAddMethodInWorkcopy() throws JavaModelException {
+		testCU.getTypes()[0].createMethod("private void getSomething() {}", null, true, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.
+	}
+	protected void tearDownAddMethodInWorkingCopy() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();		
+	}	
+	
+	
+	protected void setUpSaveFromWorkingCopy() throws JavaModelException {
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		testCU.becomeWorkingCopy(null, null);		
+		testCU.getTypes()[0].createMethod("private void getSomething() {}", null, true, new NullProgressMonitor());		
+	}
+	public void testSaveFromWorkingCopy() throws JavaModelException {
+		testCU.commitWorkingCopy(true, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.		
+	}
+	protected void tearDownSaveFromWorkingCopy() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();				
+	}
+	
+	protected void setUpRevert() throws JavaModelException {
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		testCU.becomeWorkingCopy(null, null);		
+		testCU.getTypes()[0].createMethod("private void getSomething() {}", null, true, new NullProgressMonitor());				
+	}	
+	public void testRevert() throws JavaModelException {
+		testCU.restore();
+		tester.isException();
+		tester.isComplete();	// It should of been complete.		
+	}
+	protected void tearDownRevert() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();				
+	}
+	
+	protected void setupDeleteMethodNoWorkingCopy() throws JavaModelException {
+		testCU = (ICompilationUnit) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo/Test1Class.java"));
+		IMethod m = testCU.getTypes()[0].getMethod("getSomething", new String[0]);
+		if (m.exists())
+			m.delete(true, new NullProgressMonitor());
+		testCU.getTypes()[0].createMethod("private void getSomething() {}", null, true, new NullProgressMonitor());						
+	}
+	public void testDeleteMethodNoWorkingCopy() throws CoreException {
+		JavaCore.run(new IWorkspaceRunnable() {
+			public void run(IProgressMonitor monitor) throws CoreException {
+				// Actually there will be a working copy. This is to simulate what delete method from member list
+				// with no open editor. This is done by batching everything up, but there is a working copy created.
+				// But it changes the file directly then. (Confusing, no? But that is the way it does it in JDT).
+				testCU.becomeWorkingCopy(null, null);
+				IMethod method = testCU.getTypes()[0].getMethod("getSomething", new String[] {});
+				IBuffer cuBuffer = testCU.getBuffer();
+				ISourceRange sr = method.getSourceRange();
+				cuBuffer.replace(sr.getOffset(), sr.getLength(),"");
+				cuBuffer.save(monitor, true);
+				testCU.discardWorkingCopy();
+			}
+		}, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.				
+	}
+	protected void tearDownDeleteMethodNoWorkingCopy() throws JavaModelException {
+		if (testCU != null)
+			testCU.discardWorkingCopy();						
+	}
+	
+	protected void setupAddClass() {
+		
+	}
+	public void testAddClass() throws JavaModelException {
+		IPackageFragment pkg = (IPackageFragment) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo"));
+		testCU = pkg.createCompilationUnit("NewClass.java", "public class NewClass {}", true, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.				
+	}
+	protected void tearDownAddClass() throws JavaModelException {
+		if (testCU != null) {
+			testCU.delete(true, new NullProgressMonitor());
+		}
+	}
+	
+	protected void setupDeleteClassWithWorkingCopy() throws JavaModelException {
+		IPackageFragment pkg = (IPackageFragment) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo"));
+		testCU = pkg.createCompilationUnit("NewClass.java", "public class NewClass {}", true, new NullProgressMonitor());
+		testCU.becomeWorkingCopy(null, null);
+	}
+	public void testDeleteClassWithWorkingCopy() throws CoreException {
+		ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+
+			public void run(IProgressMonitor monitor) throws CoreException {
+				// Need to run this way to simulate what happens for real.
+				testCU.delete(true, new NullProgressMonitor());
+				ResourcesPlugin.getWorkspace().checkpoint(true);
+				testCU.discardWorkingCopy();
+			}
+		}, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.	
+		testCU = null;
+	}
+	protected void tearDownDeleteClassWithWorkingCopy() throws JavaModelException {
+		if (testCU != null && testCU.exists()) {
+			testCU.delete(true, new NullProgressMonitor());
+		}		
+	}
+	
+	protected void setUpDeleteClassNoWorkingCopy() throws JavaModelException {
+		IPackageFragment pkg = (IPackageFragment) jp.findElement(new Path("org/eclipse/jem/tests/beaninfo"));
+		testCU = pkg.createCompilationUnit("NewClass.java", "public class NewClass {}", true, new NullProgressMonitor());		
+	}
+	public void testDeleteClassNoWorkingCopy() throws JavaModelException {
+		testCU.delete(true, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.	
+		testCU = null;		
+	}
+	protected void tearDownDeleteClassNoWorkingCopy() throws JavaModelException {
+		if (testCU != null && testCU.exists()) {
+			testCU.delete(true, new NullProgressMonitor());
+		}				
+	}
+	
+	protected void setUpAddPackage() throws JavaModelException {
+		IPackageFragment pkg = (IPackageFragment) jp.findElement(new Path("test"));
+		if (pkg != null)
+			pkg.delete(true, new NullProgressMonitor());
+	}
+	public void testAddPackage() throws JavaModelException {
+		IPackageFragmentRoot[] roots = jp.getPackageFragmentRoots();
+		for (int i = 0; i < roots.length; i++) {
+			if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+				roots[i].createPackageFragment("test", true, new NullProgressMonitor());
+				break;
+			}
+		}
+		tester.isException();
+		tester.isComplete();	// It should of been complete.			
+	}
+	protected void tearDownAddPackage() throws JavaModelException {
+		IPackageFragment pkg = (IPackageFragment) jp.findElement(new Path("test"));
+		if (pkg != null)
+			pkg.delete(true, new NullProgressMonitor());		
+	}
+	
+	protected IPackageFragment testPkg;
+	protected void setUpDeletePackage() throws JavaModelException {
+		IPackageFragmentRoot[] roots = jp.getPackageFragmentRoots();
+		for (int i = 0; i < roots.length; i++) {
+			if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+				testPkg = roots[i].createPackageFragment("test", true, new NullProgressMonitor());
+				break;
+			}
+		}		
+	}
+	public void testDeletePackage() throws JavaModelException {
+		testPkg.delete(true, new NullProgressMonitor());
+		tester.isException();
+		tester.isComplete();	// It should of been complete.			
+		testPkg = null;
+	}
+	protected void tearDownDeletePackage() throws JavaModelException {
+		if (testPkg != null && testPkg.exists())
+			testPkg.delete(true, new NullProgressMonitor());
+	}
+	
+}