/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:58:33 GMT 2019
 */

package com.alibaba.dubbo.rpc.cluster.router.condition;

import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.InvokerListener;
import com.alibaba.dubbo.rpc.RpcInvocation;
import com.alibaba.dubbo.rpc.cluster.Router;
import com.alibaba.dubbo.rpc.cluster.router.MockInvokersSelector;
import com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter;
import com.alibaba.dubbo.rpc.protocol.InvokerWrapper;
import java.lang.reflect.Array;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;

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

  @Test(timeout = 4000)
  public void test00()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "jcl", (-2663), "jcl");
      URL uRL1 = uRL0.addParameter("rule", (int) (byte)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      InvokerWrapper<String> invokerWrapper0 = new InvokerWrapper<String>((Invoker<String>) null, uRL0);
      linkedList0.add((Invoker<String>) invokerWrapper0);
      conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertEquals(1, linkedList0.size());
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "jcl", (-2663), "jcl");
      URL uRL1 = uRL0.addParameter("rule", (byte)0);
      URL uRL2 = uRL0.addParameter("rule", (int) (byte)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter1);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "rule";
      URL uRL0 = new URL("8O", "gC;UJuI\"^", "gC;UJuI\"^", "MBE9#", (-1762), (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL0);
      // Undeclared exception!
      try { 
        conditionRouter0.compareTo((Router) conditionRouter1);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
      }
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "rule";
      URL uRL0 = new URL("8O", "gC;UJuI\"^", "gC;UJuI\"^", "MBE9#", (-1762), (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, (Invocation) null);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test04()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "jcl", 1173, "jcl");
      URL uRL1 = uRL0.addParameter("rule", (byte)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertEquals("", uRL2.getUsername());
  }

  @Test(timeout = 4000)
  public void test05()  throws Throwable  {
      URL uRL0 = new URL("priority", "ykUm_9", 1669);
      String[] stringArray0 = new String[8];
      stringArray0[2] = "priority";
      stringArray0[3] = "ykUm_9";
      URL uRL1 = uRL0.addParameters(stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"ykUm_9\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test06()  throws Throwable  {
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter((URL) null);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test07()  throws Throwable  {
      URL uRL0 = new URL("te", "te", "te", "jcl", (-2663), "jcl");
      URL uRL1 = uRL0.addParameter("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertEquals("te", uRL2.getProtocol());
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "jcl", 1173, "jcl");
      URL uRL1 = uRL0.addParameter("rule", (byte)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      String[] stringArray0 = new String[6];
      URL uRL0 = new URL((String) null, (String) null, (-4696), "rule", stringArray0);
      URL uRL1 = uRL0.addParameter("rule", false);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      URL uRL0 = new URL("te", "te", "te", "jcl", (-2663), "jcl");
      URL uRL1 = uRL0.addParameter("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertTrue(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      URL uRL0 = new URL("te", "te", "te", "jcl", (-2663), "jcl");
      URL uRL1 = uRL0.addParameter("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<InvokerListener>> list0 = conditionRouter0.route((List<Invoker<InvokerListener>>) null, uRL0, (Invocation) rpcInvocation0);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      URL uRL0 = new URL("-128", "%KB?vVq'[;whU;F4-", "?l*`Mf`i:r[~9", "?l*`Mf`i:r[~9", (-1623045122), "i Fh(~}=`nSkxfmE");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "D&_&.jv");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      String[] stringArray0 = new String[6];
      URL uRL0 = new URL((String) null, "com.alibaba.dubbo.common.URL", (-419), stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // Illegal route rule!
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "rule";
      URL uRL0 = new URL((String) null, (String) null, (-4705), "rule", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      linkedList0.add((Invoker<MockInvokersSelector>) null);
      Class<String>[] classArray0 = (Class<String>[]) Array.newInstance(Class.class, 23);
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      RpcInvocation rpcInvocation0 = new RpcInvocation("rule", classArray0, stringArray0, hashMap0, (Invoker<?>) null);
      // Undeclared exception!
      try { 
        conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
      }
  }
}
