Skip to: Site menu | Main content

XPlanner

Planning and tracking tool for agile teams following XP or Scrum

Migration to JDK1.5 Print

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.

Coding

assert name!=null : "Name is required";

Please use a message!

Enabling/disabling

java -ea MainClass # Enable assertion
java -da MainClass # Disable assertion
java -ea:org.MyClass # Enable assertion in org.MyClass only
java -ea -da:org.MyClass # Enable assertion everywhere exception in org.MyClass

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();
}

Package annotations

Only one package annotations declaration per package.

Sun suggest to create a package-info.java to put this declaration
@TestPackage(isPerformance=true) package sis.testing;

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); 
  }