[jboss-cvs] JBossAS SVN: r64927 - projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 28 17:11:26 EDT 2007
Author: stalep
Date: 2007-08-28 17:11:26 -0400 (Tue, 28 Aug 2007)
New Revision: 64927
Modified:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java
Log:
[JBAOP-380] it should fail a bit more often now (not always though)
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java 2007-08-28 19:37:40 UTC (rev 64926)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java 2007-08-28 21:11:26 UTC (rev 64927)
@@ -23,11 +23,6 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.advice.AdviceBinding;
-import org.jboss.aop.advice.AdviceFactory;
-import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.advice.AspectFactory;
-import org.jboss.aop.advice.GenericAspectFactory;
-import org.jboss.aop.advice.Scope;
import org.jboss.aop.pointcut.ast.ParseException;
/**
@@ -36,51 +31,39 @@
* @author <a href="stalep at gmail.com">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
-public class RebuildThread implements Runnable
+public class RebuildThread extends Thread
{
- private static Boolean done = false;
+ private static volatile boolean done = false;
- private static int id = 0;
+ private int id = 0;
@Override
public void run()
{
-
- while(!isDone());
+ for(int i=0; i < 30; i++)
{
-// System.out.println("Inside rebuildthread");
- if(id > 0)
- {
- unlinkAdvice();
- linkNewAdvice();
- }
-// linkNewAdvice();
+ unlinkAdvice();
+ linkNewAdvice();
-// try
-// {
-// Thread.sleep(2);
-// }
-// catch(InterruptedException ie)
-// {
-// System.err.println("Exception during sleep "+ie.getMessage());
-// }
+ if(isDone())
+ return;
}
- System.out.println("RebuildingThread jumping out of run()");
+
}
- public synchronized void setDone(boolean b)
+ public void setDone(boolean b)
{
done = b;
}
- public synchronized Boolean isDone()
+ public boolean isDone()
{
return done;
}
- public static void linkNewAdvice()
+ public void linkNewAdvice()
{
- System.out.println("adding new advice");
+// System.out.println("adding new advice");
AdviceBinding binding1 = null;
try
{
@@ -88,7 +71,6 @@
}
catch (ParseException e)
{
- // TODO Auto-generated catch block
e.printStackTrace();
}
binding1.addInterceptor(SyncInterceptor.class);
@@ -97,34 +79,10 @@
id++;
}
- public static void unlinkAdvice()
+ public void unlinkAdvice()
{
-// System.out.println("unlinking "+id);
+// System.out.println("unlinking "+(id-1));
AspectManager.instance().removeBinding(Integer.toString((id-1)));
}
-
-
-// public static void link(String aspect_id, String methodname, String binding, String binding_id)
-// {
-// System.out.println("link aspect_id=" + aspect_id + " method=" + methodname + " binding=" + binding
-// + " binding_id=" + binding_id);
-// AdviceBinding adviceBinding = null;
-// try
-// {
-// adviceBinding = new AdviceBinding(binding, null);
-// }
-// catch (ParseException e)
-// {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// AspectDefinition ad = AspectManager.instance().getAspectDefinition(aspect_id);
-// adviceBinding.addInterceptorFactory(new AdviceFactory(ad, methodname));
-// adviceBinding.setName(binding_id);
-// AspectManager.instance().addBinding(adviceBinding);
-// }
-
-
-
+
}
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java 2007-08-28 19:37:40 UTC (rev 64926)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java 2007-08-28 21:11:26 UTC (rev 64927)
@@ -54,36 +54,14 @@
public void testRebuildingChain() throws Exception
{
System.out.println("testing rebuildingchain!");
- AspectManager.instance().verbose = true;
- RebuildThread.linkNewAdvice();
-// RebuildThread.unlinkAdvice();
-// RebuildThread.linkNewAdvice();
-
- Thread t1 = new Thread(new SyncThread());
+// AspectManager.instance().verbose = true;
+ SyncThread st = new SyncThread();
RebuildThread rt = new RebuildThread();
- Thread t2 = new Thread(rt);
- t1.start();
- t2.start();
- try
- {
- long start = System.currentTimeMillis();
- Thread.sleep(20);
- System.out.println("Slept for: "+(System.currentTimeMillis()-start));
- }
- catch(InterruptedException ie)
- {
- System.err.println("BAH "+ie.getMessage());
- }
+ rt.linkNewAdvice();
- SyncThread.setDone(false);
- rt.setDone(true);
+ rt.start();
+ st.start();
- t2.join();
- if(t2.isAlive())
- System.out.println("rebuildingthread is still alive!!");
-
- t1.start();
-
try
{
long start = System.currentTimeMillis();
@@ -95,9 +73,10 @@
System.err.println("BAH "+ie.getMessage());
}
- SyncThread.setDone(false);
+ st.setDone(true);
+ rt.setDone(true);
- assertFalse("All well....", failed);
+ assertFalse("Failed to match pointcut when rebuilding the chain....", failed);
}
public static void setTestFailed()
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java 2007-08-28 19:37:40 UTC (rev 64926)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java 2007-08-28 21:11:26 UTC (rev 64927)
@@ -27,34 +27,32 @@
* @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
-public class SyncThread implements Runnable
+public class SyncThread extends Thread
{
- private static boolean status = false;
- private static boolean done = false;
+ private static volatile boolean status = false;
+ private volatile boolean done = false;
@Override
public void run()
{
- while(!done)
- {
+
+ for(int i=0; i < 30; i++)
+ {
checkStatus();
-// try
-// {
-// Thread.sleep(2);
-// }
-// catch(InterruptedException ie)
-// {
-// System.err.println("Exception during sleep "+ie.getMessage());
-// }
+
+ if(isDone())
+ return;
+
}
}
private void checkStatus()
{
+// System.out.println("checking status...");
if(getStatus() == false)
{
RebuildingChainTestCase.setTestFailed();
- throw new RuntimeException("Status wasnt true!!!!");
+ throw new RuntimeException("Status failed!!!!");
}
}
@@ -68,8 +66,13 @@
status = b;
}
- public synchronized static void setDone(boolean b)
+ public void setDone(boolean b)
{
done = b;
}
+
+ private boolean isDone()
+ {
+ return done;
+ }
}
More information about the jboss-cvs-commits
mailing list