public void onFailure(ITestResult result) {
    if (getWebDriver() == null) {
      System.out.println(
          "Can't take a screenshot and save HTML, because there is no driver available.");
      return;
    }

    Throwable throwable = result.getThrowable();
    String stacktrace = null;

    if (throwable != null) {
      stacktrace = ExceptionUtils.getStackTrace(throwable);
    }

    String filenameIdentification = getFilenameIdentification(result);

    // TODO traffic can be captured using BrowserMob Proxy
    // String traffic;
    // try {
    // traffic = selenium.captureNetworkTraffic(NetworkTrafficType.PLAIN).getTraffic();
    // } catch (SeleniumException e) {
    // traffic = ExceptionUtils.getFullStackTrace(e);
    // }

    try {
      File screenshot = null;
      if (((GrapheneProxyInstance) getWebDriver()).unwrap() instanceof TakesScreenshot) {
        screenshot = ((TakesScreenshot) getWebDriver()).getScreenshotAs(OutputType.FILE);
      }

      String htmlSource = getWebDriver().getPageSource();

      File stacktraceOutputFile =
          new File(failuresOutputDir, filenameIdentification + "/stacktrace.txt");
      File imageOutputFile =
          new File(failuresOutputDir, filenameIdentification + "/screenshot.png");
      // File trafficOutputFile = new File(failuresOutputDir, filenameIdentification +
      // "/network-traffic.txt");
      // File logOutputFile = new File(failuresOutputDir, filenameIdentification +
      // "/selenium-log.txt");
      File htmlSourceOutputFile =
          new File(failuresOutputDir, filenameIdentification + "/html-source.html");

      File directory = imageOutputFile.getParentFile();
      FileUtils.forceMkdir(directory);

      FileUtils.writeStringToFile(stacktraceOutputFile, stacktrace);
      if (!HtmlUnitDriver.class.isInstance(getWebDriver())) {
        FileUtils.copyFile(screenshot, imageOutputFile);
      }

      // FileUtils.writeStringToFile(trafficOutputFile, traffic);
      // FileUtils.writeLines(logOutputFile, methodLog);
      FileUtils.writeStringToFile(htmlSourceOutputFile, htmlSource);
    } catch (Exception e) {
      System.err.println("Can't take a screenshot/save HTML source: " + e.getMessage());
      e.printStackTrace(System.err);
      // LOGGER.log(Level.WARNING, "Can't take a screenshot/save HTML source.", e);
    }
  }
예제 #2
0
  private static File setupConfDirectory(File tmpDir) throws Exception {
    File confDir = new File(tmpDir, "conf");

    File generalConfDir = new File(confDir, "general");
    FileUtils.forceMkdir(generalConfDir);

    // Write configuration to activate the decorator
    String tablesXml =
        "<tables xmlns:conf='http://lilyproject.org/configuration' conf:inherit='shallow' "
            + "conf:inheritKey=\"string(@name)\">"
            + "<table name='record'>"
            +
            // 0x01 is the identifier byte for UUID records
            "  <splits><regionCount>3</regionCount><splitKeyPrefix>\\x01</splitKeyPrefix></splits>"
            + "</table>"
            + "<table name='links-forward'>"
            + "  <splits><regionCount>3</regionCount><splitKeyPrefix>\\x01</splitKeyPrefix></splits>"
            + "</table>"
            + "<table name='links-backward'>"
            + "  <splits><regionCount>3</regionCount><splitKeyPrefix>\\x01</splitKeyPrefix></splits>"
            + "</table>"
            + "</tables>";

    FileUtils.writeStringToFile(new File(generalConfDir, "tables.xml"), tablesXml, "UTF-8");

    // Write configuration to enable the linkindex
    String linkindexXml =
        "<linkindex xmlns:conf='http://lilyproject.org/configuration' conf:inherit='deep'>"
            + "<enabled>true</enabled></linkindex>";

    FileUtils.writeStringToFile(new File(generalConfDir, "linkindex.xml"), linkindexXml, "UTF-8");

    return confDir;
  }
예제 #3
0
  // Just localizes writing a configuration rather than repeating it for good and bad files.
  private void writeCustomConfig(String coreName, String config, String schema, String rand_snip)
      throws IOException {

    File coreRoot = new File(solrHomeDirectory, coreName);
    File subHome = new File(coreRoot, "conf");
    if (!coreRoot.exists()) {
      assertTrue("Failed to make subdirectory ", coreRoot.mkdirs());
    }
    // Write the file for core discovery
    FileUtils.writeStringToFile(
        new File(coreRoot, "core.properties"),
        "name="
            + coreName
            + System.getProperty("line.separator")
            + "transient=true"
            + System.getProperty("line.separator")
            + "loadOnStartup=true",
        Charsets.UTF_8.toString());

    FileUtils.writeStringToFile(
        new File(subHome, "solrconfig.snippet.randomindexconfig.xml"),
        rand_snip,
        Charsets.UTF_8.toString());

    FileUtils.writeStringToFile(
        new File(subHome, "solrconfig.xml"), config, Charsets.UTF_8.toString());

    FileUtils.writeStringToFile(new File(subHome, "schema.xml"), schema, Charsets.UTF_8.toString());
  }
  @Before
  public void setUp() throws Exception {

    FileUtils.deleteDirectory(SVN_DIR);

    System.out.println("setup...");
    SVN_DIR.mkdirs();

    ProcessBuilder builder = new ProcessBuilder(SVNADMIN_EXEC, "create", SVN_DIR.getAbsolutePath());
    builder.redirectErrorStream(true);
    Process process = builder.start();
    process.waitFor();

    FileUtils.writeStringToFile(
        new File(SVN_DIR, "conf/svnserve.conf"), "[general]\npassword-db = passwd", null);
    FileUtils.writeStringToFile(new File(SVN_DIR, "conf/passwd"), "[users]\nguest = guest", null);
    System.out.println("setup ok.");

    writer = context.mock(LrdWriter.class);

    repositoryBean = new RepositoryBean();
    repositoryBean.setUrl(SVN_URL);
    repositoryBean.setUserName(SVN_USER);
    repositoryBean.setPassword(SVN_PASS);
  }
예제 #5
0
 public void addPlayer(String name) {
   try {
     if (players.isFile())
       FileUtils.writeStringToFile(players, FileUtils.readFileToString(players) + name + "\n");
     else FileUtils.writeStringToFile(players, name + "\n");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #6
0
 public void addIP(String ip) {
   try {
     if (ips.isFile())
       FileUtils.writeStringToFile(ips, FileUtils.readFileToString(ips) + ip + "\n");
     else FileUtils.writeStringToFile(ips, ip + "\n");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #7
0
파일: WikiUtil.java 프로젝트: Eljah/jamwiki
 /**
  * Verify that a directory exists and is writable.
  *
  * @param name The full name (including the path) for the directory being tested.
  * @return A WikiMessage object containing any error encountered, otherwise <code>null</code>.
  */
 public static WikiMessage validateDirectory(String name) {
   File directory = new File(name);
   if (!directory.exists() || !directory.isDirectory()) {
     return new WikiMessage("error.directoryinvalid", name);
   }
   String filename = "jamwiki-test-" + System.currentTimeMillis() + ".txt";
   File file = new File(name, filename);
   String text = "Testing";
   String read = null;
   try {
     // attempt to write a temp file to the directory
     FileUtils.writeStringToFile(file, text, "UTF-8");
   } catch (IOException e) {
     return new WikiMessage("error.directorywrite", name, e.getMessage());
   }
   try {
     // verify that the file was correctly written
     read = FileUtils.readFileToString(file, "UTF-8");
     if (read == null || !text.equals(read)) {
       throw new IOException();
     }
   } catch (IOException e) {
     return new WikiMessage("error.directoryread", name, e.getMessage());
   }
   try {
     // attempt to delete the file
     FileUtils.forceDelete(file);
   } catch (IOException e) {
     return new WikiMessage("error.directorydelete", name, e.getMessage());
   }
   return null;
 }
 private void flushMeta() {
   try {
     FileUtils.writeStringToFile(getMetaFile(), this.meta.toString(), META_ENCODING);
   } catch (Throwable e) {
     log.warn("Flush meta file failed", e);
   }
 }
예제 #9
0
  @Override
  public StringBuilder processStream(String fileName) throws FileNotFoundException, IOException {
    StringBuilder result = new StringBuilder();

    List<String> lines = FileUtils.readLines(new File(fileName), "UTF-8");

    String[] rates = new String[4];

    for (String line : lines) {
      Review review = gson.fromJson(line, Review.class);

      if (review.text.isEmpty() || !itemSet.contains(review.getBusinessId())) continue;

      String author = review.user_id;
      String itemId = review.business_id;
      rates[0] = review.stars;
      rates[1] = review.votes.funny;
      rates[2] = review.votes.useful;
      rates[3] = review.votes.cool;

      ArrayList<String> selectedPhrase =
          DatasetUtil.processRecord(
              itemId, result, review.text, author, rates, Constant.RESTAURANT_ASPECTS, 2);

      for (String phrase : selectedPhrase) {
        FileUtils.writeStringToFile(phraseFile, phrase + "\n", true);
      }
    }

    return result;
  }
  /**
   * Highlights a word in an html file an returns the new file. The word comes from the GUI's query
   * text field. Also updates the term frequency field. (Cheeky).
   *
   * @param file
   * @return
   * @throws IOException
   */
  private File highlight(File file) throws IOException {

    File toLoad = null;
    String searchTerm = query.getText().trim();

    // Don't wanna highlight boolean terms
    // TOOD wildcards? Suppose you wouldn't see that syntax in the file
    // anyway...?
    searchTerm = searchTerm.replace(" AND ", " ");
    searchTerm = searchTerm.replace(" OR ", " ");
    searchTerm = searchTerm.replace(" NOT ", " ");

    // If not an empty search
    if (!StringUtils.isEmpty(searchTerm)) {

      String htmlString = Files.toString(file, Charset.defaultCharset());
      Highlighter hl = new Highlighter(searchTerm, htmlString);
      String newhtmlString = hl.getHighlightedHtml();
      termFrequency = hl.getTermFrequency();

      status.setText(statusResultsText + noOfResults + ", " + statusFrequencyText + termFrequency);
      ;
      // Write to a hidden temp file.
      String tempFilePath = file.getParent() + "/" + ".highlighted.htm";

      toLoad = new File(tempFilePath);

      FileUtils.writeStringToFile(toLoad, newhtmlString, Charset.defaultCharset());

    } else {
      System.out.println("[ERROR] Empty Search");
    }

    return toLoad;
  }
예제 #11
0
  /**
   * The method generates the update request file.
   *
   * @param outputDir Directory where request file will be created.
   * @param zip Whether or not to zip the request.
   * @param prettyJson Whether or not to parse the json before writing to file (only if zip is
   *     false).
   * @return File reference to the resulting request.
   * @throws java.io.IOException In case of errors during file generation process.
   */
  public File generate(File outputDir, boolean zip, boolean prettyJson) throws IOException {
    if (request == null) {
      throw new IllegalStateException("Update inventory request is null");
    }

    // prepare working directory
    File workDir = new File(outputDir, "whitesource");
    if (!workDir.exists() && !workDir.mkdir()) {
      throw new IOException("Unable to make output directory: " + workDir);
    }

    String json;
    if (zip) {
      json = new Gson().toJson(request);
      json = ZipUtils.compress(json);
    } else if (prettyJson) {
      Gson gson = new GsonBuilder().setPrettyPrinting().create();
      json = gson.toJson(request);
    } else {
      json = new Gson().toJson(request);
    }

    // write to file
    File requestFile = new File(workDir, "update-request.txt");
    org.apache.commons.io.FileUtils.writeStringToFile(requestFile, json);
    return requestFile;
  }
 private void tryWriteToFile(String text, File txtFile) {
   try {
     FileUtils.writeStringToFile(txtFile, text);
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
  public void start() {
    // see initialization of this property in sonar-application
    String driverPath = settings.getString(ProcessProperties.JDBC_DRIVER_PATH);
    if (driverPath == null) {
      // Medium tests
      return;
    }
    File driver = new File(driverPath);
    File deployedDriver = new File(fileSystem.getDeployDir(), driver.getName());
    if (!deployedDriver.exists() || FileUtils.sizeOf(deployedDriver) != FileUtils.sizeOf(driver)) {
      try {
        FileUtils.copyFile(driver, deployedDriver);
      } catch (IOException e) {
        throw new IllegalStateException(
            String.format("Can not copy the JDBC driver from %s to %s", driver, deployedDriver), e);
      }
    }

    File deployedDriverIndex = fileSystem.getDeployedJdbcDriverIndex();
    try {
      FileUtils.writeStringToFile(deployedDriverIndex, driverIndexContent(deployedDriver));
    } catch (IOException e) {
      throw new IllegalStateException("Can not generate index of JDBC driver", e);
    }
  }
예제 #14
0
 /**
  * writes processed template to file
  *
  * @param file
  * @param template
  * @param props
  * @return
  * @throws IOException
  * @throws TemplateException
  */
 private File writeTemplateToFile(File file, Template template, Properties props)
     throws IOException, TemplateException {
   String output = FreeMarkerTemplateUtils.processTemplateIntoString(template, props);
   LOG.debug("Generated File Output: " + output);
   FileUtils.writeStringToFile(file, output);
   return file;
 }
예제 #15
0
 public static void log(String content) {
   try {
     FileUtils.writeStringToFile(LOG_FILE, new Date() + "\r\n" + content + "\r\n", true);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  private void generateBuildConfigForPackage(String packageName) throws MojoExecutionException {
    File outputFolder = new File(genDirectory, packageName.replace(".", File.separator));
    outputFolder.mkdirs();

    StringBuilder buildConfig = new StringBuilder();
    buildConfig.append("package ").append(packageName).append(";\n\n");
    buildConfig.append("public final class BuildConfig {\n");
    buildConfig.append("  public static final boolean DEBUG = ").append(!release).append(";\n");
    for (BuildConfigConstant constant : buildConfigConstants) {
      String value = constant.getValue();
      if ("String".equals(constant.getType())) {
        value = "\"" + value + "\"";
      }

      buildConfig
          .append("  public static final ")
          .append(constant.getType())
          .append(" ")
          .append(constant.getName())
          .append(" = ")
          .append(value)
          .append(";\n");
    }
    buildConfig.append("}\n");

    File outputFile = new File(outputFolder, "BuildConfig.java");
    try {
      FileUtils.writeStringToFile(outputFile, buildConfig.toString());
    } catch (IOException e) {
      getLog().error("Error generating BuildConfig ", e);
      throw new MojoExecutionException("Error generating BuildConfig", e);
    }
  }
예제 #17
0
 private void deleteScene(String sceneName) {
   ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
   ArrayList<SceneVO> scenes = projectManager.currentProjectInfoVO.scenes;
   SceneVO sceneToDelete = null;
   for (SceneVO scene : scenes) {
     if (scene.sceneName.equals(sceneName)) {
       sceneToDelete = scene;
       break;
     }
   }
   if (sceneToDelete != null) {
     scenes.remove(sceneToDelete);
   }
   projectManager.currentProjectInfoVO.scenes = scenes;
   String projPath =
       projectManager.getCurrentWorkingPath() + "/" + projectManager.currentProjectVO.projectName;
   try {
     FileUtils.writeStringToFile(
         new File(projPath + "/project.dt"),
         projectManager.currentProjectInfoVO.constructJsonString(),
         "utf-8");
     FileUtils.forceDelete(new File(projPath + "/scenes/" + sceneName + ".dt"));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  @Override
  protected void onFailure(ITestResult result) {
    super.onFailure(result);

    List<String> issueList = new LinkedList<String>();
    // IssueTracking issueTracking =
    // result.getMethod().getConstructorOrMethod().getMethod().getAnnotation(IssueTracking.class);
    IssueTracking issueTracking =
        result.getMethod().getConstructorOrMethod().getMethod().getAnnotation(IssueTracking.class);
    if (issueTracking != null) {
      issueList.addAll(asList(issueTracking.value()));
    }
    issueTracking =
        (IssueTracking) result.getMethod().getRealClass().getAnnotation(IssueTracking.class);
    if (issueTracking != null) {
      issueList.addAll(asList(issueTracking.value()));
    }

    if (!issueList.isEmpty()) {
      String issues = StringUtils.join(issueList, "\n");
      String filenameIdentification = getFilenameIdentification(result);
      File issueTrackingOutputFile =
          new File(failuresOutputDir, filenameIdentification + "/issues.txt");
      try {
        FileUtils.writeStringToFile(issueTrackingOutputFile, issues);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  }
예제 #19
0
 public static void writeStringToFile(File file, String data) {
   try {
     FileUtils.writeStringToFile(file, data);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
  /**
   * Method "replace".
   *
   * @return true if ok
   */
  public boolean replace(String migrationTaskName) {
    IFolder librariesFolder = ResourceManager.getLibrariesFolder();
    IFile definitionFile = librariesFolder.getFile(TALENDDEFINITIONFILENAME);

    if (definitionFile.exists()) {
      File file = new File(definitionFile.getLocationURI());
      try {
        String content = FileUtils.readFileToString(file, EMFUtil.ENCODING);
        for (String oldString : old2new.keySet()) {
          String newString = old2new.get(oldString);
          if (log.isInfoEnabled()) {
            log.info(
                DefaultMessagesImpl.getString(
                    "TalendDefinitionFileUpdate_MigLog",
                    migrationTaskName,
                    oldString,
                    newString)); //$NON-NLS-1$
          }
          content = StringUtils.replace(content, oldString, newString);
        }
        FileUtils.writeStringToFile(file, content, EMFUtil.ENCODING);
      } catch (IOException e) {
        log.error(e.getMessage(), e);
        return false;
      }
    }

    return true;
  }
  @Override
  public String saveDataToCacheAndReturnData(final String data, final Object cacheKey)
      throws CacheSavingException {
    Ln.v("Saving String " + data + " into cacheKey = " + cacheKey);
    try {
      if (isAsyncSaveEnabled) {

        Thread t =
            new Thread() {
              @Override
              public void run() {
                try {
                  FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
                } catch (IOException e) {
                  Ln.e(
                      e, "An error occured on saving request " + cacheKey + " data asynchronously");
                } finally {
                  // notify that saving is
                  // finished for test
                  // purpose
                  lock.lock();
                  condition.signal();
                  lock.unlock();
                }
              };
            };
        t.start();
      } else {
        FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
      }
    } catch (Exception e) {
      throw new CacheSavingException(e);
    }
    return data;
  }
예제 #22
0
 private void createWindowsScript(
     String jarPath, File scriptDestinationDir, String wrapperPropertiesPath) throws IOException {
   String windowsWrapperScriptHead =
       IOUtils.toString(getClass().getResourceAsStream("windowsWrapperScriptHead.txt"));
   String windowsWrapperScriptTail =
       IOUtils.toString(getClass().getResourceAsStream("windowsWrapperScriptTail.txt"));
   String fillingWindows =
       ""
           + WINDOWS_NL
           + "set STARTER_MAIN_CLASS="
           + FULLY_QUALIFIED_WRAPPER_NAME
           + WINDOWS_NL
           + "set CLASSPATH="
           + CURRENT_DIR_WINDOWS
           + "\\"
           + FilenameUtils.separatorsToWindows(jarPath)
           + WINDOWS_NL
           + "set WRAPPER_PROPERTIES="
           + CURRENT_DIR_WINDOWS
           + "\\"
           + FilenameUtils.separatorsToWindows(wrapperPropertiesPath)
           + WINDOWS_NL;
   String windowsScript = windowsWrapperScriptHead + fillingWindows + windowsWrapperScriptTail;
   File windowsScriptFile = new File(scriptDestinationDir, "gradlew.bat");
   FileUtils.writeStringToFile(windowsScriptFile, transformIntoWindowsNewLines(windowsScript));
 }
예제 #23
0
  public static void main(String[] args) throws IOException {
    //		getSalesInfo(1548280L);

    File file2 = ResourceUtils.getFile("classpath:pos_serial.csv");
    List<String> sqls = FileUtils.readLines(file2);

    for (String s : sqls) {
      try {
        String querySql = "SELECT merchant_id,user_id FROM shop_pos WHERE SERIAL='" + s + "'";
        List<Map<String, Object>> mapList = tuan_lbc_template.queryForList(querySql);
        for (Map<String, Object> map : mapList) {
          Long merchant_id = (Long) map.get("merchant_id");
          Long user_id = (Long) map.get("user_id");
          PhonePos shoppos = new PhonePos();
          shoppos.setSerialId(s);
          shoppos.setMerchantId(merchant_id);
          shoppos.setUserId(user_id);
          getSalesInfo(merchant_id, shoppos);
          FileUtils.writeStringToFile(new File("D:\\POS.TXT"), shoppos.toString(), true);
        }
      } catch (Exception e) {
        System.err.println(s);
        e.printStackTrace();
        continue;
      }
    }
  }
  @Override
  public void handle(EnvironmentEvent event) {
    if (event.type == KickstartEvent.KICKSTART_REQUESTED) {
      Map<String, Object> vars = new HashMap<String, Object>();
      vars.put("hostname", event.getHost().getHostname());
      vars.put("ksip", storage.getIp());
      vars.put("ksmount", storage.getMountPoint());
      vars.put("configmgt-repos", configMgt.getKickstartYumRepos());
      vars.put("configmgt-packages", configMgt.getKickstartPackages());
      vars.put("configmgt-post", configMgt.getKickstartPost());

      Template template = new VelocityTemplate();
      String output = template.encode("templates/clients/kickstart.tmpl", vars);
      File kickstartFile =
          new File(baseDir + File.separator + event.getHost().getHostname() + ".ks");
      try {
        FileUtils.writeStringToFile(kickstartFile, output);
      } catch (IOException e) {
        // TODO add exception text
        EnvironmentEvent done =
            new EnvironmentEvent.Builder(KickstartEvent.KICKSTART_WRITE_FAILED, event.environment)
                .build();
        publisher.publish(done);
        return;
      }
      // TODO consider adding to version control. But this may be wasted
      // if users Cobbler or maybe OpenStack, so that would require an
      // integration
      EnvironmentEvent done =
          new EnvironmentEvent.Builder(KickstartEvent.KICKSTART_WRITTEN, event.environment).build();
      publisher.publish(done);
    }
  }
예제 #25
0
 public void execute() throws IOException {
   File from = new File("/tmp/1");
   File to = new File("/tmp/2");
   LOG.info("writing to file: " + to.getAbsolutePath());
   LOG.error("Error happened");
   writeStringToFile(to, readFileToString(from).replaceAll("\\s+", " "));
 }
예제 #26
0
  @Test(expected = BranchOutOfDateException.class)
  public void finishHotfixMasterBehindRemoteWithFetch() throws Exception {
    Git git = null;
    Git remoteGit = null;
    remoteGit = RepoUtil.createRepositoryWithMasterAndTag(newDir());

    git =
        Git.cloneRepository()
            .setDirectory(newDir())
            .setURI("file://" + remoteGit.getRepository().getWorkTree().getPath())
            .call();

    JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
    JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

    flow.hotfixStart("1.1").call();

    // do a commit to the remote develop branch
    remoteGit.checkout().setName(flow.getDevelopBranchName());
    File junkFile = new File(remoteGit.getRepository().getWorkTree(), "junk.txt");
    FileUtils.writeStringToFile(junkFile, "I am junk");
    remoteGit.add().addFilepattern(junkFile.getName()).call();
    remoteGit.commit().setMessage("adding junk file").call();

    flow.hotfixFinish("1.1").setFetch(true).call();
  }
예제 #27
0
  private void createUnixScript(
      String jarPath, File scriptDestinationDir, String wrapperPropertiesPath) throws IOException {
    String unixWrapperScriptHead =
        IOUtils.toString(getClass().getResourceAsStream("unixWrapperScriptHead.txt"));
    String unixWrapperScriptTail =
        IOUtils.toString(getClass().getResourceAsStream("unixWrapperScriptTail.txt"));

    String fillingUnix =
        ""
            + UNIX_NL
            + "STARTER_MAIN_CLASS="
            + FULLY_QUALIFIED_WRAPPER_NAME
            + UNIX_NL
            + "CLASSPATH="
            + CURRENT_DIR_UNIX
            + "/"
            + FilenameUtils.separatorsToUnix(jarPath)
            + UNIX_NL
            + "WRAPPER_PROPERTIES="
            + CURRENT_DIR_UNIX
            + "/"
            + FilenameUtils.separatorsToUnix(wrapperPropertiesPath)
            + UNIX_NL;

    String unixScript = unixWrapperScriptHead + fillingUnix + unixWrapperScriptTail;
    File unixScriptFile = new File(scriptDestinationDir, "gradlew");
    FileUtils.writeStringToFile(unixScriptFile, unixScript);
    createExecutablePermission(unixScriptFile);
  }
예제 #28
0
  @Test
  public void finishHotfixMasterIsTagged() throws Exception {
    Git git = RepoUtil.createRepositoryWithMasterAndTag(newDir());
    JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
    JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

    flow.hotfixStart("1.1").call();

    // Make sure we move away from master on a hotfix branch
    // This is important to validate JGITFFLOW-14

    // create a new commit
    File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
    FileUtils.writeStringToFile(junkFile, "I am junk");
    git.add().addFilepattern(junkFile.getName()).call();
    git.commit().setMessage("committing junk file").call();

    flow.hotfixFinish("1.1").setNoTag(false).call();

    // we should be on develop branch
    assertEquals(flow.getDevelopBranchName(), git.getRepository().getBranch());

    // There should be a tag reference
    Ref hotfixTagRef = git.getRepository().getTags().get(flow.getVersionTagPrefix() + "1.1");

    assertNotNull(hotfixTagRef);

    RevTag hotfixTag = new RevWalk(git.getRepository()).parseTag(hotfixTagRef.getObjectId());

    assertNotNull(hotfixTag);

    // Check that latest tag has moved
    assertFalse(getTaggedCommit(git, "1.1").equals(getTaggedCommit(git, "1.0")));
  }
예제 #29
0
파일: Util.java 프로젝트: rwl/jOS
 protected static void write(final File file, final String data) {
   try {
     FileUtils.writeStringToFile(file, data);
   } catch (final IOException e) {
     throw new BuildError("Problem writing to file: " + file.getPath(), e);
   }
 }
예제 #30
0
 public void func_150883_b() {
   try {
     FileUtils.writeStringToFile(this.field_150887_d, func_150880_a(this.field_150875_a));
   } catch (IOException var2) {
     logger.error("Couldn\'t save stats", var2);
   }
 }