Example #1
0
 @Test
 public void testSet_GetCurrentDeviceName() throws Exception {
   //        Assert.assertTrue(TelnetUtils.getCurrentDeviceName() == null); //test null
   String currentDeviceName = new String("test");
   TelnetUtils.setCurrentDeviceName(currentDeviceName);
   Assert.assertTrue(TelnetUtils.getCurrentDeviceName().equals("test"));
 }
Example #2
0
  @Test
  public void testConfigL3vpnOnDeviceByCli() throws Exception {
    String deviceName = new String("deviceNamePE1");
    String clearOldConfigString = new String("clearOldConfigString");
    String cliExecutionSequences = new String("cliExecutionSequences");

    telnetUtils.configL3vpnOnDeviceByCli(deviceName, clearOldConfigString, cliExecutionSequences);

    Assert.assertTrue(!TelnetUtils.isConfigOver());
    Assert.assertEquals(TelnetUtils.getInstanceOfClearCliTemplate(), "clearOldConfigString");
    Assert.assertEquals(TelnetUtils.getInstanceOfNewCliTemplate(), "cliExecutionSequences");
    Assert.assertEquals(TelnetUtils.getCurrentDeviceName(), "deviceNamePE1");
  }
Example #3
0
  @Test
  public void testStartConnectAndConfig() throws Exception {
    Class<TelnetUtils> class1 = TelnetUtils.class;
    Method method =
        class1.getDeclaredMethod(
            "startConnectAndConfig", new Class[] {SimpleChannelUpstreamHandler.class});
    Method method1 = class1.getDeclaredMethod("sendNewConfig");
    method.setAccessible(true);
    method1.setAccessible(true);

    SimpleChannelUpstreamHandler simpleChannelUpstreamHandler =
        mock(SimpleChannelUpstreamHandler.class);
    Assert.assertEquals(TelnetUtils.getCurrentDeviceName(), "deviceNamePE1");
    method.invoke(telnetUtils, simpleChannelUpstreamHandler);
    method1.invoke(telnetUtils);
  }