<commit_before>/**
 * Copyright (C) 2013 The Language Archive, Max Planck Institute for
 * Psycholinguistics
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA.
 */
package nl.mpi.yams.common.db;

import com.google.common.collect.Sets;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.ImageIcon;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import nl.mpi.flap.kinnate.entityindexer.QueryException;
import nl.mpi.flap.model.DataField;
import nl.mpi.flap.model.DataNodeLink;
import nl.mpi.flap.model.DataNodeType;
import nl.mpi.flap.model.ModelException;
import nl.mpi.flap.model.SerialisableDataNode;
import nl.mpi.flap.plugin.PluginException;
import nl.mpi.yams.common.data.DataNodeId;
import nl.mpi.yams.common.data.DatabaseLinks;
import nl.mpi.yams.common.data.DatabaseList;
import nl.mpi.yams.common.data.DatabaseStats;
import nl.mpi.yams.common.data.HighlightableDataNode;
import nl.mpi.yams.common.data.IconTable;
import nl.mpi.yams.common.data.IconTableBase64;
import nl.mpi.yams.common.data.MetadataFileType;
import nl.mpi.yams.common.data.NodeTypeImage;
import nl.mpi.yams.common.data.QueryDataStructures;
import nl.mpi.yams.common.data.SearchParameters;
import org.basex.BaseXHTTP;
import org.junit.Assert;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;

/**
 *
 * @author <NAME>
 */
public abstract class DataBaseManagerTest {

    static String testDatabaseName = "unit-test-database";
    static String restUrl = "http://localhost:9984/rest/";
//    static String restUrl = "http://tlatest03:8984/rest";
    static String restUser = "admin";
    static String restPass = "<PASSWORD>";

    private static BaseXHTTP baseXHTTP;

    abstract DbAdaptor getDbAdaptor() throws IOException, QueryException;

    public synchronized static void startDb() throws Exception {
        if (baseXHTTP == null) {
            baseXHTTP = new BaseXHTTP("-l","-h9984"); //start in local mode, on non-standard port to prevent clashes
        } else {
            throw new RuntimeException("BaseX already running");
        }
    }

    public synchronized static void stopDb() throws Exception {
        if (baseXHTTP != null) {
            baseXHTTP.stop();
            baseXHTTP = null;
        } else {
            throw new RuntimeException("BaseX not running");
        }<commit_msg>BaseX instance now running on non-standard port for tests<commit_after>/**
 * Copyright (C) 2013 The Language Archive, Max Planck Institute for
 * Psycholinguistics
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA.
 */
package nl.mpi.yams.common.db;

import com.google.common.collect.Sets;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.ImageIcon;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import nl.mpi.flap.kinnate.entityindexer.QueryException;
import nl.mpi.flap.model.DataField;
import nl.mpi.flap.model.DataNodeLink;
import nl.mpi.flap.model.DataNodeType;
import nl.mpi.flap.model.ModelException;
import nl.mpi.flap.model.SerialisableDataNode;
import nl.mpi.flap.plugin.PluginException;
import nl.mpi.yams.common.data.DataNodeId;
import nl.mpi.yams.common.data.DatabaseLinks;
import nl.mpi.yams.common.data.DatabaseList;
import nl.mpi.yams.common.data.DatabaseStats;
import nl.mpi.yams.common.data.HighlightableDataNode;
import nl.mpi.yams.common.data.IconTable;
import nl.mpi.yams.common.data.IconTableBase64;
import nl.mpi.yams.common.data.MetadataFileType;
import nl.mpi.yams.common.data.NodeTypeImage;
import nl.mpi.yams.common.data.QueryDataStructures;
import nl.mpi.yams.common.data.SearchParameters;
import org.basex.BaseXHTTP;
import org.junit.Assert;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;

/**
 *
 * @author <NAME>
 */
public abstract class DataBaseManagerTest {

    static String testDatabaseName = "unit-test-database";
    static String restUrl = "http://localhost:9985/rest/";
//    static String restUrl = "http://tlatest03:8984/rest";
    static String restUser = "admin";
    static String restPass = "<PASSWORD>";

    private static BaseXHTTP baseXHTTP;

    abstract DbAdaptor getDbAdaptor() throws IOException, QueryException;

    public synchronized static void startDb() throws Exception {
        if (baseXHTTP == null) {
            baseXHTTP = new BaseXHTTP("-l","-h9985"); //start in local mode, on non-standard port to prevent clashes
        } else {
            throw new RuntimeException("BaseX already running");
        }
    }

    public synchronized static void stopDb() throws Exception {
        if (baseXHTTP != null) {
            baseXHTTP.stop();
            baseXHTTP = null;
        } else {
            throw new RuntimeException("BaseX not running");
        }
{'fraction_non_alphanumeric': 0.09888986269354368, 'fraction_numerical': 0.010224948875255624, 'mean_word_length': 3.990524781341108, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '3523123', 'n_tokens_mistral': 2086, 'n_tokens_neox': 2024, 'n_words': 594}