You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/04/21 19:20:54 UTC
svn commit: r936397 - in
/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting:
core/reloading/ core/support/ loaders/java/
Author: werpu
Date: Wed Apr 21 17:20:54 2010
New Revision: 936397
URL: http://svn.apache.org/viewvc?rev=936397&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-117
It was a threading issue, since we run our tests multithreaded to save time, I now added a monitor
to keep the threading issue in the affected parts at bay, if this does not resolve it we
will switch back to non threaded testing.
Modified:
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java?rev=936397&r1=936396&r2=936397&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/reloading/SimpleReloadingStrategyTest.java Wed Apr 21 17:20:54 2010
@@ -85,20 +85,21 @@ public class SimpleReloadingStrategyTest
@Test
public void testReload() throws Exception {
-
- Object probe = _loader.loadClass("compiler.TestProbe1").newInstance();
- ReloadingMetadata metaData = getMetadata(probe);
- WeavingContext.getRefreshContext().getDaemon().getClassMap().put("compiler.TestProbe1", metaData);
-
- ReflectUtil.executeMethod(probe, "setTestAttr", "hello");
- Object probe2 = _strategy.reload(probe, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- Object attr = ReflectUtil.executeMethod(probe, "getTestAttr");
- assertFalse(probe.hashCode() == probe2.hashCode());
- assertTrue(attr instanceof String);
- assertTrue(((String)attr).equals("hello"));
-
- Object probe3 = _strategy.reload(probe2, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
- assertTrue(probe2 == probe3);
+ synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
+ Object probe = _loader.loadClass("compiler.TestProbe1").newInstance();
+ ReloadingMetadata metaData = getMetadata(probe);
+ WeavingContext.getRefreshContext().getDaemon().getClassMap().put("compiler.TestProbe1", metaData);
+
+ ReflectUtil.executeMethod(probe, "setTestAttr", "hello");
+ Object probe2 = _strategy.reload(probe, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
+ Object attr = ReflectUtil.executeMethod(probe, "getTestAttr");
+ assertFalse(probe.hashCode() == probe2.hashCode());
+ assertTrue(attr instanceof String);
+ assertTrue(((String) attr).equals("hello"));
+
+ Object probe3 = _strategy.reload(probe2, ScriptingConst.ENGINE_TYPE_JSF_JAVA);
+ assertTrue(probe2 == probe3);
+ }
}
private ReloadingMetadata getMetadata(Object probe) {
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java?rev=936397&r1=936396&r2=936397&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/core/support/ContextUtils.java Wed Apr 21 17:20:54 2010
@@ -37,6 +37,12 @@ import static org.junit.Assert.fail;
* @version $Revision$ $Date$
*/
public class ContextUtils {
+
+ /**
+ * locking monitor for the compile/load parts
+ */
+ public static volatile Boolean COMPILE_LOAD_MONITOR = new Boolean(true);
+
/**
* A startup routine shared by many tests
* to do the basic weaving initialization
@@ -51,6 +57,7 @@ public class ContextUtils {
/**
* same as the other one but with a web.xml path being possible
+ *
* @param webXmlPath the path to the web.xml
* @return the servlet context
*/
@@ -60,17 +67,18 @@ public class ContextUtils {
return context;
}
-
public static File doJavaRecompile(String sourceRoot) throws ClassNotFoundException {
- DynamicCompiler compiler = new CompilerFacade(false);
- try {
- FileUtils.deleteDirectory(WeavingContext.getConfiguration().getCompileTarget());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- WeavingContext.getConfiguration().getCompileTarget().mkdirs();
- return compiler.compileAllFiles(sourceRoot, "");
+ synchronized (COMPILE_LOAD_MONITOR) {
+ DynamicCompiler compiler = new CompilerFacade(false);
+ try {
+ FileUtils.deleteDirectory(WeavingContext.getConfiguration().getCompileTarget());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ WeavingContext.getConfiguration().getCompileTarget().mkdirs();
+ return compiler.compileAllFiles(sourceRoot, "");
+ }
}
}
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java?rev=936397&r1=936396&r2=936397&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/RecompiledClassLoaderTest.java Wed Apr 21 17:20:54 2010
@@ -69,14 +69,15 @@ public class RecompiledClassLoaderTest {
@Test
public void testLoadClass() throws Exception {
+ synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
+ //the simple reloading case is handled by the reloading strategy testcase
+ //so this test is mostly just to test the rest of the class
+
+ Class clazz1 = _loader.loadClass("java.lang.String");
+ Class clazz2 = _loader.loadClass("java.lang.String");
+ assertTrue(clazz1.hashCode() == clazz2.hashCode());
- //the simple reloading case is handled by the reloading strategy testcase
- //so this test is mostly just to test the rest of the class
-
- Class clazz1 = _loader.loadClass("java.lang.String");
- Class clazz2 = _loader.loadClass("java.lang.String");
- assertTrue(clazz1.hashCode() == clazz2.hashCode());
-
+ }
}
@Test
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java?rev=936397&r1=936396&r2=936397&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/loaders/java/ScannerClassloaderTest.java Wed Apr 21 17:20:54 2010
@@ -63,10 +63,11 @@ public class ScannerClassloaderTest {
@Test
public void testLoadClass() throws Exception {
- Class clazz1 = _loader.loadClass("compiler.TestProbe1");
- Class clazz2 = _loader.loadClass("compiler.TestProbe1");
- assertTrue(clazz1 == clazz2);
+ synchronized (ContextUtils.COMPILE_LOAD_MONITOR) {
+ Class clazz1 = _loader.loadClass("compiler.TestProbe1");
+ Class clazz2 = _loader.loadClass("compiler.TestProbe1");
+ assertTrue(clazz1 == clazz2);
+ }
}
-
}