use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.
the class GetDateMessage method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("[GetDateMessage]");
buf.append("\n\tVersion: ").append(_version);
if (_options != null && !_options.isEmpty()) {
buf.append("\n\tOptions: #: ").append(_options.size());
Properties sorted = new OrderedProperties();
sorted.putAll(_options);
for (Map.Entry<Object, Object> e : sorted.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");
}
}
return buf.toString();
}
use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.
the class RouterAddressTest method testSetOptionsAgain.
@SuppressWarnings("deprecation")
@Test
public void testSetOptionsAgain() {
OrderedProperties options = new OrderedProperties();
options.setProperty("hostname", "localhost");
options.setProperty("portnum", "1234");
RouterAddress addr = new RouterAddress("Blah", options, 42);
options.setProperty("portnum", "2345");
exception.expect(IllegalStateException.class);
addr.setOptions(options);
}
use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.
the class RouterAddressTest method testToString.
@Test
public void testToString() {
// addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
OrderedProperties options = new OrderedProperties();
options.setProperty("hostname", "localhost");
options.setProperty("portnum", "1234");
RouterAddress addr = new RouterAddress("Blah", options, 42);
String ret = addr.toString();
// assertEquals("[RouterAddress: \n\tTransportStyle: Blah\n\tCost: 42\n\tExpiration: Fri Jan 02 00:00:00 UTC 1970\n\tOptions: #: 2\n\t\t[hostname] = [localhost]\n\t\t[portnum] = [1234]]", ret);
assertEquals("[RouterAddress: \n\tType: Blah\n\tCost: 42\n\tOptions (2):\n\t\t[hostname] = [localhost]\n\t\t[portnum] = [1234]]", ret);
}
use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.
the class RouterAddressTest method createDataStructure.
public DataStructure createDataStructure() throws DataFormatException {
// addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
OrderedProperties options = new OrderedProperties();
options.setProperty("hostname", "localhost");
options.setProperty("portnum", "1234");
RouterAddress addr = new RouterAddress("Blah", options, 42);
return addr;
}
use of net.i2p.util.OrderedProperties in project i2p.i2p by i2p.
the class NTCPTransport method createNTCPAddress.
/**
* This only creates an address if the hostname AND port are set in router.config,
* which should be rare.
* Otherwise, notifyReplaceAddress() below takes care of it.
* Note this is only called from startListening() via configureLocalAddress()
*
* TODO return a list of one or more
* TODO unlike in UDP rebuildExternalAddress(), this only runs once, at startup,
* so we won't pick up IP changes.
* TODO only returns non-null if port is configured
*
* @since IPv6 moved from CSFI
*/
private RouterAddress createNTCPAddress() {
int p = _context.getProperty(PROP_I2NP_NTCP_PORT, -1);
if (p <= 0 || p >= 64 * 1024)
return null;
String name = getConfiguredIP();
if (name == null)
return null;
OrderedProperties props = new OrderedProperties();
props.setProperty(RouterAddress.PROP_HOST, name);
props.setProperty(RouterAddress.PROP_PORT, Integer.toString(p));
int cost = getDefaultCost(false);
RouterAddress addr = new RouterAddress(STYLE, props, cost);
return addr;
}
Aggregations