<commit_before>/**
 * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
 *
 * This file is part of fiware-cygnus (FI-WARE project).
 *
 * fiware-cygnus is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
 * General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * fiware-cygnus 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 Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with fiware-cygnus. If not, see
 * http://www.gnu.org/licenses/.
 *
 * For those usages not covered by the GNU Affero General Public License please contact with iot_support at tid dot es
 */

package com.telefonica.iot.cygnus.http;

import com.telefonica.iot.cygnus.http.JettyServer;
import com.telefonica.iot.cygnus.management.ManagementInterface;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.*;

/**
 *
 * @author frb
 */
@RunWith(MockitoJUnitRunner.class)
public class JettyServerTest {
    
    // instance to be tested
    private JettyServer jettyServer;
    
    // other instances
    private ManagementInterface managementInterface;
    
    // constants
    private final int port = 12345;
    
    /**
     * Sets up tests by creating a unique instance of the tested class, and by defining the behaviour of the mocked
     * classes.
     *  
     * @throws Exception
     */
    @Before
    public void setUp() throws Exception {
        // set up the instance of the tested class
        jettyServer = new JettyServer(port, managementInterface);
    } // setUp
    
    /**
     * Test of startServer method, of class JettyServer.
     */
    @Test
    public void testRun() {
        System.out.println("Testing JettyServer.testConfigure");
        
        try {
            jettyServer.start();
        } catch (Exception e) {
            fail(e.getMessage());
        } finally {
            assertTrue(true);
        } // try catch
        
        try {
            System.out.println("Wait 5 seconds before checking the Jetty server is running");
            Thread.sleep(5000);
        } catch (Exception e) {
            fail(e.getMessage());
        } // try catch

        assertTrue(jettyServer.getServer().isRunning());
    } // testStartServer
    <commit_msg>FIX the tests according to the new JettyServer<commit_after>/**
 * Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U
 *
 * This file is part of fiware-cygnus (FI-WARE project).
 *
 * fiware-cygnus is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
 * General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * fiware-cygnus 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 Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with fiware-cygnus. If not, see
 * http://www.gnu.org/licenses/.
 *
 * For those usages not covered by the GNU Affero General Public License please contact with iot_support at tid dot es
 */

package com.telefonica.iot.cygnus.http;

import com.telefonica.iot.cygnus.management.ManagementInterface;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.*;
import org.junit.Before;

/**
 *
 * @author frb
 */
@RunWith(MockitoJUnitRunner.class)
public class JettyServerTest {
    
    // instance to be tested
    private JettyServer jettyServer;
    
    // other instances
    private ManagementInterface managementInterface;
    
    // constants
    private final int mgmtPort = 8081;
    private final int guiPort = 8082;
    
    /**
     * Sets up tests by creating a unique instance of the tested class, and by defining the behaviour of the mocked
     * classes.
     *  
     * @throws Exception
     */
    @Before
    public void setUp() throws Exception {
        // set up the instance of the tested class
        jettyServer = new JettyServer(mgmtPort, guiPort, managementInterface);
    } // setUp
    
    /**
     * Test of startServer method, of class JettyServer.
     */
    @Test
    public void testRun() {
        System.out.println("Testing JettyServer.testConfigure");
        
        try {
            jettyServer.start();
        } catch (Exception e) {
            fail(e.getMessage());
        } finally {
            assertTrue(true);
        } // try catch
        
        try {
            System.out.println("Wait 5 seconds before checking the Jetty server is running");
            Thread.sleep(5000);
        } catch (Exception e) {
            fail(e.getMessage());
        } // try catch

        assertTrue(jettyServer.getServer().isRunning());
    } // testStartServer
    
{'fraction_non_alphanumeric': 0.08226656626506024, 'fraction_numerical': 0.0062123493975903615, 'mean_word_length': 2.6440329218106995, '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': '257840', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1433, 'n_words': 533}