forked from I2P_Developers/i2p.i2p
Router tests: Remove or supporess deprecation warnings
Remove cast warnings Fix RouterAddress.setExpiration() to match javadoc, used only by tests
This commit is contained in:
@ -22,8 +22,8 @@ import net.i2p.data.TunnelId;
|
||||
public class DeliveryInstructionsTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
DeliveryInstructions instructions = new DeliveryInstructions();
|
||||
instructions.setDelayRequested(true);
|
||||
instructions.setDelaySeconds(42);
|
||||
//instructions.setDelayRequested(true);
|
||||
//instructions.setDelaySeconds(42);
|
||||
instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL);
|
||||
// encryption key read/write disabled
|
||||
//instructions.setEncrypted(true);
|
||||
|
@ -14,6 +14,7 @@ import java.util.Properties;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing Hash objects
|
||||
@ -22,21 +23,16 @@ import net.i2p.data.StructureTest;
|
||||
*/
|
||||
public class RouterAddressTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
RouterAddress addr = new RouterAddress();
|
||||
byte data[] = new byte[32];
|
||||
for (int i = 0; i < data.length; i++)
|
||||
data[i] = (byte)(i%16);
|
||||
addr.setCost(42);
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
OrderedProperties options = new OrderedProperties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
addr.setOptions(options);
|
||||
addr.setTransportStyle("Blah");
|
||||
RouterAddress addr = new RouterAddress("Blah", options, 42);
|
||||
return addr;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new RouterAddress(); }
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSetNullOptions(){
|
||||
RouterAddress addr = new RouterAddress();
|
||||
boolean error = false;
|
||||
@ -48,12 +44,12 @@ public class RouterAddressTest extends StructureTest {
|
||||
assertTrue(error);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testSetOptionsAgain(){
|
||||
RouterAddress addr = new RouterAddress();
|
||||
Properties options = new Properties();
|
||||
OrderedProperties options = new OrderedProperties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
addr.setOptions(options);
|
||||
RouterAddress addr = new RouterAddress("Blah", options, 42);
|
||||
options.setProperty("portnum", "2345");
|
||||
boolean error = false;
|
||||
try{
|
||||
@ -76,33 +72,21 @@ public class RouterAddressTest extends StructureTest {
|
||||
}
|
||||
|
||||
public void testNullEquals(){
|
||||
RouterAddress addr = new RouterAddress();
|
||||
byte data[] = new byte[32];
|
||||
for (int i = 0; i < data.length; i++)
|
||||
data[i] = (byte)(i%16);
|
||||
addr.setCost(42);
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
OrderedProperties options = new OrderedProperties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
addr.setOptions(options);
|
||||
addr.setTransportStyle("Blah");
|
||||
RouterAddress addr = new RouterAddress("Blah", options, 42);
|
||||
assertFalse(addr.equals(null));
|
||||
assertFalse(addr.equals(""));
|
||||
}
|
||||
|
||||
public void testToString(){
|
||||
RouterAddress addr = new RouterAddress();
|
||||
byte data[] = new byte[32];
|
||||
for (int i = 0; i < data.length; i++)
|
||||
data[i] = (byte)(i%16);
|
||||
addr.setCost(42);
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
OrderedProperties options = new OrderedProperties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
addr.setOptions(options);
|
||||
addr.setTransportStyle("Blah");
|
||||
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);
|
||||
|
@ -31,6 +31,8 @@ import net.i2p.util.Log;
|
||||
*/
|
||||
public class RouterInfoTest extends StructureTest {
|
||||
private final static Log _log = new Log(RouterInfoTest.class);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
RouterInfo info = new RouterInfo();
|
||||
HashSet<RouterAddress> addresses = new HashSet<RouterAddress>();
|
||||
|
Reference in New Issue
Block a user