Esempio n. 1
0
  @BeforeClass(groups = {"wso2.greg"})
  public void init() throws Exception {
    log.info("Initializing Notification Test");
    log.debug("Registry Notification Test Initialised");

    int userId = 0;
    EnvironmentBuilder builder = new EnvironmentBuilder().greg(userId);
    ManageEnvironment environment = builder.build();

    loggedInSessionCookie = environment.getGreg().getSessionCookie();
    UserInfo userInfo = UserListCsvReader.getUserInfo(userId);

    infoServiceAdminClient =
        new InfoServiceAdminClient(
            environment.getGreg().getBackEndUrl(), userInfo.getUserName(), userInfo.getPassword());
  }
 @BeforeClass(groups = {"wso2.greg"})
 public void init() throws Exception {
   log.info("Initializing Tests for Activity Search");
   log.debug("Activity Search Tests Initialised");
   userInfo = UserListCsvReader.getUserInfo(userId);
   EnvironmentBuilder builder = new EnvironmentBuilder().greg(userId);
   environment = builder.build();
   log.debug("Running SuccessCase");
   resourceAdminServiceClient =
       new ResourceAdminServiceClient(
           environment.getGreg().getBackEndUrl(), userInfo.getUserName(), userInfo.getPassword());
   activityAdminServiceClient =
       new ActivityAdminServiceClient(
           environment.getGreg().getBackEndUrl(), userInfo.getUserName(), userInfo.getPassword());
   userManagementClient =
       new UserManagementClient(
           environment.getGreg().getBackEndUrl(), environment.getGreg().getSessionCookie());
 }
  @BeforeClass(alwaysRun = true)
  @SetEnvironment(executionEnvironments = {ExecutionEnvironment.integration_user})
  public void serverRestart() throws Exception {
    int userId = 0;
    EnvironmentBuilder builder = new EnvironmentBuilder().greg(userId);
    ManageEnvironment environment = builder.build();
    UserInfo userInfo = UserListCsvReader.getUserInfo(userId);

    serverAdminClient =
        new ServerAdminClient(
            environment.getGreg().getBackEndUrl(), userInfo.getUserName(), userInfo.getPassword());

    frameworkProperties = FrameworkFactory.getFrameworkProperties(ProductConstant.GREG_SERVER_NAME);

    resourceAdminServiceClient =
        new ResourceAdminServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            userInfo.getUserName(),
            userInfo.getPassword());
  }
Esempio n. 4
0
  @BeforeClass(alwaysRun = true)
  public void init() throws Exception {
    int userId = 1;
    UserInfo userInfo = UserListCsvReader.getUserInfo(userId);
    EnvironmentBuilder builderAdmin = new EnvironmentBuilder().greg(ProductConstant.ADMIN_USER_ID);
    ManageEnvironment adminEnvironment = builderAdmin.build();

    EnvironmentBuilder builderUser1 = new EnvironmentBuilder().greg(userId);
    ManageEnvironment user1Environment = builderUser1.build();

    adminUserManagementClient =
        new UserManagementClient(
            adminEnvironment.getGreg().getBackEndUrl(),
            adminEnvironment.getGreg().getSessionCookie());
    user1UserManagementClient =
        new UserManagementClient(
            user1Environment.getGreg().getBackEndUrl(),
            user1Environment.getGreg().getSessionCookie());
    ROLE_USERS = new String[] {userInfo.getUserNameWithoutDomain()};
    // setup roles
    adminUserManagementClient.addRole(ROLE_NAME, ROLE_USERS, SECURITY_PERMISSION_LIST);
    adminUserManagementClient.updateUserListOfRole(EXISTING_ROLE, new String[] {}, ROLE_USERS);
  }
Esempio n. 5
0
/*
Search Registry metadata by last updater Name
*/
public class RegistrySearchByUpdaterTestCase {

  private WSRegistryServiceClient registry;
  private final int userId = 0;
  private final UserInfo userInfo = UserListCsvReader.getUserInfo(userId);
  private SearchAdminServiceClient searchAdminServiceClient;
  private String userName;

  private String resourcePath;

  @BeforeClass
  public void init() throws Exception {
    EnvironmentBuilder builder = new EnvironmentBuilder().greg(userId);
    ManageEnvironment environment = builder.build();
    RegistryProviderUtil registryProviderUtil = new RegistryProviderUtil();
    registry = registryProviderUtil.getWSRegistry(userId, ProductConstant.GREG_SERVER_NAME);
    userName = userInfo.getUserName();
    searchAdminServiceClient =
        new SearchAdminServiceClient(
            environment.getGreg().getBackEndUrl(), userInfo.getUserName(), userInfo.getPassword());

    resourcePath = "/_system/governance/test";

    populateResource();
  }

  private void populateResource() throws RegistryException {
    Resource initialResource = registry.newResource();

    //        Adding the resource for the first time
    //        user admin will be the creator and updater of this resource.
    initialResource.setContent("Test content");
    registry.put(resourcePath, initialResource);
  }

  @Test(
      groups = {"wso2.greg"},
      description = "Metadata search by available Updater Name")
  public void searchResourceByUpdater()
      throws SearchAdminServiceRegistryExceptionException, RemoteException, RegistryException {
    CustomSearchParameterBean searchQuery = new CustomSearchParameterBean();
    SearchParameterBean paramBean = new SearchParameterBean();
    paramBean.setUpdater(userName);
    ArrayOfString[] paramList = paramBean.getParameterList();

    searchQuery.setParameterValues(paramList);
    AdvancedSearchResultsBean result =
        searchAdminServiceClient.getAdvancedSearchResults(searchQuery);
    Assert.assertNotNull(result.getResourceDataList(), "No Record Found");
    Assert.assertTrue(
        (result.getResourceDataList().length > 0), "No Record Found. set valid updater name");
    for (ResourceData resource : result.getResourceDataList()) {
      Assert.assertTrue(
          registry.get(resource.getResourcePath()).getLastUpdaterUserName().contains(userName),
          "search word not contain on Updater Name :" + resource.getResourcePath());
    }
  }

  @Test(
      groups = {"wso2.greg"},
      description = "Metadata search by available Updater Name not",
      dependsOnMethods = "searchResourceByUpdater")
  public void searchResourceByUpdaterNot()
      throws SearchAdminServiceRegistryExceptionException, RemoteException, RegistryException {
    CustomSearchParameterBean searchQuery = new CustomSearchParameterBean();
    SearchParameterBean paramBean = new SearchParameterBean();
    paramBean.setUpdater(userName);
    ArrayOfString[] paramList = paramBean.getParameterList();

    searchQuery.setParameterValues(paramList);

    // to set updatedRangeNegate
    ArrayOfString updaterNameNegate = new ArrayOfString();
    updaterNameNegate.setArray(new String[] {"updaterNameNegate", "on"});

    searchQuery.addParameterValues(updaterNameNegate);

    AdvancedSearchResultsBean result =
        searchAdminServiceClient.getAdvancedSearchResults(searchQuery);
    Assert.assertNotNull(result.getResourceDataList(), "No Record Found");
    Assert.assertTrue(
        (result.getResourceDataList().length > 0), "No Record Found. set valid Updater name");
    for (ResourceData resource : result.getResourceDataList()) {
      Resource regResource = registry.get(resource.getResourcePath());
      if (regResource.getProperty("registry.link") == null) {
        Assert.assertFalse(
            regResource.getLastUpdaterUserName().contains(userName),
            "searched updater name not contain on actual Updater Name :"
                + resource.getResourcePath());
      }
    }
  }

  @Test(
      groups = {"wso2.greg"},
      description = "Metadata search by Updater Name pattern matching",
      dependsOnMethods = "searchResourceByUpdaterNot")
  public void searchResourceByUpdaterNamePattern()
      throws SearchAdminServiceRegistryExceptionException, RemoteException, RegistryException {
    CustomSearchParameterBean searchQuery = new CustomSearchParameterBean();
    SearchParameterBean paramBean = new SearchParameterBean();
    paramBean.setUpdater("adm%");
    ArrayOfString[] paramList = paramBean.getParameterList();

    searchQuery.setParameterValues(paramList);
    AdvancedSearchResultsBean result =
        searchAdminServiceClient.getAdvancedSearchResults(searchQuery);
    Assert.assertNotNull(result.getResourceDataList(), "No Record Found");
    Assert.assertTrue(
        (result.getResourceDataList().length > 0),
        "No Record Found. set valid Updater name pattern");
    for (ResourceData resourceData : result.getResourceDataList()) {
      Resource resource = registry.get(resourceData.getResourcePath());
      Assert.assertTrue(
          (resource.getLastUpdaterUserName().startsWith("adm")),
          "search word pattern not contain on Updater Name :" + resourceData.getResourcePath());
    }
  }

  @Test(
      groups = {"wso2.greg"},
      description = "Metadata search by unavailable Updater Name",
      dependsOnMethods = "searchResourceByUpdaterNamePattern")
  public void searchResourceByUnAvailableUpdaterName()
      throws SearchAdminServiceRegistryExceptionException, RemoteException {
    CustomSearchParameterBean searchQuery = new CustomSearchParameterBean();
    SearchParameterBean paramBean = new SearchParameterBean();
    paramBean.setUpdater("xyz1234");
    ArrayOfString[] paramList = paramBean.getParameterList();

    searchQuery.setParameterValues(paramList);
    AdvancedSearchResultsBean result =
        searchAdminServiceClient.getAdvancedSearchResults(searchQuery);
    Assert.assertNull(result.getResourceDataList(), "Result Object found");
  }

  @Test(
      dataProvider = "invalidCharacter",
      groups = {"wso2.greg"},
      dataProviderClass = Parameters.class,
      description = "Metadata search by Updater Name with invalid characters",
      dependsOnMethods = "searchResourceByUnAvailableUpdaterName")
  public void searchResourceByUpdaterNameWithInvalidCharacter(String invalidInput)
      throws SearchAdminServiceRegistryExceptionException, RemoteException {
    CustomSearchParameterBean searchQuery = new CustomSearchParameterBean();
    SearchParameterBean paramBean = new SearchParameterBean();

    paramBean.setUpdater(invalidInput);
    ArrayOfString[] paramList = paramBean.getParameterList();
    searchQuery.setParameterValues(paramList);
    AdvancedSearchResultsBean result = null;
    try {
      result = searchAdminServiceClient.getAdvancedSearchResults(searchQuery);
    } finally {
      Assert.assertTrue(result.getErrorMessage().contains("illegal characters"), "Wrong exception");
    }
  }

  @AfterClass
  public void destroy() throws RegistryException {
    registry.delete(resourcePath);
    searchAdminServiceClient = null;
    registry = null;
  }
}
/**
 * Use LCs with different transitionPermission roles defined for "Promote/Demote" options and make
 * sure that users under only those roles are allowed to do the transition. Login from other roles
 * and verify whether they are not allowed to perform LC transition
 */
public class LCPromoteDemotePermissionTestCase {
  private int userId = 2;
  private UserInfo userInfo = UserListCsvReader.getUserInfo(userId);
  private int user2Id = 3;
  private UserInfo user2Info = UserListCsvReader.getUserInfo(user2Id);
  private String serviceString;
  private WSRegistryServiceClient wsRegistryServiceClient;
  private LifeCycleAdminServiceClient lifeCycleAdminServiceClient;
  private LifeCycleManagementClient lifeCycleManagementClient;
  private GovernanceServiceClient governanceServiceClient;
  private ListMetaDataServiceClient listMetadataServiceClient;
  private UserManagementClient userManagementClient;
  private ResourceAdminServiceClient resourceAdminServiceClient;

  private ServiceManager serviceManager;

  private final String SERVICE_NAME = "IntergalacticService13";
  private final String LC_NAME = "CheckListPermissionLC2";

  private static final String ACTION_PROMOTE = "Promote";
  private static final String ACTION_DEMOTE = "Demote";
  private static final String LC_STATE0 = "Commencement";
  private static final String LC_STATE1 = "Creation";

  private static final String ACTION_ITEM_CLICK = "itemClick";

  private static final String GOV_PATH = "/_system/governance";
  private String servicePath = "/trunk/services/com/abb/IntergalacticService13";
  private final String absPath = GOV_PATH + servicePath;

  private LifecycleBean lifeCycle;
  private RegistryProviderUtil registryProviderUtil = new RegistryProviderUtil();
  private ServiceBean service;

  /**
   * @throws RemoteException
   * @throws LoginAuthenticationExceptionException
   * @throws RegistryException
   */
  @BeforeClass(alwaysRun = true)
  public void init()
      throws RemoteException, LoginAuthenticationExceptionException, RegistryException {
    EnvironmentBuilder builder = new EnvironmentBuilder().greg(userId);
    ManageEnvironment environment = builder.build();

    lifeCycleAdminServiceClient =
        new LifeCycleAdminServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    governanceServiceClient =
        new GovernanceServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    listMetadataServiceClient =
        new ListMetaDataServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    lifeCycleManagementClient =
        new LifeCycleManagementClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    userManagementClient =
        new UserManagementClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    resourceAdminServiceClient =
        new ResourceAdminServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    wsRegistryServiceClient =
        registryProviderUtil.getWSRegistry(userId, ProductConstant.GREG_SERVER_NAME);

    Registry reg =
        registryProviderUtil.getGovernanceRegistry(
            new RegistryProviderUtil().getWSRegistry(userId, ProductConstant.GREG_SERVER_NAME),
            userId);
    GovernanceUtils.loadGovernanceArtifacts((UserRegistry) reg);
    serviceManager = new ServiceManager(reg);
  }

  /**
   * @throws XMLStreamException
   * @throws IOException
   * @throws AddServicesServiceRegistryExceptionException
   * @throws ListMetadataServiceRegistryExceptionException
   * @throws ResourceAdminServiceExceptionException
   */
  @Test(groups = "wso2.greg", description = "Create a service")
  public void testCreateService()
      throws XMLStreamException, IOException, AddServicesServiceRegistryExceptionException,
          ListMetadataServiceRegistryExceptionException, ResourceAdminServiceExceptionException {

    String servicePath =
        ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "services"
            + File.separator
            + "intergalacticService13.metadata.xml";
    DataHandler dataHandler = new DataHandler(new URL("file:///" + servicePath));
    String mediaType = "application/vnd.wso2-service+xml";
    String description = "This is a test service";
    resourceAdminServiceClient.addResource(
        "/_system/governance/service13", mediaType, description, dataHandler);

    ResourceData[] data = resourceAdminServiceClient.getResource(absPath);

    assertNotNull(data, "Service not found");
  }

  /**
   * @throws LifeCycleManagementServiceExceptionException
   * @throws IOException
   * @throws InterruptedException
   */
  @Test(
      groups = "wso2.greg",
      description = "Create new life cycle",
      dependsOnMethods = "testCreateService")
  public void testCreateNewLifeCycle()
      throws LifeCycleManagementServiceExceptionException, IOException, InterruptedException {
    String resourcePath =
        ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "lifecycle"
            + File.separator
            + "CheckListPermissionLC2.xml";
    String lifeCycleContent = FileManager.readFile(resourcePath);
    lifeCycleManagementClient.addLifeCycle(lifeCycleContent);
    String[] lifeCycles = lifeCycleManagementClient.getLifecycleList();

    boolean lcStatus = false;
    for (String lc : lifeCycles) {

      if (lc.equalsIgnoreCase(LC_NAME)) {
        lcStatus = true;
      }
    }
    assertTrue(lcStatus, "LifeCycle not found");
  }

  /**
   * @throws RegistryException
   * @throws RemoteException
   * @throws CustomLifecyclesChecklistAdminServiceExceptionException
   * @throws ListMetadataServiceRegistryExceptionException
   * @throws ResourceAdminServiceExceptionException
   */
  @Test(
      groups = "wso2.greg",
      description = "Add lifecycle to a service",
      dependsOnMethods = "testCreateNewLifeCycle")
  public void testAddLcToService()
      throws RegistryException, RemoteException,
          CustomLifecyclesChecklistAdminServiceExceptionException,
          ListMetadataServiceRegistryExceptionException, ResourceAdminServiceExceptionException {

    wsRegistryServiceClient.associateAspect(absPath, LC_NAME);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    Property[] properties = lifeCycle.getLifecycleProperties();

    boolean lcStatus = false;
    for (Property prop : properties) {
      if (prop.getKey().contains(LC_NAME)) {
        lcStatus = true;
      }
    }
    assertTrue(lcStatus, "LifeCycle not added to service");
  }

  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Promote from Commencement to Creation",
      dependsOnMethods = "testAddLcToService")
  public void testPromoteToCreation() throws Exception {

    addRole("managerrole", userInfo.getUserNameWithoutDomain());
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_PROMOTE)) {
        isPermitted = true;
      }
    }
    assertTrue(isPermitted, "Not allowed to promote with permission");

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);

    Service[] services = serviceManager.getAllServices();

    for (Service service : services) {
      String path = service.getPath();
      if (path.contains("IntergalacticService13")) {
        serviceString = path;
      }
    }
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE1),
            "Not promoted to Creation with permission");
      }
    }
  }

  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Demote from Commencement to Creation",
      dependsOnMethods = "testPromoteToCreation",
      expectedExceptions = org.apache.axis2.AxisFault.class)
  public void testDemoteFromCreation() throws Exception, GovernanceException {
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(GOV_PATH + serviceString);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_DEMOTE)) {
        isPermitted = true;
      }
    }
    assertFalse(isPermitted, "Allowed to demote without permission");

    lifeCycleAdminServiceClient.invokeAspect(
        GOV_PATH + serviceString, LC_NAME, ACTION_DEMOTE, null);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(GOV_PATH + serviceString);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(prop.getValues()[0].equalsIgnoreCase(LC_STATE1), "Demoted without permission");
      }
    }
  }

  /**
   * @throws RemoteException
   * @throws LoginAuthenticationExceptionException
   * @throws RegistryException
   */
  @Test(
      groups = "wso2.greg",
      description = "Log in as a different user without devrole",
      dependsOnMethods = "testDemoteFromCreation")
  public void testSetNewUser()
      throws RemoteException, LoginAuthenticationExceptionException, RegistryException {

    EnvironmentBuilder builder = new EnvironmentBuilder().greg(user2Id);
    ManageEnvironment environment = builder.build();

    lifeCycleAdminServiceClient =
        new LifeCycleAdminServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());

    governanceServiceClient =
        new GovernanceServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    listMetadataServiceClient =
        new ListMetaDataServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    lifeCycleManagementClient =
        new LifeCycleManagementClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    wsRegistryServiceClient =
        registryProviderUtil.getWSRegistry(user2Id, ProductConstant.GREG_SERVER_NAME);
    userManagementClient =
        new UserManagementClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
    resourceAdminServiceClient =
        new ResourceAdminServiceClient(
            environment.getGreg().getProductVariables().getBackendUrl(),
            environment.getGreg().getSessionCookie());
  }

  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Demote  from Creation with permission",
      dependsOnMethods = "testSetNewUser")
  public void testDemoteFromCreationAgain() throws Exception {
    addRole("archrole", user2Info.getUserNameWithoutDomain());
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_DEMOTE)) {
        isPermitted = true;
      }
    }
    assertTrue(isPermitted, "Not allowed to demote with permission");

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_DEMOTE, null);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE0),
            "Not promoted to Creation with permission");
      }
    }
  }

  /**
   * @throws Exception Expected exception because user is not allowed to promote LC without
   *     permission(ex: using WS)
   */
  @Test(
      groups = "wso2.greg",
      description = "Promote from Commencement to Creation without permission",
      dependsOnMethods = "testDemoteFromCreationAgain",
      expectedExceptions = org.apache.axis2.AxisFault.class)
  public void testPromoteToCreationAgain() throws Exception, GovernanceException {
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_PROMOTE)) {
        isPermitted = true;
      }
    }
    assertFalse(isPermitted, "Allowed to promote without permission");

    lifeCycleAdminServiceClient.invokeAspect(
        absPath,
        LC_NAME,
        ACTION_ITEM_CLICK,
        new String[] {"false", "false", "false", "false", "false", "false"});

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);

    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(prop.getValues()[0].equalsIgnoreCase(LC_STATE0), "Promoted without permission");
      }
    }
  }

  /**
   * @param roleName name of the role needs to be added to the current user
   * @throws Exception
   */
  private void addRole(String roleName, String userName) throws Exception {
    String[] permissions = {"/permission/admin/manage/"};
    if (!userManagementClient.roleNameExists(roleName)) {
      userManagementClient.addRole(roleName, new String[] {userName}, permissions);
    }
  }

  /** @throws Exception */
  @AfterClass()
  public void clear() throws Exception {
    String servicePathToDelete = absPath;
    if (wsRegistryServiceClient.resourceExists(servicePathToDelete)) {
      resourceAdminServiceClient.deleteResource(servicePathToDelete);
    }
    /*        String schemaPathToDelete = "/_system/governance/trunk/schemas/org/bar/purchasing/purchasing.xsd";
    if (wsRegistryServiceClient.resourceExists(schemaPathToDelete)) {
        resourceAdminServiceClient.deleteResource(schemaPathToDelete);
    }
    String wsdlPathToDelete = "/_system/governance/trunk/wsdls/com/foo/IntergalacticService.wsdl";
    if (wsRegistryServiceClient.resourceExists(wsdlPathToDelete)) {
        resourceAdminServiceClient.deleteResource(wsdlPathToDelete);
    }*/
    lifeCycleManagementClient.deleteLifeCycle(LC_NAME);

    if (userManagementClient.roleNameExists("archrole")) {
      userManagementClient.deleteRole("archrole");
    }
    if (userManagementClient.roleNameExists("managerrole")) {
      userManagementClient.deleteRole("managerrole");
    }

    governanceServiceClient = null;
    wsRegistryServiceClient = null;
    lifeCycleAdminServiceClient = null;
    lifeCycleManagementClient = null;
    governanceServiceClient = null;
    listMetadataServiceClient = null;
    resourceAdminServiceClient = null;
    resourceAdminServiceClient = null;
    userManagementClient = null;
  }
}