Skip to content

Instantly share code, notes, and snippets.

@loddar
loddar / MyAjUnit0Test.java
Last active August 29, 2015 14:06
ajUnit - Step 0 (create an ajUnit test)
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
/**
* ajUnit - Initial Step 0 (create an ajUnit test).
*
* Create an JUnit4 Test by creating a test class extending AjUnit4Test.
*
* First error message:
@loddar
loddar / MyAjUnit1Test.java
Last active August 29, 2015 14:06
ajUnit - Step 1 (Override setup()).
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
import org.failearly.ajunit.AjUnitSetup;
/**
* ajUnit - Step 1 (Override {@link #setup(org.failearly.ajunit.AjUnitSetup)}).
*
* Next error message:
*
@loddar
loddar / MyAjUnit2Test.java
Created September 22, 2014 12:46
ajUnit - Step 2 (Create an aspect and assign it).
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
import org.failearly.ajunit.AjUnitSetup;
/**
* ajUnit - Step 2 (Create an aspect and assign it).
*
* Next error message:
*
@loddar
loddar / IncorrectAspect.aj
Created September 22, 2014 12:47
An (incorrect) aspect.
package com.company.project.aspects;
public aspect IncorrectAspect {
}
@loddar
loddar / MyAspect.aj
Created September 22, 2014 12:48
A correct ajUnit test aspect.
package com.company.project.aspects;
import org.failearly.ajunit.aspect.classic.AjUnitBeforeClassicAspect;
public aspect MyAspect extends AjUnitBeforeClassicAspect {
protected pointcut pointcutUnderTest();
}
@loddar
loddar / MyAjUnit3Test.java
Created September 22, 2014 12:49
ajUnit - Step 3 (Extend your aspect from one of the provided ajUnit (classic or annotation) aspects).
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
import org.failearly.ajunit.AjUnitSetup;
/**
* ajUnit - Step 3 (Extend your aspect from one of the provided ajUnit (classic or annotation) aspects).
*
* Next Error message:
*
@loddar
loddar / MyAjUnit4Test.java
Created September 22, 2014 12:50
ajUnit - Step 4 (Create at least one test fixture class and add it/them).
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
import org.failearly.ajunit.AjUnitSetup;
/**
* ajUnit - Step 4 (Create at least one test fixture class and add it/them).
*
* Next error message:
*
@loddar
loddar / MyTestFixture.java
Created September 22, 2014 12:52
A sample test fixture class for ajUnit.
package com.company.project.aspects.testfixture;
/**
* A test fixture class for ajUnit. These class exists only for ajUnit tests.
*/
public class MyTestFixture {
}
@loddar
loddar / MyAjUnit5Test.java
Created September 22, 2014 12:54
ajUnit - Step 5 (Override method assertPointcut(JoinPointSelector) and "implement" it).
package com.company.project.aspects;
import org.failearly.ajunit.AjUnit4Test;
import org.failearly.ajunit.AjUnitSetup;
import org.failearly.ajunit.builder.JoinPointSelector;
/**
* ajUnit - Step 5 (Override method assertPointcut(JoinPointSelector) and "implement" it by calling JoinPointSelector.notYetSpecified()).
*
* Next error messages:
@loddar
loddar / MyAjUnit6Test.java
Last active August 29, 2015 14:06
ajUnit - Final Step 6 (Override method execute()).
/**
* ajUnit - Final Step 6 (Override method execute()).
*
* NOW you're done! No more "ajUnit - Setup Error: ..."! You can start developing your aspect - sorry I mean your pointcut :-)
*
* You got an test failure (not an setup error):
*
* java.lang.AssertionError: ajUnit - Pointcut test failed with 2 error(s).
*
* Details: