示例#1
0
 /**
  * Create a test database and start BaseXHTTP.
  *
  * @throws Exception if database cannot be created or server cannot be started
  */
 @Before
 public void setUp() throws Exception {
   startBaseXHTTP();
   try (final ClientSession cs = new ClientSession(context, UserText.ADMIN, UserText.ADMIN)) {
     cs.execute(new CreateDB(NAME));
   }
 }
示例#2
0
 /**
  * Drop the test database and stop BaseXHTTP.
  *
  * @throws Exception if database cannot be dropped or server cannot be stopped
  */
 @After
 public void tearDown() throws Exception {
   try (final ClientSession cs = new ClientSession(context, UserText.ADMIN, UserText.ADMIN)) {
     cs.execute(new DropDB(NAME));
   }
   stopBaseXHTTP();
 }
示例#3
0
 @Override
 public void run() {
   try {
     // Perform query
     session.execute("xquery " + QUERY);
     session.close();
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
示例#4
0
 /**
  * Runs the stress test.
  *
  * @param clients number of clients
  * @param runs number of runs per client
  * @throws Exception exception
  */
 private void run(final int clients, final int runs) throws Exception {
   // run server instance
   server = createServer();
   // create test database
   try (final ClientSession cs = createClient()) {
     cs.execute("create db test <test/>");
     // run clients
     final Client[] cl = new Client[clients];
     for (int i = 0; i < clients; ++i) cl[i] = new Client(runs, i % 2 == 0);
     for (final Client c : cl) c.start();
     for (final Client c : cl) c.join();
     // drop database and stop server
     cs.execute("drop db test");
   }
   stopServer(server);
 }
示例#5
0
 @Override
 public void run() {
   try {
     // Perform some queries
     for (int i = 0; i < runs; ++i) {
       final String qu =
           read
               ? "count(db:open('test'))"
               : "db:add('test', <a/>, 'test.xml', map { 'intparse': true() })";
       session.execute("xquery " + qu);
     }
     session.close();
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
示例#6
0
    @Override
    public void run() {
      try {
        // Perform some queries
        for (int i = 0; i < runs; ++i) {
          Performance.sleep((long) (50 * RND.nextDouble()));

          // Return nth text of the database
          final int n = RND.nextInt() % MAX + 1;
          final String qu = Util.info(QUERY, n);
          session.execute("xquery " + qu);
        }
        session.close();
      } catch (final Exception ex) {
        ex.printStackTrace();
      }
    }
示例#7
0
 /**
  * Constructor.
  *
  * @param runs number of runs
  * @param read read flag
  * @throws Exception exception
  */
 Client(final int runs, final boolean read) throws Exception {
   this.runs = runs;
   this.read = read;
   session = createClient();
   session.execute("set autoflush false");
 }