forked from I2P_Developers/i2p.i2p
Added missing test classes to net.i2p.data.i2cp
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing BandwidthLimitsMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class BandwidthLimitsMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
BandwidthLimitsMessage msg = new BandwidthLimitsMessage(10240, 1024);
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new BandwidthLimitsMessage(); }
|
||||
}
|
26
core/java/test/net/i2p/data/i2cp/DestLookupMessageTest.java
Normal file
26
core/java/test/net/i2p/data/i2cp/DestLookupMessageTest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing DestLookupMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class DestLookupMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
DestLookupMessage msg = new DestLookupMessage();
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new DestLookupMessage(); }
|
||||
}
|
26
core/java/test/net/i2p/data/i2cp/DestReplyMessageTest.java
Normal file
26
core/java/test/net/i2p/data/i2cp/DestReplyMessageTest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing DestReplyMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class DestReplyMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
DestReplyMessage msg = new DestReplyMessage();
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new DestReplyMessage(); }
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing GetBandwidthLimitsMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class GetBandwidthLimitsMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
GetBandwidthLimitsMessage msg = new GetBandwidthLimitsMessage();
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new GetBandwidthLimitsMessage(); }
|
||||
}
|
26
core/java/test/net/i2p/data/i2cp/GetDateMessageTest.java
Normal file
26
core/java/test/net/i2p/data/i2cp/GetDateMessageTest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing GetDateMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class GetDateMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
GetDateMessage msg = new GetDateMessage("0.8.13-0");
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new GetDateMessage(); }
|
||||
}
|
40
core/java/test/net/i2p/data/i2cp/I2CPTestSuite.java
Normal file
40
core/java/test/net/i2p/data/i2cp/I2CPTestSuite.java
Normal file
@ -0,0 +1,40 @@
|
||||
package net.i2p.data.i2cp;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class I2CPTestSuite {
|
||||
|
||||
public static Test suite() {
|
||||
|
||||
TestSuite suite = new TestSuite("net.i2p.data.i2cp.I2CPTestSuite");
|
||||
|
||||
suite.addTestSuite(AbuseReasonTest.class);
|
||||
suite.addTestSuite(AbuseSeverityTest.class);
|
||||
suite.addTestSuite(BandwidthLimitsMessageTest.class);
|
||||
suite.addTestSuite(CreateLeaseSetMessageTest.class);
|
||||
suite.addTestSuite(CreateSessionMessageTest.class);
|
||||
suite.addTestSuite(DestLookupMessageTest.class);
|
||||
suite.addTestSuite(DestReplyMessageTest.class);
|
||||
suite.addTestSuite(DestroySessionMessageTest.class);
|
||||
suite.addTestSuite(DisconnectMessageTest.class);
|
||||
suite.addTestSuite(GetBandwidthLimitsMessageTest.class);
|
||||
suite.addTestSuite(GetDateMessageTest.class);
|
||||
suite.addTestSuite(MessageIdTest.class);
|
||||
suite.addTestSuite(MessagePayloadMessageTest.class);
|
||||
suite.addTestSuite(MessageStatusMessageTest.class);
|
||||
suite.addTestSuite(ReceiveMessageBeginMessageTest.class);
|
||||
suite.addTestSuite(ReceiveMessageEndMessageTest.class);
|
||||
suite.addTestSuite(ReconfigureSessionMessageTest.class);
|
||||
suite.addTestSuite(ReportAbuseMessageTest.class);
|
||||
suite.addTestSuite(RequestLeaseSetMessageTest.class);
|
||||
suite.addTestSuite(SendMessageExpiresMessageTest.class);
|
||||
suite.addTestSuite(SendMessageMessageTest.class);
|
||||
suite.addTestSuite(SessionConfigTest.class);
|
||||
suite.addTestSuite(SessionIdTest.class);
|
||||
suite.addTestSuite(SessionStatusMessageTest.class);
|
||||
suite.addTestSuite(SetDateMessageTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing ReconfigureSessionMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class ReconfigureSessionMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
ReconfigureSessionMessage msg = new ReconfigureSessionMessage();
|
||||
msg.setSessionId((SessionId)(new SessionIdTest()).createDataStructure());
|
||||
msg.setSessionConfig((SessionConfig)(new SessionConfigTest()).createDataStructure());
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new ReconfigureSessionMessage(); }
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.DestinationTest;
|
||||
import net.i2p.data.Payload;
|
||||
import net.i2p.data.PayloadTest;
|
||||
import net.i2p.data.DateAndFlags;
|
||||
import net.i2p.data.DateAndFlagsTest;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing SendMessageExpiresMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
|
||||
public class SendMessageExpiresMessageTest extends StructureTest {
|
||||
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
SendMessageExpiresMessage msg = new SendMessageExpiresMessage();
|
||||
msg.setDestination((Destination)(new DestinationTest()).createDataStructure());
|
||||
msg.setPayload((Payload)(new PayloadTest()).createDataStructure());
|
||||
msg.setSessionId((SessionId)(new SessionIdTest()).createDataStructure());
|
||||
msg.setNonce(1);
|
||||
DateAndFlags daf = (DateAndFlags)(new DateAndFlagsTest()).createDataStructure();
|
||||
msg.setExpiration(daf.getDate());
|
||||
msg.setFlags(daf.getFlags());
|
||||
return msg;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
26
core/java/test/net/i2p/data/i2cp/SetDateMessageTest.java
Normal file
26
core/java/test/net/i2p/data/i2cp/SetDateMessageTest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.i2p.data.i2cp;
|
||||
/*
|
||||
* free (adj.): unencumbered; not under the control of others
|
||||
* Written by str4d in 2012 and released into the public domain
|
||||
* with no warranty of any kind, either expressed or implied.
|
||||
* It probably won't make your computer catch on fire, or eat
|
||||
* your children, but it might. Use at your own risk.
|
||||
*
|
||||
*/
|
||||
|
||||
import net.i2p.data.StructureTest;
|
||||
import net.i2p.data.DataStructure;
|
||||
import net.i2p.data.DataFormatException;
|
||||
|
||||
/**
|
||||
* Test harness for loading / storing SetDateMessage objects
|
||||
*
|
||||
* @author str4d
|
||||
*/
|
||||
public class SetDateMessageTest extends StructureTest {
|
||||
public DataStructure createDataStructure() throws DataFormatException {
|
||||
SetDateMessage msg = new SetDateMessage("0.8.13-0");
|
||||
return msg;
|
||||
}
|
||||
public DataStructure createStructureToRead() { return new SetDateMessage(); }
|
||||
}
|
Reference in New Issue
Block a user