Author: yradtsevich
Date: 2010-02-11 12:53:22 -0500 (Thu, 11 Feb 2010)
New Revision: 20248
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/jbide5818/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/jbide5818/MessagesJBIDE5818.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5818/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5818/JBIDE-5818.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ChangeMessageBundleTest_JBIDE5818.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5818
VPE throws java.util.ConcurrentModificationException
- fixed
- JUnit created
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/jbide5818/MessagesJBIDE5818.properties
===================================================================
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5818/JBIDE-5818.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5818/JBIDE-5818.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5818/JBIDE-5818.xhtml 2010-02-11
17:53:22 UTC (rev 20248)
@@ -0,0 +1,23 @@
+<html
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html">
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+ <f:view>
+ <f:loadBundle var="Message"
basename="jbide5818.MessagesJBIDE5818"></f:loadBundle>
+ <h1><h:outputText value="#{Message.header}"/></h1>
+
+ <h:messages style="color: red"/>
+
+ <h:form id="greetingForm">
+ <h:outputText value="#{Message.prompt_message}"/>
+ <h:inputText value="#{user.name}" required="true">
+ <f:validateLength maximum="30" minimum="3"/>
+ </h:inputText>
+
+ <h:commandButton action="hello" value="Say Hello!" />
+ </h:form>
+ </f:view>
+ </body>
+</html>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-02-11
17:51:14 UTC (rev 20247)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-02-11
17:53:22 UTC (rev 20248)
@@ -16,6 +16,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.ChangeMessageBundleTest_JBIDE5818;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ContextMenuDoubleInsertionTest_JBIDE3888;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.FacetProcessingTest;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1105Test;
@@ -121,6 +122,7 @@
TestSuite suite = new TestSuite("Tests for Vpe Jsf components");
//$NON-NLS-1$
// $JUnit-BEGIN$
+ suite.addTestSuite(ChangeMessageBundleTest_JBIDE5818.class);
suite.addTestSuite(TestForUsingComponentsLibrariesWithDefaultNamespace.class);
suite.addTestSuite(EditingSPecialSymbolsVPE_JBIDE3810.class);
suite.addTestSuite(OpenOnJsf20Test_JBIDE5382.class);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ChangeMessageBundleTest_JBIDE5818.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ChangeMessageBundleTest_JBIDE5818.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ChangeMessageBundleTest_JBIDE5818.java 2010-02-11
17:53:22 UTC (rev 20248)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+/**
+ * @author yradtsevich
+ *
+ */
+public class ChangeMessageBundleTest_JBIDE5818 extends VpeTest {
+ private static final String TEST_PAGE_NAME = "JBIDE/5818/JBIDE-5818.xhtml";
+ private static final String PROPERTIES_FILE_NAME =
"JavaSource/jbide5818/MessagesJBIDE5818.properties";
+ private static final String PROPERTIES_EDITOR_ID =
"org.eclipse.ui.DefaultTextEditor";
+
+ public ChangeMessageBundleTest_JBIDE5818(String name) {
+ super(name);
+ }
+
+ /**
+ * Test for <a
href="http://jira.jboss.org/jira/browse/JBIDE-5818">JBIDE-58...;.
+ */
+ public void testRemoveAllBundleMessages() throws Throwable {
+ setException(null);
+
+ /* Initialize the message bundle with three messages
+ * which are used on the test page */
+ replaceFileContent(PROPERTIES_FILE_NAME,
+ "header=Hello Demo Application\n"
+ + "prompt_message=Name:\n"
+ + "hello_message=Hello\n");
+
+ // Open the test page first time
+ openInVpe(JsfAllTests.IMPORT_PROJECT_NAME, TEST_PAGE_NAME);
+ TestUtil.waitForIdle();
+
+ // Remove all messages from the message bundle
+ replaceFileContent(PROPERTIES_FILE_NAME, "");
+
+ /* Open the test page second time.
+ * The java.util.ConcurrentModificationException may be thrown here.*/
+ openInVpe(JsfAllTests.IMPORT_PROJECT_NAME, TEST_PAGE_NAME);
+ TestUtil.waitForIdle();
+
+ if (getException() != null) {
+ throw new RuntimeException(getException());
+ }
+ }
+
+ /**
+ * Opens the specified file by text editor, replaces its content
+ * with {@code newContent} and saves it.
+ */
+ private TextEditor replaceFileContent(final String path,
+ final String newContent) throws CoreException {
+ IFile elementPageFile = (IFile) TestUtil.getResource(path,
JsfAllTests.IMPORT_PROJECT_NAME);
+ IEditorInput input = new FileEditorInput(elementPageFile);
+ TextEditor editor = (TextEditor)
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().openEditor(input, PROPERTIES_EDITOR_ID, true);
+ assertNotNull(editor);
+ StyledText propertiesStyledText = (StyledText) editor.getAdapter(Control.class);
+ propertiesStyledText.setText(newContent);
+ editor.doSave(new NullProgressMonitor());
+ return editor;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2010-02-11
17:51:14 UTC (rev 20247)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2010-02-11
17:53:22 UTC (rev 20248)
@@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -363,9 +364,15 @@
private void refreshUsedKeys(){
UsedKey keyValue;
+
+
+ /* yradtsevich: Fix of JBIDE-5818. The map usedKey cannot be modified
+ * in the following foreach loop. Therefore the keys to remove
+ * are marked and removed after the loop. */
+ List<String> keysToBeRemoved = new ArrayList<String>(0);
+
Set<String> usedKeysSet = this.usedKeys.keySet();
-
- for(String key:usedKeysSet){
+ for(String key : usedKeysSet){
keyValue =this.usedKeys.get(key);
BundleEntry entry = getBundle(keyValue.prefix);
if(entry != null){
@@ -375,7 +382,8 @@
}catch(MissingResourceException ex){
value = null;
fireBundleKeyChanged(keyValue.prefix, keyValue.key, value);
- this.usedKeys.remove(key);
+ // Fix of JBIDE-5818
+ keysToBeRemoved.add(key);
continue;
}
if((value == null && keyValue.value != null) || (value != null &&
keyValue.value == null)){
@@ -392,6 +400,11 @@
fireBundleKeyChanged(keyValue.prefix, keyValue.key, null);
}
}
+
+ // Fix of JBIDE-5818
+ for (String key : keysToBeRemoved) {
+ this.usedKeys.remove(key);
+ }
}
private List<ELInstance> parseJSFExpression(String expression){
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2010-02-11
17:51:14 UTC (rev 20247)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2010-02-11
17:53:22 UTC (rev 20248)
@@ -96,7 +96,18 @@
return null;
}
+
+ public static IResource getResource(String path,
+ String projectName) throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ projectName);
+ if (project != null) {
+ return project.findMember(path);
+ }
+ return null;
+ }
+
/**
* Gets the web content path.
*