towards a practical approach to testing pointcut descriptors with jquati

21
Towards a Practical Approach to Testing Pointcut Descriptors With JQuati 1 LA-WASP 2009

Upload: tuyet

Post on 13-Jan-2016

20 views

Category:

Documents


1 download

DESCRIPTION

Towards a Practical Approach to Testing Pointcut Descriptors With JQuati. LA-WASP 2009. By The Authors. Sandro Hiroki Tanaka Emmanuel de Castro Santana Eduardo Martins Guerra Clovis Fernandez Torres Fábio Fagundes Silveira. Agenda. Quick Conceptualization The Problem Causes Task - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Towards a Practical Approach to Testing Pointcut Descriptors With JQuati

1

LA-WASP 2009

Page 2: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

By The Authors2

Sandro Hiroki Tanaka Emmanuel de Castro Santana Eduardo Martins Guerra Clovis Fernandez Torres Fábio Fagundes Silveira

Page 3: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Agenda3

Quick Conceptualization The Problem Causes Task Objectives Using JQuati Architecture and Components Most Related Tools Conclusion, Limitations and Future

Developments Source Code and Constribution

Page 4: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Testing on Aspect Orientation

4

Aspect Behavior Testing Does it do what it proposes itself to do ? Several approaches (data flow-based,

machine state-based, petri nets-based, and UML model-based)

Page 5: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Testing on Aspect Orientation

5

Pointcut Descriptor Testing Is this behavior being executed where and

when it should ? Three kinds of faults: too strong PCD, to

weak PCD and both too strong and too weak PCD

Page 6: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

The Problem6

How to offer developers a practical and productive way to write test code to identify faults in pointcut descriptors, in a way to separate PCD testing and aspect behavior testing ?

Page 7: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Some Causes7

Lack of ways to automatically trigger an advice and identify if a join point has been matched by a PCD.

In a test case that tests aspect behavior, usually it is not possible to conclude that a fault is due to an incorrectness in the PCDs.

Page 8: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Objectives8

Allow the developer to define expectations regarding the execution of advices in a given test case and then identify faults from checking them against the actual executions.

Provide a intuitive syntax for developers to write test code specifically for PCD testing

Page 9: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Task9

By using a new tool Simulate execution contexts, i.e. join

points to be matched by a group of PCDs. Intercept advice executions. Define and verify expectations related to

advice execution given a set o join points. By using additional metadata to test cases,

integrate with existing testing tools

Page 10: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

JQuati10

A simple tool for testing PCDs integrated with jUnit

has it’s own Test Runner which controls the execution of each test case.

Allows the developer to generates classes in runtime using ClassMock for simulating execution contexts simply by adding metadata to the test class.

Allows the developer to define which advices should and which should not be executed in a test case through metadata added to the test method.

Page 11: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

The tested Advice11

...

public aspect FooBarAspect {@AdviceName(“interceptFoo")after() : execution(* *.foo(..)) { }

@AdviceName(“interceptBar")after() : execution(* *.bar(..)) { }

@AdviceName(“interceptFooBar")after() : execution(* *.fooBar(..)) { }

}

The annotation AdviceName should be

added to the tested advice

Page 12: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

JQuati - Simulating Execution Contexts

12

....

@ExecutionContextCreation(classNames={“Foo",“Bar”},methods={

"void foo()","void bar(Integer)"

})@RunWith(JQuatiRunner.class)public class AspectXTest {

@ExecutionContextElementClassExecutionContext cec;

....

Defining which classes will be used for testing.

These classes are created in runtime. The

methods will be replicated to all classes on the classNames list.

Methods can also receive parameters.

JQuati Runner controlling the test

cycle

Element through which method in the

generated classes will be called

Page 13: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

JQuati - Testing13

....

@Test@MustExecute({“interceptFoo“,”interceptBar”})@MustNotExecute({“interceptFooBar“})public void shouldNotFooBarButFooAndBar() throws Exception {

cec.executeMethodOnAll(“foo");cec.executeMethodOnAll(“bar“, 0);cec.executeMethodOnClass("Foo", “bar", 0);

}

....

Expectations are defined by using the

annotations MustExecute and MustNotExecute

Every call to methods on the created classes

should meet the expectations defined for

the test method. The developer can make calls to one specific method of one specific Class or in all available Classes.

Developers can use BDD naming conventions and

better describe their intentions for where aspectual behavior

should be inserted into.

Page 14: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

JQuati – lets play !!14

Page 15: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Architecture15

Page 16: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Most Related Tools16

AdviceTracer (Delamare et al, 2009) APTE (Anbalagan e Xie, 2006) AJTE (Yamazaki et al, 2005)

Page 17: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Contributions17

A new tool to help developers describe their intentions for better addressing the business rules.

Path to new researches towards developing aspect oriented software with a test driven approach.

Page 18: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Some limitations18

Triggering of advices not affected by reflection calls. In this case it is still possible to use real stub classes.

Page 19: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Future Developments19

Improvements in JQuati Automatic creation of aop-ajc.xml for the tests Additional features in execution context

creation A way to choose which aspects to be woven in

each test case Ways to make the configuration easier

Additional research on JQuati Solution of other problems on aspect

orientation. Case studies in industry.

Page 20: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Source Code and Colaboration

20

JQuati under LGPL and GPL Shared on sourceforge:

https://jquati.svn.sourceforge.net/svnroot/jquati

Evolution plan Testing

Page 21: Towards a Practical Approach to Testing  Pointcut  Descriptors With JQuati

Thank you all !!!

Questions ?

21