Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=149730.
Includes test case coverage and refactoring of ProjectTestEnvironment to separate web projects from basic and java natured projects.
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF
index bd13fb2..de14451 100644
--- a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/META-INF/MANIFEST.MF
@@ -14,6 +14,8 @@
org.eclipse.jst.jsf.test.util,
org.eclipse.jdt.core,
org.eclipse.jst.jsf.core.tests,
- org.eclipse.ui
+ org.eclipse.ui,
+ org.eclipse.emf.edit,
+ org.eclipse.jface.text
Eclipse-LazyStart: true
Bundle-Activator: org.eclipse.jst.jsf.context.symbol.tests.ContextSymbolTestPlugin
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java
index 7de7ff7..51f59d2 100644
--- a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/ContextSymbolTestPlugin.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+
package org.eclipse.jst.jsf.context.symbol.tests;
import org.eclipse.ui.plugin.AbstractUIPlugin;
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java
index c4a424c..19b175a 100644
--- a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIJavaTypeDescriptor2.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+
package org.eclipse.jst.jsf.context.symbol.tests;
import java.util.HashMap;
@@ -19,7 +31,7 @@
import org.eclipse.jst.jsf.core.tests.TestsPlugin;
import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
import org.eclipse.jst.jsf.test.util.TestFileResource;
-import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
import org.osgi.framework.Bundle;
/**
@@ -53,8 +65,8 @@
protected void setUp() throws Exception
{
super.setUp();
- final ProjectTestEnvironment projectTestEnvironment =
- new ProjectTestEnvironment("TestJDTBeanIntrospectorProject");
+ final WebProjectTestEnvironment projectTestEnvironment =
+ new WebProjectTestEnvironment("TestJDTBeanIntrospectorProject");
projectTestEnvironment.createProject();
_jdtTestEnvironment = new JDTTestEnvironment(projectTestEnvironment);
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIPropertySymbolItemProvider.java b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIPropertySymbolItemProvider.java
new file mode 100644
index 0000000..08f50a9
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/src/org/eclipse/jst/jsf/context/symbol/tests/TestIPropertySymbolItemProvider.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+
+package org.eclipse.jst.jsf.context.symbol.tests;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jst.jsf.context.symbol.SymbolFactory;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IComponentSymbol;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.IMapTypeDescriptor;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.ISymbol;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.provider.IContentProposalProvider;
+import org.eclipse.jst.jsf.context.symbol.internal.provisional.provider.ProposalCreationFactoryAdapter;
+import org.eclipse.jst.jsf.test.util.TestFileResource;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Tests for TestIPropertySymbolItemProvider
+ *
+ * @author cbateman
+ *
+ */
+public class TestIPropertySymbolItemProvider extends TestCase
+{
+ private Properties props;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ TestFileResource propertiesFile = new TestFileResource();
+ propertiesFile.load(ContextSymbolTestPlugin.getDefault().getBundle(),
+ "/testdata/bundle.properties.data");
+ props = new Properties();
+ props.load(new ByteArrayInputStream(propertiesFile.toBytes()));
+ }
+
+ /**
+ * Ensure test is in sync with test data and other sanity checks
+ */
+ public void testSanity()
+ {
+ assertEquals(props.size(), 3);
+ }
+
+ /**
+ * Test completion proposal construction for a properties map
+ */
+ public void testProposalConstructionForMap()
+ {
+ IMapTypeDescriptor mapDesc =
+ SymbolFactory.eINSTANCE.createIMapTypeDescriptor();
+ mapDesc.setImmutable(true);
+ mapDesc.setMapSource(props);
+
+ final IComponentSymbol symbol =
+ SymbolFactory.eINSTANCE.createIComponentSymbol();
+ symbol.setName("myTestSymbol");
+ symbol.setTypeDescriptor(mapDesc);
+
+ final ComposedAdapterFactory factory =
+ new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ final MyCompletionFactory creationInfo = new MyCompletionFactory();
+
+ for (final Iterator it = symbol.getTypeDescriptor().getProperties().iterator(); it.hasNext();)
+ {
+ final ISymbol propSymbol = (ISymbol) it.next();
+ final Object provider =
+ factory.adapt(propSymbol, IContentProposalProvider.class);
+
+ assertTrue(provider instanceof IContentProposalProvider);
+
+ final ICompletionProposal[] proposal =
+ ((IContentProposalProvider) provider).
+ getProposals(propSymbol, creationInfo);
+
+ assertNotNull(proposal);
+ }
+
+ List list = creationInfo._replacementText;
+
+ assertEquals(list.size(), 3);
+
+ for (final Iterator it = list.iterator();it.hasNext();)
+ {
+ String replacementText = (String) it.next();
+
+ if (replacementText.startsWith("['"))
+ {
+ replacementText = replacementText.substring(2);
+ replacementText = replacementText.substring(0, replacementText.length()-2);
+ }
+ assertTrue(props.containsKey(replacementText));
+ }
+ }
+
+ private class MyCompletionFactory extends ProposalCreationFactoryAdapter
+ {
+ final List _replacementText;
+
+ /**
+ *
+ */
+ public MyCompletionFactory()
+ {
+ super(0, 0);
+ _replacementText = new ArrayList();
+ }
+
+ public ICompletionProposal createProposal(String replacementText, String displayText, String additionalText, Image displayImage, Object targetObject)
+ {
+ _replacementText.add(replacementText);
+
+ return super.createProposal(replacementText, displayText, additionalText,
+ displayImage, targetObject);
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/bundle.properties.data b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/bundle.properties.data
new file mode 100644
index 0000000..02979fd
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.context.symbol.tests/testdata/bundle.properties.data
@@ -0,0 +1,3 @@
+simpleprop=blah
+two.dot=value
+three.dot.property=chicken
\ No newline at end of file
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 953e3e5..4807123 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
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+
package org.eclipse.jst.jsf.core.tests.util;
import java.util.HashSet;
@@ -8,7 +20,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jem.util.logger.proxy.Logger;
import org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDataModelProvider;
-import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+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;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
@@ -26,14 +38,14 @@
*/
public class JSFFacetedTestEnvironment
{
- private final ProjectTestEnvironment _projectTestEnvironment;
+ private final WebProjectTestEnvironment _projectTestEnvironment;
private JSFFacetInstallDataModelProvider _modelProvider;
private IDataModel _model;
/**
* @param projectTestEnvironment
*/
- public JSFFacetedTestEnvironment(final ProjectTestEnvironment projectTestEnvironment)
+ public JSFFacetedTestEnvironment(final WebProjectTestEnvironment projectTestEnvironment)
{
super();
_projectTestEnvironment = projectTestEnvironment;
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanIntrospector.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanIntrospector.java
index 0d3d027..1819615 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanIntrospector.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanIntrospector.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+
package org.eclipse.jst.jsf.core.tests.util;
import java.util.Iterator;
@@ -13,7 +25,7 @@
import org.eclipse.jst.jsf.core.tests.TestsPlugin;
import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
import org.eclipse.jst.jsf.test.util.TestFileResource;
-import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
/**
* Tester fot he JDTBeanIntrospector class
@@ -37,8 +49,8 @@
protected void setUp() throws Exception {
super.setUp();
- final ProjectTestEnvironment projectTestEnvironment =
- new ProjectTestEnvironment("TestJDTBeanIntrospectorProject");
+ final WebProjectTestEnvironment projectTestEnvironment =
+ new WebProjectTestEnvironment("TestJDTBeanIntrospectorProject");
projectTestEnvironment.createProject();
_jdtTestEnvironment = new JDTTestEnvironment(projectTestEnvironment);
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanPropertyWorkingCopy.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanPropertyWorkingCopy.java
index 74697f8..8ed98a0 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanPropertyWorkingCopy.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/util/TestJDTBeanPropertyWorkingCopy.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
package org.eclipse.jst.jsf.core.tests.util;
import junit.framework.TestCase;
@@ -10,7 +21,7 @@
import org.eclipse.jst.jsf.core.tests.TestsPlugin;
import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
import org.eclipse.jst.jsf.test.util.TestFileResource;
-import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
/**
* Tests basic operations on the jdt bean property
@@ -28,8 +39,8 @@
protected void setUp() throws Exception {
super.setUp();
- final ProjectTestEnvironment projectTestEnvironment =
- new ProjectTestEnvironment("TestJDTBeanPropertyWorkingCopyProject");
+ final WebProjectTestEnvironment projectTestEnvironment =
+ new WebProjectTestEnvironment("TestJDTBeanPropertyWorkingCopyProject");
projectTestEnvironment.createProject();
_jdtTestEnvironment = new JDTTestEnvironment(projectTestEnvironment);
diff --git a/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestDefaultBeanSymbolSourceProvider.java b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestDefaultBeanSymbolSourceProvider.java
index c36979a..724e8c1 100644
--- a/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestDefaultBeanSymbolSourceProvider.java
+++ b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestDefaultBeanSymbolSourceProvider.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
package org.eclipse.jst.jsf.designtime.tests;
import junit.framework.TestCase;
@@ -9,8 +20,8 @@
import org.eclipse.jst.jsf.core.tests.util.JSFFacetedTestEnvironment;
import org.eclipse.jst.jsf.designtime.internal.provisional.symbols.DefaultBeanSymbolSourceProvider;
import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
-import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
import org.eclipse.jst.jsf.test.util.TestFileResource;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
import org.osgi.framework.Bundle;
/**
@@ -32,8 +43,8 @@
{
super.setUp();
- final ProjectTestEnvironment projectTestEnvironment =
- new ProjectTestEnvironment("TestDefaultBeanSymbolSourceProvider_"+getName());
+ final WebProjectTestEnvironment projectTestEnvironment =
+ new WebProjectTestEnvironment("TestDefaultBeanSymbolSourceProvider_"+getName());
projectTestEnvironment.createProject();
_facesConfigFile = (IFile) projectTestEnvironment.
loadResourceInWebRoot(DesignTimeTestsPlugin.getDefault().getBundle(),
diff --git a/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestResourceBundleMapSource.java b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestResourceBundleMapSource.java
new file mode 100644
index 0000000..6da0a29
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/src/org/eclipse/jst/jsf/designtime/tests/TestResourceBundleMapSource.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+package org.eclipse.jst.jsf.designtime.tests;
+
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.jsf.designtime.internal.jsp.ResourceBundleMapSourceFactory;
+import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
+import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.eclipse.jst.jsf.test.util.TestFileResource;
+
+/**
+ * Test cases for ResourceBundleMapSource
+ *
+ * @author cbateman
+ *
+ */
+public class TestResourceBundleMapSource extends TestCase
+{
+
+ private static final String BUNDLE1_PATH = "bundles";
+ private static final String BUNDLE1_NAME = "bundle1.properties";
+
+// private static final String BUNDLE2_PATH = "bundles";
+// private static final String BUNDLE2_NAME = "bundle2.properties";
+
+ private IProject _project1;
+ private IProject _project2;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _project1 = initProject("BundleResourceTestProject1",
+ "/testdata/bundle1.resources.data",
+ BUNDLE1_PATH, BUNDLE1_NAME);
+ _project2 = initProject("BundleResourceTestProject2",
+ "/testdata/bundle2.resources.data",
+ BUNDLE1_PATH, BUNDLE1_NAME);
+ }
+
+ private IProject initProject(final String projectName, final String dataFilePath,
+ final String bundlePath, final String bundleName)
+ throws Exception
+ {
+ final ProjectTestEnvironment testEnv = new ProjectTestEnvironment(projectName);
+ testEnv.createProject();
+ final JDTTestEnvironment jdtTestEnv = new JDTTestEnvironment(testEnv);
+ final TestFileResource input = new TestFileResource();
+ input.load(DesignTimeTestsPlugin.getDefault().getBundle(),
+ dataFilePath);
+ jdtTestEnv.addResourceFile("src", new ByteArrayInputStream(input.toBytes()),
+ bundlePath, bundleName);
+ IProject project = testEnv.getTestProject();
+ assertNotNull(project);
+ assertTrue(project.isAccessible());
+ return project;
+ }
+
+ /**
+ * Basic sanity check that properties files can be loaded and contain
+ * what's expected
+ */
+ public void testSanity()
+ {
+ try
+ {
+ Map map = ResourceBundleMapSourceFactory.getResourceBundleMapSource(_project1, "bundles.bundle1");
+ assertNotNull(map);
+ assertEquals(map.size(), 3);
+
+ map = ResourceBundleMapSourceFactory.getResourceBundleMapSource(_project2, "bundles.bundle1");
+ assertNotNull(map);
+ assertEquals(map.size(), 3);
+ }
+ catch (Exception e)
+ {
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * Verify the expected contents of bundle1 in project1
+ */
+ public void testContentsProject1Bundle1()
+ {
+ try
+ {
+ Map map = ResourceBundleMapSourceFactory.getResourceBundleMapSource(_project1, "bundles.bundle1");
+ assertTrue(map.containsKey("prop1"));
+ assertEquals("blah", map.get("prop1"));
+ assertTrue(map.containsKey("one.dot"));
+ assertEquals("blah1", map.get("one.dot"));
+ assertTrue(map.containsKey("two.dot.property"));
+ assertEquals("blah3", map.get("two.dot.property"));
+ }
+ catch (Exception e)
+ {
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * Verify the expected contents of bundle1 in project2
+ */
+ public void testContentsProject2Bundle1()
+ {
+ try
+ {
+ Map map = ResourceBundleMapSourceFactory.getResourceBundleMapSource(_project2, "bundles.bundle1");
+ assertTrue(map.containsKey("x_prop1"));
+ assertEquals("x_blah", map.get("x_prop1"));
+ assertTrue(map.containsKey("x_one.dot"));
+ assertEquals("x_blah1", map.get("x_one.dot"));
+ assertTrue(map.containsKey("x_two.dot.property"));
+ assertEquals("x_blah3", map.get("x_two.dot.property"));
+ }
+ catch (Exception e)
+ {
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle1.resources.data b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle1.resources.data
new file mode 100644
index 0000000..388355e
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle1.resources.data
@@ -0,0 +1,3 @@
+prop1=blah
+one.dot=blah1
+two.dot.property=blah3
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle2.resources.data b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle2.resources.data
new file mode 100644
index 0000000..c20ba77
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.designtime.tests/testdata/bundle2.resources.data
@@ -0,0 +1,3 @@
+x_prop1=x_blah
+x_one.dot=x_blah1
+x_two.dot.property=x_blah3
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/JDTTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/JDTTestEnvironment.java
index 900f28d..74bbdb4 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/JDTTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/JDTTestEnvironment.java
@@ -1,9 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
package org.eclipse.jst.jsf.test.util;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
@@ -22,10 +43,42 @@
/**
* @param projectTestEnvironment
+ * @throws CoreException
*/
- public JDTTestEnvironment(ProjectTestEnvironment projectTestEnvironment)
+ public JDTTestEnvironment(ProjectTestEnvironment projectTestEnvironment) throws CoreException
{
_projectTestEnvironment = projectTestEnvironment;
+
+ IProject project = _projectTestEnvironment.getTestProject();
+ if (!project.hasNature(JavaCore.NATURE_ID)) {
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures= description.getNatureIds();
+ String[] newNatures= new String[prevNatures.length + 1];
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+ newNatures[prevNatures.length]= JavaCore.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, new NullProgressMonitor());
+ }
+
+ IJavaProject javaProject = JavaCore.create(project);
+
+ // make sure that the project root is not on the classpath
+ IClasspathEntry[] entries =
+ javaProject.getRawClasspath();
+ List preservedEntries = new ArrayList();
+
+ for (int i=0; i < entries.length; i++)
+ {
+ IClasspathEntry entry = entries[i];
+
+ if (!entry.getPath().equals(project.getFullPath()))
+ {
+ preservedEntries.add(entry);
+ }
+ }
+
+ javaProject.setRawClasspath((IClasspathEntry[]) preservedEntries.toArray(new IClasspathEntry[0]),
+ new NullProgressMonitor());
}
/**
@@ -49,11 +102,35 @@
if (!folder.exists())
{
folder.create(true, true, new NullProgressMonitor());
- }
-
+ IPath path = project.getFullPath().append("bin");
+ IClasspathEntry entry = JavaCore.newSourceEntry(folder.getFullPath(), new IPath[]{path}, path);
+ addClasspathEntry(entry);
+ }
+
+
return folder;
}
+ /**
+ * Tries to add the newEntry to the java project's classpath
+ * @param newEntry
+ */
+ public void addClasspathEntry(IClasspathEntry newEntry)
+ {
+ try
+ {
+ IClasspathEntry[] entries = getJavaProject().getRawClasspath();
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length+1];
+ System.arraycopy(entries, 0, newEntries, 0, entries.length);
+ newEntries[entries.length] = newEntry;
+ getJavaProject().setRawClasspath(newEntries, new NullProgressMonitor());
+ }
+ catch (JavaModelException jme)
+ {
+ jme.printStackTrace();
+ }
+ }
+
/**
* @param folderName
* @return the package fragment root for the folder name; resource may or may not exist
@@ -62,7 +139,10 @@
public IPackageFragmentRoot getPackageFragmentRoot(final String folderName) throws CoreException
{
final IJavaProject javaProject = JavaCore.create(_projectTestEnvironment.getTestProject());
- return javaProject.getPackageFragmentRoot(getSourceFolder(folderName));
+ IFolder folder = getSourceFolder(folderName);
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
+
+ return root;
}
/**
@@ -80,8 +160,7 @@
public ICompilationUnit addSourceFile(final String folder, final String packageName, final String className, final String contents) throws CoreException, JavaModelException
{
IPackageFragmentRoot root = getPackageFragmentRoot(folder);
-
- IPackageFragment packageFrag = root.getPackageFragment(packageName);
+ IPackageFragment packageFrag = root.getPackageFragment(packageName);
if (!packageFrag.exists())
{
@@ -96,6 +175,50 @@
}
/**
+ * @param folderName
+ * @param src
+ * @param path
+ * @param fileName
+
+ * @return a new IFile corresponding to src being created and copied
+ * into a new file at folderName/IPath
+ * @throws IOException
+ * @throws CoreException
+ */
+ public IFile addResourceFile(final String folderName, final InputStream src, final String path, final String fileName) throws CoreException
+ {
+// IPackageFragmentRoot root = getPackageFragmentRoot(folderName);
+//
+// IFolder folder = (IFolder) root.getUnderlyingResource();
+// IFolder newFolder = folder.getFolder(new Path(path));
+// if (!newFolder.exists())
+// {
+// newFolder.create(true, true, null);
+// }
+//
+// IFile file = newFolder.getFile(new Path(fileName));
+// file.create(src, true, null);
+// return file;
+ IPackageFragmentRoot root = getPackageFragmentRoot(folderName);
+
+ IPackageFragment packageFrag = root.getPackageFragment(path);
+
+ if (!packageFrag.exists())
+ {
+ packageFrag =
+ root.createPackageFragment(path,
+ true, new NullProgressMonitor());
+ packageFrag.open(null);
+ }
+
+ final IFolder folder = (IFolder) packageFrag.getUnderlyingResource();
+
+ IFile file = folder.getFile(new Path(fileName));
+ file.create(src, true, null);
+ return file;
+ }
+
+ /**
* @return the IJavaProject instance for this test environment object
*/
public IJavaProject getJavaProject()
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 f434f54..47aac9c 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
@@ -11,35 +11,34 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.test.util;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
-import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.osgi.framework.Bundle;
/**
* Utility class for launching JSF-related wizard operations.
*
* @author spaxton, cbateman
*/
-public class ProjectTestEnvironment {
- private boolean projectCreated = false;
- private final String _projectName;
- private IProject _project;
+public class ProjectTestEnvironment
+{
+ /**
+ * flag indicating if the project test env has been created
+ */
+ protected boolean _projectCreated = false;
+
+ /**
+ * the project name
+ */
+ protected final String _projectName;
+ /**
+ * the project
+ */
+ protected IProject _project;
/**
@@ -54,7 +53,7 @@
* @return true if the project is in a valid created state
*/
public boolean isProjectCreated() {
- return projectCreated;
+ return _projectCreated;
}
/**
@@ -66,14 +65,24 @@
{
// first delete the projects of these names, if present
deleteProject();
- try
- {
- _project = createWebProject(_projectName);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- projectCreated = true;
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(_projectName);
+
+ if (!project.exists())
+ {
+ try
+ {
+ final IProgressMonitor monitor = new NullProgressMonitor();
+ project.create(monitor);
+ project.open(monitor);
+ _project = project;
+ _projectCreated = true;
+ }
+ catch (CoreException ce)
+ {
+ ce.printStackTrace();
+ }
+ }
}
}
@@ -98,27 +107,13 @@
}
}
- /**
- * @param projectName
- * @return the web project
- * @throws Exception
- */
- private IProject createWebProject(String projectName) throws Exception {
- if(!isProjectCreated()) {
- IDataModel dataModel = DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
- dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projectName);
- dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
- dataModel.dispose();
- }
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
/**
- * Clears the projectCreated flag, allowing createProject to be called to reset
+ * Clears the _projectCreated flag, allowing createProject to be called to reset
* the web project back to it's initial state
*/
public void setProjectDirtied() {
- projectCreated = false;
+ _projectCreated = false;
}
/**
@@ -136,95 +131,11 @@
*/
public IProject getTestProject()
{
- if (projectCreated)
+ if (_projectCreated)
{
return _project;
}
return null;
}
-
- /**
- * @param create
- * @param force
- * @return the web root container for the project
- */
- public IVirtualContainer getWebRoot(boolean create, boolean force)
- {
- IVirtualContainer webRoot =
- ComponentCore.createComponent(getTestProject()).getRootFolder();
-
- if (!webRoot.exists() && create)
- {
- try
- {
- webRoot.create(force ? IVirtualResource.FORCE : 0, new NullProgressMonitor());
- }
- catch (CoreException ce)
- {
- Activator.log("Error creating web root", ce);
- ce.printStackTrace();
- }
- }
-
- return webRoot;
- }
-
-
- /**
- * @param bundle
- * @param srcFileName
- * @param destDirName
- * @param destFileName
- * @return the IResource for the newly loaded resource
- * @throws IOException
- * @throws CoreException
- */
- public IResource loadResourceInWebRoot(Bundle bundle, String srcFileName, String destFileName) throws IOException, CoreException
- {
- final TestFileResource resource = new TestFileResource();
- resource.load(bundle, srcFileName);
-
- IFile file = getWebRoot(true, true).getFile(new Path(destFileName)).getUnderlyingFile();
- file.create(new ByteArrayInputStream(resource.toBytes()), true, null);
-
- return file;
- }
-
-// public void checkAndAddFacesConfig() {
-// final IProject project = getTestProject();
-// IContainer container = ComponentCore.createComponent(project).getRootFolder().getFolder("/WEB-INF").getUnderlyingFolder();
-// IFile facesConfigFile = ResourcesPlugin.getWorkspace().getRoot().getFile(container.getFullPath().append(new Path("faces-config.xml"))); //$NON-NLS-1$
-// IFile facesConfigFile1 = ResourcesPlugin.getWorkspace().getRoot().getFile(container.getFullPath().append(new Path("faces-config1.xml"))); //$NON-NLS-1$
-// IFile facesConfigFile2 = ResourcesPlugin.getWorkspace().getRoot().getFile(container.getFullPath().append(new Path("faces-config2.xml"))); //$NON-NLS-1$
-//
-// if(facesConfigFile.exists()) {
-// return;
-// } else {
-// // there is no faces-config, so add our starting template
-// try {
-// String sourcePath = Platform.asLocalURL(Platform.find(Platform.getBundle("org.eclipse.jst.jsf.facesconfig.tests"), new Path("/template/faces-config.xml"))).getPath().toString(); //$NON-NLS-1$ //$NON-NLS-2$
-// File f = new File(sourcePath);
-// FileInputStream sourceStream = new FileInputStream(f);
-// facesConfigFile.create(sourceStream, true, null);
-// sourceStream.close();
-//
-// String sourcePath1 = Platform.asLocalURL(Platform.find(Platform.getBundle("org.eclipse.jst.jsf.facesconfig.tests"), new Path("/template/faces-config1.xml"))).getPath().toString(); //$NON-NLS-1$ //$NON-NLS-2$
-// File f1 = new File(sourcePath1);
-// FileInputStream sourceStream1 = new FileInputStream(f1);
-// facesConfigFile1.create(sourceStream1, true, null);
-// sourceStream1.close();
-//
-// String sourcePath2 = Platform.asLocalURL(Platform.find(Platform.getBundle("org.eclipse.jst.jsf.facesconfig.tests"), new Path("/template/faces-config2.xml"))).getPath().toString(); //$NON-NLS-1$ //$NON-NLS-2$
-// File f2 = new File(sourcePath2);
-// FileInputStream sourceStream2 = new FileInputStream(f2);
-// facesConfigFile2.create(sourceStream2, true, null);
-// sourceStream2.close();
-// } catch (IOException ioe) {
-// } catch (CoreException ce) {
-// }
-//
-// }
-//
-// }
}
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
new file mode 100644
index 0000000..8617671
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/WebProjectTestEnvironment.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+package org.eclipse.jst.jsf.test.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
+import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.osgi.framework.Bundle;
+
+/**
+ * Test environment for dynamic web projects
+ * @author cbateman
+ *
+ */
+public class WebProjectTestEnvironment extends ProjectTestEnvironment {
+
+ /**
+ * @param projectName
+ */
+ public WebProjectTestEnvironment(String projectName) {
+ super(projectName);
+ }
+
+
+ public void createProject()
+ {
+ try
+ {
+ _project = createWebProject(_projectName);
+ _projectCreated = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ /**
+ * @param projectName
+ * @return the web project
+ * @throws Exception
+ */
+ private IProject createWebProject(String projectName) throws Exception {
+ if(!isProjectCreated()) {
+ IDataModel dataModel = DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
+ dataModel.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projectName);
+ dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ dataModel.dispose();
+ }
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ }
+
+ /**
+ * @param create
+ * @param force
+ * @return the web root container for the project
+ */
+ public IVirtualContainer getWebRoot(boolean create, boolean force)
+ {
+ IVirtualContainer webRoot =
+ ComponentCore.createComponent(getTestProject()).getRootFolder();
+
+ if (!webRoot.exists() && create)
+ {
+ try
+ {
+ webRoot.create(force ? IVirtualResource.FORCE : 0, new NullProgressMonitor());
+ }
+ catch (CoreException ce)
+ {
+ Activator.log("Error creating web root", ce);
+ ce.printStackTrace();
+ }
+ }
+
+ return webRoot;
+ }
+
+
+ /**
+ * @param bundle
+ * @param srcFileName
+ * @param destDirName
+ * @param destFileName
+ * @return the IResource for the newly loaded resource
+ * @throws IOException
+ * @throws CoreException
+ */
+ public IResource loadResourceInWebRoot(Bundle bundle, String srcFileName, String destFileName) throws IOException, CoreException
+ {
+ final TestFileResource resource = new TestFileResource();
+ resource.load(bundle, srcFileName);
+
+ IFile file = getWebRoot(true, true).getFile(new Path(destFileName)).getUnderlyingFile();
+ file.create(new ByteArrayInputStream(resource.toBytes()), true, null);
+
+ return file;
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestJDTTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestJDTTestEnvironment.java
index 28fd5a5..09abf71 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestJDTTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestJDTTestEnvironment.java
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
package org.eclipse.jst.jsf.test.util.sanity;
import junit.framework.TestCase;
@@ -7,8 +18,8 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.jsf.test.util.Activator;
import org.eclipse.jst.jsf.test.util.JDTTestEnvironment;
-import org.eclipse.jst.jsf.test.util.TestFileResource;
import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
+import org.eclipse.jst.jsf.test.util.TestFileResource;
/**
* @author cbateman
@@ -17,12 +28,14 @@
public class TestJDTTestEnvironment extends TestCase
{
private ProjectTestEnvironment _projectTestEnvironment;
+ private JDTTestEnvironment _jdtTestEnv;
private String _testClass1;
protected void setUp() throws Exception {
super.setUp();
_projectTestEnvironment = new ProjectTestEnvironment("JDTTestProject");
_projectTestEnvironment.createProject();
+ _jdtTestEnv = new JDTTestEnvironment(_projectTestEnvironment);
TestFileResource codeRes = new TestFileResource();
codeRes.load(Activator.getDefault().getBundle(), "/testdata/TestClass1.java.data");
_testClass1 = codeRes.toString();
@@ -33,13 +46,11 @@
*/
public void testCreateJavaClassFile()
{
- JDTTestEnvironment jdtTestEnvironment = new JDTTestEnvironment(_projectTestEnvironment);
-
ICompilationUnit compUnit = null;
try
{
compUnit =
- jdtTestEnvironment.
+ _jdtTestEnv.
addSourceFile("src", "com.test", "TestClass1", _testClass1.toString());
}
@@ -49,11 +60,12 @@
}
assertNotNull(compUnit);
+ assertTrue(compUnit.exists());
assertTrue(compUnit.getResource().isAccessible());
try
{
- IType type = jdtTestEnvironment.getJavaProject().findType("com.test.TestClass1");
+ IType type = _jdtTestEnv.getJavaProject().findType("com.test.TestClass1");
assertNotNull(type);
assertTrue(type.getMethods().length == 1);
assertTrue(type.getMethods()[0].getElementName().equals("amethod"));
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestProjectTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestProjectTestEnvironment.java
index 98efab2..6fcae24 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestProjectTestEnvironment.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestProjectTestEnvironment.java
@@ -1,9 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
package org.eclipse.jst.jsf.test.util.sanity;
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.jsf.test.util.Activator;
import org.eclipse.jst.jsf.test.util.ProjectTestEnvironment;
/**
@@ -19,9 +29,6 @@
*/
public void testCreateProject()
{
-// InternetPlugin iPlugin = InternetPlugin.getInstance();
-// IPreferenceStore store = iPlugin.getPreferenceStore();
-
ProjectTestEnvironment testEnv = new ProjectTestEnvironment("TestProject1");
testEnv.createProject();
assertTrue(testEnv.isProjectCreated());
@@ -31,25 +38,4 @@
assertNotNull(project);
assertTrue(project.isAccessible());
}
-
- /**
- * Test creating a web project and adding a faces-config.xml file to it
- */
- public void testAddFileToWebRoot()
- {
- ProjectTestEnvironment testEnv = new ProjectTestEnvironment("TestProject2");
- testEnv.createProject();
- assertTrue(testEnv.isProjectCreated());
-
- try
- {
- testEnv.loadResourceInWebRoot(Activator.getDefault().getBundle(),
- "/testdata/faces-config.xml.data",
- "/WEB-INF/faces-config.xml");
- }
- catch (Exception e)
- {
- fail(e.getLocalizedMessage());
- }
- }
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestWebProjectTestEnvironment.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestWebProjectTestEnvironment.java
new file mode 100644
index 0000000..a4e19e7
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/sanity/TestWebProjectTestEnvironment.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cameron Bateman/Oracle - initial API and implementation
+ *
+ ********************************************************************************/
+ package org.eclipse.jst.jsf.test.util.sanity;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.jsf.test.util.Activator;
+import org.eclipse.jst.jsf.test.util.WebProjectTestEnvironment;
+
+/**
+ * Sanity test for web project test environment
+ *
+ * @author cbateman
+ *
+ */
+public class TestWebProjectTestEnvironment extends TestCase
+{
+ /**
+ * Test project creation
+ */
+ public void testCreateProject()
+ {
+// InternetPlugin iPlugin = InternetPlugin.getInstance();
+// IPreferenceStore store = iPlugin.getPreferenceStore();
+
+ WebProjectTestEnvironment testEnv = new WebProjectTestEnvironment("TestProject1");
+ testEnv.createProject();
+ assertTrue(testEnv.isProjectCreated());
+
+ IProject project = testEnv.getTestProject();
+
+ assertNotNull(project);
+ assertTrue(project.isAccessible());
+ }
+
+ /**
+ * Test creating a web project and adding a faces-config.xml file to it
+ */
+ public void testAddFileToWebRoot()
+ {
+ WebProjectTestEnvironment testEnv = new WebProjectTestEnvironment("TestProject2");
+ testEnv.createProject();
+ assertTrue(testEnv.isProjectCreated());
+
+ try
+ {
+ testEnv.loadResourceInWebRoot(Activator.getDefault().getBundle(),
+ "/testdata/faces-config.xml.data",
+ "/WEB-INF/faces-config.xml");
+ }
+ catch (Exception e)
+ {
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+}