Search in sources :

Example 1 with EvoSuiteAddress

use of org.evosuite.runtime.testdata.EvoSuiteAddress in project evosuite by EvoSuite.

the class LocalAddressPrimitiveStatement method getTestCode.

@Override
public String getTestCode(String varName) {
    String testCode = "";
    VariableReference retval = getReturnValue();
    Object value = getValue();
    if (value != null) {
        String escapedAddress = StringUtil.getEscapedString(((EvoSuiteAddress) value).getHost());
        int port = ((EvoSuiteAddress) value).getPort();
        testCode += ((Class<?>) retval.getType()).getSimpleName() + " " + varName + " = new " + ((Class<?>) retval.getType()).getSimpleName() + "(\"" + escapedAddress + "\", " + port + ");\n";
    } else {
        testCode += ((Class<?>) retval.getType()).getSimpleName() + " " + varName + " = null;\n";
    }
    return testCode;
}
Also used : VariableReference(org.evosuite.testcase.variable.VariableReference) EvoSuiteAddress(org.evosuite.runtime.testdata.EvoSuiteAddress)

Example 2 with EvoSuiteAddress

use of org.evosuite.runtime.testdata.EvoSuiteAddress in project evosuite by EvoSuite.

the class RemoteAddressPrimitiveStatement method getTestCode.

@Override
public String getTestCode(String varName) {
    String testCode = "";
    VariableReference retval = getReturnValue();
    Object value = getValue();
    if (value != null) {
        String escapedAddress = StringUtil.getEscapedString(((EvoSuiteAddress) value).getHost());
        int port = ((EvoSuiteAddress) value).getPort();
        testCode += ((Class<?>) retval.getType()).getSimpleName() + " " + varName + " = new " + ((Class<?>) retval.getType()).getSimpleName() + "(\"" + escapedAddress + "\", " + port + ");\n";
    } else {
        testCode += ((Class<?>) retval.getType()).getSimpleName() + " " + varName + " = null;\n";
    }
    return testCode;
}
Also used : VariableReference(org.evosuite.testcase.variable.VariableReference) EvoSuiteAddress(org.evosuite.runtime.testdata.EvoSuiteAddress)

Aggregations

EvoSuiteAddress (org.evosuite.runtime.testdata.EvoSuiteAddress)2 VariableReference (org.evosuite.testcase.variable.VariableReference)2