public void testprocessCarriers() throws Exception {
    Setup setup = new SetupImpl();
    Console console = new ConsoleImpl();
    setup.setConsole(console);

    CarrierTask task = new CarrierTask();
    task.setSetup(setup);

    List<String> filenames = new ArrayList<String>();
    filenames.add(carrierDataFile);
    task.setFilenames(filenames);
    ManagementBeanFactoryDemo managementBeanFactory = new ManagementBeanFactoryDemo();
    task.setManagementBeanFactory(managementBeanFactory);
    task.process();
    CarrierBeanImpl carrierBean = managementBeanFactory.getCarrierBean();
    List<Carrier> carriers = carrierBean.getUpdateCarriers();

    assertNotNull(carriers);
    assertTrue(carriers.size() == 5);

    Carrier c = (Carrier) carriers.get(0);
    assertEquals(c.getName(), carrier_name_1);
    assertEquals(c.getExternalID(), carrier_externalID_1);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_1);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_1);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_1);
    assertEquals(c.getServerAuthType(), carrier_authtype_1);
    assertEquals(c.getNotificationType(), carrier_notificationtype_1);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_1);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_1);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_1);
    assertEquals(c.getDefaultBootstrapPinType(), carrier_defaultBootstrapPinType_1);
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_1);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_1);

    c = (Carrier) carriers.get(1);
    assertEquals(c.getName(), carrier_name_2);
    assertEquals(c.getExternalID(), carrier_externalID_2);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_2);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_2);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_2);
    assertEquals(c.getServerAuthType(), carrier_authtype_2);
    assertEquals(c.getNotificationType(), carrier_notificationtype_2);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_2);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_2);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_2);
    assertEquals(
        c.getDefaultBootstrapPinType(),
        "" + OMACPSecurityMethod.valueByString(carrier_defaultBootstrapPinType_2).getValue());
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_2);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_2);

    c = (Carrier) carriers.get(2);
    assertEquals(c.getName(), carrier_name_3);
    assertEquals(c.getExternalID(), carrier_externalID_3);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_3);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_3);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_3);
    assertEquals(c.getServerAuthType(), carrier_authtype_3);
    assertEquals(c.getNotificationType(), carrier_notificationtype_3);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_3);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_3);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_3);
    assertEquals(
        c.getDefaultBootstrapPinType(),
        "" + OMACPSecurityMethod.valueByString(carrier_defaultBootstrapPinType_3).getValue());
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_3);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_3);

    // test default boot userPin error
    List<String> filenames2 = new ArrayList<String>();
    filenames2.add(carrierDataFileErr);
    task.setFilenames(filenames2);
    try {
      task.process();
      assertTrue(false);
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(true);
    }
  }
  public void testCopy() throws Exception {
    CarrierTask task = new CarrierTask();
    List<CarrierItem> carriers = task.loadCarrierItems(new File(carrierDataFile));
    assertNotNull(carriers);
    assertTrue(carriers.size() == 5);
    CarrierBeanImpl carrierBean = new CarrierBeanImpl();
    List<Carrier> resultlist = new ArrayList<Carrier>();
    ManagementBeanFactory factory = new ManagementBeanFactoryDemo();
    for (CarrierItem item : carriers) {
      Carrier carrier = carrierBean.newCarrierInstance();
      task.copy(factory, item, carrier);
      resultlist.add(carrier);
    }
    assertNotNull(resultlist);
    assertTrue(resultlist.size() == 5);

    Carrier c = (Carrier) resultlist.get(0);
    assertEquals(c.getName(), carrier_name_1);
    assertEquals(c.getExternalID(), carrier_externalID_1);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_1);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_1);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_1);
    assertEquals(c.getServerAuthType(), carrier_authtype_1);
    assertEquals(c.getNotificationType(), carrier_notificationtype_1);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_1);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_1);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_1);
    assertEquals(c.getDefaultBootstrapPinType(), carrier_defaultBootstrapPinType_1);
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_1);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_1);

    c = (Carrier) resultlist.get(1);
    assertEquals(c.getName(), carrier_name_2);
    assertEquals(c.getExternalID(), carrier_externalID_2);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_2);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_2);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_2);
    assertEquals(c.getServerAuthType(), carrier_authtype_2);
    assertEquals(c.getNotificationType(), carrier_notificationtype_2);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_2);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_2);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_2);
    assertEquals(
        c.getDefaultBootstrapPinType(),
        "" + OMACPSecurityMethod.valueByString(carrier_defaultBootstrapPinType_2).getValue());
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_2);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_2);

    c = (Carrier) resultlist.get(2);
    assertEquals(c.getName(), carrier_name_3);
    assertEquals(c.getExternalID(), carrier_externalID_3);
    // assertEquals(c.getCountry().getISOCode(), carrier_country_3);
    // assertEquals(c.getBootstrapProfileConfig(), carrier_bootstrapNAOprofile_3);
    assertEquals(c.getPhoneNumberPolicy(), carrier_phoneNumberpolicy_3);
    assertEquals(c.getServerAuthType(), carrier_authtype_3);
    assertEquals(c.getNotificationType(), carrier_notificationtype_3);
    assertEquals(String.valueOf(c.getNotificationStateTimeout()), carrier_notificationtimeout_3);
    assertEquals(String.valueOf(c.getBootstrapTimeout()), carrier_bootstraptimeout_3);
    assertEquals(
        String.valueOf(c.getNotificationMaxNumRetries()), carrier_notificationMaxRetries_3);
    assertEquals(
        c.getDefaultBootstrapPinType(),
        "" + OMACPSecurityMethod.valueByString(carrier_defaultBootstrapPinType_3).getValue());
    assertEquals(c.getDefaultBootstrapUserPin(), carrier_defaultBootstrapUserPin_3);
    assertEquals(String.valueOf(c.getBootstrapMaxRetries()), carrier_bootstrapMaxRetries_3);

    // test default boot userPin error
    carriers = task.loadCarrierItems(new File(carrierDataFileErr));
    assertNotNull(carriers);
    assertTrue(carriers.size() == 1);
    Carrier carrier = carrierBean.newCarrierInstance();
    try {
      task.copy(factory, carriers.get(0), carrier);
      assertTrue(false);
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(true);
    }
  }