20011221_17
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutable.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutable.java
index e2233bd..93122f9 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutable.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutable.java
@@ -228,7 +228,7 @@
 		if (files != null) // be careful since it can be null

 			for (int i = 0; i < files.length; ++i){

 				if (files[i].isDirectory()){

-					result.add(getFiles(files[i]));

+					result.addAll(getFiles(files[i]));

 				} else {

 					result.add(files[i]);

 				}

diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/Site.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/Site.java
index ed292da..7dd6cac 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/Site.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/Site.java
@@ -176,9 +176,10 @@
 		}

 

 		// notify listeners

-		ISiteChangedListener[] siteListeners = (ISiteChangedListener[]) listeners.getListeners();

+		

+		Object[] siteListeners = listeners.getListeners();

 		for (int i = 0; i < siteListeners.length; i++) {

-			siteListeners[i].featureUninstalled(feature);

+			((ISiteChangedListener)siteListeners[i]).featureUninstalled(feature);

 		}

 

 	}

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/AllTests.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/AllTests.java
index c1473c4..63c869d 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/AllTests.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/AllTests.java
@@ -11,6 +11,7 @@
 import org.eclipse.update.tests.core.boot.AllPlatformConfigurationTests;

 import org.eclipse.update.tests.parser.AllParserTests;

 import org.eclipse.update.tests.regularInstall.AllRegularInstallTests;

+import org.eclipse.update.tests.regularRemove.AllRegularRemoveTests;

 import org.eclipse.update.tests.types.AllTypesTests;

 import org.eclipse.update.tests.uivalues.AllCoreUITests;

 

@@ -28,6 +29,7 @@
 		suite.addTest(AllCoreUITests.suite());

 		suite.addTest(AllConfigurationsTests.suite());

 		suite.addTest(AllTypesTests.suite());

+		suite.addTest(AllRegularRemoveTests.suite());		

 		return suite;

 	}

 }
\ No newline at end of file
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/TestRevert.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/TestRevert.java
index 87b9782..08953d8 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/TestRevert.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/TestRevert.java
@@ -45,7 +45,7 @@
 		IFeatureReference installedFeature = configSite.install(feature,null);

 		site.save();

 

-		configSite.unconfigure(installedFeature);

+		configSite.unconfigure(installedFeature,null);

 

 		IFeature feature2 = featureRef2.getFeature();

 		IInstallConfiguration newConfig2 = site.cloneCurrentConfiguration(null,"new Label2");

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/implementation/SiteFTP.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/implementation/SiteFTP.java
index de86f33..fec94fc 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/implementation/SiteFTP.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/implementation/SiteFTP.java
@@ -6,6 +6,7 @@
 import org.eclipse.core.runtime.CoreException;

 import org.eclipse.core.runtime.IProgressMonitor;

 import org.eclipse.update.core.*;

+import org.eclipse.update.core.IPluginEntry;

 

 public class SiteFTP implements ISite {

 

@@ -140,4 +141,10 @@
 		return null;

 	}

 

+	/*

+	 * @see IPluginContainer#remove(IPluginEntry)

+	 */

+	public void remove(IPluginEntry entry) throws CoreException {

+	}

+

 }

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/AllRegularRemoveTests.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/AllRegularRemoveTests.java
new file mode 100644
index 0000000..13c1cbe
--- /dev/null
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/AllRegularRemoveTests.java
@@ -0,0 +1,28 @@
+package org.eclipse.update.tests.regularRemove;

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved.

+ */

+

+import org.eclipse.update.tests.UpdateManagerTestCase;

+import junit.framework.*;

+

+

+public class AllRegularRemoveTests extends UpdateManagerTestCase {

+public AllRegularRemoveTests(String name) {

+	super(name);

+}

+public static Test suite() {

+	TestSuite suite = new TestSuite();

+	suite.setName("Regular Remove Tests");

+	

+	// the following will take all teh test methods in teh class that start with 'test'

+	suite.addTest(new TestSuite(TestRemove.class));

+	

+	

+	// or you can specify the method

+	//suite.addTest(new TestGetFeature("methodThatDoesNotStartWithtest"));	

+	

+	return suite;

+}

+}

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/TestRemove.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/TestRemove.java
new file mode 100644
index 0000000..c5d5f0e
--- /dev/null
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularRemove/TestRemove.java
@@ -0,0 +1,237 @@
+package org.eclipse.update.tests.regularRemove;

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved.

+ */

+import java.io.File;

+import java.net.MalformedURLException;

+import java.net.URL;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.update.core.*;

+import org.eclipse.update.core.IFeature;

+import org.eclipse.update.internal.core.*;

+import org.eclipse.update.tests.UpdateManagerTestCase;

+

+public class TestRemove extends UpdateManagerTestCase {

+	

+	

+	public class Listener implements ISiteChangedListener{

+		

+		public boolean notified = false;

+		/*

+		 * @see ISiteChangedListener#featureUpdated(IFeature)

+		 */

+		public void featureUpdated(IFeature feature) {}

+

+			/*

+		 * @see ISiteChangedListener#featureInstalled(IFeature)

+		 */

+		public void featureInstalled(IFeature feature) {

+			notified = true;

+			System.out.println("Notified Feature Installed");

+		}

+

+		/*

+		 * @see ISiteChangedListener#featureUninstalled(IFeature)

+		 */

+		public void featureUninstalled(IFeature feature) {}

+

+		public boolean isNotified() {

+			return notified;

+		}

+}	

+	

+	/**

+	 * Constructor for Test1

+	 */

+	public TestRemove(String arg0) {

+		super(arg0);

+	}

+

+	private IFeature getFeature1(ISite site) throws MalformedURLException, CoreException {

+		URL id = UpdateManagerUtils.getURL(site.getURL(), "features/org.eclipse.update.core.tests.feature1_1.0.4.jar", null);

+		FeaturePackaged remoteFeature = new FeaturePackaged(id, site);

+		//remoteFeature.initializeFeature();

+		return remoteFeature;

+	}

+

+	public void testFileSite() throws Exception {

+

+		ISite remoteSite = SiteManager.getSite(SOURCE_FILE_SITE);

+		IFeature remoteFeature = getFeature1(remoteSite);

+		ISite localSite = SiteManager.getSite(TARGET_FILE_SITE);

+		IFeatureReference ref = localSite.install(remoteFeature, null);

+

+		String featureRef =  ref.getFeature().getIdentifier().toString();	

+		System.out.println();	

+		localSite.remove(ref.getFeature(),null);

+

+		// verify

+		String site = localSite.getURL().getFile();

+		IPluginEntry[] entries = remoteFeature.getPluginEntries();

+		assertTrue("no plugins entry", (entries != null && entries.length != 0));

+		String pluginName = entries[0].getIdentifier().toString();

+		

+		File pluginFile = new File(site, Site.DEFAULT_PLUGIN_PATH + pluginName);

+		assertTrue("plugin files installed locally", !pluginFile.exists());

+

+		File featureFile = new File(site, SiteFile.INSTALL_FEATURE_PATH +featureRef);

+		assertTrue("feature info installed locally:"+featureFile, !featureFile.exists());

+

+

+	}

+

+	private IFeature getFeature2(ISite site) throws MalformedURLException, CoreException {

+		URL id = UpdateManagerUtils.getURL(site.getURL(), "features/features2.jar", null);

+		FeaturePackaged remoteFeature = new FeaturePackaged(id, site);

+		//remoteFeature.initializeFeature();

+		return remoteFeature;

+	}

+

+	public void testHTTPSite() throws Exception {

+

+/*		ISite remoteSite = SiteManager.getSite(SOURCE_HTTP_SITE);

+		IFeatureReference[] features = remoteSite.getFeatureReferences();

+		IFeature remoteFeature = null;

+

+		if (features == null || features.length == 0)

+			fail("No features on the site");

+

+		for (int i = 0; i < features.length; i++) {

+			if (features[i].getURL().toExternalForm().endsWith("features2.jar")) {

+				remoteFeature = features[i].getFeature();

+				break;

+			}

+		}

+

+		assertNotNull("Cannot find feature2.jar on site", remoteFeature);

+		ISite localSite = SiteManager.getSite(TARGET_FILE_SITE);

+		localSite.install(remoteFeature, null);

+		

+		// feature2.jar should not be in the local site

+		IFeatureReference[] localFeatures = localSite.getFeatureReferences();		

+		if (localFeatures == null || localFeatures.length == 0)

+			fail("No features on the target site");

+

+		boolean found = false;

+		for (int i = 0; i < localFeatures.length; i++) {

+			if (features[i].getURL().toExternalForm().endsWith("features2.jar")) {

+				found= true;

+				break;

+			}

+		}

+

+		assertTrue("Found feature2.jar on target site. Target site feature ref shouldnot contain JAR file", !found);

+

+

+		// check

+		String site = UpdateManagerUtils.getPath(localSite.getURL());			

+		IPluginEntry[] entries = remoteFeature.getPluginEntries();

+		assertTrue("no plugins entry", (entries != null && entries.length != 0));

+

+		String pluginName = entries[0].getIdentifier().toString();

+		File pluginFile = new File(site, Site.DEFAULT_PLUGIN_PATH + pluginName);

+		assertTrue("plugin info not installed locally", pluginFile.exists());

+

+		File featureFile = new File(site, SiteFile.INSTALL_FEATURE_PATH + remoteFeature.getIdentifier().toString());

+		assertTrue("feature info not installed locally", featureFile.exists());

+

+		localSite.save();

+

+		//cleanup

+		UpdateManagerUtils.removeFromFileSystem(pluginFile);

+		UpdateManagerUtils.removeFromFileSystem(new File(localSite.getURL().getFile()));		

+	}

+

+	public void testInstall() throws Exception {

+		

+		// cleanup local files...

+		File localFile = new File(new URL(((SiteLocal)SiteManager.getLocalSite()).getLocation(),SiteLocal.SITE_LOCAL_FILE).getFile());

+		UpdateManagerUtils.removeFromFileSystem(localFile);		

+		

+

+		URL INSTALL_SITE = null;

+		try {

+			INSTALL_SITE = new URL("http", bundle.getString("HTTP_HOST_1"), bundle.getString("HTTP_PATH_2"));

+		} catch (Exception e) {

+			fail(e.toString());

+			e.printStackTrace();

+		}

+

+		ISite remoteSite = SiteManager.getSite(INSTALL_SITE);

+		IFeatureReference[] features = remoteSite.getFeatureReferences();

+		IFeature remoteFeature = null;

+

+		if (features == null || features.length == 0)

+			fail("No features on the site");

+

+		for (int i = 0; i < features.length; i++) {

+			if (features[i].getURL().toExternalForm().endsWith("helpFeature.jar")) {

+				remoteFeature = features[i].getFeature();

+				break;

+			}

+		}

+

+		assertNotNull("Cannot find help.jar on site", remoteFeature);

+		ILocalSite localSite = SiteManager.getLocalSite();

+		IConfigurationSite site = localSite.getCurrentConfiguration().getConfigurationSites()[0];

+		Listener listener = new Listener();

+		site.getSite().addSiteChangedListener(listener);

+		

+		site.getSite().install(remoteFeature, null);

+

+

+		IPluginEntry[] entries = remoteFeature.getPluginEntries();

+		assertTrue("no plugins entry", (entries != null && entries.length != 0));

+

+		String sitePath = UpdateManagerUtils.getPath(site.getSite().getURL());			

+		String pluginName = entries[0].getIdentifier().toString();

+		File pluginFile = new File(sitePath, Site.DEFAULT_PLUGIN_PATH + pluginName);

+		assertTrue("plugin info not installed locally", pluginFile.exists());

+

+		File featureFile = new File(sitePath, SiteFile.INSTALL_FEATURE_PATH + remoteFeature.getIdentifier().toString());

+		assertTrue("feature info not installed locally", featureFile.exists());

+

+		//cleanup

+		File file = new File(site.getSite().getURL().getFile()+File.separator+SiteFile.INSTALL_FEATURE_PATH+remoteFeature.getIdentifier());

+		UpdateManagerUtils.removeFromFileSystem(file);

+		UpdateManagerUtils.removeFromFileSystem(pluginFile);

+		UpdateManagerUtils.removeFromFileSystem(localFile);		

+

+		site.getSite().removeSiteChangedListener(listener);

+		assertTrue("Listener hasn't received notification",listener.isNotified());

+	}

+	

+	

+	public void testFileSiteWithoutSiteXML() throws Exception {

+		

+		ISite remoteSite = SiteManager.getSite(SOURCE_FILE_SITE);

+		IFeature remoteFeature = getFeature1(remoteSite);

+		IConfigurationSite localSite = SiteManager.getLocalSite().getCurrentConfiguration().getConfigurationSites()[0];

+		localSite.getSite().install(remoteFeature, null);

+

+		IFeatureReference[] features = localSite.getSite().getFeatureReferences();

+		if (features.length==0) fail("The local site does not contain feature, should not contain an XML file but features should be found anyway by parsing");

+		if (localSite.getSite().getArchives().length==0) fail("The local site does not contain archives, should not contain an XML file but archives should be found anyway by parsing");

+		

+		//cleanup

+		File file = new File(localSite.getSite().getURL().getFile()+File.separator+SiteFile.INSTALL_FEATURE_PATH+remoteFeature.getIdentifier());

+		UpdateManagerUtils.removeFromFileSystem(file);

+		file = new File(localSite.getSite().getURL().getFile()+File.separator+SiteFile.DEFAULT_PLUGIN_PATH+"org.eclipse.update.core.tests.feature1.plugin1_3.5.6");

+		UpdateManagerUtils.removeFromFileSystem(file);

+		file = new File(localSite.getSite().getURL().getFile()+File.separator+SiteFile.DEFAULT_PLUGIN_PATH+"org.eclipse.update.core.tests.feature1.plugin2_5.0.0");

+		UpdateManagerUtils.removeFromFileSystem(file);

+		File localFile = new File(new URL(((SiteLocal)SiteManager.getLocalSite()).getLocation(),SiteLocal.SITE_LOCAL_FILE).getFile());

+		UpdateManagerUtils.removeFromFileSystem(localFile);		

+		

+		

+		ISite site = SiteManager.getSite(new URL("http://www.eclipse.org/"));

+		features = site.getFeatureReferences();

+		if (features.length!=0) fail("The site contains feature... it is an HTTP site without an XML file, so it should not contain any features");

+

+*/		

+	}

+

+	

+}
\ No newline at end of file