forked from I2P_Developers/i2p.i2p
Actually test something in DatagramTest.testBadagram, remove excess whitespace
This commit is contained in:
@ -28,34 +28,33 @@ import net.i2p.data.Hash;
|
||||
*/
|
||||
public class DatagramTest extends TestCase {
|
||||
private I2PClient _client;
|
||||
|
||||
|
||||
public void setUp(){
|
||||
}
|
||||
|
||||
|
||||
protected void tearDown() {
|
||||
System.gc();
|
||||
}
|
||||
|
||||
|
||||
public void testDatagram() throws Exception{
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
I2PClient client = I2PClientFactory.createClient();
|
||||
Destination d = client.createDestination(out);
|
||||
I2PSession session = client.createSession(new ByteArrayInputStream(out.toByteArray()), null);
|
||||
|
||||
|
||||
I2PDatagramMaker dm = new I2PDatagramMaker(session);
|
||||
byte[] dg = dm.makeI2PDatagram("What's the deal with 42?".getBytes());
|
||||
|
||||
|
||||
I2PDatagramDissector dd = new I2PDatagramDissector();
|
||||
dd.loadI2PDatagram(dg);
|
||||
byte[] x = dd.getPayload();
|
||||
assertTrue(DataHelper.eq(x, "What's the deal with 42?".getBytes()));
|
||||
|
||||
|
||||
x = dd.extractPayload();
|
||||
assertTrue(DataHelper.eq(x, "What's the deal with 42?".getBytes()));
|
||||
|
||||
|
||||
assertEquals(d, dd.getSender());
|
||||
assertEquals(d, dd.extractSender());
|
||||
|
||||
}
|
||||
|
||||
/*public void testMakeNullDatagram() throws Exception{
|
||||
@ -85,29 +84,38 @@ public class DatagramTest extends TestCase {
|
||||
Destination d = client.createDestination(out);
|
||||
I2PSession session = client.createSession(new ByteArrayInputStream(out.toByteArray()), null);
|
||||
DSAEngine dsaEng = DSAEngine.getInstance();
|
||||
|
||||
|
||||
ByteArrayOutputStream dout = new ByteArrayOutputStream();
|
||||
d.writeBytes(dout);
|
||||
dsaEng.sign(Hash.FAKE_HASH.toByteArray(), session.getPrivateKey()).writeBytes(dout);
|
||||
dout.write("blah".getBytes());
|
||||
|
||||
|
||||
byte[] data = dout.toByteArray();
|
||||
I2PDatagramDissector dd = new I2PDatagramDissector();
|
||||
dd.loadI2PDatagram(data);
|
||||
|
||||
|
||||
boolean error = false;
|
||||
try{
|
||||
dd.getPayload();
|
||||
}catch(I2PInvalidDatagramException i2pide){
|
||||
error = true;
|
||||
}
|
||||
|
||||
assertTrue(error);
|
||||
|
||||
error = false;
|
||||
try{
|
||||
dd.getSender();
|
||||
}catch(I2PInvalidDatagramException i2pide){
|
||||
error = true;
|
||||
}
|
||||
|
||||
assertTrue(error);
|
||||
|
||||
error = false;
|
||||
try{
|
||||
dd.getHash();
|
||||
}catch(I2PInvalidDatagramException i2pide){
|
||||
error = true;
|
||||
}
|
||||
assertTrue(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user