Пример #1
0
 /**
  * Replaces documents in a database.
  *
  * @throws IOException I/O exception
  */
 @Test
 public final void replace() throws IOException {
   session.execute("create db " + NAME);
   assertEqual("0", session.query("count(" + _DB_OPEN.args(NAME) + ')').execute());
   session.replace(NAME, new ArrayInput("<X/>"));
   assertEqual("1", session.query("count(" + _DB_OPEN.args(NAME) + ')').execute());
   session.replace(NAME + '2', new ArrayInput("<X/>"));
   assertEqual("2", session.query("count(" + _DB_OPEN.args(NAME) + ')').execute());
   session.replace(NAME + '2', new ArrayInput("<X/>"));
   assertEqual("2", session.query("count(" + _DB_OPEN.args(NAME) + ')').execute());
 }
Пример #2
0
 /**
  * Adds a file with missing input.
  *
  * @throws IOException I/O exception
  */
 @Test(expected = BaseXException.class)
 public final void replaceNoInput() throws IOException {
   session.execute("create db " + NAME);
   session.replace("", new ArrayInput(""));
 }