Пример #1
0
  /**
   * POST Test: specify an option.
   *
   * @throws IOException I/O exception
   */
  @Test
  public void postOption() throws IOException {
    assertEquals(
        "2",
        post(
            "",
            "<query xmlns=\""
                + URI
                + "\">"
                + "<text>2, delete node &lt;a/&gt;</text>"
                + "<option name='"
                + MainOptions.MIXUPDATES.name()
                + "' value='true'/></query>",
            APP_XML));

    try {
      post(
          "",
          "<query xmlns=\""
              + URI
              + "\">"
              + "<text>1, delete node &lt;a/&gt;</text>"
              + "<option name='"
              + MainOptions.MIXUPDATES.name()
              + "' value='false'/></query>",
          APP_XML);
      fail("Error expected.");
    } catch (final IOException ex) {
      assertContains(ex.getMessage(), "[XUST0001]");
    }
  }
Пример #2
0
 /** POST Test: execute buggy query. */
 @Test
 public void postErr() {
   try {
     assertEquals("", post("", "<query xmlns=\"" + URI + "\"><text>(</text></query>", APP_XML));
   } catch (final IOException ex) {
     assertContains(ex.getMessage(), "[XPST0003]");
   }
 }
Пример #3
0
 @Override
 protected final boolean run() {
   try {
     run0();
     return true;
   } catch (final IOException ex) {
     return error(ex.getMessage());
   } finally {
     new Close().run(context);
   }
 }
Пример #4
0
  @Override
  public void action(final Object comp) {
    final String pth = path();
    final IOFile io = new IOFile(pth);
    String inf = io.isDir() && io.children().length > 0 ? DIR_NOT_EMPTY : null;
    ok = !pth.isEmpty();

    final SerialMethod mth = SerialMethod.valueOf(method.getSelectedItem());
    final OptionsOption<? extends Options> opts =
        mth == SerialMethod.JSON
            ? SerializerOptions.JSON
            : mth == SerialMethod.CSV ? SerializerOptions.CSV : null;
    final boolean showmparams = opts != null;
    mparams.setEnabled(showmparams);

    if (ok) {
      gui.gopts.set(GUIOptions.INPUTPATH, pth);
      try {
        if (comp == method) {
          if (showmparams) {
            final Options mopts = options(null).get(opts);
            mparams.setToolTipText(tooltip(mopts));
            mparams.setText(mopts.toString());
          } else {
            mparams.setToolTipText(null);
            mparams.setText("");
          }
        }
        Serializer.get(new ArrayOutput(), options(mth));
      } catch (final IOException ex) {
        ok = false;
        inf = ex.getMessage();
      }
    }

    info.setText(inf, ok ? Msg.WARN : Msg.ERROR);
    enableOK(buttons, B_OK, ok);
  }