# Path: JapaneseTokenizer/common/sever_handler.py
# class ProcessDownException(Exception):
# class UnixProcessHandler(object):
# class JumanppHnadler(UnixProcessHandler):
#     def __init__(self,
#                  command,
#                  option=None,
#                  pattern='EOS',
#                  timeout_second=10):
#     def __del__(self):
#     def launch_process(self, command):
#     def restart_process(self):
#     def stop_process(self):
#     def __query(self, input_string):
#     def __notify_handler(self, signum, frame):
#     def query(self, input_string):
#     def __init__(self,
#                  jumanpp_command,
#                  option = None,
#                  pattern = 'EOS',
#                  timeout_second = 10):
#     def launch_jumanpp_process(self, command):


from JapaneseTokenizer.common import sever_handler
    from JapaneseTokenizer.jumanpp_wrapper.__jumanpp_wrapper_python2 import JumanppWrapper
    from JapaneseTokenizer.jumanpp_wrapper.__jumanpp_wrapper_python3 import JumanppWrapper
import six
import sys
import unittest
import os
import time
# else

__author__ = 'kensuke-mi'


class TestServerHandler(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        if six.PY3:
            cls.test_senetence = '紗倉 まな（さくらまな、1993年3月23日 - ）は、日本のAV女優。'
        else:
            cls.test_senetence = u'紗倉 まな（さくらまな、1993年3月23日 - ）は、日本のAV女優。'

        cls.jumanpp_command = "/usr/local/bin/jumanpp"


    def test_jumanpp_process_hanlder_normal(self):
        """It tests jumanpp process handler"""
        # normal test #
        jumanpp_process_handler = sever_handler.JumanppHnadler(jumanpp_command=self.jumanpp_command)
        result_jumanpp_analysis = jumanpp_process_handler.query(input_string=self.test_senetence)
        self.assertTrue(isinstance(result_jumanpp_analysis,six.text_type))
        ## stop process ##
        jumanpp_process_handler.stop_process()
        ## delete instance ##
        del jumanpp_process_handler

    def test_jumanpp_process_handler_timeout_exception(self):
        """It tests the case which causes timeout exception"""
        with self.assertRaises(Exception) as exc:

# Path: JapaneseTokenizer/common/sever_handler.py
# class ProcessDownException(Exception):
# class UnixProcessHandler(object):
# class JumanppHnadler(UnixProcessHandler):
#     def __init__(self,
#                  command,
#                  option=None,
#                  pattern='EOS',
#                  timeout_second=10):
#     def __del__(self):
#     def launch_process(self, command):
#     def restart_process(self):
#     def stop_process(self):
#     def __query(self, input_string):
#     def __notify_handler(self, signum, frame):
#     def query(self, input_string):
#     def __init__(self,
#                  jumanpp_command,
#                  option = None,
#                  pattern = 'EOS',
#                  timeout_second = 10):
#     def launch_jumanpp_process(self, command):


# Path: test/common/test_server_handler.py
from JapaneseTokenizer.common import sever_handler
    from JapaneseTokenizer.jumanpp_wrapper.__jumanpp_wrapper_python2 import JumanppWrapper
    from JapaneseTokenizer.jumanpp_wrapper.__jumanpp_wrapper_python3 import JumanppWrapper
import six
import sys
import unittest
import os
import time

# else

__author__ = 'kensuke-mi'


class TestServerHandler(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        if six.PY3:
            cls.test_senetence = '紗倉 まな（さくらまな、1993年3月23日 - ）は、日本のAV女優。'
        else:
            cls.test_senetence = u'紗倉 まな（さくらまな、1993年3月23日 - ）は、日本のAV女優。'

        cls.jumanpp_command = "/usr/local/bin/jumanpp"


    def test_jumanpp_process_hanlder_normal(self):
        """It tests jumanpp process handler"""
        # normal test #
        jumanpp_process_handler = sever_handler.JumanppHnadler(jumanpp_command=self.jumanpp_command)
        result_jumanpp_analysis = jumanpp_process_handler.query(input_string=self.test_senetence)
        self.assertTrue(isinstance(result_jumanpp_analysis,six.text_type))
        ## stop process ##
        jumanpp_process_handler.stop_process()
        ## delete instance ##
        del jumanpp_process_handler

    def test_jumanpp_process_handler_timeout_exception(self):
        """It tests the case which causes timeout exception"""
        with self.assertRaises(Exception) as exc:

            jumanpp_process_handler = sever_handler.JumanppHnadler(jumanpp_command=self.jumanpp_command,