330894 - expanding and opening up j2eeflexprojdeployable and the list of participants
diff --git a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider.java b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider.java
new file mode 100644
index 0000000..b4927da
--- /dev/null
+++ b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider.java
@@ -0,0 +1,24 @@
+package org.eclipse.wst.common.tests.flatten;
+
+import java.util.Properties;
+
+import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
+
+public class ExampleFlattenParticipantProvider implements
+		IFlattenParticipantProvider {
+
+	public static final String DUMMY_PARTICIPANT = "example1";
+	public IFlattenParticipant findParticipant(String id, Properties props) {
+		if( DUMMY_PARTICIPANT.equals(id)) {
+			return new DummyFlattenParticipant();
+		}
+		return null;
+	}
+	
+	public static class DummyFlattenParticipant extends AbstractFlattenParticipant {
+		
+	}
+
+}
diff --git a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider2.java b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider2.java
new file mode 100644
index 0000000..e6f6cec
--- /dev/null
+++ b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider2.java
@@ -0,0 +1,29 @@
+package org.eclipse.wst.common.tests.flatten;
+
+import java.util.Properties;
+
+import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
+
+public class ExampleFlattenParticipantProvider2 implements
+		IFlattenParticipantProvider {
+
+	public static final String DUMMY_PARTICIPANT = "example2";
+	
+	public static final String COMMON_KEY = "common";
+	public IFlattenParticipant findParticipant(String id, Properties props) {
+		if( DUMMY_PARTICIPANT.equals(id)) {
+			return new Dummy2FlattenParticipant();
+		}
+		if( COMMON_KEY.equals(id))
+			return new Dummy2FlattenParticipant();
+		
+		return null;
+	}
+	
+	public static class Dummy2FlattenParticipant extends AbstractFlattenParticipant {
+		
+	}
+
+}
diff --git a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider3.java b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider3.java
new file mode 100644
index 0000000..2a75b89
--- /dev/null
+++ b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/ExampleFlattenParticipantProvider3.java
@@ -0,0 +1,26 @@
+package org.eclipse.wst.common.tests.flatten;
+
+import java.util.Properties;
+
+import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipantProvider;
+
+public class ExampleFlattenParticipantProvider3 implements
+		IFlattenParticipantProvider {
+
+	public static final String DUMMY_PARTICIPANT = "example3";
+	public static final String COMMON_KEY = ExampleFlattenParticipantProvider2.COMMON_KEY;
+	public IFlattenParticipant findParticipant(String id, Properties props) {
+		if( DUMMY_PARTICIPANT.equals(id))
+			return new Dummy3FlattenParticipant();
+		if( COMMON_KEY.equals(id))
+			return new Dummy3FlattenParticipant();
+		return null;
+	}
+	
+	public static class Dummy3FlattenParticipant extends AbstractFlattenParticipant {
+		
+	}
+
+}
diff --git a/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/FlattenParticipantProviderTest.java b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/FlattenParticipantProviderTest.java
new file mode 100644
index 0000000..01c12ab
--- /dev/null
+++ b/tests/org.eclipse.wst.common.tests/commontests/org/eclipse/wst/common/tests/flatten/FlattenParticipantProviderTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.common.tests.flatten;
+
+import junit.framework.TestCase;
+
+import org.eclipse.wst.common.componentcore.internal.flat.FlattenParticipantModel;
+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant;
+
+
+public class FlattenParticipantProviderTest extends TestCase {
+
+    public FlattenParticipantProviderTest(String name) {
+        super(name);
+    }
+
+    public void testNotFoundParticipantFound() {
+    	assertNull(searchModel("NOT FOUND"));
+    }
+
+    public void testExample1ParticipantFound() {
+    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider.DUMMY_PARTICIPANT);
+    	assertNotNull(fp);
+    	assertTrue(fp.getClass().getName().endsWith("DummyFlattenParticipant"));
+    }
+
+    public void testExample2ParticipantFound() {
+    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.DUMMY_PARTICIPANT);
+    	assertNotNull(fp);
+    	assertTrue(fp.getClass().getName().endsWith("Dummy2FlattenParticipant"));
+    }
+
+    public void testExample3ParticipantFound() {
+    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider3.DUMMY_PARTICIPANT);
+    	assertNotNull(fp);
+    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
+    }
+
+    /**
+     * This test ensures that the weighting is done properly.
+     * providers with a higher weight should be consulted first.
+     * Weight 10 should be asked before weight 0
+     */
+    public void testCommonParticipantFound() {
+    	IFlattenParticipant fp = searchModel(ExampleFlattenParticipantProvider2.COMMON_KEY);
+    	assertNotNull(fp);
+    	assertTrue(fp.getClass().getName().endsWith("Dummy3FlattenParticipant"));
+    }
+
+    private IFlattenParticipant searchModel(String id) {
+    	return FlattenParticipantModel.getDefault().getParticipant(id);
+    }
+}
diff --git a/tests/org.eclipse.wst.common.tests/plugin.xml b/tests/org.eclipse.wst.common.tests/plugin.xml
index ad5432c..56b574f 100644
--- a/tests/org.eclipse.wst.common.tests/plugin.xml
+++ b/tests/org.eclipse.wst.common.tests/plugin.xml
@@ -105,6 +105,20 @@
       <operationExtension
             id="org.eclipse.wst.common.frameworks.datamodel.tests.extended.H"/>
    </extension>
+  <extension
+        point="org.eclipse.wst.common.modulecore.flattenParticipantProvider">
+     <flattenParticipantProvider
+           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider"
+           weight="5">
+     </flattenParticipantProvider>
+     <flattenParticipantProvider
+           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider2">
+     </flattenParticipantProvider>
+     <flattenParticipantProvider
+           class="org.eclipse.wst.common.tests.flatten.ExampleFlattenParticipantProvider3"
+           weight="10">
+     </flattenParticipantProvider>
+  </extension>
    
    
    <!-- Uncomment the below hook to test specific operation extension ids when needed -->