@Override
  protected void setUp() throws Exception {
    super.setUp();

    identityStorage =
        (IdentityStorage) getContainer().getComponentInstanceOfType(IdentityStorage.class);
    activityStorage =
        (ActivityStorage) getContainer().getComponentInstanceOfType(ActivityStorage.class);
    relationshipManager =
        (RelationshipManagerImpl)
            getContainer().getComponentInstanceOfType(RelationshipManager.class);

    assertNotNull(identityStorage);
    assertNotNull(activityStorage);
    assertNotNull(relationshipManager);

    rootIdentity = new Identity("organization", "root");
    johnIdentity = new Identity("organization", "john");
    maryIdentity = new Identity("organization", "mary");
    demoIdentity = new Identity("organization", "demo");

    identityStorage.saveIdentity(rootIdentity);
    identityStorage.saveIdentity(johnIdentity);
    identityStorage.saveIdentity(maryIdentity);
    identityStorage.saveIdentity(demoIdentity);

    assertNotNull(rootIdentity.getId());
    assertNotNull(johnIdentity.getId());
    assertNotNull(maryIdentity.getId());
    assertNotNull(demoIdentity.getId());

    tearDownActivityList = new ArrayList<ExoSocialActivity>();
    tearDownRelationshipList = new ArrayList<Relationship>();
  }
 public void tearDown() throws Exception {
   for (Identity identity : tearDownIdentityList) {
     identityManager.deleteIdentity(identity);
   }
   for (Space space : tearDownSpaceList) {
     Identity spaceIdentity =
         identityManager.getOrCreateIdentity(
             SpaceIdentityProvider.NAME, space.getPrettyName(), false);
     if (spaceIdentity != null) {
       identityManager.deleteIdentity(spaceIdentity);
     }
     spaceService.deleteSpace(space);
   }
   super.tearDown();
 }
  public void setUp() throws Exception {
    super.setUp();
    identityManager =
        (IdentityManager) getContainer().getComponentInstanceOfType(IdentityManager.class);
    assertNotNull(identityManager);

    spaceService = (SpaceService) getContainer().getComponentInstanceOfType(SpaceService.class);
    assertNotNull(spaceService);

    activityManager =
        (ActivityManager) getContainer().getComponentInstanceOfType(ActivityManager.class);
    assertNotNull(activityManager);

    userHandler = SpaceUtils.getOrganizationService().getUserHandler();

    tearDownIdentityList = new ArrayList<Identity>();
    tearDownSpaceList = new ArrayList<Space>();
  }
  @Override
  protected void tearDown() throws Exception {

    for (ExoSocialActivity activity : tearDownActivityList) {
      activityStorage.deleteActivity(activity.getId());
    }

    for (Relationship relationship : tearDownRelationshipList) {
      relationshipManager.delete(relationship);
    }

    identityStorage.deleteIdentity(rootIdentity);
    identityStorage.deleteIdentity(johnIdentity);
    identityStorage.deleteIdentity(maryIdentity);
    identityStorage.deleteIdentity(demoIdentity);

    super.tearDown();
  }