Clover coverage report -
Coverage timestamp: Sat Jul 7 2007 16:41:13 CEST
file stats: LOC: 91   Methods: 8
NCLOC: 55   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NodeInfo.java 66.7% 80.8% 87.5% 78.3%
coverage coverage
 1    /*
 2    * JTRunner is free software; you can redistribute it and/or modify it under the
 3    * terms of the GNU General Public License as published by the Free Software
 4    * Foundation; either version 2, or (at your option) any later version.
 5    */
 6   
 7    package jtr.remote.test;
 8   
 9    import java.io.Serializable;
 10   
 11    import static jtr.test.SystemProperties.*;
 12    import jtr.config.remote.Node;
 13   
 14    /**
 15    * A <code>NodeInfo</code> instance represents a node member of the JTR network.
 16    *
 17    * @author frusso
 18    * @version 4.0
 19    * @since 4.0
 20    */
 21    public class NodeInfo extends Node implements Serializable {
 22   
 23  4 public static NodeInfo newLocalNodeInfo() {
 24  4 return new NodeInfo("localhost",NO_PORT,null);
 25    }
 26   
 27    /**
 28    * Creates a new instance of NodeInfo
 29    * @param host
 30    * @param port
 31    * @param serviceName
 32    */
 33  5 public NodeInfo(String host, int port, String serviceName) {
 34  5 setHost(host);
 35  5 setPort(port);
 36  5 if(serviceName!=null)
 37  1 this.serviceName = serviceName;
 38    else
 39  4 this.serviceName = NO_SERVICE;
 40    }
 41   
 42  3 public NodeInfo(String serviceName) {
 43  3 String host = System.getProperty(RMI_REGISTRY_HOST, DEF_RMI_REGISTRY_HOST);
 44  3 int port = new Integer(System.getProperty(RMI_REGISTRY_PORT, DEF_RMI_REGISTRY_PORT.toString()));
 45  3 setHost(host);
 46  3 setPort(port);
 47  3 if(serviceName!=null)
 48  3 this.serviceName = serviceName;
 49    else
 50  0 this.serviceName = NO_SERVICE;
 51    }
 52   
 53    /**
 54    * Returns the service name (whatever the service is).
 55    * @return The service name
 56    */
 57  0 public String getServiceName() {
 58  0 return serviceName;
 59    }
 60   
 61  45070 public String toString() {
 62  45070 return toURL();
 63    }
 64   
 65  46795 public String toURL() {
 66  46795 if(!serviceName.equals(NO_SERVICE))
 67  24238 if(getPort()!=NO_PORT)
 68  24238 return "rmi://"+getHost()+":"+getPort()+"/"+serviceName;
 69    else
 70  0 return "rmi://"+getHost()+"/"+serviceName;
 71    else
 72  22557 if(getPort()!=NO_PORT)
 73  0 return "rmi://"+getHost()+":"+getPort();
 74    else
 75  22557 return "rmi://"+getHost();
 76    }
 77   
 78  44702 public int hashCode() {
 79  44702 return toString().hashCode();
 80    }
 81   
 82  4 public boolean equals(Object obj) {
 83  4 if(!(obj instanceof NodeInfo))
 84  0 return false;
 85  4 return this.toString().equals(((NodeInfo)obj).toString());
 86    }
 87   
 88    private String serviceName;
 89    private static final String NO_SERVICE = "";
 90    private static final int NO_PORT = -1;
 91    }