/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:50:57 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.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.util.LinkedList;
import java.util.List;
import java.util.Map;
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("OFF", "OFF", (-41), "GAfWhy C=s*sMa", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, (Invocation) null);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "Illegal route rule \"", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "kY(");
      URL uRL2 = uRL1.setProtocol("kY(");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      URL uRL3 = conditionRouter0.getUrl();
      assertEquals("Illegal route rule \"", uRL3.getPath());
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "Illegal route rule \"", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter0);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "Illegal route rule \"", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "kY(");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = uRL1.addParameter("!p*I8><0~t.*`x", true);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL2);
      int int0 = conditionRouter1.compareTo((Router) conditionRouter0);
      assertEquals((-81), int0);
  }

  @Test(timeout = 4000)
  public void test04()  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 test05()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[4] = "rule";
      stringArray0[5] = "P1,yjH>%oX&0jr^0";
      URL uRL0 = new URL("P1,yjH>%oX&0jr^0", "P1,yjH>%oX&0jr^0", (byte)27, "OFF", stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // URLDecoder: Illegal hex characters in escape (%) pattern - For input string: \"oX\"
         //
         verifyException("java.net.URLDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test06()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[4] = "rule";
      stringArray0[5] = "gM6K)jo$dV=U pF";
      URL uRL0 = new URL("rule", "rule", "rule", "rule", 10000, "e</(0V0ZwRh$", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      // Undeclared exception!
      try { 
        conditionRouter0.compareTo((Router) conditionRouter0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("java.util.TreeMap", e);
      }
  }

  @Test(timeout = 4000)
  public void test07()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-55), "OFF", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-55), "OFF", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      URL uRL2 = uRL1.setProtocol("d");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-55), "OFF", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameter("OFF", (short)0);
      URL uRL2 = uRL1.addParameterAndEncoded("rule", "OFF");
      URL uRL3 = uRL2.setProtocol("d");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL3);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      InvokerWrapper<MockInvokersSelector> invokerWrapper0 = new InvokerWrapper<MockInvokersSelector>((Invoker<MockInvokersSelector>) null, uRL1);
      linkedList0.add((Invoker<MockInvokersSelector>) invokerWrapper0);
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL3, (Invocation) null);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-55), "GAfWhy C=s*sMa", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      InvokerWrapper<MockInvokersSelector> invokerWrapper0 = new InvokerWrapper<MockInvokersSelector>((Invoker<MockInvokersSelector>) null, uRL0);
      linkedList0.add((Invoker<MockInvokersSelector>) invokerWrapper0);
      conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) null);
      assertEquals(1, linkedList0.size());
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-55), "GAfWhy C=s*sMa", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "OFF");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) null);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      URL uRL0 = new URL("O4^", "O4^", "O4^", "GAfWhy C=s*sMa", 1283, "O4^", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "O4^");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      List<Invoker<InvokerWrapper<Integer>>> list0 = conditionRouter0.route((List<Invoker<InvokerWrapper<Integer>>>) null, uRL0, (Invocation) null);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "Illegal route rule \"", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "([&!=,]*)s*([^&!=,s]+)");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"([&!=,]*)s*([^&!=,s]+)\", The error char '&!=,' at index 2 before \"]*)s*([^\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "Illegal route rule \"", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", ";C,uf#|s=<Xx%2");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \";C,uf#|s=<Xx%2\", The error char ',' at index 2 before \"uf#|s\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      URL uRL0 = new URL("OFF", "OFF", (-41), "OFF", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "H$'bU&~tzZ$H~X");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test16()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[4] = "rule";
      stringArray0[5] = "false";
      URL uRL0 = new URL("rule", "false", (byte)27, "Vt\"={`w,&z,", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
  }

  @Test(timeout = 4000)
  public void test17()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "", (-162), "");
      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 test18()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[4] = "rule";
      stringArray0[5] = "gM6K)jo$dV=U pF";
      URL uRL0 = new URL("rule", "rule", "rule", "rule", 10000, "e</(0V0ZwRh$", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      URL uRL1 = conditionRouter0.getUrl();
      assertSame(uRL1, uRL0);
  }
}
