Esempio n. 1
0
 private void extractBuild() throws MojoExecutionException {
   try {
     ArchiveUtil.extractArchive(buildFile.getPath(), targetDir.getPath(), ArchiveType.ZIP);
   } catch (PhrescoException e) {
     throw new MojoExecutionException(e.getErrorMessage(), e);
   }
 }
 @POST
 @Path(REST_API_TESTSUITES)
 @Produces(MediaType.APPLICATION_JSON)
 public Response createTestSuite(
     @QueryParam(REST_API_TESTSUITE) String testSuiteName,
     @QueryParam(REST_QUERY_APPDIR_NAME) String appDirName,
     @QueryParam(REST_QUERY_MODULE_NAME) String moduleName)
     throws PhrescoException {
   ResponseInfo responseData = new ResponseInfo();
   try {
     String rootModulePath = "";
     String subModuleName = "";
     if (StringUtils.isNotEmpty(moduleName)) {
       rootModulePath = Utility.getProjectHome() + appDirName;
       subModuleName = moduleName;
     } else {
       rootModulePath = Utility.getProjectHome() + appDirName;
     }
     FrameworkUtil frameworkUtil = FrameworkUtil.getInstance();
     ProjectInfo projectinfo = Utility.getProjectInfo(rootModulePath, subModuleName);
     File manualDir = Utility.getTestFolderLocation(projectinfo, rootModulePath, subModuleName);
     String manualTestDir = getManualTestReportDir(rootModulePath, subModuleName);
     StringBuilder sb = new StringBuilder(manualDir.toString()).append(manualTestDir);
     String cellValue[] = {"", "", testSuiteName, "", "", "", "", "", "", "", "", "", ""};
     frameworkUtil.addNew(sb.toString(), testSuiteName, cellValue);
     ResponseInfo finalOutput =
         responseDataEvaluation(responseData, null, null, RESPONSE_STATUS_SUCCESS, PHRQ400004);
     return Response.status(Status.OK).entity(finalOutput).build();
   } catch (PhrescoException e) {
     e.printStackTrace();
     ResponseInfo finalOutput =
         responseDataEvaluation(responseData, e, null, RESPONSE_STATUS_ERROR, PHRQ410006);
     return Response.status(Status.OK).entity(finalOutput).build();
   }
 }
Esempio n. 3
0
 public static void main(String a[]) {
   try {
     System.out.println(unmask("U2F2ZUFuaW1hbHM1"));
   } catch (PhrescoException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 @POST
 @Path(REST_API_TESTCASES)
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
 public Response createTestCase(
     com.photon.phresco.commons.model.TestCase testCase,
     @QueryParam("testSuiteName") String testSuiteName,
     @QueryParam(REST_QUERY_APPDIR_NAME) String appDirName,
     @QueryParam(REST_QUERY_MODULE_NAME) String moduleName)
     throws PhrescoException {
   ResponseInfo responseData = new ResponseInfo();
   try {
     String rootModulePath = "";
     String subModuleName = "";
     if (StringUtils.isNotEmpty(moduleName)) {
       rootModulePath = Utility.getProjectHome() + appDirName;
       subModuleName = moduleName;
     } else {
       rootModulePath = Utility.getProjectHome() + appDirName;
     }
     FrameworkUtil frameworkUtil = FrameworkUtil.getInstance();
     ProjectInfo projectinfo = Utility.getProjectInfo(rootModulePath, subModuleName);
     File manualDir = Utility.getTestFolderLocation(projectinfo, rootModulePath, subModuleName);
     String manualTestDir = getManualTestReportDir(rootModulePath, subModuleName);
     StringBuilder sb = new StringBuilder(manualDir.toString()).append(manualTestDir);
     String cellValue[] = {
       "",
       testCase.getFeatureId(),
       "",
       testCase.getTestCaseId(),
       testCase.getDescription(),
       testCase.getPreconditions(),
       testCase.getSteps(),
       "",
       "",
       testCase.getExpectedResult(),
       testCase.getActualResult(),
       testCase.getStatus(),
       testCase.getBugComment()
     };
     frameworkUtil.addNewTestCase(sb.toString(), testSuiteName, cellValue, testCase.getStatus());
     ResponseInfo finalOutput =
         responseDataEvaluation(responseData, null, testCase, RESPONSE_STATUS_SUCCESS, PHRQ400005);
     return Response.status(Status.OK).entity(finalOutput).build();
   } catch (PhrescoException e) {
     e.printStackTrace();
     ResponseInfo finalOutput =
         responseDataEvaluation(responseData, e, null, RESPONSE_STATUS_ERROR, PHRQ410007);
     return Response.status(Status.OK).entity(finalOutput).build();
   }
 }
 public void execute() throws MojoExecutionException, MojoFailureException {
   try {
     String infoFile = baseDir + File.separator + Constants.LOAD_TEST_INFO_FILE;
     if (isGoalAvailable(infoFile, LOAD_TEST) && getDependency(infoFile, LOAD_TEST) != null) {
       PhrescoPlugin plugin = getPlugin(getDependency(infoFile, LOAD_TEST));
       plugin.runLoadTest(getConfiguration(infoFile, LOAD_TEST), getMavenProjectInfo(project));
     } else {
       PhrescoPlugin plugin = new PhrescoBasePlugin(getLog());
       plugin.runLoadTest(getConfiguration(infoFile, LOAD_TEST), getMavenProjectInfo(project));
     }
   } catch (PhrescoException e) {
     throw new MojoExecutionException(e.getMessage(), e);
   }
 }
 @Ignore
 public void testGetServer() {
   try {
     serviceManager = ServiceClientFactory.getServiceManager(context);
     RestClient<Server> customerClient =
         serviceManager.getRestClient(RestResourceURIs.REST_API_SERVERS);
     customerClient.setType(MediaType.APPLICATION_JSON);
     GenericType<List<Server>> genericType = new GenericType<List<Server>>() {};
     List<Server> list = customerClient.get(genericType);
     for (Server Server : list) {
       System.out.println("Server Name == " + Server.getName());
     }
   } catch (PhrescoException e) {
     e.printStackTrace();
   }
 }
Esempio n. 7
0
 private void extractBuild() throws MojoExecutionException {
   try {
     String context = "";
     List<com.photon.phresco.configuration.Configuration> configuration =
         pUtil.getConfiguration(baseDir, environmentName, Constants.SETTINGS_TEMPLATE_SERVER);
     for (com.photon.phresco.configuration.Configuration config : configuration) {
       context = config.getProperties().getProperty(Constants.SERVER_CONTEXT);
       break;
     }
     tempDir = new File(buildDir.getPath() + TEMP_DIR + File.separator + context);
     tempDir.mkdirs();
     ArchiveUtil.extractArchive(buildFile.getPath(), tempDir.getPath(), ArchiveType.ZIP);
   } catch (PhrescoException e) {
     throw new MojoExecutionException(e.getErrorMessage(), e);
   }
 }
 @Ignore
 public void testGetServerById() throws PhrescoException {
   try {
     String id = "2c909c4836f2bb7b0136f2bba6db0003";
     serviceManager = ServiceClientFactory.getServiceManager(context);
     RestClient<Server> ServerClient =
         serviceManager.getRestClient(RestResourceURIs.REST_API_SERVERS);
     ServerClient.setType(MediaType.APPLICATION_JSON);
     GenericType<List<Server>> genericType = new GenericType<List<Server>>() {};
     List<Server> list = ServerClient.get(genericType);
     for (Server Server : list) {
       System.out.println("name == " + Server.getName());
     }
   } catch (PhrescoException e) {
     e.printStackTrace();
   }
 }
Esempio n. 9
0
 private void deploy() throws MojoExecutionException {
   String deployLocation = "";
   try {
     List<com.photon.phresco.configuration.Configuration> configuration =
         pUtil.getConfiguration(baseDir, environmentName, Constants.SETTINGS_TEMPLATE_SERVER);
     for (com.photon.phresco.configuration.Configuration config : configuration) {
       deployLocation = config.getProperties().getProperty(Constants.SERVER_DEPLOY_DIR);
       break;
     }
     File deployDir = new File(deployLocation);
     if (!deployDir.exists()) {
       throw new MojoExecutionException("Deploy Directory" + deployLocation + " Does Not Exists ");
     }
     log.info("Project is deploying into " + deployLocation);
     FileUtils.copyDirectoryStructure(tempDir.getParentFile(), deployDir);
     log.info("Project is deployed successfully");
   } catch (PhrescoException e) {
     throw new MojoExecutionException(e.getMessage(), e);
   } catch (IOException e) {
     throw new MojoExecutionException(e.getMessage(), e);
   }
 }
Esempio n. 10
0
  private void extractBuild() throws MojoExecutionException {
    try {
      ArchiveUtil.extractArchive(buildFile.getPath(), tempDir.getPath(), ArchiveType.ZIP);

      String tempDirPath = tempDir.getPath();
      File directory = new File(tempDirPath);
      String[] wspFiles =
          directory.list(
              new FilenameFilter() {
                public boolean accept(File directory, String fileName) {
                  return fileName.endsWith(".wsp");
                }
              });
      wspFile = wspFiles[0];
      temp = new File(tempDir.getPath() + "\\" + wspFile);

      FileUtils.copyFileToDirectory(temp, build);
      FileUtils.deleteDirectory(tempDir);
    } catch (PhrescoException e) {
      throw new MojoExecutionException(e.getErrorMessage(), e);
    } catch (IOException e) {
      throw new MojoExecutionException(e.getMessage(), e);
    }
  }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    File outputFile = null, outputAlignedFile = null, destFile = null, destAlignedFile = null;
    String techId;
    if (baseDir.getPath().endsWith("source")
        || baseDir.getPath().endsWith("unit")
        || baseDir.getPath().endsWith("functional")
        || baseDir.getPath().endsWith("performance")) {
      try {
        if (baseDir.getPath().endsWith("source")) {
          rootPomFile =
              new File(
                  baseDir.getParentFile().getPath() + File.separator + PluginConstants.POM_XML);
        } else {
          String rootDir = baseDir.getParentFile().getParentFile().getParentFile().getPath();
          SplitedSourceDirName = rootDir.substring(rootDir.lastIndexOf(File.separator) + 1);
          rootPomFile =
              new File(
                  baseDir.getParentFile().getParentFile().getParentFile().getPath()
                      + File.separator
                      + SplitedSourceDirName
                      + File.separator
                      + PluginConstants.POM_XML);
        }
        try {

          if (rootPomFile.exists()) {
            rootPomProcessor = new PomProcessor(rootPomFile);
            if (StringUtils.isNotEmpty(
                rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_PHRESCO_DIR))) {
              dotPhrescoDirName =
                  rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_PHRESCO_DIR);
              testDirName = rootPomProcessor.getProperty(Constants.POM_PROP_KEY_SPLIT_TEST_DIR);
            }
          }
        } catch (PhrescoPomException e) {
          e.printStackTrace();
        }
        buildInfoList = new ArrayList<BuildInfo>(); // initialization
        if (baseDir.getPath().endsWith("source") && dotPhrescoDirName == null) {
          buildDir = new File(baseDir.getParentFile().getPath() + buildDirectory);
          packageInfoFile =
              new File(
                  baseDir.getParentFile().getPath()
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");

        } else if (baseDir.getPath().endsWith("source") && dotPhrescoDirName != null) {
          // code for new archetype changes starts
          dotPhrescoDir =
              baseDir.getParentFile().getParentFile().getPath()
                  + File.separator
                  + dotPhrescoDirName;
          File projectDir = new File(baseDir.getParentFile().getParentFile().getPath());
          File[] filesInDir = projectDir.listFiles();
          fileProcessor(filesInDir);
          // code for new archetype changes ends
          buildDir = new File(finalBuildDir + File.separator + buildDirectory);
          packageInfoFile =
              new File(
                  dotPhrescoDir
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");

        } else if (dotPhrescoDirName != null) {
          dotPhrescoDir =
              baseDir.getParentFile().getParentFile().getParentFile().getPath()
                  + File.separator
                  + dotPhrescoDirName;
          buildDir = new File(baseDir.getPath() + buildDirectory);

        } else {
          buildDir = new File(baseDir.getPath() + buildDirectory);
        }

        if (!buildDir.exists()) {
          buildDir.mkdir();
        }
        buildInfoFile = new File(buildDir.getPath() + "/build.info");

        if ((baseDir.getPath().endsWith("unit")
                || baseDir.getPath().endsWith("functional")
                || baseDir.getPath().endsWith("performance"))
            && dotPhrescoDir != null) {
          packageInfoFile =
              new File(
                  dotPhrescoDir
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");
        } else if (baseDir.getPath().endsWith("unit")
            || baseDir.getPath().endsWith("functional")
            || baseDir.getPath().endsWith("performance")) {
          packageInfoFile =
              new File(
                  baseDir.getParentFile().getParentFile()
                      + File.separator
                      + ".phresco"
                      + File.separator
                      + "phresco-package-info.xml");
          buildDir = baseDir.getParentFile().getParentFile();
          buildInfoFile = new File(baseDir.getPath() + buildDirectory + "/build.info");
        }

        MojoProcessor processor = new MojoProcessor(packageInfoFile);
        Configuration configuration = processor.getConfiguration("package");
        Map<String, String> configs = MojoUtil.getAllValues(configuration);
        techId = configs.get("techId");
        if (StringUtils.isNotEmpty(techId)) {

          outputFile =
              new File(
                  project.getBuild().getDirectory(),
                  project.getBuild().getFinalName() + '.' + APKLIB);

        } else {

          outputFile =
              new File(
                  project.getBuild().getDirectory(), project.getBuild().getFinalName() + '.' + APK);
          outputAlignedFile =
              new File(
                  project.getBuild().getDirectory(),
                  project.getBuild().getFinalName() + "-aligned." + APK);
        }

        nextBuildNo = generateNextBuildNo();

        currentDate = Calendar.getInstance().getTime();
      } catch (IOException e) {
        throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
      } catch (PhrescoException e) {
        throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
      }

      if (outputFile.exists()) {
        try {
          if (StringUtils.isNotEmpty(techId)) {
            getLog().info("APKLib created.. Copying to Build directory.....");
          } else {
            getLog().info("APK created.. Copying to Build directory.....");
          }
          String buildNameLocal =
              project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);

          if (baseDir.getPath().endsWith("unit")
              || baseDir.getPath().endsWith("functional")
              || baseDir.getPath().endsWith("performance")) {
            buildDir = new File(baseDir.getPath() + buildDirectory);
          }
          if (buildName != null) {
            if (StringUtils.isNotEmpty(techId)) {
              destFile = new File(buildDir, buildName + '.' + APKLIB);

            } else {

              destFile = new File(buildDir, buildName + '.' + APK);
              // Creating the file in build folder for copying the aligned APK - Created by Hari -
              // 20-May-2013
              destAlignedFile = new File(buildDir, buildName + "-aligned." + APK);
            }

            FileUtils.copyFile(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());

            /* If outputAlignedFile exists in target folder,
             * Then we are copying it to destinationFile in build folder
             * Added By - Hari - May, 20 , 2013
             */

            if (outputAlignedFile != null && outputAlignedFile.exists()) {

              FileUtils.copyFile(outputAlignedFile, destAlignedFile);
            }
            apkFileName = destFile.getName();

            getLog().info("Creating deliverables.....");

            ZipArchiver zipArchiver = new ZipArchiver();
            File tmpFile = new File(buildDir, buildName);

            if (!tmpFile.exists()) {

              tmpFile.mkdirs();
            }
            FileUtils.copyFileToDirectory(destFile, tmpFile);

            /*To Copy the aligned apk into zip file in build folder,
             *It is for downloading the aligned apk from build Tab
             * Added by - Hari -May, 20 ,2013
             */
            if (destAlignedFile != null && destAlignedFile.exists()) {

              FileUtils.copyFileToDirectory(destAlignedFile, tmpFile);
            }
            if (!packageInfoFile.exists()) {
              PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
            }
            File inputFile = new File(apkFileName);
            zipArchiver.addDirectory(tmpFile);
            File deliverableZip = new File(buildDir, buildName + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getPath();
            getLog().info("Deliverables available at " + deliverableZip.getName());
            if (tmpFile.exists()) {
              FileUtil.delete(tmpFile);
            }
            writeBuildInfo(true);
          } else {
            if (StringUtils.isNotEmpty(techId)) {
              destFile = new File(buildDir, buildNameLocal + '.' + APKLIB);

            } else {

              destFile = new File(buildDir, buildNameLocal + '.' + APK);
              // Creating the file in build folder for copying the aligned APK - Created by Hari -
              // 20-May-2013
              destAlignedFile = new File(buildDir, buildNameLocal + "-aligned." + APK);
            }

            FileUtils.copyFile(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());

            /* If outputAlignedFile exists in target folder,
             * Then we are copying it to destinationFile in build folder
             * Added By - Hari - May, 20 , 2013
             */

            if (outputAlignedFile != null && outputAlignedFile.exists()) {

              FileUtils.copyFile(outputAlignedFile, destAlignedFile);
            }
            apkFileName = destFile.getName();

            getLog().info("Creating deliverables.....");

            ZipArchiver zipArchiver = new ZipArchiver();
            File tmpFile = new File(buildDir, buildNameLocal);

            if (!tmpFile.exists()) {

              tmpFile.mkdirs();
            }
            FileUtils.copyFileToDirectory(destFile, tmpFile);

            /*To Copy the aligned apk into zip file in build folder,
             *It is for downloading the aligned apk from build Tab
             * Added by - Hari -May, 20 ,2013
             */
            if (destAlignedFile != null && destAlignedFile.exists()) {

              FileUtils.copyFileToDirectory(destAlignedFile, tmpFile);
            }
            if (!packageInfoFile.exists()) {
              PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
            }
            File inputFile = new File(apkFileName);
            zipArchiver.addDirectory(tmpFile);
            File deliverableZip = new File(buildDir, buildNameLocal + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getPath();
            getLog().info("Deliverables available at " + deliverableZip.getName());
            if (tmpFile.exists()) {
              FileUtil.delete(tmpFile);
            }
            writeBuildInfo(true);
          }

        } catch (IOException e) {
          throw new MojoExecutionException("Error in writing output...");
        }
      }
    } else {
      getLog().info("It is a component ");
    }
  }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    File outputFile = null, destFile = null, projectHome = null;
    String techId;
    try {
      getLog().info("Base Dir === " + baseDir.getAbsolutePath());

      buildInfoList = new ArrayList<BuildInfo>(); // initialization
      //			srcDir = new File(baseDir.getPath() + File.separator + sourceDirectory);
      buildDir = new File(baseDir.getPath() + buildDirectory);
      if (!buildDir.exists()) {
        buildDir.mkdir();
        getLog().info("Build directory created..." + buildDir.getPath());
      }
      buildInfoFile = new File(buildDir.getPath() + "/build.info");
      if (baseDir.getPath().endsWith("unit")
          || baseDir.getPath().endsWith("functional")
          || baseDir.getPath().endsWith("performance")) {
        projectHome =
            new File(
                baseDir.getParentFile().getParentFile()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + "phresco-package-info.xml");
      } else {
        projectHome =
            new File(
                baseDir.getPath()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + "phresco-package-info.xml");
      }
      MojoProcessor processor = new MojoProcessor(projectHome);
      Configuration configuration = processor.getConfiguration("package");
      Map<String, String> configs = MojoUtil.getAllValues(configuration);
      if (baseDir.getPath().endsWith("unit")
          || baseDir.getPath().endsWith("functional")
          || baseDir.getPath().endsWith("performance")) {
        buildDir = baseDir.getParentFile().getParentFile();
        buildInfoFile = new File(baseDir.getPath() + buildDirectory + "/build.info");
      }

      techId = configs.get("techId");
      if (StringUtils.isNotEmpty(techId)) {
        outputFile =
            new File(
                project.getBuild().getDirectory(),
                project.getBuild().getFinalName() + '.' + APKLIB);
      } else {
        outputFile =
            new File(
                project.getBuild().getDirectory(), project.getBuild().getFinalName() + '.' + APK);
      }

      nextBuildNo = generateNextBuildNo();

      currentDate = Calendar.getInstance().getTime();
    } catch (IOException e) {
      throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
    } catch (PhrescoException e) {
      throw new MojoFailureException("APK could not initialize " + e.getLocalizedMessage());
    }

    if (outputFile.exists()) {
      try {
        getLog().info("APK created.. Copying to Build directory.....");
        String buildName =
            project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);

        if (baseDir.getPath().endsWith("unit")
            || baseDir.getPath().endsWith("functional")
            || baseDir.getPath().endsWith("performance")) {
          buildDir = new File(baseDir.getPath() + buildDirectory);
        }

        if (StringUtils.isNotEmpty(techId)) {
          destFile = new File(buildDir, buildName + '.' + APKLIB);
        } else {
          destFile = new File(buildDir, buildName + '.' + APK);
        }

        FileUtils.copyFile(outputFile, destFile);
        getLog().info("copied to..." + destFile.getName());
        apkFileName = destFile.getName();
        getLog().info("Creating deliverables.....");
        File packageInfoFile =
            new File(
                baseDir.getPath()
                    + File.separator
                    + ".phresco"
                    + File.separator
                    + PluginConstants.PHRESCO_PACKAGE_FILE);
        ZipArchiver zipArchiver = new ZipArchiver();
        File tmpFile = new File(buildDir, buildName);
        if (!tmpFile.exists()) {
          tmpFile.mkdirs();
        }
        FileUtils.copyFileToDirectory(destFile, tmpFile);
        if (packageInfoFile.exists()) {
          PluginUtils.createBuildResources(packageInfoFile, baseDir, tmpFile);
        }
        File inputFile = new File(apkFileName);
        zipArchiver.addDirectory(tmpFile);
        File deliverableZip = new File(buildDir, buildName + ".zip");
        zipArchiver.setDestFile(deliverableZip);
        zipArchiver.createArchive();

        deliverable = deliverableZip.getPath();
        getLog().info("Deliverables available at " + deliverableZip.getName());
        writeBuildInfo(true);
        if (!tmpFile.exists()) {
          FileUtil.delete(tmpFile);
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Error in writing output...");
      }
    }
  }