/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 02:28:01 GMT 2019
 */

package org.traccar.protocol;

import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.shaded.org.mockito.Mockito.*;
import static org.evosuite.runtime.EvoAssertions.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.ViolatedAssumptionAnswer;
import org.evosuite.runtime.mock.java.net.MockInetAddress;
import org.evosuite.runtime.mock.java.net.MockInetSocketAddress;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelSink;
import org.jboss.netty.channel.DefaultChannelPipeline;
import org.jboss.netty.channel.SimpleChannelDownstreamHandler;
import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory;
import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory;
import org.jboss.netty.channel.local.LocalServerChannel;
import org.jboss.netty.channel.socket.nio.NioSocketChannel;
import org.jboss.netty.channel.socket.nio.NioWorker;
import org.junit.runner.RunWith;
import org.traccar.TrackerServer;
import org.traccar.protocol.Gl200Protocol;
import org.traccar.protocol.Gl200ProtocolDecoder;

@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true) 
public class Gl200ProtocolDecoder_ESTest extends Gl200ProtocolDecoder_ESTest_scaffolding {

  @Test(timeout = 4000)
  public void test0()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      gl200Protocol0.getSupportedCommands();
      gl200Protocol0.getSupportedCommands();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultLocalServerChannelFactory defaultLocalServerChannelFactory0 = new DefaultLocalServerChannelFactory();
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      LocalServerChannel localServerChannel0 = defaultLocalServerChannelFactory0.newChannel(defaultChannelPipeline0);
      InetAddress inetAddress0 = MockInetAddress.anyLocalAddress();
      MockInetSocketAddress mockInetSocketAddress0 = new MockInetSocketAddress(inetAddress0, 0);
      Integer.getInteger("WS_T*/7DS7&@;FHl_");
      try { 
        gl200ProtocolDecoder0.decode(localServerChannel0, mockInetSocketAddress0, (Object) null);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("org.traccar.protocol.Gl200ProtocolDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test1()  throws Throwable  {
    Future<?> future = executor.submit(new Runnable(){ 
            @Override public void run() { 
        try {
          Gl200Protocol gl200Protocol0 = new Gl200Protocol();
          Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
          DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
          defaultChannelPipeline0.getChannel();
          MockInetSocketAddress mockInetSocketAddress0 = new MockInetSocketAddress("", 0);
          mockInetSocketAddress0.getHostName();
          Integer integer0 = new Integer(0);
          try { 
            gl200ProtocolDecoder0.decode((Channel) null, mockInetSocketAddress0, integer0);
            fail("Expecting exception: ClassCastException");
          
          } catch(ClassCastException e) {
             //
             // java.lang.Integer cannot be cast to java.lang.String
             //
             verifyException("org.traccar.protocol.Gl200ProtocolDecoder", e);
          }
        } catch(Throwable t) {
            // Need to catch declared exceptions
        }
      } 
    });
    future.get(4000, TimeUnit.MILLISECONDS);
  }

  @Test(timeout = 4000)
  public void test2()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      defaultChannelPipeline0.getChannel();
      InetSocketAddress inetSocketAddress0 = MockInetSocketAddress.createUnresolved("laipac", 824);
      gl200ProtocolDecoder0.decode((Channel) null, inetSocketAddress0, "laipac");
      gl200ProtocolDecoder0.decode((Channel) null, inetSocketAddress0, "laipac");
      SimpleChannelDownstreamHandler simpleChannelDownstreamHandler0 = new SimpleChannelDownstreamHandler();
      try { 
        gl200ProtocolDecoder0.decode((Channel) null, inetSocketAddress0, simpleChannelDownstreamHandler0);
        fail("Expecting exception: ClassCastException");
      
      } catch(ClassCastException e) {
         //
         // org.jboss.netty.channel.SimpleChannelDownstreamHandler cannot be cast to java.lang.String
         //
         verifyException("org.traccar.protocol.Gl200ProtocolDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test3()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      defaultChannelPipeline0.toString();
      defaultChannelPipeline0.getChannel();
      MockInetSocketAddress mockInetSocketAddress0 = null;
      try {
        mockInetSocketAddress0 = new MockInetSocketAddress((-240));
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // port out of range:-240
         //
         verifyException("java.net.InetSocketAddress", e);
      }
  }

  @Test(timeout = 4000)
  public void test4()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      LinkedList<TrackerServer> linkedList0 = new LinkedList<TrackerServer>();
      TrackerServer trackerServer0 = mock(TrackerServer.class, new ViolatedAssumptionAnswer());
      linkedList0.add(trackerServer0);
      linkedList0.stream();
      // Undeclared exception!
      try { 
        gl200Protocol0.initTrackerServers(linkedList0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("org.traccar.TrackerServer", e);
      }
  }

  @Test(timeout = 4000)
  public void test5()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultLocalClientChannelFactory defaultLocalClientChannelFactory0 = new DefaultLocalClientChannelFactory();
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      defaultLocalClientChannelFactory0.newChannel(defaultChannelPipeline0);
      DefaultChannelPipeline defaultChannelPipeline1 = new DefaultChannelPipeline();
      defaultLocalClientChannelFactory0.newChannel(defaultChannelPipeline1);
      // Undeclared exception!
      try { 
        defaultChannelPipeline1.replace((ChannelHandler) gl200ProtocolDecoder0, "", (ChannelHandler) gl200ProtocolDecoder0);
        fail("Expecting exception: NoSuchElementException");
      
      } catch(NoSuchElementException e) {
         //
         // org.traccar.protocol.Gl200ProtocolDecoder
         //
         verifyException("org.jboss.netty.channel.DefaultChannelPipeline", e);
      }
  }

  @Test(timeout = 4000)
  public void test6()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      defaultChannelPipeline0.getChannel();
      DefaultLocalServerChannelFactory defaultLocalServerChannelFactory0 = new DefaultLocalServerChannelFactory();
      ChannelSink channelSink0 = defaultChannelPipeline0.getSink();
      SocketChannel socketChannel0 = SocketChannel.open();
      int int0 = 176;
      ThreadPoolExecutor.DiscardPolicy threadPoolExecutor_DiscardPolicy0 = new ThreadPoolExecutor.DiscardPolicy();
      ScheduledThreadPoolExecutor scheduledThreadPoolExecutor0 = new ScheduledThreadPoolExecutor(176, threadPoolExecutor_DiscardPolicy0);
      NioWorker nioWorker0 = new NioWorker(scheduledThreadPoolExecutor0);
      NioSocketChannel nioSocketChannel0 = new NioSocketChannel((Channel) null, defaultLocalServerChannelFactory0, defaultChannelPipeline0, channelSink0, socketChannel0, nioWorker0);
      String string0 = "\"\\gvQ\"@\"O !Nq";
      int int1 = 106;
      // Undeclared exception!
      try { 
        defaultLocalServerChannelFactory0.newChannel(defaultChannelPipeline0);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // attached already
         //
         verifyException("org.jboss.netty.channel.DefaultChannelPipeline", e);
      }
  }

  @Test(timeout = 4000)
  public void test7()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      LinkedList<TrackerServer> linkedList0 = new LinkedList<TrackerServer>();
      // Undeclared exception!
      try { 
        gl200Protocol0.initTrackerServers(linkedList0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("org.traccar.TrackerServer", e);
      }
  }

  @Test(timeout = 4000)
  public void test8()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      DefaultChannelPipeline defaultChannelPipeline0 = new DefaultChannelPipeline();
      String[] stringArray0 = new String[7];
      stringArray0[0] = "";
      stringArray0[1] = "";
      stringArray0[2] = "";
      stringArray0[3] = "qg!&{v!<2'd=07K";
      stringArray0[4] = "";
      stringArray0[5] = "key must not be empty.";
      stringArray0[6] = "QIb`j";
      gl200Protocol0.setSupportedCommands(stringArray0);
      defaultChannelPipeline0.getChannel();
      String string0 = "Origin";
      int int0 = 1368;
      // Undeclared exception!
      try { 
        defaultChannelPipeline0.remove((ChannelHandler) gl200ProtocolDecoder0);
        fail("Expecting exception: NoSuchElementException");
      
      } catch(NoSuchElementException e) {
         //
         // org.traccar.protocol.Gl200ProtocolDecoder
         //
         verifyException("org.jboss.netty.channel.DefaultChannelPipeline", e);
      }
  }

  @Test(timeout = 4000)
  public void test9()  throws Throwable  {
      Gl200Protocol gl200Protocol0 = new Gl200Protocol();
      String[] stringArray0 = new String[2];
      stringArray0[0] = "Q2qNT";
      stringArray0[1] = "M";
      gl200Protocol0.setSupportedCommands(stringArray0);
      Gl200ProtocolDecoder gl200ProtocolDecoder0 = new Gl200ProtocolDecoder(gl200Protocol0);
      assertEquals("gl200", gl200ProtocolDecoder0.getProtocolName());
  }
}
