JSF Library Registry/References related changes
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF
index 6779534..e5ddbef 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.eclipse.jst.jsf.core.tests Plug-in
-Bundle-SymbolicName: org.eclipse.jst.jsf.core.tests; singleton:=true
+Bundle-SymbolicName: org.eclipse.jst.jsf.core.tests;singleton:=true
Bundle-Version: 0.5.0
Bundle-Activator: org.eclipse.jst.jsf.core.tests.TestsPlugin
Bundle-Vendor: Oracle
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml
index 4d8a631..11fb4e6 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
+ <extension
+ id="id1"
+ point="org.eclipse.jst.jsf.core.pluginProvidedJsfLibraries">
+ <jsfLibrary
+ archiveFilesDelegate="org.eclipse.jst.jsf.core.tests.jsflibraryregistry.TEST_PP_LIBArchiveFilesDelegate"
+ isImplementation="true"
+ label="2_JAR_LIB"
+ maxVersionSupported="v1_1"
+ name="TEST_PP_LIB_2">
+ </jsfLibrary>
+ <jsfLibrary
+ archiveFilesDelegate="org.eclipse.jst.jsf.core.tests.jsflibraryregistry.TEST_PP_LIB_EMPTYArchiveFilesDelegate"
+ isImplementation="false"
+ label="EMPTY_LIB"
+ maxVersionSupported="v1_2"
+ name="TEST_PP_LIB_EMPTY">
+ </jsfLibrary>
+ </extension>
</plugin>
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 8088f8f..eb9c57b 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
@@ -13,11 +13,11 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.jst.jsf.core.tests.appconfig.provider.TestJARFileJSFAppConfigProvider;
import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryConfigDialogSettingDataTestCases;
import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryConfigModelTestCases;
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.jsflibraryregistry.ArchiveFileTestCases;
import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.JSFLibraryRegistryPackageTestCases;
import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.JSFLibraryRegistryTestCases;
@@ -70,6 +70,9 @@
// BUT, to be on the safe side, always run them LAST.
suite.addTestSuite(MigrationV1toV2Test.class);
+ suite.addTestSuite(JSFLibraryReferenceTestCases.class);
+
+ //
//$JUnit-END$
return suite;
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigDialogSettingDataTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigDialogSettingDataTestCases.java
index a29822c..f72bea6 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigDialogSettingDataTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryConfigDialogSettingDataTestCases.java
@@ -17,7 +17,7 @@
super.setUp();
JSFCoreUtilHelper.createJSFLibraryRegistry();
- libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
compLibs = new String[1]; // test data has one component library
JSFLibrary lib = (JSFLibrary)libReg.getNonImplJSFLibraries().get(0);
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 1d8f0f4..58e5469 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
@@ -12,7 +12,7 @@
import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigDialogSettingData;
import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModel;
import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfiglModelSource;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryReference;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference;
import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryConfigModel.JSFLibraryConfigModelFactory;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry;
@@ -31,7 +31,7 @@
super.setUp();
JSFCoreUtilHelper.createJSFLibraryRegistry();
- JSFLibraryRegistry libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ JSFLibraryRegistry libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
/* number of components is changed in workspace when running the whole test suite.
* Recording the number from registry for testing.
@@ -74,8 +74,8 @@
public void testGetSavedJSFImplementationLibrary() {
JSFLibraryConfigModel model = JSFLibraryConfigModelFactory.createInstance(modelSrc);
- JSFLibraryRegistry libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
- JSFLibraryReference libImplRef = model.getCurrentJSFImplementationLibrarySelection();
+ JSFLibraryRegistry libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
+ JSFLibraryInternalReference libImplRef = model.getCurrentJSFImplementationLibrarySelection();
Assert.assertNotNull(libImplRef);
Assert.assertTrue(libReg.getDefaultImplementation().getID().equals(libImplRef.getID()));
}
@@ -83,12 +83,12 @@
public void testGetSavedJSFComponentLibraries() {
JSFLibraryConfigModel model = JSFLibraryConfigModelFactory.createInstance(modelSrc);
- /*JSFLibraryRegistry libReg = */JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ /*JSFLibraryRegistry libReg = */JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
List lstCompRef = model.getCurrentJSFComponentLibrarySelection();
Assert.assertTrue(lstCompRef.size() == 1);
- JSFLibraryReference libCompRef = (JSFLibraryReference) lstCompRef.get(0);
+ JSFLibraryInternalReference libCompRef = (JSFLibraryInternalReference) lstCompRef.get(0);
Assert.assertNotNull(libCompRef);
Assert.assertTrue(libCompRef.isSelected());
Assert.assertTrue(libCompRef.isCheckedToBeDeployed());
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryRegistryUtilTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryRegistryUtilTestCases.java
index 70990ed..5fe35ce 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryRegistryUtilTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFLibraryRegistryUtilTestCases.java
@@ -1,15 +1,15 @@
package org.eclipse.jst.jsf.core.tests.jsflibraryconfig;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference;
import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryReference;
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.JSFLibraryRegistryFactory;
import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
public class JSFLibraryRegistryUtilTestCases extends TestCase {
private JSFLibraryRegistry libReg = null;
private JSFLibraryRegistryUtil libUtilInstance = null;
@@ -19,7 +19,7 @@
super.setUp();
JSFCoreUtilHelper.createJSFLibraryRegistry();
- libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ libReg = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
numCompLibs = libReg.getNonImplJSFLibraries().size();
libUtilInstance = JSFLibraryRegistryUtil.getInstance();
}
@@ -36,13 +36,13 @@
}
public void testGetDefaultJSFImplementationLibrary() {
- JSFLibraryReference dftImplLib = libUtilInstance.getDefaultJSFImplementationLibrary();
+ JSFLibraryInternalReference dftImplLib = libUtilInstance.getDefaultJSFImplementationLibrary();
Assert.assertNotNull(dftImplLib);
Assert.assertEquals(libReg.getDefaultImplementation().getID(), dftImplLib.getID());
}
public void testGetJSFLibryReferencebyID() {
- JSFLibraryReference lib = libUtilInstance.getJSFLibraryReferencebyID(libReg.getDefaultImplementationID());
+ JSFLibraryInternalReference lib = libUtilInstance.getJSFLibraryReferencebyID(libReg.getDefaultImplementationID());
Assert.assertNotNull(lib);
Assert.assertEquals(libReg.getDefaultImplementation().getID(), lib.getID());
}
@@ -53,7 +53,7 @@
jsfLib.setName("A_COMP_LIB");
jsfLib.setImplementation(false);
- JSFLibraryReference jsfLibRef = new JSFLibraryReference(jsfLib,
+ JSFLibraryInternalReference jsfLibRef = new JSFLibraryInternalReference(jsfLib,
false, // selected
false); // to be deployed
Assert.assertTrue(libReg.getNonImplJSFLibraries().size() == numCompLibs);
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFProjectLibraryReferenceTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFProjectLibraryReferenceTestCases.java
index 03857aa..66c4eb4 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFProjectLibraryReferenceTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfig/JSFProjectLibraryReferenceTestCases.java
@@ -3,7 +3,7 @@
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryReference;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory;
@@ -14,7 +14,7 @@
// private String JSF_ID = "123456789";
private boolean isImpl = false;
private JSFLibrary jsfLib = null;
- private JSFLibraryReference jsfLibRef = null;
+ private JSFLibraryInternalReference jsfLibRef = null;
public JSFProjectLibraryReferenceTestCases(String name) {
super(name);
@@ -24,11 +24,10 @@
super.setUp();
jsfLib = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibrary();
-// jsfLib.setID(JSF_ID);
jsfLib.setName(JSF_NAME);
jsfLib.setImplementation(false);
- jsfLibRef = new JSFLibraryReference(jsfLib,
+ jsfLibRef = new JSFLibraryInternalReference(jsfLib,
true, // selected
true); // to be deployed
}
@@ -41,21 +40,22 @@
}
/*
- * General test class for JSFLibraryReference class
+ * General test class for JSFLibraryInternalReference class
*/
public void testJSFProjectLibraryReference() {
- JSFLibraryReference jsfLibRef_ = new JSFLibraryReference(jsfLib, true, true);
+ JSFLibraryInternalReference jsfLibRef_ = new JSFLibraryInternalReference(jsfLib, true, true);
Assert.assertNotNull(jsfLibRef_);
Assert.assertTrue(jsfLibRef_.isSelected());
Assert.assertTrue(jsfLibRef_.isCheckedToBeDeployed());
Assert.assertTrue(JSF_NAME.equals(jsfLibRef_.getName()));
Assert.assertTrue(JSF_NAME.equals(jsfLibRef_.getID()));
+ Assert.assertTrue(JSF_NAME.equals(jsfLibRef_.getLabel()));
Assert.assertTrue(isImpl == jsfLibRef_.isImplementation());
}
/*
- * test method for JSFLibraryReference.getLibrary()
+ * test method for JSFLibraryInternalReference.getLibrary()
*/
public void testGetLibrary() {
Assert.assertNotNull(jsfLibRef);
@@ -63,19 +63,19 @@
}
/*
- * test method for JSFLibraryReference.isCheckedToBeDeployed()
+ * test method for JSFLibraryInternalReference.isCheckedToBeDeployed()
*/
public void testIsCheckedToBeDeployed() {
- JSFLibraryReference jsfLibRef_ = new JSFLibraryReference(jsfLib, true, true);
+ JSFLibraryInternalReference jsfLibRef_ = new JSFLibraryInternalReference(jsfLib, true, true);
Assert.assertNotNull(jsfLibRef_);
Assert.assertTrue(jsfLibRef_.isCheckedToBeDeployed());
}
/*
- * test method for JSFLibraryReference.setSelected()
+ * test method for JSFLibraryInternalReference.setSelected()
*/
public void testSetSelected() {
- JSFLibraryReference jsfLibRef_ = new JSFLibraryReference(jsfLib, true, true);
+ JSFLibraryInternalReference jsfLibRef_ = new JSFLibraryInternalReference(jsfLib, true, true);
Assert.assertNotNull(jsfLibRef_);
Assert.assertTrue(jsfLibRef_.isSelected());
@@ -85,14 +85,14 @@
}
/*
- * test method for JSFLibraryReference.isImplementation()
+ * test method for JSFLibraryInternalReference.isImplementation()
*/
public void testIsImplementation() {
Assert.assertFalse(jsfLibRef.isImplementation());
}
/*
- * test method for JSFLibraryReference.getArchiveFiles()
+ * test method for JSFLibraryInternalReferenceJSFLibraryInternalReference.getArchiveFiles()
*/
public void testGetArchiveFiles() {
String path2TestJAR = TestsPlugin.getInstallLocation().getPath() + "testfiles/faces-all-bogus.jar";
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
new file mode 100644
index 0000000..6923cd3
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryconfiguration/JSFLibraryReferenceTestCases.java
@@ -0,0 +1,184 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryconfiguration;
+
+import java.util.Collection;
+
+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.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;
+
+public class JSFLibraryReferenceTestCases 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("JSFLibraryReferenceTestCases");
+ boolean created = projectTestEnvironment.createProject(true);
+
+ assertNotNull(projectTestEnvironment);
+ assertNotNull(projectTestEnvironment.getTestProject());
+ assertTrue(projectTestEnvironment.getTestProject().isAccessible());
+
+ if (created) {
+ // initialize test case for faces 1.1
+ JSFFacetedTestEnvironment jsfFacedEnv = new JSFFacetedTestEnvironment(projectTestEnvironment);
+ jsfFacedEnv.initialize(IJSFCoreConstants.FACET_VERSION_1_1);
+
+ 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.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 testGetJSFLibraryReferences() {
+ Collection<JSFLibraryReference> results = JSFLibraryConfigurationHelper.getJSFLibraryReferences(projectTestEnvironment.getTestProject());
+ Assert.assertNotNull(results);
+ Assert.assertTrue(results.size() >= 3);
+ }
+
+ public void testIsJSFLibraryContainer() throws JavaModelException, CoreException {
+ IClasspathEntry[] entries = null;
+ entries = getJDTTestEnv().getJavaProject().getRawClasspath();
+ for (int i=0;i<entries.length;i++) {
+ IClasspathEntry cpEntry = entries[i];
+ boolean isJsfLib = JSFLibraryConfigurationHelper.isJSFLibraryContainer(cpEntry);
+ if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
+ cpEntry.getPath().segment(0).equals(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID)) {
+ Assert.assertTrue("Is a JSF LIB: "+cpEntry.toString(), isJsfLib);
+ }
+ else
+ Assert.assertFalse("Is NOT a JSF LIB: "+cpEntry.toString(), isJsfLib);
+ }
+ }
+
+ public void testJSFLibraryReferenceFacadeFactoryCreate() throws CoreException{
+ IClasspathEntry[] entries = null;
+ try {
+ entries = getJDTTestEnv().getJavaProject().getRawClasspath();
+ for (int i=0;i<entries.length;i++){
+ IClasspathEntry cpEntry = entries[i];
+ boolean isJsfLib = JSFLibraryConfigurationHelper.isJSFLibraryContainer(cpEntry);
+ JSFLibraryReference ref = JSFLibraryReferenceFacadeFactory.create(cpEntry);
+ if (isJsfLib) {
+ 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 );
+ }
+ else if (libID.equals("JSFLIBNONIMPL_NAME")){
+ doAsserts(ref, "JSFLibraryReferenceUserDefinedImpl", "JSFLIBNONIMPL_NAME", "JSFLIBNONIMPL_NAME", false, false,JSFVersion.V1_2 );
+ }
+ 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 {
+ Assert.assertNull(ref);
+ }
+ }
+
+// JSFLibraryReferenceFacadeFactory.create(cpEntry)
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private JDTTestEnvironment getJDTTestEnv() throws CoreException {
+ if (jdtTestEnv == null){
+ jdtTestEnv = new JDTTestEnvironment(projectTestEnvironment);
+ }
+ return jdtTestEnv;
+ }
+
+ private void doAsserts(JSFLibraryReference ref, String instanceName, String id, String label, boolean isDeployed, boolean isImpl, JSFVersion version ) {
+ Assert.assertTrue(id+":instanceName", ref.getClass().getSimpleName().equals(instanceName));
+ Assert.assertEquals(id+": id",id, ref.getId());
+ 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());
+ }
+
+
+
+ private String getLibId(IClasspathEntry cpEntry){
+ return cpEntry.getPath().segment(1);
+ }
+
+// public void testCreateServerSuppliedJSFLibRef() {
+// fail("Not yet implemented");
+// }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/ArchiveFileTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/ArchiveFileTestCases.java
index be0c404..64d7482 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/ArchiveFileTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/ArchiveFileTestCases.java
@@ -12,18 +12,18 @@
import java.io.File;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.jsf.core.tests.TestsPlugin;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryFactory;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import org.eclipse.jst.jsf.core.tests.TestsPlugin;
public class ArchiveFileTestCases extends TestCase {
private String path4TestFiles;
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryPackageTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryPackageTestCases.java
index 3e0e06b..81d4384 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryPackageTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryPackageTestCases.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage;
-import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl;
-
import junit.framework.Assert;
import junit.framework.TestCase;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistryPackage;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryPackageImpl;
+
public class JSFLibraryRegistryPackageTestCases extends TestCase {
public JSFLibraryRegistryPackageTestCases(String name) {
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryTestCases.java
index d66ad9d..06d47fe 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryTestCases.java
@@ -10,12 +10,16 @@
*******************************************************************************/
package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+import java.util.List;
+
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
+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.tests.util.JSFCoreUtilHelper;
public class JSFLibraryRegistryTestCases extends TestCase {
@@ -86,15 +90,22 @@
*/
public void testGetPluginProvidedJSFLibraries() {
JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
- JSFLibrary pluginLib = JSFCoreUtilHelper.constructJSFLib("plugin_provided", "testfiles/JSFLib", true, true);
+ PluginProvidedJSFLibrary pluginLib = (PluginProvidedJSFLibrary)JSFCoreUtilHelper.constructJSFLib("plugin_provided", "testfiles/JSFLib", true, true);
jsfLibRegistry.addJSFLibrary(pluginLib);
JSFLibrary nonPluginLib = JSFCoreUtilHelper.constructJSFLib("non_plugin_provided", "testfiles/JSFLib", true, false);
jsfLibRegistry.addJSFLibrary(nonPluginLib);
- Assert.assertEquals(1, jsfLibRegistry.getPluginProvidedJSFLibraries().size());
- }
+ Assert.assertEquals(1, jsfLibRegistry.getPluginProvidedJSFLibraries().size());
+
+ Assert.assertEquals(pluginLib.getName(), pluginLib.getLabel());
+ pluginLib.setLabel("plugin_providedLABEL");
+ Assert.assertEquals("plugin_providedLABEL", pluginLib.getLabel());
+
+ Assert.assertEquals(nonPluginLib.getName(), nonPluginLib.getLabel());
+ Assert.assertEquals(nonPluginLib.getName(), nonPluginLib.getID());
+ }
/*
- * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getDefaultImplementation()'
+ * Test method for 'org.eclipse.jst.jsf.core.jsflibraryregistry.internal.internal.impl.JSFLibraryRegistryImpl.getDefaultImplementation()'
*/
public void testGetDefaultImplementation() {
JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
@@ -177,6 +188,7 @@
Assert.assertEquals(2, jsfLibRegistry.getAllJSFLibraries().size());
}
+
/*
* Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.addJSFLibrary(JSFLibrary)'
*/
@@ -203,5 +215,29 @@
jsfLibRegistry.removeJSFLibrary(lib);
Assert.assertEquals(0, jsfLibRegistry.getJSFLibraries().size());
}
+
+ public void testPluginProvidedJSFLibCreationFromExtPt() {
+ //2 jar lib
+ JSFLibraryRegistry jsfLibRegistry = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry();
+ List libs = jsfLibRegistry.getJSFLibrariesByName("TEST_PP_LIB_2");
+ Assert.assertNotNull(libs);
+ Assert.assertEquals(1, libs.size());
+ JSFLibrary lib = (JSFLibrary)libs.get(0);
+ Assert.assertTrue(lib instanceof PluginProvidedJSFLibrary);
+ Assert.assertEquals(2, lib.getArchiveFiles().size());
+ Assert.assertEquals("2_JAR_LIB", lib.getLabel());
+ Assert.assertTrue(lib.isImplementation());
+
+ //empty jar lib
+ libs = jsfLibRegistry.getJSFLibrariesByName("TEST_PP_LIB_EMPTY");
+ Assert.assertNotNull(libs);
+ Assert.assertEquals(1, libs.size());
+ lib = (JSFLibrary)libs.get(0);
+ Assert.assertTrue(lib instanceof PluginProvidedJSFLibrary);
+ Assert.assertEquals(0, lib.getArchiveFiles().size());
+ Assert.assertEquals("EMPTY_LIB", lib.getLabel());
+ Assert.assertFalse(lib.isImplementation());
+
+ }
} // end of JSFLibraryRegistryTestCases
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryTestCases.java
index 6ace15d..75561bc 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryTestCases.java
@@ -16,10 +16,10 @@
import junit.framework.TestCase;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.jst.jsf.core.tests.TestsPlugin;
-import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
+import org.eclipse.jst.jsf.core.tests.TestsPlugin;
+import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
public class JSFLibraryTestCases extends TestCase {
private JSFLibrary jsfLib = null;
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/MaintainDefaultImplementationAdapterTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/MaintainDefaultImplementationAdapterTestCases.java
index 0431ead..a357b96 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/MaintainDefaultImplementationAdapterTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/MaintainDefaultImplementationAdapterTestCases.java
@@ -13,9 +13,9 @@
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibraryRegistry;
+import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
public class MaintainDefaultImplementationAdapterTestCases extends TestCase {
@@ -25,7 +25,7 @@
protected JSFLibraryRegistry getPreparedJSFLibraryRegistry() {
//get registry from JSFCorePlugin
- JSFLibraryRegistry registry = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ JSFLibraryRegistry registry = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFLibraryHelper();
//clear registry (loaded and plugin-provided libs may have crept in)
registry.getJSFLibraries().clear();
registry.getPluginProvidedJSFLibraries().clear();
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIBArchiveFilesDelegate.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIBArchiveFilesDelegate.java
new file mode 100644
index 0000000..c0572e4
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIBArchiveFilesDelegate.java
@@ -0,0 +1,18 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+import org.eclipse.jst.jsf.core.jsflibraryregistry.PluginProvidedJSFLibraryArchiveFilesDelegate;
+
+public class TEST_PP_LIBArchiveFilesDelegate extends
+ PluginProvidedJSFLibraryArchiveFilesDelegate {
+
+ public TEST_PP_LIBArchiveFilesDelegate() {
+ super();
+ }
+
+ @Override
+ public void getArchiveFiles() {
+ addArchiveFile("/lib/foo.jar");
+ addArchiveFile("/boo.jar");
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIB_EMPTYArchiveFilesDelegate.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIB_EMPTYArchiveFilesDelegate.java
new file mode 100644
index 0000000..9f1d40a
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/TEST_PP_LIB_EMPTYArchiveFilesDelegate.java
@@ -0,0 +1,16 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+import org.eclipse.jst.jsf.core.jsflibraryregistry.PluginProvidedJSFLibraryArchiveFilesDelegate;
+
+public class TEST_PP_LIB_EMPTYArchiveFilesDelegate extends
+ PluginProvidedJSFLibraryArchiveFilesDelegate {
+
+ public TEST_PP_LIB_EMPTYArchiveFilesDelegate() {
+ super();
+ }
+
+ @Override
+ public void getArchiveFiles() {
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/migration/MigrationV1toV2Test.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/migration/MigrationV1toV2Test.java
index 6db9718..3a8bb83 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/migration/MigrationV1toV2Test.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/migration/MigrationV1toV2Test.java
@@ -10,6 +10,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.util.JSFLibraryRegistryUpgradeUtil;
import org.eclipse.jst.jsf.core.tests.TestsPlugin;
import org.eclipse.jst.jsf.test.util.JSFTestUtil;
@@ -34,6 +35,7 @@
// the test data when start is called
assertEquals(Bundle.ACTIVE, JSFCorePlugin.getDefault().getBundle().getState());
+ JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry();
// clear plugin meta-data on every call
_v1RegistryFile = clearRegistryFile(JSFLibraryRegistryUpgradeUtil.JSF_LIBRARY_REGISTRY_V1_URL);
_v2RegistryFile = clearRegistryFile(JSFLibraryRegistryUpgradeUtil.JSF_LIBRARY_REGISTRY_V2_URL);
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/project/facet/JSFFacetInstallDataModelProviderTestCases.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/project/facet/JSFFacetInstallDataModelProviderTestCases.java
index f6f4ec7..9080ca3 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/project/facet/JSFFacetInstallDataModelProviderTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/project/facet/JSFFacetInstallDataModelProviderTestCases.java
@@ -16,8 +16,8 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryReference;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryInternalReference;
+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.project.facet.IJSFFacetInstallDataModelProperties;
import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
@@ -38,7 +38,7 @@
//create a project, if one doesn't exist in the current workspace
IProject project = JSFCoreUtilHelper.createWebProject(PROJ_2_3_NAME);
//create lib
- jsfLib = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation();
+ jsfLib = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getDefaultImplementation();
dm = new JSFFacetInstallDataModelProvider();
IDataModel model = DataModelFactory.createDataModel(dm);
@@ -64,8 +64,8 @@
*/
public void testGetDefaultPropertyString() {
Assert.assertNotNull(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION));
- Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION) instanceof JSFLibraryReference);
- JSFLibraryReference ref = (JSFLibraryReference)dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION) ;
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION) instanceof JSFLibraryInternalReference);
+ JSFLibraryInternalReference ref = (JSFLibraryInternalReference)dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION) ;
Assert.assertTrue(ref.getLibrary() == jsfLib);
Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION) == Boolean.TRUE);
Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH) != null);
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 9e2d0de..17e449e 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
@@ -17,15 +17,15 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
-import org.eclipse.jst.jsf.core.tests.TestsPlugin;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
+import org.eclipse.jst.jsf.core.internal.jsflibraryconfig.JSFLibraryRegistryUtil;
import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.ArchiveFile;
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.JSFLibraryRegistryFactory;
+import org.eclipse.jst.jsf.core.tests.TestsPlugin;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
public class JSFCoreUtilHelper {
@@ -76,16 +76,16 @@
* If the JSF Library registry is empty, it will seed it with an Impl and non-Impl library
*/
public static void createJSFLibraryRegistry(){
- if (JSFCorePlugin.getDefault().getJSFLibraryRegistry().getAllJSFLibraries().size() < 2){
+ if (JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getAllJSFLibraries().size() < 2){
//create Impl
JSFLibrary lib = constructJSFLib("AN-IMPL-LIB", "/testfiles/JSFLib/", true, false);
- JSFCorePlugin.getDefault().getJSFLibraryRegistry().addJSFLibrary(lib);
+ JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().addJSFLibrary(lib);
//create non-Impl. Uses same jars but declares it to be non implementation
lib = constructJSFLib("A-NON-IMPL-LIB", "/testfiles/JSFLib/", false, false);
- JSFCorePlugin.getDefault().getJSFLibraryRegistry().addJSFLibrary(lib);
+ JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().addJSFLibrary(lib);
//create plugin impl
- lib = constructJSFLib("AN-IMPL-LIB", "/testfiles/JSFLib/", true, true);
- JSFCorePlugin.getDefault().getJSFLibraryRegistry().addJSFLibrary(lib);
+ lib = constructJSFLib("AN-IMPL-LIB-PP", "/testfiles/JSFLib/", true, true);
+ JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().addJSFLibrary(lib);
//create plugin-non impl
}
@@ -104,16 +104,16 @@
}
/**
- * Convenience method to get JSFLibraryRegistry instance from JSFCorePlugin
- * (which will cause the JSFCorePlugin.loadJSFLibraryRegistry() and
- * JSFCorePlugin.loadJSFLibraryExtensions() methods to be called and will
- * subsequently allow JSFCorePlugin.saveJSFLibraryRegistry() to be called,
+ * Convenience method to get the JSFLibraryRegistry instance
+ * (which will cause the loadJSFLibraryRegistry() and
+ * loadJSFLibraryExtensions() methods to be called and will
+ * subsequently allow saveJSFLibraryRegistry() to be called,
* if desired).
*
* @return JSFLibraryRegistry instance from JSFCorePlugin.
*/
- public static JSFLibraryRegistry getJSFLibraryRegistryFromJSFCorePlugin() {
- return JSFCorePlugin.getDefault().getJSFLibraryRegistry();
+ public static JSFLibraryRegistry getJSFLibraryRegistryFromJSFLibraryHelper() {
+ return JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry();
}
/**
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFFacetedTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFFacetedTestEnvironment.java
index bcefb90..733399a 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFFacetedTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFFacetedTestEnvironment.java
@@ -18,8 +18,18 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
+import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
import org.eclipse.jst.jsf.core.IJSFCoreConstants;
+import org.eclipse.jst.jsf.core.internal.jsflibraryregistry.JSFLibrary;
import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
+import org.eclipse.jst.jsf.core.jsflibraryconfiguration.JSFLibraryConfigurationHelper;
+import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.componentcore.internal.operation.FacetProjectCreationOperation;
@@ -62,9 +72,8 @@
{
final IProject project =
_projectTestEnvironment.getTestProject();
- //seed JSFLib registry if not present
- // TODO: is this really necessary for the facet?
- JSFCoreUtilHelper.createJSFLibraryRegistry();
+ //NO LONGER seeding JSFLib registry if not present
+ // call generateJSFLibraryRegistry if needed
_modelProvider = new JSFFacetInstallDataModelProvider();
_model = DataModelFactory.createDataModel(_modelProvider);
@@ -96,6 +105,25 @@
return facet.getVersion(version);
}
+ public void generateJSFLibraryRegistry() {
+ JSFCoreUtilHelper.createJSFLibraryRegistry();
+ }
+
+ public void addJSFLibraryReference(JSFLibrary lib, boolean isDeployed) throws CoreException{
+ JDTTestEnvironment jdtTestEnv = new JDTTestEnvironment(this._projectTestEnvironment);
+ IPath path = new Path(JSFLibraryConfigurationHelper.JSF_LIBRARY_CP_CONTAINER_ID).append(lib.getID());
+
+ IClasspathEntry cpEntry = null;
+ if (isDeployed) {
+ IClasspathAttribute depAttrib = JavaCore.newClasspathAttribute(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
+ ClasspathDependencyUtil.getDefaultRuntimePath(true).toString());
+ cpEntry = JavaCore.newContainerEntry( path ,null, new IClasspathAttribute[]{depAttrib}, true);
+ } else {
+ cpEntry = JavaCore.newContainerEntry(path);
+ }
+ jdtTestEnv.addClasspathEntry(cpEntry);
+ }
+
/**
* Dispose of held resources
*/
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/ProjectTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/ProjectTestEnvironment.java
index 9e2b66c..a4f3d00 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/ProjectTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/ProjectTestEnvironment.java
@@ -62,8 +62,10 @@
* will return without error if the project exists (it will be deleted and recreated)
*
* If set to false and the project exists, a runtime exception will be thrown
+ *
+ * @return true if project is created
*/
- public void createProject(boolean ignoreProjectExists)
+ public boolean createProject(boolean ignoreProjectExists)
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(_projectName);
@@ -86,6 +88,7 @@
project.open(monitor);
_project = project;
_projectCreated = true;
+ return true;
}
catch (CoreException ce)
{
@@ -93,6 +96,7 @@
}
}
}
+ return false;
}
/**
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
index c0dd847..7c6d12e 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
@@ -86,10 +86,10 @@
* throw a RuntimeException if faceting doesn't match what is expected.
*
* If set to false and the project exists, a runtime exception will be thrown
- *
+ * @return true if project was created
*/
@Override
- public void createProject(boolean ignoreProjectExists)
+ public boolean createProject(boolean ignoreProjectExists)
{
boolean doCreate = true;
@@ -117,6 +117,8 @@
_project = createWebProject(_projectName);
}
_projectCreated = true;
+
+ return doCreate;
} catch (Exception t) {
throw new RuntimeException(t);
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUITestsPlugin.java b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUITestsPlugin.java
index 341e2a6..df80023 100644
--- a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUITestsPlugin.java
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUITestsPlugin.java
@@ -11,8 +11,8 @@
********************************************************************************/
package org.eclipse.jst.jsf.ui.tests;
-import org.eclipse.ui.plugin.*;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibrariesPreferencePageTestCases.java b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibrariesPreferencePageTestCases.java
index 7c1273c..a660307 100644
--- a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibrariesPreferencePageTestCases.java
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibrariesPreferencePageTestCases.java
@@ -20,16 +20,16 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jst.jsf.ui.tests.util.JSFUITestHelper;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
+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.PluginProvidedJSFLibrary;
import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
import org.eclipse.jst.jsf.ui.internal.Messages;
import org.eclipse.jst.jsf.ui.internal.classpath.JSFLibrariesPreferencePage;
+import org.eclipse.jst.jsf.ui.tests.util.JSFUITestHelper;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
/**
* Tests the <code>org.eclipse.jsf.ui.internal.classpaths.JSFLibrariesPreferencePage</code>
@@ -74,7 +74,7 @@
Assert.assertFalse(controls.getRemoveLibraryButton().getEnabled());
Assert.assertFalse(controls.getMakeDefaultLibraryButton().getVisible());
- Iterator it = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getAllJSFLibraries().iterator();
+ Iterator it = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getAllJSFLibraries().iterator();
while (it.hasNext()){
JSFLibrary lib = (JSFLibrary)it.next();
tv.setSelection(new StructuredSelection(lib));
@@ -99,7 +99,7 @@
}
//now select an Archive file of a library
- JSFLibrary lib = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation();
+ JSFLibrary lib = JSFLibraryRegistryUtil.getInstance().getJSFLibraryRegistry().getDefaultImplementation();
tv.setSelection(new StructuredSelection(lib));
((TreeViewer)tv).expandAll();
tv.setSelection(new StructuredSelection(lib.getArchiveFiles().get(0)));