Author: estherbin
Date: 2008-07-15 05:14:06 -0400 (Tue, 15 Jul 2008)
New Revision: 9139
Added:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java
Log:
Write service for EL substitution for
http://jira.jboss.com/jira/browse/JBIDE-2010 issue.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF 2008-07-15 09:13:37 UTC
(rev 9138)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/META-INF/MANIFEST.MF 2008-07-15 09:14:06 UTC
(rev 9139)
@@ -10,6 +10,8 @@
org.junit,
org.jboss.tools.common,
org.jboss.tools.vpe,
+ org.jboss.tools.vpe.ui.test,
+ org.jboss.tools.jsf.vpe.jsf.test,
org.jboss.tools.tests;bundle-version="2.0.0",
org.jboss.tools.common.model.ui;bundle-version="2.0.0"
Eclipse-LazyStart: true
Added:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java 2008-07-15
09:14:06 UTC (rev 9139)
@@ -0,0 +1,141 @@
+
+
+package org.jboss.tools.vpe.test;
+
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.vpe.editor.css.ELReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ElPreferencesTestCase.
+ */
+public class ElPreferencesTestCase extends VpeTest {
+
+ /** The Constant KEY_3. */
+ private static final String KEY_3 = "#{facesContext.requestPath}";
+
+ /** The Constant KEY_2. */
+ private static final String KEY_2 = "#{beanA.property2}";
+
+ /** The Constant IMPORT_PROJECT_NAME. */
+ public static final String IMPORT_PROJECT_NAME = "jsfTest";
+
+ /** The Constant DIR_TEST_PAGE_NAME. */
+ private static final String DIR_TEST_PAGE_NAME = "JBIDE/2010/page.xhtml";
+
+ /**
+ * The Constructor.
+ *
+ * @param name the name
+ */
+ public ElPreferencesTestCase(String name) {
+ super(name);
+
+ }
+
+ /**
+ * The Constructor.
+ */
+ public ElPreferencesTestCase() {
+ super(ElPreferencesTestCase.class.getName());
+
+ }
+
+ /** The Constant KEY_1. */
+ private static final String KEY_1 = "#{beanA.property1}";
+
+ /** The Constant elValuesMap. */
+ protected static final Map<String, String> elValuesMap = new HashMap<String,
String>();
+
+ /** The file. */
+ private IFile file;
+
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ elValuesMap.put(KEY_1, "/path/image/path/to/image/");
+ elValuesMap.put(KEY_2, "/path2/");
+ elValuesMap.put(KEY_3, "/facesContext/");
+ file = (IFile) TestUtil.getComponentPath(DIR_TEST_PAGE_NAME,
IMPORT_PROJECT_NAME);
+ ResourceReference[] entries = new ResourceReference[elValuesMap.size()];
+ int i = 0;
+ for (Entry<String, String> string : elValuesMap.entrySet()) {
+
+ entries[i] = new ResourceReference(string.getValue(),
ResourceReference.PROJECT_SCOPE);
+ entries[i].setProperties(string.getKey());
+ i++;
+
+ setValues(entries);
+ }
+ }
+
+ /**
+ * Sets the values.
+ *
+ * @param key the key
+ * @param value the value
+ * @param scope the scope
+ */
+ protected void setValues(ResourceReference[] entries) {
+
+ ELReferenceList.getInstance().setAllResources(file, entries);
+ }
+
+ /**
+ * Tear down.
+ *
+ * @throws Exception the exception
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ }
+
+ /**
+ * Test replace attribute value.
+ *
+ * @throws CoreException the core exception
+ */
+ public void testReplaceAttributeValue() throws CoreException {
+ String string1 = "#{beanA.property1}/images/smalle.gif";
+ String replacedValue = ElService.getInstance().replaceEl(file, string1);
+
+ assertEquals("Should be equals " + elValuesMap.get(KEY_1) +
"/images/smalle.gif", replacedValue, elValuesMap.get(KEY_1)
+ + "/images/smalle.gif");
+
+ }
+
+ /**
+ * Test replace attribute value2.
+ *
+ * @throws CoreException the core exception
+ */
+ public void testReplaceAttributeValue2() throws CoreException {
+ String string1 =
"#{beanA.property1}/images/#{beanA.property2}/path2/#{facesContext.requestPath}/smalle.gif";
+
+ final String replacedValue = ElService.getInstance().replaceEl(file, string1);
+ final String check = elValuesMap.get(KEY_1) + "/images/" +
elValuesMap.get(KEY_2) + "/path2/" + elValuesMap.get(KEY_3)
+ + "/smalle.gif";
+ assertEquals("Should be equals " + check, check, replacedValue);
+
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/ElPreferencesTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java 2008-07-15
09:13:37 UTC (rev 9138)
+++
trunk/vpe/tests/org.jboss.tools.vpe.test/src/org/jboss/tools/vpe/test/VpeAllTests.java 2008-07-15
09:14:06 UTC (rev 9139)
@@ -10,13 +10,20 @@
******************************************************************************/
package org.jboss.tools.vpe.test;
-import org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPageTest;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManagerTest;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfComponentTest;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfTestPlugin;
+import org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPageTest;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManagerTest;
+import org.jboss.tools.vpe.ui.test.VpeTestSetup;
+import org.jboss.tools.vpe.ui.test.beans.ImportBean;
+
/**
* Class created for run tests for org.jboss.tools.vpe plugin.
*
@@ -33,7 +40,15 @@
suite.addTestSuite(TemplatesExpressionParsingTest.class);
suite.addTestSuite(VpeEditorPreferencesPageTest.class);
suite.addTestSuite(VpeTemplateManagerTest.class);
- // $JUnit-END$
- return suite;
+ suite.addTestSuite(ElPreferencesTestCase.class);
+
+
+ List<ImportBean> projectToImport = new ArrayList<ImportBean>();
+ ImportBean importBean = new ImportBean();
+ importBean.setImportProjectName(JsfComponentTest.IMPORT_PROJECT_NAME);
+ importBean.setImportProjectPath(JsfTestPlugin.getPluginResourcePath());
+ projectToImport.add(importBean);
+
+ return new VpeTestSetup(suite, projectToImport);
}
}