[jboss-cvs] JBossAS SVN: r63920 - in projects/aop/trunk/aop: src/resources/test/stress and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 9 17:28:03 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-07-09 17:28:03 -0400 (Mon, 09 Jul 2007)
New Revision: 63920

Added:
   projects/aop/trunk/aop/src/resources/test/stress/weavetest/
   projects/aop/trunk/aop/src/resources/test/stress/weavetest/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/SkipWarmup.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/Factory.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesScenario.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesTestDelegate.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/MethodCaller.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TemplatePOJO.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TestInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/WeaveManyClassesTestCase.java
Modified:
   projects/aop/trunk/aop/
   projects/aop/trunk/aop/src/resources/test/stress/config.properties
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/ScenarioRunner.java
Log:
[JBAOP-376] Stress test for weaving lots of classes


Property changes on: projects/aop/trunk/aop
___________________________________________________________________
Name: svn:ignore
   - output
build.log
TEST-org.jboss.test.aop.*.txt
junit*.properties
comments.txt
jbossAgent.dll
jboss-aop-dist.zip
local.properties
org
*.class
aopc.tmpdir
target
com

   + output
build.log
TEST-org.jboss.test.aop.*.txt
junit*.properties
comments.txt
jbossAgent.dll
jboss-aop-dist.zip
local.properties
org
*.class
aopc.tmpdir
target
com
eclipse-classes


Modified: projects/aop/trunk/aop/src/resources/test/stress/config.properties
===================================================================
--- projects/aop/trunk/aop/src/resources/test/stress/config.properties	2007-07-09 19:52:19 UTC (rev 63919)
+++ projects/aop/trunk/aop/src/resources/test/stress/config.properties	2007-07-09 21:28:03 UTC (rev 63920)
@@ -1,5 +1,5 @@
-warmup=5000000
-loops=10000000
+warmup=0
+loops=500
 threads=1
 random_sleep_interval=false
 sleeptime_millis=0

Added: projects/aop/trunk/aop/src/resources/test/stress/weavetest/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/stress/weavetest/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/stress/weavetest/jboss-aop.xml	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <bind pointcut="execution(* org.jboss.test.aop.stress.weavetest.Woven*->method())">
+   	<interceptor class="org.jboss.test.aop.stress.weavetest.TestInterceptor"/>
+   </bind>
+</aop>

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/ScenarioRunner.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/ScenarioRunner.java	2007-07-09 19:52:19 UTC (rev 63919)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/ScenarioRunner.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -245,6 +245,12 @@
       
       public void run()
       {
+         if (forWarmup && scenario.getClass().isAnnotationPresent(SkipWarmup.class))
+         {
+            System.out.println("Skipping warmup for " + scenario.getName());
+            return;
+         }
+         
          final int max = forWarmup ? warmup : loops;
          try
          {

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/SkipWarmup.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/SkipWarmup.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/SkipWarmup.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface SkipWarmup {
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/Factory.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/Factory.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/Factory.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Factory
+{
+   public Class loadClass();
+   public MethodCaller create();
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesScenario.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesScenario.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesScenario.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,150 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.Modifier;
+
+import org.jboss.aop.classpool.AOPClassPoolRepository;
+import org.jboss.test.aop.stress.AbstractScenario;
+import org.jboss.test.aop.stress.SkipWarmup;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SkipWarmup
+public class GenerateClassesScenario extends AbstractScenario
+{
+   private static final String WOVEN = ".Woven";
+   private static final String VANILLA = ".Vanilla";
+   
+   boolean initialised;
+
+   private File directory;
+   ClassPool pool;
+   String packageName;
+   
+   List<Factory> wovenFactories = new ArrayList<Factory>();  
+   
+   List<Factory> vanillaFactories = new ArrayList<Factory>();  
+   
+   public List<Factory> getVanillaFactories()
+   {
+      return vanillaFactories;
+   }
+   
+   public List<Factory> getWovenFactories()
+   {
+      return wovenFactories;
+   }
+   
+   public void execute(int thread, int loop) throws Exception
+   {
+      if (thread > 0)
+      {
+         throw new RuntimeException("This test can only be used with one thred");
+      }
+      if (!initialised)
+      {
+         initialise();
+         initialised = true;
+      }
+      vanillaFactories.add(generateClassAndFactory(loop, VANILLA));
+      wovenFactories.add(generateClassAndFactory(loop, WOVEN));
+   }
+   
+   private Factory generateClassAndFactory(int loop, String rootName) throws Exception
+   {
+      CtClass clazz = createClass(loop, rootName);
+      clazz.writeFile(directory.getAbsolutePath());
+      clazz.detach();
+      
+      CtClass factoryClass = createFactory(loop, rootName);
+      factoryClass.writeFile(directory.getAbsolutePath());
+      Class<Factory> realClass = factoryClass.toClass();
+      return realClass.newInstance();
+   }
+   
+   private CtClass createClass(int loop, String rootName) throws Exception
+   {
+      CtClass clazz = pool.makeClass(packageName + rootName + loop);
+      clazz.addInterface(pool.get(MethodCaller.class.getName()));
+
+      CtField field = new CtField(CtClass.intType, "counter", clazz);
+      field.setModifiers(Modifier.STATIC & Modifier.PRIVATE);
+      clazz.addField(field);
+      
+      CtMethod method = CtNewMethod.make("public void method(){counter++;}", clazz);
+      method.setModifiers(Modifier.PUBLIC);
+      clazz.addMethod(method);
+      
+      return clazz;
+   }
+
+   private CtClass createFactory(int loop, String rootName) throws Exception
+   {
+      CtClass clazz = pool.makeClass(packageName + rootName + "Factory" + loop);
+      clazz.addInterface(pool.get(Factory.class.getName()));
+      
+      CtMethod method = CtNewMethod.make("public " + packageName + ".MethodCaller create(){return new " + packageName + rootName + loop + "();}", clazz);
+      method.setModifiers(Modifier.PUBLIC);
+      clazz.addMethod(method);
+      
+      method = CtNewMethod.make("public java.lang.Class loadClass(){return java.lang.Class.forName(\"" + packageName + rootName + loop + "\", false, this.getClass().getClassLoader());}", clazz);
+      method.setModifiers(Modifier.PUBLIC);
+      clazz.addMethod(method);
+      
+      return clazz;
+   }
+
+   private void initialise() throws Exception
+   {
+      initDirectory();
+      
+      pool = AOPClassPoolRepository.getInstance().registerClassLoader(this.getClass().getClassLoader());
+      packageName = this.getClass().getPackage().getName();
+      CtClass clazz = pool.get("org.jboss.test.aop.stress.weavetest.TemplatePOJO");
+      if (clazz == null)
+      {
+         throw new RuntimeException(TemplatePOJO.class.getName() + " does not exist in pool");
+      }
+   }
+   
+   private void initDirectory() throws Exception
+   {
+      URL url = TemplatePOJO.class.getProtectionDomain().getCodeSource().getLocation();
+      URI uri = url.toURI();
+      directory = new File(uri);
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesTestDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesTestDelegate.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/GenerateClassesTestDelegate.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+import java.util.List;
+
+import org.jboss.test.aop.stress.ScenarioTestDelegate;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenerateClassesTestDelegate extends ScenarioTestDelegate
+{
+   private GenerateClassesScenario setupScenario;
+   private Factory[] wovenFactories;
+   private Factory[] vanillaFactories;
+   
+   public GenerateClassesTestDelegate(Class clazz)
+   {
+      super(clazz);
+   }
+
+   @Override
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      System.out.println("Seeing up delegate");
+      setupScenario = new GenerateClassesScenario();
+      super.getRunner().executeScenario(setupScenario);
+   }
+   
+   public Factory[] getWovenFactories()
+   {
+      if (wovenFactories == null)
+      {
+         List<Factory> facs = setupScenario.getWovenFactories();
+         //loops are one-based while arrays are zero-based so add a first null element to avoid having to do arithmetic in the tests
+         facs.add(0, null);
+         wovenFactories = facs.toArray(new Factory[0]);
+      }
+      return wovenFactories;
+   }
+   
+   public Factory[] getVanillaFactories()
+   {
+      if (vanillaFactories == null)
+      {
+         List<Factory> facs = setupScenario.getVanillaFactories();
+         //loops are one-based while arrays are zero-based so add a first null element to avoid having to do arithmetic in the tests
+         facs.add(0, null);
+         vanillaFactories = facs.toArray(new Factory[0]);
+      }
+      return vanillaFactories;
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/MethodCaller.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/MethodCaller.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/MethodCaller.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MethodCaller
+{
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TemplatePOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TemplatePOJO.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TemplatePOJO.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TemplatePOJO
+{
+   private static int counter;
+   
+   public void method()
+   {
+      counter++;
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TestInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TestInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/TestInterceptor.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestInterceptor implements Interceptor
+{
+   public static int counter;
+   public String getName()
+   {
+      return null;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      counter++;
+      return invocation.invokeNext();
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/WeaveManyClassesTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/WeaveManyClassesTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/weavetest/WeaveManyClassesTestCase.java	2007-07-09 21:28:03 UTC (rev 63920)
@@ -0,0 +1,129 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.stress.weavetest;
+
+import org.jboss.aop.Advised;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.aop.stress.AbstractScenario;
+import org.jboss.test.aop.stress.ScenarioTest;
+import org.jboss.test.aop.stress.SkipWarmup;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeaveManyClassesTestCase extends ScenarioTest
+{
+
+   public WeaveManyClassesTestCase(String arg0)
+   {
+      super(arg0);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      //The delegate is called once and generates the classes
+      GenerateClassesTestDelegate delegate = new GenerateClassesTestDelegate(clazz);
+      return delegate;
+   }
+
+   public void testVanilla() throws Exception
+   {
+      getRunner().executeScenario(new VanillaScenario());
+   }
+   
+   public void testWeave() throws Exception
+   {
+      getRunner().executeScenario(new WeaveScenario());
+   }
+   
+   @SkipWarmup
+   private class VanillaOrWeaveScenario extends AbstractScenario
+   {
+      boolean vanilla;
+      Factory[] factories;
+      
+      protected VanillaOrWeaveScenario(boolean vanilla, Factory[] factories)
+      {
+         this.vanilla = vanilla;
+         this.factories = factories;
+      }
+      
+      public void execute(int thread, int loop) throws Exception
+      {
+         Class clazz = factories[loop].loadClass();
+         System.out.println("Loaded class " + clazz);
+         if (clazz == null)
+         {
+            throw new RuntimeException("Class was null");
+         }
+         if (vanilla)
+         {
+            if (Advised.class.isAssignableFrom(clazz))
+            {
+               throw new RuntimeException(clazz.getName() + " should not implement Advised");
+            }
+         }
+         else
+         {
+            if (!Advised.class.isAssignableFrom(clazz))
+            {
+               throw new RuntimeException(clazz.getName() + " should implement Advised");
+            }
+         }
+      }
+   }
+   
+   @SkipWarmup
+   private class VanillaScenario extends VanillaOrWeaveScenario
+   {
+      VanillaScenario()
+      {
+         super(true, ((GenerateClassesTestDelegate)getDelegate()).getVanillaFactories());
+      }
+   }
+   
+   @SkipWarmup
+   private class WeaveScenario extends VanillaOrWeaveScenario
+   {
+      WeaveScenario()
+      {
+         super(false, ((GenerateClassesTestDelegate)getDelegate()).getWovenFactories());
+      }
+   }
+   
+   public void testInitAdvisor() throws Exception
+   {
+      getRunner().executeScenario(new InitAdvisorScenario());
+   }
+
+   @SkipWarmup
+   private class InitAdvisorScenario extends AbstractScenario
+   {
+      Factory[] factories = ((GenerateClassesTestDelegate)getDelegate()).getWovenFactories(); 
+      public void execute(int thread, int loop) throws Exception
+      {
+         MethodCaller caller = factories[loop].create();
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list