@Test(dependsOnMethods = "testAddCollections")
  public void testAddResource()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          XPathExpressionException {

    String path =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "testresource.txt";
    DataHandler dataHandler = new DataHandler(new URL("file:///" + path));

    String fileType = "plain/text";
    resourceAdminClient.addResource(PATH + RES_NAME, fileType, RES_DESC, dataHandler);

    String authorUserName = resourceAdminClient.getResource(PATH + RES_NAME)[0].getAuthorUserName();
    assertTrue(
        automationContext
            .getContextTenant()
            .getContextUser()
            .getUserName()
            .equalsIgnoreCase(authorUserName),
        "Resource creation failure");
  }
  @BeforeClass(alwaysRun = true)
  public void init() throws Exception {

    super.init(userMode);
    genericRestClient = new GenericRestClient();
    queryParamMap = new HashMap<>();
    headerMap = new HashMap<>();

    headerMap.put(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER_VALUE);

    registryAPIUrl = automationContext.getContextUrls().getWebAppURLHttps();
    generalPath = "/resource/1.0.0/";
    String registryPath = "/_system/governance";
    resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, sessionCookie);
    String filePath =
        getTestArtifactLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "txt"
            + File.separator
            + "MyText.txt";
    DataHandler dh = new DataHandler(new URL("file:///" + filePath));
    path = registryPath + "/" + "MyText.txt";
    resourceAdminServiceClient.addResource(path, "text/xml", "desc", dh);
  }
Ejemplo n.º 3
0
  public void addService() throws Exception {
    String resourcePath =
        getTestArtifactLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "services"
            + File.separator
            + "intergalacticService.xml";

    DataHandler dataHandler = new DataHandler(new URL("file:///" + resourcePath));
    String mediaType = "application/vnd.wso2-service+xml";
    String description = "This is a test service";
    resourceAdminServiceClient.addResource(
        "/_system/governance/service1", mediaType, description, dataHandler);
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddDependencyFromOwnCollection")
  public void testAddWsdlAsADependency()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException, XPathExpressionException {
    String resourcePath =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "wsdl"
            + File.separator
            + "AmazonWebServices.wsdl";
    DataHandler dh = new DataHandler(new URL("file:///" + resourcePath));
    resourceAdminClient.addResource(
        ROOT + "AmazonWebServices.wsdl", "application/wsdl+xml", "testDesc", dh);
    assertTrue(
        resourceAdminClient
            .getResource(WSDL_PATH)[0]
            .getAuthorUserName()
            .contains(automationContext.getContextTenant().getContextUser().getUserName()),
        "WSDL has not been added");

    String dependencyType = "depends";
    String todo = "add";

    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, WSDL_PATH, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        WSDL_PATH.equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove dependency
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, WSDL_PATH, "remove");
  }
  @Test(groups = "wso2.greg", description = "Create a service")
  public void testCreateService()
      throws XMLStreamException, IOException, AddServicesServiceRegistryExceptionException,
          ListMetadataServiceRegistryExceptionException, ResourceAdminServiceExceptionException {

    String servicePath =
        getTestArtifactLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "services"
            + File.separator
            + "intergalacticService16.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/service2", mediaType, description, dataHandler);
    ResourceData[] data = resourceAdminServiceClient.getResource(absPath);
    assertNotNull(data, "Service not found");
  }
  @Test(
      groups = {"wso2.greg"},
      description = "add a wsdl")
  public void testAddGar()
      throws RegistryException, IOException, ResourceAdminServiceExceptionException {

    String filePath =
        getTestArtifactLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "gar"
            + File.separator
            + "myGar.gar";
    DataHandler dh = new DataHandler(new URL("file:///" + filePath));
    resourceAdminServiceClient.addResource(
        "/_system/governance/trunk/test/wsdls",
        "application/vnd.wso2.governance-archive",
        "desc",
        dh);
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddSchemaAsADependency")
  public void testAddRxt()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          XPathExpressionException {
    String resourcePath =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "rxt"
            + File.separator
            + "person.rxt";
    DataHandler dh = new DataHandler(new URL("file:///" + resourcePath));

    resourceAdminClient.addResource(RXT_LOCATION, RXT_FILE_TYPE, "TstDec", dh);

    assertTrue(
        resourceAdminClient
            .getResource(RXT_LOCATION)[0]
            .getAuthorUserName()
            .contains(automationContext.getContextTenant().getContextUser().getUserName()));
  }