[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: Update AOPTestDelegate to better integrate into eclipse

kabir.khan@jboss.com do-not-reply at jboss.com
Tue Jan 2 15:02:06 EST 2007


The initialization of the AOPSetup/TestDelegate results from the  testcase setUp() method. Once that is called the class has already been loaded:


  | Thread [main] (Suspended (breakpoint at line 39 in AOPTestDelegate))	
  | 	AOPTestDelegate.<init>(Class) line: 39	
  | 	AOPTestWithSetup.getDelegate(Class) line: 51	
  | 	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
  | 	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
  | 	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
  | 	Method.invoke(Object, Object...) line: 585	
  | 	AbstractTestDelegate.getDelegate(Class) line: 70	
  | 	AbstractTestSetup.setUp() line: 62	
  | 	AOPArrayTestCase(AbstractTestCaseWithSetup).setUp() line: 90	
  | 	AOPArrayTestCase(TestCase).runBare() line: 125	
  | 	TestResult$1.protect() line: 106	
  | 	TestResult.runProtected(Test, Protectable) line: 124	
  | 	TestResult.run(TestCase) line: 109	
  | 	AOPArrayTestCase(TestCase).run(TestResult) line: 118	
  | 	TestSuite.runTest(Test, TestResult) line: 208	
  | 	TestSuite.run(TestResult) line: 203	
  | 	TestSuite.runTest(Test, TestResult) line: 208	
  | 	TestSuite.run(TestResult) line: 203	
  | 	JUnit3TestReference.run(TestExecution) line: 128	
  | 	TestExecution.run(ITestReference[]) line: 38	
  | 	RemoteTestRunner.runTests(String[], String, TestExecution) line: 460	
  | 	RemoteTestRunner.runTests(TestExecution) line: 673	
  | 	RemoteTestRunner.run() line: 386	
  | 	RemoteTestRunner.main(String[]) line: 196	
  | 

The classloader uses whatever -aop.xml info has been deployed in AOP to determine if the class should be woven, in other words having this deployed by the Setup/Delegate is too late.

2 possible solutions:
1) Refactor all existing xxxTestCase classes to xxxTestCaseDelegate and create new xxxTestCase classes delegating to the xxxTestCaseDelegate

2) Create a new javaagent that delegates to the exisiting transformer. This transformer should be able to leverage the existing transformer for it's work and deploy use the info about the testcase to 

1) is a pain, and 2) while conceptually straight-forward is complicated by the fact that there doesn't seem to be a way to tell which test is being run.

One option though could be to have my classloader dig into the junit stack, and weave the org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main() method so this information is available in a system property somewhere. Eclipse seems to load that class for each test run.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997352#3997352

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997352



More information about the jboss-dev-forums mailing list