code coverage JUnits for jsf.core
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
index d7a5296..f804ae3 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
@@ -19,6 +19,7 @@
 import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryRegistryUtilTestCases;
 import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFProjectLibraryReferenceTestCases;
 import org.eclipse.jst.jsf.core.tests.jsflibraryconfiguration.JSFLibraryReferenceTestCases;
+import org.eclipse.jst.jsf.core.tests.jsflibraryconfiguration.JSFLibraryServerSuppliedReferenceTestCases;
 import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.ArchiveFileTestCases;
 import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.JSFLibraryRegistryPackageTestCases;
 import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.JSFLibraryRegistryTestCases;
@@ -88,7 +89,7 @@
         suite.addTestSuite(MigrationV1toV2Test.class);
 
         suite.addTestSuite(JSFLibraryReferenceTestCases.class);
-        
+        suite.addTestSuite(JSFLibraryServerSuppliedReferenceTestCases.class);
         //
 		//$JUnit-END$
 		return suite;
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigModelTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigModelTestCases.java
index f711392..0843474 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigModelTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigModelTestCases.java
@@ -67,7 +67,7 @@
 		JSFLibraryConfigModel model = JSFLibraryConfigModelFactory.createInstance(modelSrc);
 
 		Assert.assertNotNull(model);
-		Assert.assertTrue(model.getJSFImplementationLibraries().size() == 2);		
+		Assert.assertTrue(model.getJSFImplementationLibraries().size() >= 2);		
 	}
 
 	public void testGetJSFComponentLibraries() {
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryReferenceTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryReferenceTestCases.java
index fdfda2e..f349fbc 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryReferenceTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryReferenceTestCases.java
@@ -25,8 +25,10 @@
 import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary;
 import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper;
 import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReference;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferencePluginProvided;
 import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFVersion;
 import org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.JSFLibraryReferenceFacadeFactory;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.JSFLibraryReferencePluginProvidedImpl;
 import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
 import org.eclipse.jst.jsf.core.tests.util.JSFFacetedTestEnvironment;
 import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
@@ -56,11 +58,11 @@
 	        JSFFacetedTestEnvironment jsfFacedEnv = new JSFFacetedTestEnvironment(projectTestEnvironment);
 	        jsfFacedEnv.initialize(IJSFCoreConstants.FACET_VERSION_1_1);
 	        
-	        createRegistryAndAddreferences(projectTestEnvironment, jsfFacedEnv);
+	        createRegistryAndAddReferences(projectTestEnvironment, jsfFacedEnv);
         }
 	}
 
-	private void createRegistryAndAddreferences(WebProjectTestEnvironment projectTestEnvironment, JSFFacetedTestEnvironment jsfFacedEnv) throws CoreException {
+	private void createRegistryAndAddReferences(WebProjectTestEnvironment projectTestEnvironment, JSFFacetedTestEnvironment jsfFacedEnv) throws CoreException {
 		JSFLibraryRegistry jsfLibRegistry = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry();
 
 		String[] archivefiles1 = {
@@ -72,8 +74,7 @@
 		String[] archivefiles2 = {
 				"faces-all-bogu2.jar",
 				"faces-api-bogus2.jar", 
-				"faces-impl-bogus2.jar", 
-				"tomahawk-bogus2.jar"};
+				"faces-impl-bogus2.jar"};
 
 		JSFLibrary implJSFLib = JSFCoreUtilHelper.constructJSFLib("JSFLIBIMPL_NAME", 
 				"JSFLIBIMPL_NAME", 
@@ -91,6 +92,7 @@
 				"testfiles/JSFLib", 
 				false, 
 				true);
+		ppJSFLib.setPluginID("PluginProvidedLib");
 		ppJSFLib.setLabel("PluginProvidedLib");
 		ppJSFLib.setJSFVersion(org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_1_LITERAL);
 				
@@ -107,7 +109,7 @@
 	public void testGetJSFLibraryReferences() {
 		Collection<JSFLibraryReference> results = JSFLibraryConfigurationHelper.getJSFLibraryReferences(projectTestEnvironment.getTestProject());
 		Assert.assertNotNull(results);
-		Assert.assertTrue(results.size() >= 3);		
+		Assert.assertTrue(results.size() >= 3);	//expect 3 libs from project...	JSFLIBIMPL_NAME, JSFLIBNOIMPL_NAME, PP-JSFLIBNOIMPL_NAME
 	}
 
 	public void testIsJSFLibraryContainer() throws JavaModelException, CoreException {
@@ -137,20 +139,15 @@
 					String libID = getLibId(cpEntry);
 					Assert.assertNotNull(libID+": ref", ref);
 					if (libID.equals("JSFLIBIMPL_NAME")){
-						doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "JSFLIBIMPL_NAME", "JSFLIBIMPL_NAME", false, true, JSFVersion.V1_1 );	
+						doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "JSFLIBIMPL_NAME", "JSFLIBIMPL_NAME", "JSFLIBIMPL_NAME", false, true, JSFVersion.V1_1, 4 );						
 					}
 					else if (libID.equals("JSFLIBNONIMPL_NAME")){
-						doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "JSFLIBNONIMPL_NAME", "JSFLIBNONIMPL_NAME", false, false,JSFVersion.V1_2 );	
+						doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "JSFLIBNONIMPL_NAME", "JSFLIBNONIMPL_NAME", "JSFLIBNONIMPL_NAME", false,false, JSFVersion.V1_2, 3);	
 					}
-					else if (libID.equals("null$$PP-JSFLIBNONIMPL_NAME")){
-						doAsserts(ref, "JSFLibraryReferencePluginProvidedImpl", "null$$PP-JSFLIBNONIMPL_NAME", "PluginProvidedLib", true, false, JSFVersion.V1_1 );
-					}
-					else if (libID.equals("AN-IMPL-LIB")){
-						doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "AN-IMPL-LIB", "AN-IMPL-LIB", true, true, JSFVersion.UNKNOWN );					
-					}
-					else if (libID.equals("AN-IMPL-LIB-PP")){
-						doAsserts(ref, "JSFLibraryReferencePluginProvidedImpl", "AN-IMPL-LIB-PP", "AN-IMPL-LIB-PP", true, true, JSFVersion.UNKNOWN);					
-					}
+					else if (libID.equals("PluginProvidedLib$$PP-JSFLIBNONIMPL_NAME")){
+						doAsserts(ref, "JSFLibraryReferencePluginProvidedImpl", "PluginProvidedLib$$PP-JSFLIBNONIMPL_NAME", "PP-JSFLIBNONIMPL_NAME", "PluginProvidedLib", true, false, JSFVersion.V1_1, 8 );
+					}	
+					ref.toString();//just for coverage
 				}
 				else {
 					Assert.assertNull(ref);
@@ -172,13 +169,16 @@
 		return jdtTestEnv;
 	}
 
-	private void doAsserts(JSFLibraryReference ref, String instanceName, String id, String label, boolean isDeployed, boolean isImpl, JSFVersion version ) {
+	private void doAsserts(JSFLibraryReference ref, String instanceName, String id, String name, String label, boolean isDeployed, boolean isImpl, JSFVersion version, int jarCount ) {		
 		Assert.assertTrue(id+":instanceName", ref.getClass().getSimpleName().equals(instanceName));
 		Assert.assertEquals(id+": id",id, ref.getId());
+		Assert.assertEquals(id+": name", name, ref.getName());
 		Assert.assertEquals(id+": label",label, ref.getLabel());
 		Assert.assertEquals(id+": isDeployed",isDeployed, ref.isDeployed());
 		Assert.assertEquals(id+": isImpl", isImpl, ref.isJSFImplementation());
 		Assert.assertEquals(id+": version", version, ref.getMaxSupportedVersion());
+		Assert.assertEquals(id+": jarCount", jarCount, ref.getJars().size());
+		
 	}
 	
 
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryServerSuppliedReferenceTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryServerSuppliedReferenceTestCases.java
new file mode 100644
index 0000000..a06e709
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryServerSuppliedReferenceTestCases.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2007 Oracle 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:
+ *     Oracle Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsf.core.tests.jsflibraryconfiguration;
+
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.jsf.core.IJSFCoreConstants;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.PluginProvidedJSFLibrary;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReference;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryReferenceServerSupplied;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFVersion;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.JSFLibraryReferenceFacadeFactory;
+import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
+import org.eclipse.jst.jsf.core.tests.util.JSFFacetedTestEnvironment;
+import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
+import org.eclipse.jst.jsf.test.util.JSFTestUtil;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+public class JSFLibraryServerSuppliedReferenceTestCases extends TestCase {
+	WebProjectTestEnvironment projectTestEnvironment;
+	JDTTestEnvironment jdtTestEnv;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+        JSFTestUtil.setValidationEnabled(false);
+        JSFTestUtil.setInternetProxyPreferences(true, "www-proxy.us.oracle.com", "80");
+        
+        projectTestEnvironment = 
+            new WebProjectTestEnvironment("JSFLibraryServerSuppliedReferenceTestCases", ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_JAVA ).getVersion( "5.0" )
+                    , ProjectFacetsManager.getProjectFacet( "jst.web" ).getVersion("2.5"));
+        boolean created = projectTestEnvironment.createProject(true);
+
+        assertNotNull(projectTestEnvironment);       
+        assertNotNull(projectTestEnvironment.getTestProject());
+        assertTrue(projectTestEnvironment.getTestProject().isAccessible());
+        
+        if (created) {
+	        // initialize test case for faces 1.2
+	        JSFFacetedTestEnvironment jsfFacedEnv = new JSFFacetedTestEnvironment(projectTestEnvironment);
+	        jsfFacedEnv.initialize(IJSFCoreConstants.FACET_VERSION_1_2);
+	        
+	        createRegistryAndAddreferences(projectTestEnvironment, jsfFacedEnv);
+        }
+	}
+
+	private void createRegistryAndAddreferences(WebProjectTestEnvironment projectTestEnvironment, JSFFacetedTestEnvironment jsfFacedEnv) throws CoreException {
+		JSFLibraryRegistry jsfLibRegistry = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry();
+
+		String[] archivefiles1 = {
+				"faces-all-bogu.jar",
+				"faces-api-bogus.jar", 
+				"faces-impl-bogus.jar", 
+				"tomahawk-bogus.jar"};
+		
+		String[] archivefiles2 = {
+				"faces-all-bogu2.jar",
+				"faces-api-bogus2.jar", 
+				"faces-impl-bogus2.jar", 
+				"tomahawk-bogus2.jar"};
+
+		JSFLibrary implJSFLib = JSFCoreUtilHelper.constructJSFLib("JSFLIBIMPL_NAME", 
+				"JSFLIBIMPL_NAME", 
+				archivefiles1, 
+				true);
+		implJSFLib.setJSFVersion(org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_1_LITERAL);
+		
+		JSFLibrary nonimplJSFLib = JSFCoreUtilHelper.constructJSFLib("JSFLIBNONIMPL_NAME",
+				"JSFLIBNONIMPL_NAME",
+				archivefiles2,
+				false);
+		nonimplJSFLib.setJSFVersion(org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_2_LITERAL);
+		
+		PluginProvidedJSFLibrary ppJSFLib = (PluginProvidedJSFLibrary)JSFCoreUtilHelper.constructJSFLib("PP-JSFLIBNONIMPL_NAME", 
+				"testfiles/JSFLib", 
+				false, 
+				true);
+		ppJSFLib.setPluginID("PluginProvidedLib");
+		ppJSFLib.setLabel("PluginProvidedLib");
+		ppJSFLib.setJSFVersion(org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFVersion.V1_1_LITERAL);
+				
+		jsfLibRegistry.addJSFLibrary(implJSFLib);
+//        jsfFacedEnv.addJSFLibraryReference(implJSFLib, false);
+        
+		jsfLibRegistry.addJSFLibrary(nonimplJSFLib);
+//		jsfFacedEnv.addJSFLibraryReference(nonimplJSFLib, false);
+		
+		jsfLibRegistry.addJSFLibrary(ppJSFLib);
+//		jsfFacedEnv.addJSFLibraryReference(ppJSFLib, true);
+	}
+	
+	public void testGetJSFLibraryReferencesAndServerSuppliedRef() throws CoreException{
+	   Collection<JSFLibraryReference> libs = JSFLibraryConfigurationHelper.getJSFLibraryReferences(projectTestEnvironment.getTestProject());
+	   Assert.assertNotNull(libs);
+	   Assert.assertEquals(1, libs.size());
+	   JSFLibraryReference ref = (JSFLibraryReference)libs.iterator().next();
+	   Assert.assertTrue(ref instanceof JSFLibraryReferenceServerSupplied);
+	   doAsserts(ref, "JSFLibraryReferenceServerSuppliedImpl", "_ServerSupplied_", "_ServerSupplied_", "Server Supplied", false, true, JSFVersion.UNKNOWN, 0 );	
+				
+	}
+
+	private void doAsserts(JSFLibraryReference ref, String instanceName, String id, String name, String label, boolean isDeployed, boolean isImpl, JSFVersion version, int jarCount ) {		
+		Assert.assertTrue(id+":instanceName", ref.getClass().getSimpleName().equals(instanceName));
+		Assert.assertEquals(id+": id",id, ref.getId());
+		Assert.assertEquals(id+": name", name, ref.getName());
+		Assert.assertEquals(id+": label",label, ref.getLabel());
+		Assert.assertEquals(id+": isDeployed",isDeployed, ref.isDeployed());
+		Assert.assertEquals(id+": isImpl", isImpl, ref.isJSFImplementation());
+		Assert.assertEquals(id+": version", version, ref.getMaxSupportedVersion());
+		Assert.assertEquals(id+": jarCount", jarCount, ref.getJars().size());
+		Assert.assertNotNull(ref.toString());
+	}
+	
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFCoreUtilHelper.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFCoreUtilHelper.java
index 17e449e..e8e35a8 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFCoreUtilHelper.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFCoreUtilHelper.java
@@ -16,6 +16,7 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Plugin;
 import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
 import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
 import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
@@ -29,22 +30,49 @@
 
 public class JSFCoreUtilHelper {
 
+	/**
+	 * Constructs jsfLib using this plugin's install path and "testfiles" subdirectory 
+	 * @param id
+	 * @param name
+	 * @param archivefiles
+	 * @param bImpl
+	 * @return
+	 */
 	public static JSFLibrary constructJSFLib(
 			String id, 
 			String name,			
 			String[] archivefiles, 
 			boolean bImpl) {
+	
+		String pathTestFiles = TestsPlugin.getInstallLocation().getPath() + "testfiles/";
+		
+		return constructJSFLib(id, name, pathTestFiles, archivefiles, bImpl);
+	}
+	
+	/**
+	 * @param id
+	 * @param name
+	 * @param pluginRelativePathToArchiveFiles
+	 * @param archivefiles
+	 * @param bImpl
+	 * @return JSF Library
+	 */
+	public static JSFLibrary constructJSFLib(
+			String id, 
+			String name,
+			String pluginRelativePathToArchiveFiles,
+			String[] archivefiles, 
+			boolean bImpl) {
 		
 		ArchiveFile archiveFile = null;	
 		String testData;		
-		String pathTestFiles = TestsPlugin.getInstallLocation().getPath() + "testfiles/";
 		JSFLibrary jsfLib = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibrary();
 //		jsfLib.setID(id);
 		jsfLib.setName(name);	
 		jsfLib.setImplementation(bImpl);
 		
 		for (int i = 0; i < archivefiles.length; i++) {
-			testData = pathTestFiles + archivefiles[i];						
+			testData = pluginRelativePathToArchiveFiles + archivefiles[i];						
 			archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
 			archiveFile.setRelativeToWorkspace(false);
 			archiveFile.setSourceLocation(testData);