Java Code Examples for org.testng.util.Strings#isNullOrEmpty()

The following examples show how to use org.testng.util.Strings#isNullOrEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonitorController.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
private boolean checkWiresharkLocation() {
    Preferences preferences = PreferencesManager.getInstance().getPreferences();
    if (preferences != null && !Strings.isNullOrEmpty(preferences.getWireSharkLocation())) {
        String executablePath = preferences.getWireSharkLocation();
        return !Strings.isNullOrEmpty(executablePath) && new File(executablePath).exists();
    }
    
    boolean wsinstalled = locateWireshark();
    if (!wsinstalled) {
        TrexAlertBuilder.build()
                .setType(Alert.AlertType.ERROR)
                .setTitle("Wireshark error")
                .setHeader("Unable to start monitor")
                .setContent("Could not find Wireshark in default installation path.\n" +
                        "Please install it first to proceed with this action.\n" +
                        "You can download it from https://www.wireshark.org\n" +
                        "Or you can specify location manually in preferences")
                .getAlert()
                .showAndWait();
    }
    return wsinstalled;
}
 
Example 2
Source File: ImportedPacketTableView.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Set table data
 *
 * @param packetInfoList
 */
private void setTableData(List<PacketInfo> packetInfoList) {

    index = 1;
    tableDataList.clear();
    for (PacketInfo packetInfo : packetInfoList) {
        ImportPcapTableData tableData = new ImportPcapTableData();

        StringBuilder name = new StringBuilder();
        if (!Strings.isNullOrEmpty(propertiesBinder.getPrefix())) {
            name.append(propertiesBinder.getPrefix()).append("_");
        }
        name.append("packet_").append(index);

        tableData.setName(name.toString());
        tableData.setIndex(index);
        tableData.setLength(packetInfo.getPacket().length());
        tableData.setMacSrc(packetInfo.getSrcMac());
        tableData.setMacDst(packetInfo.getDestMac());
        tableData.setIpSrc(packetInfo.getSrcIpv4());
        tableData.setIpDst(packetInfo.getDestIpv4());
        tableData.setPacketType(trafficProfile.getPacketTypeText(packetInfo.getPacket()).getType());
        tableData.setPacket(packetInfo.getPacket());
        tableData.setHasVlan(packetInfo.hasVlan());
        tableData.setTimeStamp(packetInfo.getTimeStamp());
        tableDataList.add(tableData);
        index++;
    }
    importedStreamTable.setItems(tableDataList);
}
 
Example 3
Source File: CloudInitScriptBuilderTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * loads the given file into a string, ignoring the comments, but considering "#!/bin/bash"
 * @param file file to read
 * @return file content as a string
 * @throws IOException
 */
private String loadFile(String file) throws IOException {
  StringBuilder sb = new StringBuilder();

  List<String> lines = IOUtils
      .readLines(new InputStreamReader(GobblinAWSClusterLauncherTest.class.getClassLoader().getResourceAsStream(file), "UTF-8"));

  for (String line : lines) {
    if (line.equals(CloudInitScriptBuilder.BASH) || (!line.startsWith("#") && !Strings.isNullOrEmpty(line))) {
      sb.append(line).append("\n");
    }
  }
  return sb.toString();
}
 
Example 4
Source File: PortModel.java    From trex-stateless-gui with Apache License 2.0 4 votes vote down vote up
public static PortModel createModelFrom(Port port) {
    PortModel model = new PortModel();
    model.index.bindBidirectional(port.indexProperty());
    model.portDriver.bindBidirectional(port.driverProper());
    model.rxFilterMode.bindBidirectional(port.rxFilterModeProperty());
    model.multicast.bindBidirectional(port.multicastProperty());
    model.promiscuousMode.bindBidirectional(port.promiscuousProperty());
    
    model.owner.bindBidirectional(port.ownerProperty());
    port.ownerProerty.addListener((observable, oldVal, newVal) -> {
        String currentUser = ConnectionManager.getInstance().getClientName();
        model.setIsOwned(currentUser.equalsIgnoreCase(newVal));
    });
    
    model.portSpeed.bind(port.getAttr().speedProperty().asString());
    model.portStatus.addListener((_o, o, n) -> model.isTransmitProperty.set(n.equalsIgnoreCase("tx") || n.equalsIgnoreCase("pause")));
    model.portStatus.bindBidirectional(port.statusProerty());
    model.capturingMode.bind(port.captureStatusProperty());
    model.linkStatus.bindBidirectional(port.linkProperty());
    model.ledControl.bindBidirectional(port.ledProperty());
    model.numaMode.bind(port.numaProerty().asString());
    model.pciAddress.bind(port.pciAddrProperty());
    model.rxQueueing.bind(port.rxQueueProperty());
    PortStatus.PortStatusResult.PortStatusResultRxInfo.PortStatusResultRxInfoGratArp grat_arp = port.getRx_info().getGrat_arp();
    model.gratARP.bind(grat_arp.stateProperty());
    
    model.flowControl.setValue(port.getFlowControl());
    model.serviceModeProperty.bindBidirectional(port.serviceModeProerty());

    model.initHandlers(port);
    
    PortStatus.PortStatusResult.PortStatusResultAttr.PortStatusResultAttrLayerCfg layerConfiguration = port.getAttr().getLayer_cfg();
    
    PortStatus.PortStatusResult.PortStatusResultAttr.PortStatusResultAttrLayerCfg.PortStatusResultAttrLayerCfgEther l2 = layerConfiguration.getEther();
    model.l2Configuration = new PortLayerConfigurationModel(ConfigurationMode.L2, l2.getSrc(), l2.getDst(), l2.getState());
    model.l2Configuration.dstProperty().bindBidirectional(port.getAttr().getLayer_cfg().getEther().dstProperty());

    PortStatus.PortStatusResult.PortStatusResultAttr.PortStatusResultAttrLayerCfg.PortStatusResultAttrLayerCfgIPv4 l3 = layerConfiguration.getIpv4();
    model.l3Configuration = new PortLayerConfigurationModel(ConfigurationMode.L3, l3.getSrc(), l3.getDst(), l3.getState());
    model.l3Configuration.srcProperty().bindBidirectional(port.getAttr().getLayer_cfg().getIpv4().srcProperty());
    model.l3Configuration.dstProperty().bindBidirectional(port.getAttr().getLayer_cfg().getIpv4().dstProperty());

    if (Strings.isNullOrEmpty(l3.getSrc()) && Strings.isNullOrEmpty(l3.getDst())) {
        model.layerConfigurationType.setValue(ConfigurationMode.L2);
    } else {
        model.layerConfigurationType.setValue(ConfigurationMode.L3);
    }
    model.linkControlSupportProperty().set(port.is_link_supported);
    model.ledControlProperty().set(port.is_led_supported);
    model.flowControlSupportProperty().set(port.is_fc_supported);
    return model;
}