Initial checkin after module renamed.
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/.classpath b/jsf/tests/org.eclipse.jst.jsf.core.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/.cvsignore b/jsf/tests/org.eclipse.jst.jsf.core.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/.project b/jsf/tests/org.eclipse.jst.jsf.core.tests/.project
new file mode 100644
index 0000000..bcb3609
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jst.jsf.core.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/.settings/org.eclipse.jdt.ui.prefs b/jsf/tests/org.eclipse.jst.jsf.core.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..23a177f
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Wed Mar 08 10:10:00 PST 2006
+eclipse.preferences.version=1
+internal.default.compliance=default
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
new file mode 100644
index 0000000..f67833f
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+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-Version: 0.5.0
+Bundle-Activator: org.eclipse.jst.jsf.core.tests.TestsPlugin
+Bundle-Vendor: Oracle
+Bundle-Localization: plugin
+Bundle-ClassPath: jsfcoretests.jar
+Require-Bundle: org.eclipse.jst.jsf.core,
+ org.eclipse.ui,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.jst.j2ee.web,
+ org.eclipse.jst.server.core,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.jst.j2ee,
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jem.util,
+ org.eclipse.core.runtime,
+ org.eclipse.core.runtime.compatibility,
+ org.junit,
+ org.eclipse.wst.xml.core,
+ org.eclipse.jst.jsp.core
+Eclipse-AutoStart: true
+Export-Package: org.eclipse.jst.jsf.core.tests;x-friends:="org.eclipse.jst.jsf.ui.tests",
+ org.eclipse.jst.jsf.core.tests.jsflibraryregistry,
+ org.eclipse.jst.jsf.core.tests.project.facet,
+ org.eclipse.jst.jsf.core.tests.util
+Plugin-Class: org.eclipse.jst.jsf.core.tests.TestsPlugin
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/about.html b/jsf/tests/org.eclipse.jst.jsf.core.tests/about.html
new file mode 100644
index 0000000..6f6b96c
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/about.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>February 24, 2005</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/build.properties b/jsf/tests/org.eclipse.jst.jsf.core.tests/build.properties
new file mode 100644
index 0000000..3bc1810
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/build.properties
@@ -0,0 +1,8 @@
+bin.includes = META-INF/,\
+ about.html,\
+ test.xml,\
+ jsfcoretests.jar,\
+ testfiles/
+jars.compile.order = jsfcoretests.jar
+source.jsfcoretests.jar = src/
+output.jsfcoretests.jar = bin/
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml
new file mode 100644
index 0000000..4d8a631
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/plugin.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+</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
new file mode 100644
index 0000000..25d09ed
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
@@ -0,0 +1,43 @@
+package org.eclipse.jst.jsf.core.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/*import org.eclipse.jst.jsf.core.tests.annotations.AnnotationHelperTestCases;
+import org.eclipse.jst.jsf.core.tests.annotations.AnnotationMapTestCases;
+import org.eclipse.jst.jsf.core.tests.annotations.CaseInsensitiveAnnotationsTestCases;
+import org.eclipse.jst.jsf.core.tests.annotations.DuplicateAnnotationsTestCases;
+import org.eclipse.jst.jsf.core.tests.annotations.NegativeAnnotationFileTestCases;
+*/
+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;
+import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.JSFLibraryTestCases;
+import org.eclipse.jst.jsf.core.tests.jsflibraryregistry.MaintainDefaultImplementationAdapterTestCases;
+import org.eclipse.jst.jsf.core.tests.project.facet.JSFFacetInstallDataModelProviderTestCases;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.jst.jsf.core.tests");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(JSFLibraryRegistryTestCases.class);
+ suite.addTestSuite(JSFLibraryTestCases.class);
+ suite.addTestSuite(ArchiveFileTestCases.class);
+ suite.addTestSuite(MaintainDefaultImplementationAdapterTestCases.class);
+ suite.addTestSuite(JSFLibraryRegistryPackageTestCases.class);
+
+ suite.addTestSuite(JSFFacetInstallDataModelProviderTestCases.class);
+
+ //annotations
+/* suite.addTestSuite(AnnotationMapTestCases.class);
+ suite.addTestSuite(AnnotationHelperTestCases.class);
+ suite.addTestSuite(DuplicateAnnotationsTestCases.class);
+ suite.addTestSuite(CaseInsensitiveAnnotationsTestCases.class);
+ suite.addTestSuite(NegativeAnnotationFileTestCases.class);
+*/
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/TestsPlugin.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/TestsPlugin.java
new file mode 100644
index 0000000..762a8b2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/TestsPlugin.java
@@ -0,0 +1,84 @@
+package org.eclipse.jst.jsf.core.tests;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class TestsPlugin extends AbstractUIPlugin {
+ private static String ID_BUNDLE = "org.eclipse.jst.jsf.core.tests";
+
+ //The shared instance.
+ private static TestsPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public TestsPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static TestsPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.jst.jsf.core.tests", path);
+ }
+
+ public static URL getInstallLocation() {
+ URL installLocation = Platform.getBundle(TestsPlugin.ID_BUNDLE).getEntry("/");
+ URL resolvedLocation = null;
+ try {
+ resolvedLocation = FileLocator.resolve(installLocation);
+ }
+ catch (IOException e) {
+ // impossible
+ throw new Error(e);
+ }
+ return resolvedLocation;
+ }
+
+ public static File getTestFile(String filepath) {
+ URL installURL = getInstallLocation();
+ //String scheme = installURL.getProtocol();
+ String path = installURL.getPath();
+ String location = path + filepath;
+ File result = new File(location);
+ return result;
+ }
+
+}
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
new file mode 100644
index 0000000..4313946
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/ArchiveFileTestCases.java
@@ -0,0 +1,216 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+import java.io.File;
+
+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;
+
+public class ArchiveFileTestCases extends TestCase {
+ private String path4TestFiles;
+
+ // Test Data
+ private String[] archivefiles = {
+ "faces-all-bogus.jar",
+ "faces-api-bogus.jar",
+ "faces-impl-bogus.jar",
+ "tomahawk-bogus.jar"};
+
+ public ArchiveFileTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ path4TestFiles = TestsPlugin.getInstallLocation().getPath() + "testfiles/";
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testArchiveFile() {
+ JSFLibrary jsfLib = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibrary();
+ jsfLib.setID("Myfaces");
+ jsfLib.setName("Myfaces");
+
+ ArchiveFile archiveFile = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ for (int i = 0; i < archivefiles.length; i++) {
+ testData = path4TestFiles + archivefiles[i];
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+
+ Assert.assertEquals(testData, archiveFile.getSourceLocation());
+
+ Assert.assertEquals(path4TestFiles.substring(0, subStrEnd), archiveFile.getPath());
+
+ Assert.assertEquals(archivefiles[i], archiveFile.getName());
+
+ Assert.assertTrue(archiveFile.exists());
+
+ archiveFile.setJSFLibrary(jsfLib);
+
+ Assert.assertEquals(jsfLib, archiveFile.getJSFLibrary());
+ }
+
+ // test number of jar files in the library.
+ Assert.assertEquals(archivefiles.length, jsfLib.getArchiveFiles().size());
+ }
+
+ public void testsetSourceLocation() {
+ ArchiveFile archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+
+ Assert.assertNotNull(archiveFile);
+
+ // Not relative To workspace
+ archiveFile.setRelativeToWorkspace(false);
+ String testData = "c:\\test\\archivefiles";
+ archiveFile.setSourceLocation(testData);
+ Assert.assertEquals(testData, archiveFile.getSourceLocation());
+
+ // Relative to workspace
+ archiveFile.setRelativeToWorkspace(true);
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+ testData = "archivefiles";
+ archiveFile.setSourceLocation(wsRootPath.toOSString() + File.separator + testData);
+ Assert.assertEquals(testData, archiveFile.getSourceLocation());
+
+ }
+
+ public void testgetPath() {
+ ArchiveFile archiveFile = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ // Branch test - not-relative to workspace
+ testData = path4TestFiles + archivefiles[archivefiles.length-1];
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+// Assert.assertTrue(path4TestFiles.contains(archiveFile.getPath()));
+
+ // Branch test - relative to workspace
+ archiveFile.setRelativeToWorkspace(true);
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+ testData = "test.jar";
+ archiveFile.setSourceLocation(wsRootPath.toOSString() + File.separator + testData);
+ IPath arPath = new Path(archiveFile.getPath());
+ Assert.assertEquals(wsRootPath, arPath);
+
+ }
+
+ public void testgetName() {
+ ArchiveFile archiveFile = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ // Branch test - not-relative to workspace
+ testData = path4TestFiles + archivefiles[archivefiles.length-1];
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+ Assert.assertEquals(archivefiles[archivefiles.length-1], archiveFile.getName());
+
+ // Branch test - relative to workspace
+ archiveFile.setRelativeToWorkspace(true);
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+ testData = "test.jar";
+ archiveFile.setSourceLocation(wsRootPath.toOSString() + File.separator + testData);
+ Assert.assertEquals(testData, archiveFile.getName());
+
+ }
+
+ public void testexists() {
+ ArchiveFile archiveFile = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ testData = path4TestFiles + archivefiles[archivefiles.length-1];
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+
+ Assert.assertTrue(archiveFile.exists());
+
+ archiveFile.setRelativeToWorkspace(true);
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+ testData = "test.jar";
+ archiveFile.setSourceLocation(wsRootPath.toOSString() + File.separator + testData);
+ Assert.assertFalse(archiveFile.exists());
+
+ }
+
+ public void testequals() {
+ ArchiveFile archiveFile_01 = null;
+ ArchiveFile archiveFile_02 = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ testData = path4TestFiles + archivefiles[archivefiles.length-1];
+ archiveFile_01 = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile_01.setRelativeToWorkspace(false);
+ archiveFile_01.setSourceLocation(testData);
+
+ archiveFile_02 = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile_02.setRelativeToWorkspace(false);
+ archiveFile_02.setSourceLocation(testData);
+
+ Assert.assertEquals(archiveFile_01, archiveFile_02);
+
+ archiveFile_01.setRelativeToWorkspace(true);
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+ testData = "test.jar";
+ archiveFile_01.setSourceLocation(wsRootPath.toOSString() + File.separator + testData);
+ Assert.assertFalse(archiveFile_01.equals(archiveFile_02));
+ }
+
+ public void testcopyTo() {
+ ArchiveFile archiveFile = null;
+ String testData;
+ int subStrEnd = path4TestFiles.length() - 1;
+
+ testData = path4TestFiles + archivefiles[0];
+
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+
+ IWorkspaceRoot wsRoot = getWorkspaceRoot();
+ IPath wsRootPath = wsRoot.getLocation();
+
+ boolean copied = archiveFile.copyTo(wsRootPath.toOSString());
+
+ Assert.assertTrue(copied);
+ File fileCopied = new File(wsRootPath.toOSString() + File.separator + archivefiles[0]);
+ Assert.assertTrue(fileCopied.exists());
+
+ Assert.assertFalse(archiveFile.copyTo(wsRootPath.toOSString()));
+
+ // cleanup test data
+ fileCopied.deleteOnExit();
+ }
+
+ private IWorkspaceRoot getWorkspaceRoot() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ return (workspace != null) ? workspace.getRoot() : null;
+ }
+
+} // end of ArchiveFileTestCases
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
new file mode 100644
index 0000000..008bb67
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryPackageTestCases.java
@@ -0,0 +1,39 @@
+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;
+
+public class JSFLibraryRegistryPackageTestCases extends TestCase {
+
+ public JSFLibraryRegistryPackageTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testObjectCreation() {
+ JSFLibraryRegistryPackage jlrp = JSFLibraryRegistryPackageImpl.init();
+
+ Assert.assertNotNull(jlrp);
+
+ // test some getters that initialized in the Class satic init methods
+ Assert.assertNotNull(jlrp.getJSFLibrary_ID());
+ Assert.assertNotNull(jlrp.getName());
+ Assert.assertNotNull(jlrp.getJSFLibraryRegistry());
+ Assert.assertNotNull(jlrp.getArchiveFile());
+ Assert.assertNotNull(jlrp.getJSFLibrary());
+ Assert.assertNotNull(jlrp.getPluginProvidedJSFLibrary());
+ Assert.assertNotNull(jlrp.getJSFVersion());
+
+ }
+
+}
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
new file mode 100644
index 0000000..c6a3532
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryRegistryTestCases.java
@@ -0,0 +1,197 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+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;
+
+public class JSFLibraryRegistryTestCases extends TestCase {
+
+ public JSFLibraryRegistryTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getDefaultImplementationID()'
+ */
+ public void testGetDefaultImplementationID() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ Assert.assertEquals("", jsfLibRegistry.getDefaultImplementationID());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.setDefaultImplementationID(String)'
+ */
+ public void testSetDefaultImplementationID() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ String updatedImplID = "myfaces_reg";
+ jsfLibRegistry.setDefaultImplementationID(updatedImplID);
+ Assert.assertEquals(updatedImplID, jsfLibRegistry.getDefaultImplementationID());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getJSFLibraries()'
+ */
+ public void testGetJSFLibraries() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+
+ String[] archivefiles = {
+ "faces-all-bogu.jar",
+ "faces-api-bogus.jar",
+ "faces-impl-bogus.jar",
+ "tomahawk-bogus.jar"};
+
+ JSFLibrary implJSFLib = JSFCoreUtilHelper.constructJSFLib("impljsflib_id",
+ "impljsflib_name",
+ archivefiles,
+ true);
+ JSFLibrary nonimplJSFLib = JSFCoreUtilHelper.constructJSFLib("nonimpljsflib_id",
+ "nonimpljsflib_name",
+ archivefiles,
+ false);
+
+ jsfLibRegistry.addJSFLibrary(implJSFLib);
+ jsfLibRegistry.addJSFLibrary(nonimplJSFLib);
+
+ Assert.assertEquals(2, jsfLibRegistry.getJSFLibraries().size());
+ Assert.assertEquals(1, jsfLibRegistry.getImplJSFLibraries().size());
+ Assert.assertEquals(1, jsfLibRegistry.getNonImplJSFLibraries().size());
+ Assert.assertEquals(1, jsfLibRegistry.getJSFLibrariesByName("impljsflib_name").size());
+ Assert.assertEquals(1, jsfLibRegistry.getJSFLibrariesByName("nonimpljsflib_name").size());
+ Assert.assertNull(jsfLibRegistry.getJSFLibraryByID("nosuchlib_id"));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getPluginProvidedJSFLibraries()'
+ */
+ public void testGetPluginProvidedJSFLibraries() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary pluginLib = 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());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getDefaultImplementation()'
+ */
+ public void testGetDefaultImplementation() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary lib = JSFCoreUtilHelper.constructJSFLib("lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib);
+ jsfLibRegistry.setDefaultImplementation(lib);
+ Assert.assertEquals(lib, jsfLibRegistry.getDefaultImplementation());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.setDefaultImplementation(JSFLibrary)'
+ */
+ public void testSetDefaultImplementation() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary lib = JSFCoreUtilHelper.constructJSFLib("lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib);
+ jsfLibRegistry.setDefaultImplementation(lib);
+ Assert.assertEquals(lib, jsfLibRegistry.getDefaultImplementation());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getJSFLibraryByID(String)'
+ */
+ public void testGetJSFLibraryByID() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary lib = JSFCoreUtilHelper.constructJSFLib("lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib);
+ String libID = "myNewID";
+ lib.setID(libID);
+ Assert.assertEquals(lib, jsfLibRegistry.getJSFLibraryByID(libID));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getJSFLibrariesByName(String)'
+ */
+ public void testGetJSFLibrariesByName() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ String lib1Name = "Sun RI v1.1";
+ JSFLibrary lib1 = JSFCoreUtilHelper.constructJSFLib(lib1Name, "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib1);
+ String lib2Name = "Another Sun RI v1.1";
+ JSFLibrary lib2 = JSFCoreUtilHelper.constructJSFLib(lib2Name, "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib2);
+ Assert.assertEquals(1, jsfLibRegistry.getJSFLibrariesByName(lib1Name).size());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getImplJSFLibraries()'
+ */
+ public void testGetImplJSFLibraries() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary implLib = JSFCoreUtilHelper.constructJSFLib("impl_lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(implLib);
+ JSFLibrary nonImplLib = JSFCoreUtilHelper.constructJSFLib("non_impl_lib", "testfiles/JSFLib", false, false);
+ jsfLibRegistry.addJSFLibrary(nonImplLib);
+ Assert.assertEquals(1, jsfLibRegistry.getImplJSFLibraries().size());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getNonImplJSFLibraries()'
+ */
+ public void testGetNonImplJSFLibraries() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary implLib = JSFCoreUtilHelper.constructJSFLib("impl_lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(implLib);
+ JSFLibrary nonImplLib = JSFCoreUtilHelper.constructJSFLib("non_impl_lib", "testfiles/JSFLib", false, false);
+ jsfLibRegistry.addJSFLibrary(nonImplLib);
+ Assert.assertEquals(1, jsfLibRegistry.getNonImplJSFLibraries().size());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.getAllJSFLibraries()'
+ */
+ public void testGetAllJSFLibraries() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary lib1 = JSFCoreUtilHelper.constructJSFLib("plugin_provided", "testfiles/JSFLib", true, true);
+ jsfLibRegistry.addJSFLibrary(lib1);
+ JSFLibrary lib2 = JSFCoreUtilHelper.constructJSFLib("non_plugin_provided", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib2);
+ Assert.assertEquals(2, jsfLibRegistry.getAllJSFLibraries().size());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.addJSFLibrary(JSFLibrary)'
+ */
+ public void testAddJSFLibrary() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary pluginLib = JSFCoreUtilHelper.constructJSFLib("plugin_provided", "testfiles/JSFLib", true, true);
+ jsfLibRegistry.addJSFLibrary(pluginLib);
+ Assert.assertEquals(1, jsfLibRegistry.getPluginProvidedJSFLibraries().size());
+ Assert.assertEquals(0, jsfLibRegistry.getJSFLibraries().size());
+ JSFLibrary nonPluginLib = JSFCoreUtilHelper.constructJSFLib("non_plugin_provided", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(nonPluginLib);
+ Assert.assertEquals(1, jsfLibRegistry.getPluginProvidedJSFLibraries().size());
+ Assert.assertEquals(1, jsfLibRegistry.getJSFLibraries().size());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryRegistryImpl.removeJSFLibrary(JSFLibrary)'
+ */
+ public void testRemoveJSFLibrary() {
+ JSFLibraryRegistry jsfLibRegistry = JSFCoreUtilHelper.getNewJSFLibraryRegistry();
+ JSFLibrary lib = JSFCoreUtilHelper.constructJSFLib("lib", "testfiles/JSFLib", true, false);
+ jsfLibRegistry.addJSFLibrary(lib);
+ Assert.assertEquals(1, jsfLibRegistry.getJSFLibraries().size());
+ jsfLibRegistry.removeJSFLibrary(lib);
+ Assert.assertEquals(0, jsfLibRegistry.getJSFLibraries().size());
+ }
+
+} // 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
new file mode 100644
index 0000000..b2f4e5c
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/JSFLibraryTestCases.java
@@ -0,0 +1,110 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+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;
+
+public class JSFLibraryTestCases extends TestCase {
+ private JSFLibrary jsfLib = null;
+
+ // test data
+ private String jsfLibID = "MyfacesID";
+ private String jsfLibName = "MyfacesName";
+ private boolean jsfDeployDefault = true;
+ private String[] archivefiles = {
+ "faces-all-bogus.jar",
+ "faces-api-bogus.jar",
+ "faces-impl-bogus.jar",
+ "tomahawk-bogus.jar"};
+
+ public JSFLibraryTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ jsfLib = JSFCoreUtilHelper.constructJSFLib(
+ jsfLibID,
+ jsfLibName,
+ archivefiles,
+ true);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jsfLib = null;
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl.getArchiveFiles()'
+ * Probably not needed...
+ */
+ public void testgetArchiveFiles() {
+ EList el = jsfLib.getArchiveFiles();
+ Assert.assertNotNull(el);
+ Assert.assertEquals(archivefiles.length, el.size());
+ Iterator it = el.iterator();
+ int i = 0;
+ while(it.hasNext()) {
+ Assert.assertEquals(archivefiles[i], ((ArchiveFile)it.next()).getName());
+ i++;
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.jsflibraryregistry.impl.JSFLibraryImpl.containsArchiveFile(String)'
+ */
+ public void testcontainsArchiveFile() {
+ String pathTestFiles = TestsPlugin.getInstallLocation().getPath() + "testfiles/";
+
+ Assert.assertTrue( jsfLib.containsArchiveFile(pathTestFiles + archivefiles[2]) );
+ Assert.assertFalse( jsfLib.containsArchiveFile(pathTestFiles + "bogus.jar") );
+ Assert.assertFalse( jsfLib.containsArchiveFile(pathTestFiles + "sandbox.jar") );
+
+ }
+
+ public void testgetWorkingCopy() {
+ JSFLibrary jsfLibWorkingCopy = jsfLib.getWorkingCopy();
+
+ Assert.assertNotNull(jsfLibWorkingCopy);
+ Assert.assertEquals(jsfLibWorkingCopy.getArchiveFiles().size(),
+ jsfLib.getArchiveFiles().size());
+
+ }
+
+ public void testupdateValue() {
+ String[] archives = {
+ "faces-all-bogus.jar",
+ "faces-api-bogus.jar" };
+
+ JSFLibrary jsfLibtmp = JSFCoreUtilHelper.constructJSFLib(
+ "jsfLibTmp",
+ "jsfLibTmpName",
+ archives,
+ true);
+
+ jsfLibtmp.updateValues(jsfLib);
+
+ Assert.assertEquals(jsfLibtmp.getID(), jsfLib.getID());
+ Assert.assertEquals(jsfLibtmp.getName(), jsfLib.getName());
+ Assert.assertEquals(jsfLibtmp.getArchiveFiles().size(),
+ jsfLib.getArchiveFiles().size());
+
+ }
+
+ /**
+ * ArchiveFile.copyTo should be sufficient to cover this case.
+ *
+ public void testcopyTo() {
+ }
+ */
+
+} // end of JSFLibraryTestCases
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
new file mode 100644
index 0000000..9c0c7c2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/jsflibraryregistry/MaintainDefaultImplementationAdapterTestCases.java
@@ -0,0 +1,112 @@
+package org.eclipse.jst.jsf.core.tests.jsflibraryregistry;
+
+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;
+
+public class MaintainDefaultImplementationAdapterTestCases extends TestCase {
+
+ public MaintainDefaultImplementationAdapterTestCases(String name) {
+ super(name);
+ }
+
+ protected JSFLibraryRegistry getPreparedJSFLibraryRegistry() {
+ //get registry from JSFCorePlugin
+ JSFLibraryRegistry registry = JSFCoreUtilHelper.getJSFLibraryRegistryFromJSFCorePlugin();
+ //clear registry (loaded and plugin-provided libs may have crept in)
+ registry.getJSFLibraries().clear();
+ registry.getPluginProvidedJSFLibraries().clear();
+ //ensure default implementation is null
+ registry.setDefaultImplementation(null);
+ return registry;
+ }
+
+ public void testAddingFirstImplSetsNewDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add impl
+ JSFLibrary impl1 = JSFCoreUtilHelper.constructJSFLib("impl1", "impl1", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl1);
+ //test
+ Assert.assertEquals(impl1, registry.getDefaultImplementation());
+ }
+
+ public void testRemovingDefaultImplSetsNewDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add impl
+ JSFLibrary impl1 = JSFCoreUtilHelper.constructJSFLib("impl1", "impl1", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl1);
+ //create and add impl
+ JSFLibrary impl2 = JSFCoreUtilHelper.constructJSFLib("impl2", "impl2", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl2);
+ //test
+ Assert.assertEquals(impl1, registry.getDefaultImplementation());
+ //remove default impl
+ registry.removeJSFLibrary(impl1);
+ //test
+ Assert.assertEquals(impl2, registry.getDefaultImplementation());
+ }
+
+ public void testRemovingLastImplNullsDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add impl
+ JSFLibrary impl1 = JSFCoreUtilHelper.constructJSFLib("impl1", "impl1", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl1);
+ //test
+ Assert.assertEquals(impl1, registry.getDefaultImplementation());
+ //remove default impl
+ registry.removeJSFLibrary(impl1);
+ //test
+ Assert.assertNull(registry.getDefaultImplementation());
+ }
+
+ public void testChangingLibToImplSetsNewDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add lib
+ JSFLibrary lib1 = JSFCoreUtilHelper.constructJSFLib("lib1", "lib1", "testfiles/JSFLib", false, false);
+ registry.addJSFLibrary(lib1);
+ //test
+ Assert.assertNull(registry.getDefaultImplementation());
+ //make lib an impl
+ lib1.setImplementation(true);
+ //test
+ Assert.assertEquals(lib1, registry.getDefaultImplementation());
+ }
+
+ public void testChangingImplToLibSetsNewDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add impl
+ JSFLibrary impl1 = JSFCoreUtilHelper.constructJSFLib("impl1", "impl1", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl1);
+ //create and add impl
+ JSFLibrary impl2 = JSFCoreUtilHelper.constructJSFLib("impl2", "impl2", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl2);
+ //test
+ Assert.assertEquals(impl1, registry.getDefaultImplementation());
+ //make default impl a lib
+ impl1.setImplementation(false);
+ //test
+ Assert.assertEquals(impl2, registry.getDefaultImplementation());
+ }
+
+ public void testChangingLastImplToLibNullsDefaultImpl() {
+ //get prepared registry
+ JSFLibraryRegistry registry = getPreparedJSFLibraryRegistry();
+ //create and add impl
+ JSFLibrary impl1 = JSFCoreUtilHelper.constructJSFLib("impl1", "impl1", "testfiles/JSFLib", true, false);
+ registry.addJSFLibrary(impl1);
+ //test
+ Assert.assertEquals(impl1, registry.getDefaultImplementation());
+ //make default impl a lib
+ impl1.setImplementation(false);
+ //test
+ Assert.assertNull(registry.getDefaultImplementation());
+ }
+}
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
new file mode 100644
index 0000000..dc3387e
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/project/facet/JSFFacetInstallDataModelProviderTestCases.java
@@ -0,0 +1,111 @@
+package org.eclipse.jst.jsf.core.tests.project.facet;
+
+import java.util.Set;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jst.jsf.core.tests.util.JSFCoreUtilHelper;
+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.jsflibraryregistry.JSFLibrary;
+import org.eclipse.jst.jsf.core.internal.project.facet.IJSFFacetInstallDataModelProperties;
+import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
+
+public class JSFFacetInstallDataModelProviderTestCases extends TestCase {
+ private static final String PROJ_2_3_NAME = "_TEST_2_3_PROJECT";
+ private static final String PROJ_2_4_NAME = "_TEST_2_4_PROJECT";
+
+ private JSFFacetInstallDataModelProvider dm;
+ private JSFLibrary jsfLib;
+
+ protected void setUp() throws Exception {
+ //seed JSFLib registry if not present
+ JSFCoreUtilHelper.createJSFLibraryRegistry();
+ //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();
+
+ dm = new JSFFacetInstallDataModelProvider();
+ IDataModel model = DataModelFactory.createDataModel(dm);
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.FACET_PROJECT_NAME, project.getName());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider.getPropertyNames()'
+ */
+ public void testGetPropertyNames() {
+ Set names = dm.getPropertyNames();
+ Assert.assertNotNull(names);
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.IMPLEMENTATION));
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION));
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.CONFIG_PATH));
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.SERVLET_NAME));
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS));
+ Assert.assertTrue(names.contains(IJSFFacetInstallDataModelProperties.WEBCONTENT_DIR));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider.getDefaultProperty(String)'
+ */
+ public void testGetDefaultPropertyString() {
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION) == jsfLib);
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.DEPLOY_IMPLEMENTATION) == Boolean.TRUE);
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH) != null);
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME) != null);
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.SERVLET_URL_PATTERNS) != null);
+ Assert.assertTrue(dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.WEBCONTENT_DIR) != null);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider.validate(String)'
+
+ public void testValidateString() {
+ //positive tests
+ IDataModel model = dm.getDataModel();
+
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, (String)dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH));
+ model.setProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION, jsfLib);
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME, (String)dm.getDefaultProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME));
+
+ Assert.assertTrue(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+ Assert.assertTrue(dm.validate(IJSFFacetInstallDataModelProperties.IMPLEMENTATION).isOK());
+ Assert.assertTrue(dm.validate(IJSFFacetInstallDataModelProperties.SERVLET_NAME).isOK());
+
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, "foo.xml");
+ Assert.assertTrue(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+ //negative tests
+ //config path
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, "");
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, "../../../foo.xml");
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, "WEB-INF/xxx.txt");
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ String pathWithDevice = new Path(Platform.getLocation().getDevice(), "/temp/faces-config.xml").toOSString();
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, pathWithDevice );
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.CONFIG_PATH, "\\WEB-INF\\xxx.txt");
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ //impl
+ model.setProperty(IJSFFacetInstallDataModelProperties.IMPLEMENTATION, null);
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.CONFIG_PATH).isOK());
+
+ //servlet name
+ //can't check null name because null set returns default value
+ model.setStringProperty(IJSFFacetInstallDataModelProperties.SERVLET_NAME, " ");
+ Assert.assertFalse(dm.validate(IJSFFacetInstallDataModelProperties.SERVLET_NAME).isOK());
+
+ }
+ */
+}
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
new file mode 100644
index 0000000..13e48cb
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/JSFCoreUtilHelper.java
@@ -0,0 +1,181 @@
+package org.eclipse.jst.jsf.core.tests.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.eclipse.core.resources.IProject;
+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.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;
+
+public class JSFCoreUtilHelper {
+
+ public static JSFLibrary constructJSFLib(
+ String id,
+ String name,
+ 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];
+ archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(testData);
+ archiveFile.setJSFLibrary(jsfLib);
+ }
+
+ return jsfLib;
+ }
+
+ /**
+ * Create a Dynamic Web application with given name using default operation.
+ * If project with given name already exists, then it returns that project.
+ *
+ * @param aProjectName Project name.
+ * @return IProject instance.
+ * @throws Exception on error.
+ */
+ public static IProject createWebProject(String aProjectName) throws Exception {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(aProjectName);
+ if (!project.exists()) {
+ IDataModel dataModel = DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
+ dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, aProjectName);
+ dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ }
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(aProjectName);
+ }
+
+ /**
+ * 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){
+ //create Impl
+ JSFLibrary lib = constructJSFLib("AN-IMPL-LIB", "/testfiles/JSFLib/", true, false);
+ JSFCorePlugin.getDefault().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);
+ //create plugin impl
+ lib = constructJSFLib("AN-IMPL-LIB", "/testfiles/JSFLib/", true, true);
+ JSFCorePlugin.getDefault().getJSFLibraryRegistry().addJSFLibrary(lib);
+ //create plugin-non impl
+
+ }
+ }
+
+ /**
+ * Convenience method to get new JSFLibraryRegistry instance from factory.
+ * Note that the returned instance is not associated with a resource and so
+ * cannot be loaded or saved unless a resource is created and the returned
+ * instance is set in the resource contents.
+ *
+ * @return JSFLibraryRegistry instance.
+ */
+ public static JSFLibraryRegistry getNewJSFLibraryRegistry() {
+ return JSFLibraryRegistryFactory.eINSTANCE.createJSFLibraryRegistry();
+ }
+
+ /**
+ * 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,
+ * if desired).
+ *
+ * @return JSFLibraryRegistry instance from JSFCorePlugin.
+ */
+ public static JSFLibraryRegistry getJSFLibraryRegistryFromJSFCorePlugin() {
+ return JSFCorePlugin.getDefault().getJSFLibraryRegistry();
+ }
+
+ /**
+ * Creates a JSF Library from all the jars and zips found at the relative path from this plugin
+ *
+ * @param name
+ * @param relPathToArchives
+ * @param isImpl
+ * @return JSFLibrary
+ */
+ public static JSFLibrary constructJSFLib(
+ String name,
+ String relPathToArchives,
+ boolean isImpl,
+ boolean isFakedPlugginLib) {
+
+ JSFLibrary jsfLib = null;
+ if (isFakedPlugginLib){
+ jsfLib = JSFLibraryRegistryFactory.eINSTANCE.createPluginProvidedJSFLibrary();
+ jsfLib.setID("fakePluginLib_"+name);
+ }
+ else
+ jsfLib = JSFLibraryRegistryFactory.eINSTANCE.createJSFLibrary();
+
+ jsfLib.setName(name);
+ jsfLib.setImplementation(isImpl);
+
+ File pathTestFiles = new File(TestsPlugin.getInstallLocation().getPath()
+ + File.separator + relPathToArchives);
+ FilenameFilter jars = new FilenameFilter(){
+ public boolean accept(File dir, String name) {
+ if (name.length() >=5){
+ String lastChars = name.toLowerCase().substring(name.length() - 4);
+ if (lastChars.equals(".jar") || lastChars.equals(".zip"))
+ return true;
+ }
+ return false;
+ }
+ };
+
+ String[] fileNames = pathTestFiles.list(jars);
+ for(int i=0;i < fileNames.length ;i++){
+ String fileName = pathTestFiles.getAbsolutePath().concat(File.separator).concat(fileNames[i]);
+ ArchiveFile archiveFile = JSFLibraryRegistryFactory.eINSTANCE.createArchiveFile();
+ archiveFile.setRelativeToWorkspace(false);
+ archiveFile.setSourceLocation(fileName);
+ archiveFile.setJSFLibrary(jsfLib);
+ }
+
+ return jsfLib;
+ }
+
+ /**
+ * Creates a JSF Library from all the jars and zips found at the relative
+ * path from this plugin.
+ *
+ * @param ID
+ * @param name
+ * @param relPathToArchives
+ * @param isImpl
+ * @return JSFLibrary
+ */
+ public static JSFLibrary constructJSFLib(
+ String ID,
+ String name,
+ String relPathToArchives,
+ boolean isImpl,
+ boolean isFakedPlugginLib) {
+
+ JSFLibrary jsfLib = constructJSFLib(name, relPathToArchives, isImpl, isFakedPlugginLib);
+ jsfLib.setID(ID);
+ return jsfLib;
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/test.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/test.xml
new file mode 100644
index 0000000..7ae855a
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/test.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <!-- <property name="eclipse-home" value="${basedir}\..\.."/> -->
+ <echo message="basedir ${basedir}" />
+ <echo message="eclipse place ${eclipse-home}" />
+ <!-- sets the properties plugin-name, and library-file -->
+ <property name="plugin-name" value="org.eclipse.jst.jsf.core.tests"/>
+ <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test_3.1.0/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org.eclipse.jst.jsp.core.tests.*xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="jsf-folder" value="${eclipse-home}/jsf_folder"/>
+ <delete dir="${jsf-folder}" quiet="true"/>
+ <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${jsf-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.eclipse.jst.jsf.core.tests.AllTests" />
+ <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org.eclipse.jst.jsf.core.tests.*xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+</project>
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-beanutils-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-beanutils-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-beanutils-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-collections-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-collections-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-collections-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-digester-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-digester-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-digester-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-logging-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-logging-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/commons-logging-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-api-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-api-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-api-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-impl-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-impl-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jsf-impl-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jstl-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jstl-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/jstl-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/standard-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/standard-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/JSFLib/standard-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-all-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-all-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-all-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-api-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-api-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-api-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-impl-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-impl-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/faces-impl-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/CaseInsensitive.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/CaseInsensitive.xml
new file mode 100644
index 0000000..606a584
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/CaseInsensitive.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:grammar-annotations
+ xmlns:p="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema ../../../org.eclipse.jst.jsf.core/schema/grammar-annotations.xsd "
+ caseSensitive="false">
+ <cm-element name="Foo">
+ <cm-attribute name="Value">
+ <property name="Type">
+ <value>String1</value>
+ </property>
+ </cm-attribute>
+ <property name="Type">
+ <value>String1</value>
+ </property>
+ </cm-element>
+</p:grammar-annotations>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileA.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileA.xml
new file mode 100644
index 0000000..54b9844
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileA.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:grammar-annotations xmlns:p="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema ../../../org.eclipse.jst.jsf.core/schema/grammar-annotations.xsd ">
+ <cm-element name="Foo">
+ <cm-attribute name="Value">
+ <property name="Type">
+ <value>String1</value>
+ </property>
+ </cm-attribute>
+ <property name="Type">
+ <value>String1</value>
+ </property>
+ </cm-element>
+</p:grammar-annotations>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileB.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileB.xml
new file mode 100644
index 0000000..60cf5fa
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/FileB.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:grammar-annotations xmlns:p="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.eclipse.jst.jsf.core/grammarAnnotationSchema ../../../org.eclipse.jst.jsf.core/schema/grammar-annotations.xsd ">
+ <cm-element name="Foo">
+ <cm-attribute name="Value">
+ <property name="Type">
+ <value>String2</value>
+ </property>
+ </cm-attribute>
+ <property name="Type">
+ <value>String2</value>
+ </property>
+ </cm-element>
+</p:grammar-annotations>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.properties b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.properties
new file mode 100644
index 0000000..7b2299c
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.properties
@@ -0,0 +1,5 @@
+NLS1=a day in the life
+NLS2=another string
+
+
+
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.xml b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.xml
new file mode 100644
index 0000000..73c8ea8
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar-annotation
+ xmlns="http://org.eclipse.jsf.core/grammarAnnotationSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://org.eclipse.jsf.core/grammarAnnotationSchema D:\\EclipseWTPLatest\\WTPWorkspace\\org.eclipse.jst.jsf.core\\schema\\grammar-annotations.xsd ">
+ <cm-element name="validator">
+ <cm-attribute name="validatorId">
+ <property name="attr-val-content-assistant">
+ <value>com.eclipse.jst.jsf.ui.internal.ValidatorAttrValueContentAssistant</value>
+ </property>
+ <property name="faces-datatype">
+ <value>com.eclipse.jst.jsf.core.internal.model.datatype.Validator</value>
+ </property>
+ </cm-attribute>
+ </cm-element>
+ <cm-element name="nopropsOrAttrs">
+ </cm-element>
+ <cm-element name="noAttrs">
+ <property name="A">
+ <value>a</value>
+ </property>
+ <property name="B">
+ <value>b</value>
+ </property>
+ </cm-element>
+ <cm-element name="loaded">
+ <cm-attribute name="att1">
+ <property name="A1">
+ <value>a1</value>
+ </property>
+ <property name="B1">
+ <value>b1</value>
+ </property>
+ </cm-attribute>
+ <cm-attribute name="att2">
+ <property name="A2">
+ <value>a2</value>
+ </property>
+ <property name="B2">
+ <value>b2</value>
+ </property>
+ </cm-attribute>
+ <cm-attribute name="att3">
+ <property name="A3">
+ <value>a3</value>
+ </property>
+ <property name="B3">
+ <value>b3</value>
+ </property>
+ <property name="multival">
+ <value>1</value>
+ <value>2</value>
+ <value>3</value>
+ </property>
+ </cm-attribute>
+ <property name="A">
+ <value>a</value>
+ </property>
+ <property name="B">
+ <value>b</value>
+ </property>
+ <property name="multival">
+ <value>1</value>
+ <value>2</value>
+ <value>3</value>
+ </property>
+ </cm-element>
+ <cm-element name="NLS">
+ <cm-attribute name="NLS">
+ <property name="NLS1">
+ <value>%NLS1</value>
+ </property>
+ <property name="NLS2">
+ <value>%NLS2</value>
+ </property>
+ <property name="NLS3">
+ <value>%NLS3</value>
+ </property>
+ <property name="multival">
+ <value>%NLS1</value>
+ <value>%NLS2</value>
+ </property>
+ </cm-attribute>
+ <property name="NLS1">
+ <value>%NLS1</value>
+ </property>
+ <property name="NLS2">
+ <value>%NLS2</value>
+ </property>
+ <property name="NLS3">
+ <value>%NLS3</value>
+ </property>
+ <property name="multival">
+ <value>%NLS1</value>
+ <value>%NLS2</value>
+ </property>
+ <property name="NullVal">
+ <value></value>
+ </property>
+ </cm-element>
+</grammar-annotation>
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test_en_US.properties b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test_en_US.properties
new file mode 100644
index 0000000..94c8b66
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/metadata/jsf_test_en_US.properties
@@ -0,0 +1,5 @@
+NLS1=a day in the life(en_US)
+NLS2=another string(en_US)
+
+
+
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/sandbox-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/sandbox-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/sandbox-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/tomahawk-bogus.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/tomahawk-bogus.jar
new file mode 100644
index 0000000..de4b037
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/tomahawk-bogus.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/.classpath b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/.cvsignore b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/.project b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.project
new file mode 100644
index 0000000..a808017
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jst.jsf.ui.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.ui.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3c927d1
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: org.eclipse.jst.jsf.ui.tests Plug-in
+Bundle-SymbolicName: org.eclipse.jst.jsf.ui.tests
+Bundle-Version: 0.5.0
+Bundle-Activator: org.eclipse.jst.jsf.ui.tests.JSFUITestsPlugin
+Bundle-Vendor: Oracle
+Bundle-Localization: plugin
+Bundle-ClassPath: jsfuitests.jar
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.jst.j2ee.web,
+ org.eclipse.jst.server.core,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.core.resources,
+ org.eclipse.jst.j2ee,
+ org.eclipse.emf.common,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.emf.ecore,
+ org.eclipse.jem.util,
+ org.eclipse.jst.jsf.core.tests,
+ org.eclipse.jst.jsf.ui,
+ org.junit
+Eclipse-AutoStart: true
+Export-Package: org.eclipse.jst.jsf.ui.tests;x-friends:="org.eclipse.jst.jsf.ui",
+ org.eclipse.jst.jsf.ui.tests.classpath,
+ org.eclipse.jst.jsf.ui.tests.util
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/build.properties b/jsf/tests/org.eclipse.jst.jsf.ui.tests/build.properties
new file mode 100644
index 0000000..4d9867d
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/build.properties
@@ -0,0 +1,11 @@
+bin.includes = META-INF/,\
+ jsfuitests.jar,\
+ test.xml,\
+ build.properties
+source.jsfuitests.jar = src/
+jars.compile.order = jsfuitests.jar
+src.includes = META-INF/,\
+ test.xml,\
+ build.properties,\
+ src/
+output.jsfuitests.jar = bin/
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUIAllTests.java b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUIAllTests.java
new file mode 100644
index 0000000..f6d1955
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUIAllTests.java
@@ -0,0 +1,21 @@
+package org.eclipse.jst.jsf.ui.tests;
+
+import org.eclipse.jst.jsf.ui.tests.classpath.JSFLibrariesPreferencePageTestCases;
+import org.eclipse.jst.jsf.ui.tests.classpath.JSFLibraryWizardTestCases;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class JSFUIAllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.jst.jsf.ui.tests");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(JSFLibrariesPreferencePageTestCases.class);
+ suite.addTestSuite(JSFLibraryWizardTestCases.class);
+
+ //$JUnit-END$
+ return suite;
+ }
+
+}
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
new file mode 100644
index 0000000..09687b2
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/JSFUITestsPlugin.java
@@ -0,0 +1,54 @@
+package org.eclipse.jst.jsf.ui.tests;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class JSFUITestsPlugin extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static JSFUITestsPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public JSFUITestsPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static JSFUITestsPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.jst.jsf.ui.tests", path);
+ }
+}
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
new file mode 100644
index 0000000..3b0e4d1
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibrariesPreferencePageTestCases.java
@@ -0,0 +1,155 @@
+package org.eclipse.jst.jsf.ui.tests.classpath;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.jface.preference.PreferenceDialog;
+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.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;
+
+/**
+ * Tests the <code>org.eclipse.jsf.ui.internal.classpaths.JSFLibrariesPreferencePage</code>
+ * @author Gerry Kessler - Oracle
+ *
+ */
+public class JSFLibrariesPreferencePageTestCases extends TestCase {
+
+ public JSFLibrariesPreferencePageTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ //create registry if necessary
+ //the deault library has 4 libs; one of each type
+ JSFCoreUtilHelper.createJSFLibraryRegistry();
+ }
+
+ /**
+ * Tests that Add, Edit, Remove and Make default buttons are
+ * enabled/visible appropriatly for the differnt kinds of
+ * JSF Library selections in the TreeViewer.
+ */
+ public void testPreferencePage() {
+ PreferenceDialog dialog = JSFUITestHelper.getPreferenceDialog("org.eclipse.jst.jsf.ui.jsfLibraryPage");
+
+ Assert.assertNotNull(dialog);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
+ Assert.assertTrue(dialog.getSelectedPage() instanceof JSFLibrariesPreferencePage);
+ JSFLibrariesPreferencePage page = (JSFLibrariesPreferencePage)dialog.getSelectedPage();
+
+ Viewer tv = page.getLibraryViewer();
+
+ PrefPageControls controls = new PrefPageControls((Composite)page.getControl());
+
+ //Test no selection
+ tv.setSelection(StructuredSelection.EMPTY);
+ Assert.assertFalse(controls.getEditLibraryButton().getEnabled());
+ Assert.assertTrue(controls.getNewLibraryButton().getEnabled());
+ Assert.assertFalse(controls.getRemoveLibraryButton().getEnabled());
+ Assert.assertFalse(controls.getMakeDefaultLibraryButton().getVisible());
+
+ Iterator it = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getAllJSFLibraries().iterator();
+ while (it.hasNext()){
+ JSFLibrary lib = (JSFLibrary)it.next();
+ tv.setSelection(new StructuredSelection(lib));
+
+ Assert.assertTrue(controls.getNewLibraryButton().getEnabled());
+
+ if (lib.isImplementation())
+ Assert.assertTrue(controls.getMakeDefaultLibraryButton().getVisible());
+ else
+ Assert.assertFalse(controls.getMakeDefaultLibraryButton().getVisible());
+
+ if (lib instanceof PluginProvidedJSFLibrary){
+ //Needs improvement to ensure that message is invoked on click
+ Assert.assertTrue(controls.getEditLibraryButton().getEnabled());
+ Assert.assertTrue(controls.getRemoveLibraryButton().getEnabled());
+ }
+ else {
+ Assert.assertTrue(controls.getEditLibraryButton().getEnabled());
+ Assert.assertTrue(controls.getRemoveLibraryButton().getEnabled());
+ }
+
+ }
+
+ //now select an Archive file of a library
+ JSFLibrary lib = JSFCorePlugin.getDefault().getJSFLibraryRegistry().getDefaultImplementation();
+ tv.setSelection(new StructuredSelection(lib));
+ ((TreeViewer)tv).expandAll();
+ tv.setSelection(new StructuredSelection(lib.getArchiveFiles().get(0)));
+ Assert.assertTrue(controls.getEditLibraryButton().getEnabled());
+ Assert.assertTrue(controls.getNewLibraryButton().getEnabled());
+ Assert.assertFalse(controls.getRemoveLibraryButton().getEnabled());
+ Assert.assertFalse(controls.getMakeDefaultLibraryButton().getVisible());
+
+ //How to test New, Edit, Make Default???
+
+ dialog.close();
+ }
+
+ private class PrefPageControls{
+ Button btnAdd;
+ Button btnRemove;
+ Button btnMakeDefault;
+ Button btnEdit;
+ TreeViewer tv;
+
+ PrefPageControls(Composite parent){
+ findButtons(parent.getChildren());
+ }
+
+ public TreeViewer getViewer(){
+ return tv;
+ }
+
+ public Button getNewLibraryButton(){
+ return btnAdd;
+ }
+
+ public Button getRemoveLibraryButton(){
+ return btnRemove;
+ }
+
+ public Button getMakeDefaultLibraryButton(){
+ return btnMakeDefault;
+ }
+
+ public Button getEditLibraryButton(){
+ return btnEdit;
+ }
+ private void findButtons(Control[] controls){
+ for (int i=0;i < controls.length;i++){
+ Control c = controls[i];
+ if (c instanceof Button){
+ Button b = (Button)c;
+ if (b.getText().equals(Messages.JSFLibrariesPreferencePage_New))
+ btnAdd = b;
+ else if (b.getText().equals(Messages.JSFLibrariesPreferencePage_Remove))
+ btnRemove = b;
+ else if (b.getText().equals(Messages.JSFLibrariesPreferencePage_Edit))
+ btnEdit = b;
+ else if (b.getText().equals(Messages.JSFLibrariesPreferencePage_MakeDefault))
+ btnMakeDefault = b;
+ }
+ else if (c instanceof Composite){
+ findButtons(((Composite)c).getChildren());
+ }
+ }
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibraryWizardTestCases.java b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibraryWizardTestCases.java
new file mode 100644
index 0000000..4e22de4
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/classpath/JSFLibraryWizardTestCases.java
@@ -0,0 +1,76 @@
+package org.eclipse.jst.jsf.ui.tests.classpath;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.jst.jsf.ui.internal.classpath.JSFLibraryWizard;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class JSFLibraryWizardTestCases extends TestCase {
+
+ // Test data
+ private String pageName = "JSF Library";
+
+ public JSFLibraryWizardTestCases(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'org.eclipse.jst.jsf.ui.internal.classpath.JSFLibraryWizard.addPages()'
+ */
+ public void testAddPages() {
+ JSFLibraryWizard jsfLibWizard = new JSFLibraryWizard();
+
+ jsfLibWizard.addPages();
+
+ // Only one page added.
+ Assert.assertEquals(1, jsfLibWizard.getPageCount());
+
+ IWizardPage wp = jsfLibWizard.getPage(pageName);
+
+ Assert.assertNotNull(wp);
+ Assert.assertEquals(pageName, wp.getName());
+
+ // What about calling addPages again?
+ // Shuld we exptec multiple wizard pages with the same name?
+ jsfLibWizard.addPages();
+ Assert.assertEquals(2, jsfLibWizard.getPageCount());
+ }
+
+ public void testWizardDialog() {
+ IWorkbenchWizard wizard = new JSFLibraryWizard();
+ IWorkbench wb = PlatformUI.getWorkbench();
+ wizard.init(wb, (IStructuredSelection)null); // no selection
+
+ WizardDialog dialog = new WizardDialog(wb.getActiveWorkbenchWindow().getShell(), wizard);
+
+ // Dialog created successfully
+ Assert.assertNotNull(dialog);
+
+ dialog.setBlockOnOpen(false);
+
+ // Open dialog, but what is next then?
+ dialog.open();
+
+ // verify control in the composite?
+
+ Assert.assertFalse( wizard.canFinish() );
+
+ dialog.close();
+ }
+
+} // end of JSFLibraryWizardTestCases
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/util/JSFUITestHelper.java b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/util/JSFUITestHelper.java
new file mode 100644
index 0000000..2351340
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/src/org/eclipse/jst/jsf/ui/tests/util/JSFUITestHelper.java
@@ -0,0 +1,103 @@
+package org.eclipse.jst.jsf.ui.tests.util;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.IPreferenceNode;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
+import org.eclipse.ui.internal.dialogs.PropertyPageContributorManager;
+import org.eclipse.ui.internal.dialogs.PropertyPageManager;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * Borrowed from UITestHelper in org.eclipse.wst.internet.monitor.ui.tests
+ *
+ * @author YCHEN3
+ */
+public class JSFUITestHelper {
+ private static class PreferenceDialogWrapper extends PreferenceDialog {
+ public PreferenceDialogWrapper(Shell parentShell, PreferenceManager manager) {
+ super(parentShell, manager);
+ }
+ protected boolean showPage(IPreferenceNode node) {
+ return super.showPage(node);
+ }
+ }
+
+ private static class PropertyDialogWrapper extends PropertyDialog {
+ public PropertyDialogWrapper(Shell parentShell, PreferenceManager manager, ISelection selection) {
+ super(parentShell, manager, selection);
+ }
+ protected boolean showPage(IPreferenceNode node) {
+ return super.showPage(node);
+ }
+ }
+
+ public static PreferenceDialog getPreferenceDialog(String id) {
+ PreferenceDialogWrapper dialog = null;
+ PreferenceManager manager = WorkbenchPlugin.getDefault().getPreferenceManager();
+ if (manager != null) {
+ dialog = new PreferenceDialogWrapper(getShell(), manager);
+ dialog.create();
+
+ for (Iterator iterator = manager.getElements(PreferenceManager.PRE_ORDER).iterator();
+ iterator.hasNext();)
+ {
+ IPreferenceNode node = (IPreferenceNode)iterator.next();
+ if ( node.getId().equals(id) ) {
+ dialog.showPage(node);
+ break;
+ }
+ }
+ }
+ return dialog;
+ }
+
+ public static PropertyDialog getPropertyDialog(String id, IAdaptable element) {
+ PropertyDialogWrapper dialog = null;
+
+ PropertyPageManager manager = new PropertyPageManager();
+ String title = "";
+ String name = "";
+
+ // load pages for the selection
+ // fill the manager with contributions from the matching contributors
+ PropertyPageContributorManager.getManager().contribute(manager, element);
+
+ IWorkbenchAdapter adapter = (IWorkbenchAdapter)element.getAdapter(IWorkbenchAdapter.class);
+ if (adapter != null) {
+ name = adapter.getLabel(element);
+ }
+
+ // testing if there are pages in the manager
+ Iterator pages = manager.getElements(PreferenceManager.PRE_ORDER).iterator();
+ if (!pages.hasNext())
+ return null;
+
+ title = "Title: " + name;
+ dialog = new PropertyDialogWrapper(getShell(), manager, new StructuredSelection(element));
+ dialog.create();
+ dialog.getShell().setText(title);
+ for (Iterator iterator = manager.getElements(PreferenceManager.PRE_ORDER).iterator();
+ iterator.hasNext();) {
+ IPreferenceNode node = (IPreferenceNode)iterator.next();
+ if ( node.getId().equals(id) ) {
+ dialog.showPage(node);
+ break;
+ }
+ }
+ return dialog;
+ }
+
+ protected static Shell getShell() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+} // end of UITestHelper
diff --git a/jsf/tests/org.eclipse.jst.jsf.ui.tests/test.xml b/jsf/tests/org.eclipse.jst.jsf.ui.tests/test.xml
new file mode 100644
index 0000000..d08fc6e
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.ui.tests/test.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <!-- <property name="eclipse-home" value="${basedir}\..\.."/> -->
+ <echo message="basedir ${basedir}" />
+ <echo message="eclipse place ${eclipse-home}" />
+ <!-- sets the properties plugin-name, and library-file -->
+ <property name="plugin-name" value="org.eclipse.jst.jsf.ui.tests"/>
+ <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test_3.1.0/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org.eclipse.jst.jsf.ui.tests.*xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="jsf-folder" value="${eclipse-home}/jsf_folder"/>
+ <delete dir="${jsf-folder}" quiet="true"/>
+ <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${jsf-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.eclipse.jst.jsf.ui.tests.JSFUIAllTests" />
+ <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org.eclipse.jst.jsf.ui.tests.*xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+</project>
\ No newline at end of file