Example #1
0
 /**
  * Saves the specified editor contents.
  *
  * @param file file to write
  * @return {@code false} if confirmation was canceled
  */
 private boolean save(final IOFile file) {
   try {
     final EditorArea edit = getEditor();
     file.write(edit.getText());
     edit.file(file);
     return true;
   } catch (final IOException ex) {
     BaseXDialog.error(gui, FILE_NOT_SAVED);
     return false;
   }
 }
Example #2
0
  /**
   * Tests writing of request content when @src is set.
   *
   * @throws IOException I/O Exception
   */
  @Test
  public void writeFromResource() throws IOException {
    // Create a file form which will be read
    final IOFile file = new IOFile(Prop.TMP, Util.className(FnHttpTest.class));
    file.write(token("test"));

    // Request
    final HttpRequest req = new HttpRequest();
    req.payloadAttrs.put("src", file.url());
    req.payloadAttrs.put("method", "binary");
    // HTTP connection
    final FakeHttpConnection fakeConn = new FakeHttpConnection(new URL("http://www.test.com"));
    HttpClient.setRequestContent(fakeConn.getOutputStream(), req);

    // Delete file
    file.delete();

    assertEquals(fakeConn.out.toString(Strings.UTF8), "test");
  }