@After
  public void tearDown() throws NamingException, NoSuchObjectException, UnauthorizedException {

    for (long nodeId : node.getToplevelNodes()) {
      node.remove(nodeId);
    }

    for (long userId : userBean.getUsers()) {
      userBean.remove(userId);
    }
  }
  @Before
  public void setUp()
      throws NamingException, PathExistsException, UnauthorizedException, InvalidNameException,
          NoSuchObjectException {

    node = connection.getNode();
    courseNode = connection.getCourseNode();
    userBean = connection.getUser();
    periodNode = connection.getPeriodNode();
    assignmentNode = connection.getAssignmentNode();

    // Add users
    names.add("Homer Simpson");
    names.add("Bart Simpson");
    names.add("Lisa Simpson");

    identity.add("homer");
    identity.add("bart");
    identity.add("lisa");

    emails.add("*****@*****.**");
    emails.add("*****@*****.**");
    emails.add("*****@*****.**");

    phoneNumbers.add("1111111");
    phoneNumbers.add("9999999");
    phoneNumbers.add("6666666");

    homerId = userBean.create(names.get(0), emails.get(0), phoneNumbers.get(0));
    userBean.addIdentity(homerId, identity.get(0));
    userBean.setIsSuperAdmin(homerId, true);

    bartId = userBean.create(names.get(1), emails.get(1), phoneNumbers.get(1));
    userBean.addIdentity(bartId, identity.get(1));

    lisaId = userBean.create(names.get(2), emails.get(2), phoneNumbers.get(2));
    userBean.addIdentity(lisaId, identity.get(2));

    // Add nodes
    uioId = node.create("uio", "UiO");
    matnatId = node.create("matnat", "Faculty of Mathematics", uioId);
    ifiId = node.create("ifi", "Department of Informatics", matnatId);

    inf1000 = courseNode.create("inf1000", "Programmering intro", ifiId);

    Calendar start = new GregorianCalendar(2009, 00, 01, 10, 15);
    Calendar end = new GregorianCalendar(2009, 05, 15);

    inf1000Spring09 =
        periodNode.create(
            "spring2009", "INF1000 spring2009", start.getTime(), end.getTime(), inf1000);
    inf1000Fall09 =
        periodNode.create("fall2009", "INf1000 fall 2009", start.getTime(), end.getTime(), inf1000);
  }