package be.iminds.ilabt.jfed.connectivity_tester;

/**
 * User: twalcari
 * Date: 12/19/13
 * Time: 4:26 PM
 */
public class Ping6Test implements ConnectivityTest {
    private static final String DEFAULT_IPV6_ADDRESS = "flsmonitor.fed4fire.eu";

    private final String address;

    public Ping6Test() {
        this(DEFAULT_IPV6_ADDRESS);
    }

    public Ping6Test(String address) {
        super();
        this.address = address;
    }

    @Override
    public String getName() {
        return "Ping to IPv6-host '" + address + "'";
    }

    @Override
    public boolean isLoginRequired() {
        return false;
    }

    @Override
    public ConnectivityTestResult call() throws Exception {
        if (PingUtils.isReachableByPing6(address)) {
            return new ConnectivityTestResult(Status.SUCCEEDED, "Successfully connected to " + address);
        } else {

            return new ConnectivityTestResult(Status.FAILED, "Unable to reach " + address);
        }
    }
}
