forked from I2P_Developers/i2p.i2p
- Fix last three I2CP message junit test failures caused by the removal of equals().
- Fix RouterAddress test failure caused by removal of expiration
This commit is contained in:
@ -24,37 +24,17 @@ import java.io.ByteArrayOutputStream;
|
||||
SessionKey key = (SessionKey)(new SessionKeyTest()).createDataStructure();
|
||||
|
||||
byte data[] = "Hello, I2P".getBytes();
|
||||
payload.setUnencryptedData(data);
|
||||
// This causes equals() to fail unless we override the test
|
||||
// to set the unencrypted data after reading.
|
||||
// Unencrypted data is deprecated, just use encrypted data for the test.
|
||||
//payload.setUnencryptedData(data);
|
||||
Hash hash = (Hash)(new HashTest()).createDataStructure();
|
||||
|
||||
Destination target = (Destination)(new DestinationTest()).createDataStructure();
|
||||
payload.setEncryptedData(data);
|
||||
payload.setEncryptedData(data);
|
||||
|
||||
return payload;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new Payload(); }
|
||||
|
||||
public void testStructure() throws Exception{
|
||||
byte[] temp = null;
|
||||
|
||||
DataStructure orig;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
orig = createDataStructure();
|
||||
orig.writeBytes(baos);
|
||||
|
||||
|
||||
temp = baos.toByteArray();
|
||||
|
||||
DataStructure ds;
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(temp);
|
||||
|
||||
ds = createStructureToRead();
|
||||
ds.readBytes(bais);
|
||||
Payload payload = (Payload)ds;
|
||||
payload.setUnencryptedData(payload.getEncryptedData());
|
||||
|
||||
assertEquals(orig, ds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class RouterAddressTest extends StructureTest {
|
||||
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
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
@ -78,7 +78,7 @@ public class RouterAddressTest extends StructureTest {
|
||||
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
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
@ -94,13 +94,14 @@ public class RouterAddressTest extends StructureTest {
|
||||
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
|
||||
//addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
|
||||
Properties options = new Properties();
|
||||
options.setProperty("hostname", "localhost");
|
||||
options.setProperty("portnum", "1234");
|
||||
addr.setOptions(options);
|
||||
addr.setTransportStyle("Blah");
|
||||
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\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\tTransportStyle: Blah\n\tCost: 42\n\tOptions: #: 2\n\t\t[hostname] = [localhost]\n\t\t[portnum] = [1234]]", ret);
|
||||
}
|
||||
}
|
||||
|
@ -33,23 +33,4 @@ import net.i2p.data.PayloadTest;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new MessagePayloadMessage(); }
|
||||
|
||||
public void testStructure() throws Exception{
|
||||
byte[] temp = null;
|
||||
|
||||
DataStructure orig;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
orig = createDataStructure();
|
||||
orig.writeBytes(baos);
|
||||
|
||||
temp = baos.toByteArray();
|
||||
|
||||
DataStructure ds;
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(temp);
|
||||
ds = createStructureToRead();
|
||||
ds.readBytes(bais);
|
||||
((MessagePayloadMessage)ds).getPayload().setUnencryptedData(((MessagePayloadMessage)ds).getPayload().getEncryptedData());
|
||||
|
||||
assertEquals(orig, ds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,26 +42,4 @@ import net.i2p.data.DateAndFlagsTest;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new SendMessageExpiresMessage(); }
|
||||
|
||||
public void testStructure() throws Exception{
|
||||
byte[] temp = null;
|
||||
|
||||
DataStructure orig;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
orig = createDataStructure();
|
||||
orig.writeBytes(baos);
|
||||
|
||||
|
||||
temp = baos.toByteArray();
|
||||
|
||||
DataStructure ds;
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(temp);
|
||||
|
||||
ds = createStructureToRead();
|
||||
ds.readBytes(bais);
|
||||
((SendMessageExpiresMessage)ds).getPayload().setUnencryptedData(((SendMessageExpiresMessage)ds).getPayload().getEncryptedData());
|
||||
|
||||
assertEquals(orig, ds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,26 +37,4 @@ import net.i2p.data.PayloadTest;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new SendMessageMessage(); }
|
||||
|
||||
public void testStructure() throws Exception{
|
||||
byte[] temp = null;
|
||||
|
||||
DataStructure orig;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
orig = createDataStructure();
|
||||
orig.writeBytes(baos);
|
||||
|
||||
|
||||
temp = baos.toByteArray();
|
||||
|
||||
DataStructure ds;
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(temp);
|
||||
|
||||
ds = createStructureToRead();
|
||||
ds.readBytes(bais);
|
||||
((SendMessageMessage)ds).getPayload().setUnencryptedData(((SendMessageMessage)ds).getPayload().getEncryptedData());
|
||||
|
||||
assertEquals(orig, ds);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user