Planning
here is a good reference on how to plan for the migration
Features
Assertions
Defensive programming is key to obtain a stable system. One defensive technique is to catch any adnormal behaviors as close to the source as possible to prevent nasty side effects and ease the troubleshooting.
We can use assertions to test pre-conditions and post-conditions.
Annotations
Syntax
@TestPackage(isPerformance=true) package sis.testing;
"Complex annotations usage"
class IgnoreMethodTest {
@TestMethod public void testA() {}
@TestMethod public void testB() {}
@Ignore(
reasons={TestRunnerTest.IGNORE_REASON1,
TestRunnerTest.IGNORE_REASON2},
initials=TestRunnerTest.IGNORE_INITIALS,
date=@Date(month=1, day=2, year=2005))
@TestMethod public void testC() {}
}
class DefaultIgnoreMethodTest {
@TestMethod public void testA() {}
@TestMethod public void testB() {}
@Ignore(initials=TestRunnerTest.IGNORE_INITIALS,
date=@Date(month=1, day=2, year=2005))
@TestMethod public void testC() {}
}
"Complex annotations definition"
package sis.testing; import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Ignore { String[] reasons() default TestRunner.DEFAULT_IGNORE_REASON; String initials(); Date date(); }
Enums
Code
enum Disposition{ planned("disposition.planned", "disposition.planned.abbreviation"), carriedOver("disposition.carriedOver", "disposition.carriedOver.abbreviation"), added("disposition.added", "disposition.added.abbreviation"), discovered("disposition.discovered", "disposition.discovered.abbreviation"); Disposition(String key, String abbreviationKey) { this.key = key; this.abbreviationKey = abbreviationKey; } String key; String abbreviationKey; } public class EnumMain { public static void main(String args[]) { Disposition d; System.out.println("Here are all Dispositions"); // use values() Disposition allDispositions[] = Disposition.values(); for(Disposition d : allDispositions) // use ordinal() // use name() System.out.println("("+d.ordinal()+","+d.name()+")"); // (0,planned), (1, carriedOver)... System.out.println(); // use valueOf() d = Disposition.valueOf("added"); System.out.println("d contains " + d); }


