<commit_before>/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.elasticsearch.client.sniff;

import com.carrotsearch.randomizedtesting.generators.RandomInts;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.http.HttpHost;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.client.RestClient;

import java.util.Arrays;

public class SnifferBuilderTests extends LuceneTestCase {

    public void testBuild() throws Exception {

        try {
            Sniffer.builder().setScheme(null);
            fail("should have failed");
        } catch(NullPointerException e) {
            assertEquals(e.getMessage(), "scheme cannot be null");
        }

        try {
            Sniffer.builder().setScheme("whatever");
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "scheme must be either http or https");
        }

        try {
            Sniffer.builder().setSniffInterval(RandomInts.randomIntBetween(random(), Integer.MIN_VALUE, 0));
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "sniffInterval must be greater than 0");
        }

        try {
            Sniffer.builder().setSniffRequestTimeout(RandomInts.randomIntBetween(random(), Integer.MIN_VALUE, 0));
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "sniffRequestTimeout must be greater than 0");
        }<commit_msg>[TEST] restore needed LogManager.reset to prevent logging to sysout<commit_after>/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.elasticsearch.client.sniff;

import com.carrotsearch.randomizedtesting.generators.RandomInts;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.http.HttpHost;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.client.RestClient;

import java.util.Arrays;
import java.util.logging.LogManager;

public class SnifferBuilderTests extends LuceneTestCase {

    static {
        LogManager.getLogManager().reset();
    }

    public void testBuild() throws Exception {

        try {
            Sniffer.builder().setScheme(null);
            fail("should have failed");
        } catch(NullPointerException e) {
            assertEquals(e.getMessage(), "scheme cannot be null");
        }

        try {
            Sniffer.builder().setScheme("whatever");
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "scheme must be either http or https");
        }

        try {
            Sniffer.builder().setSniffInterval(RandomInts.randomIntBetween(random(), Integer.MIN_VALUE, 0));
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "sniffInterval must be greater than 0");
        }

        try {
            Sniffer.builder().setSniffRequestTimeout(RandomInts.randomIntBetween(random(), Integer.MIN_VALUE, 0));
            fail("should have failed");
        } catch(IllegalArgumentException e) {
            assertEquals(e.getMessage(), "sniffRequestTimeout must be greater than 0");
        }
{'fraction_non_alphanumeric': 0.09028500104014978, 'fraction_numerical': 0.0033284793010193467, 'mean_word_length': 3.195462478184991, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4234124', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1181, 'n_words': 396}