<commit_before>package org.basex.http;

import static org.basex.core.users.UserText.*;
import static org.basex.util.Token.*;
import static org.basex.util.http.HttpMethod.*;
import static org.junit.Assert.*;

import java.io.*;
import java.net.*;
import java.util.*;

import org.basex.*;
import org.basex.core.*;
import org.basex.core.StaticOptions.*;
import org.basex.io.*;
import org.basex.io.in.*;
import org.basex.util.*;
import org.basex.util.Base64;
import org.basex.util.http.*;
import org.basex.util.list.*;
import org.junit.*;

/**
 * This class contains common methods for the HTTP services.
 *
 * @author BaseX Team 2005-19, BSD License
 * @author <NAME>
 */
public abstract class HTTPTest extends SandboxTest {
  /** Database context. */
  private static final Context CONTEXT = HTTPContext.context();
  /** HTTP server. */
  private static BaseXHTTP http;
  /** Root path. */
  private static String rootUrl;

  // INITIALIZATION ===============================================================================

  /**
   * Initializes the test.
   * @param rt root path
   * @param local local flag
   * @throws Exception exception
   */
  protected static void init(final String rt, final boolean local) throws Exception {
    init(rt, local, false);
  }

  /**
   * Initializes the test.
   * @param url root path
   * @param local local flag
   * @param auth enforce authentication
   * @throws Exception exception
   */
  protected static void init(final String url, final boolean local, final boolean auth)
      throws Exception {

    assertTrue(new IOFile(CONTEXT.soptions.get(StaticOptions.WEBPATH)).md());
    rootUrl = url;

    final StringList sl = new StringList();
    sl.add("-p" + DB_PORT, "-h" + HTTP_PORT, "-s" + STOP_PORT, "-z", "-q");
    if(local) sl.add("-l");
    if(!auth) sl.add("-U" + ADMIN);
    http = new BaseXHTTP(sl.toArray());
    http.context.soptions.set(StaticOptions.RESTXQERRORS, true);
  }

  /**
   * Finish test.
   * @throws Exception exception
   */
  @AfterClass public static void stop() throws Exception {
    http.stop();

    // cleanup: remove project specific system properties
    final StringList keys = new StringList();
    final Properties props = System.getProperties();<commit_msg>[MIN] Changed RESTXQERRORS default<commit_after>package org.basex.http;

import static org.basex.core.users.UserText.*;
import static org.basex.util.Token.*;
import static org.basex.util.http.HttpMethod.*;
import static org.junit.Assert.*;

import java.io.*;
import java.net.*;
import java.util.*;

import org.basex.*;
import org.basex.core.*;
import org.basex.core.StaticOptions.*;
import org.basex.io.*;
import org.basex.io.in.*;
import org.basex.util.*;
import org.basex.util.Base64;
import org.basex.util.http.*;
import org.basex.util.list.*;
import org.junit.*;

/**
 * This class contains common methods for the HTTP services.
 *
 * @author BaseX Team 2005-19, BSD License
 * @author <NAME>
 */
public abstract class HTTPTest extends SandboxTest {
  /** Database context. */
  private static final Context CONTEXT = HTTPContext.context();
  /** HTTP server. */
  private static BaseXHTTP http;
  /** Root path. */
  private static String rootUrl;

  // INITIALIZATION ===============================================================================

  /**
   * Initializes the test.
   * @param rt root path
   * @param local local flag
   * @throws Exception exception
   */
  protected static void init(final String rt, final boolean local) throws Exception {
    init(rt, local, false);
  }

  /**
   * Initializes the test.
   * @param url root path
   * @param local local flag
   * @param auth enforce authentication
   * @throws Exception exception
   */
  protected static void init(final String url, final boolean local, final boolean auth)
      throws Exception {

    assertTrue(new IOFile(CONTEXT.soptions.get(StaticOptions.WEBPATH)).md());
    rootUrl = url;

    final StringList sl = new StringList();
    sl.add("-p" + DB_PORT, "-h" + HTTP_PORT, "-s" + STOP_PORT, "-z", "-q");
    if(local) sl.add("-l");
    if(!auth) sl.add("-U" + ADMIN);
    http = new BaseXHTTP(sl.toArray());
  }

  /**
   * Finish test.
   * @throws Exception exception
   */
  @AfterClass public static void stop() throws Exception {
    http.stop();

    // cleanup: remove project specific system properties
    final StringList keys = new StringList();
    final Properties props = System.getProperties();
{'fraction_non_alphanumeric': 0.16486972147349505, 'fraction_numerical': 0.0035938903863432167, 'mean_word_length': 3.507085020242915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '821579', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1297, 'n_words': 398}