Changeset e6f17ec1


Ignore:
Timestamp:
Dec 2, 2017 1:56:13 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2e88850
Parents:
2becaaa
Message:

Router tests: Remove or supporess deprecation warnings
Remove cast warnings
Fix RouterAddress?.setExpiration() to match javadoc, used only by tests

Location:
router/java
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/router/RouterAddress.java

    r2becaaa re6f17ec1  
    147147    @Deprecated
    148148    public void setExpiration(Date expiration) {
    149         _expiration = expiration.getDate();
     149        if (expiration != null)
     150            _expiration = expiration.getDate();
     151        else
     152            _expiration = 0;
    150153    }
    151154
  • router/java/test/junit/net/i2p/data/i2np/DeliveryInstructionsTest.java

    r2becaaa re6f17ec1  
    2323    public DataStructure createDataStructure() throws DataFormatException {
    2424        DeliveryInstructions instructions = new DeliveryInstructions();
    25                 instructions.setDelayRequested(true);
    26                 instructions.setDelaySeconds(42);
     25                //instructions.setDelayRequested(true);
     26                //instructions.setDelaySeconds(42);
    2727                instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_TUNNEL);
    2828                // encryption key read/write disabled
  • router/java/test/junit/net/i2p/data/router/RouterAddressTest.java

    r2becaaa re6f17ec1  
    1515import net.i2p.data.DataStructure;
    1616import net.i2p.data.StructureTest;
     17import net.i2p.util.OrderedProperties;
    1718
    1819/**
     
    2324public class RouterAddressTest extends StructureTest {
    2425    public DataStructure createDataStructure() throws DataFormatException {
    25         RouterAddress addr = new RouterAddress();
    26         byte data[] = new byte[32];
    27         for (int i = 0; i < data.length; i++)
    28             data[i] = (byte)(i%16);
    29         addr.setCost(42);
    3026        //addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
    31         Properties options = new Properties();
     27        OrderedProperties options = new OrderedProperties();
    3228        options.setProperty("hostname", "localhost");
    3329        options.setProperty("portnum", "1234");
    34         addr.setOptions(options);
    35         addr.setTransportStyle("Blah");
     30        RouterAddress addr = new RouterAddress("Blah", options, 42);
    3631        return addr;
    3732    }
    3833    public DataStructure createStructureToRead() { return new RouterAddress(); }
    3934
     35    @SuppressWarnings("deprecation")
    4036    public void testSetNullOptions(){
    4137        RouterAddress addr = new RouterAddress();
     
    4945    }
    5046
     47    @SuppressWarnings("deprecation")
    5148    public void testSetOptionsAgain(){
    52         RouterAddress addr = new RouterAddress();
    53         Properties options = new Properties();
     49        OrderedProperties options = new OrderedProperties();
    5450        options.setProperty("hostname", "localhost");
    5551        options.setProperty("portnum", "1234");
    56         addr.setOptions(options);
     52        RouterAddress addr = new RouterAddress("Blah", options, 42);
    5753        options.setProperty("portnum", "2345");
    5854        boolean error = false;
     
    7773
    7874    public void testNullEquals(){
    79         RouterAddress addr = new RouterAddress();
    80         byte data[] = new byte[32];
    81         for (int i = 0; i < data.length; i++)
    82             data[i] = (byte)(i%16);
    83         addr.setCost(42);
    8475        //addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
    85         Properties options = new Properties();
     76        OrderedProperties options = new OrderedProperties();
    8677        options.setProperty("hostname", "localhost");
    8778        options.setProperty("portnum", "1234");
    88         addr.setOptions(options);
    89         addr.setTransportStyle("Blah");
     79        RouterAddress addr = new RouterAddress("Blah", options, 42);
    9080        assertFalse(addr.equals(null));
    9181        assertFalse(addr.equals(""));
     
    9383
    9484    public void testToString(){
    95         RouterAddress addr = new RouterAddress();
    96         byte data[] = new byte[32];
    97         for (int i = 0; i < data.length; i++)
    98             data[i] = (byte)(i%16);
    99         addr.setCost(42);
    10085        //addr.setExpiration(new Date(1000*60*60*24)); // jan 2 1970
    101         Properties options = new Properties();
     86        OrderedProperties options = new OrderedProperties();
    10287        options.setProperty("hostname", "localhost");
    10388        options.setProperty("portnum", "1234");
    104         addr.setOptions(options);
    105         addr.setTransportStyle("Blah");
     89        RouterAddress addr = new RouterAddress("Blah", options, 42);
    10690        String ret = addr.toString();
    10791        //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);
  • router/java/test/junit/net/i2p/data/router/RouterInfoTest.java

    r2becaaa re6f17ec1  
    3232public class RouterInfoTest extends StructureTest {
    3333    private final static Log _log = new Log(RouterInfoTest.class);
     34
     35    @SuppressWarnings("deprecation")
    3436    public DataStructure createDataStructure() throws DataFormatException {
    3537        RouterInfo info = new RouterInfo();
  • router/java/test/junit/net/i2p/router/SSUDemo.java

    r2becaaa re6f17ec1  
    220220     */
    221221    private class FooJobBuilder implements HandlerJobBuilder {
     222        @SuppressWarnings("deprecation")
    222223        public FooJobBuilder() {
    223224            I2NPMessageImpl.registerBuilder(new FooBuilder(), FooMessage.MESSAGE_TYPE);
  • router/java/test/junit/net/i2p/router/crypto/SessionEncryptionTest.java

    r2becaaa re6f17ec1  
    4949        byte[] msg = DataHelper.getASCII("msg 1");
    5050       
    51         byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
     51        byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, null, null, 64);
    5252        byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
    5353        assertTrue(DataHelper.eq(dmsg, msg));
     
    6363        byte[] msg = DataHelper.getASCII("msg 2");
    6464       
    65         byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
     65        byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, null, null, 64);
    6666        byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
    6767        assertTrue(DataHelper.eq(dmsg, msg));
     
    102102        byte[] msg5 = DataHelper.getASCII("msg 5");
    103103       
    104         byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
     104        byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, null, 64);
    105105       
    106106        byte dmsg1[] = _context.elGamalAESEngine().decrypt(emsg1, privKey, skm);
     
    202202        byte[] msg5 = DataHelper.getASCII("msg 5");
    203203       
    204         byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
     204        byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, null, 64);
    205205       
    206206        byte dmsg1[] = _context.elGamalAESEngine().decrypt(emsg1, privKey, skm);
  • router/java/test/junit/net/i2p/router/message/BuildTestMessageJob.java

    r2becaaa re6f17ec1  
    111111        DeliveryInstructions instructions = new DeliveryInstructions();
    112112        instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_ROUTER);
    113         instructions.setDelayRequested(false);
    114         instructions.setDelaySeconds(0);
    115         instructions.setEncrypted(false);
    116         instructions.setEncryptionKey(null);
    117113        instructions.setRouter(_target.getIdentity().getHash());
    118114        instructions.setTunnelId(null);
     
    136132        ackInstructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_ROUTER);
    137133        ackInstructions.setRouter(_replyTo); // yikes!
    138         ackInstructions.setDelayRequested(false);
    139         ackInstructions.setDelaySeconds(0);
    140         ackInstructions.setEncrypted(false);
    141134       
    142135        DeliveryStatusMessage msg = new DeliveryStatusMessage(getContext());
  • router/java/test/junit/net/i2p/router/networkdb/kademlia/RouterGenerator.java

    r2becaaa re6f17ec1  
    2626import net.i2p.data.SigningPublicKey;
    2727import net.i2p.util.Clock;
     28import net.i2p.util.OrderedProperties;
    2829
    2930public class RouterGenerator {
     
    122123   
    123124    private static RouterAddress createTCPAddress(int num) {
    124         RouterAddress addr = new RouterAddress();
    125         addr.setCost(10);
    126         addr.setExpiration(null);
    127         Properties props = new Properties();
     125        OrderedProperties props = new OrderedProperties();
    128126        String name = "blah.random.host.org";
    129127        String port = "" + (1024+num);
    130128        props.setProperty("host", name);
    131129        props.setProperty("port", port);
    132         addr.setOptions(props);
    133         addr.setTransportStyle("TCP");
     130        RouterAddress addr = new RouterAddress("TCP", props, 10);
    134131        return addr;
    135132    }
  • router/java/test/junit/net/i2p/router/transport/udp/UDPFlooder.java

    r2becaaa re6f17ec1  
    7676                // peers always grows, so this is fairly safe
    7777                for (int i = 0; i < _peers.size(); i++) {
    78                     PeerState peer = (PeerState)_peers.get(i);
     78                    PeerState peer = _peers.get(i);
    7979                    DataMessage m = new DataMessage(_context);
    8080                    byte data[] = _floodData; // new byte[4096];
  • router/java/test/junit/net/i2p/router/tunnel/BatchedFragmentTest.java

    r2becaaa re6f17ec1  
    1111import java.util.ArrayList;
    1212
    13 import static junit.framework.Assert.assertTrue;
     13import static org.junit.Assert.assertTrue;
    1414import org.junit.Before;
    1515import org.junit.Test;
  • router/java/test/junit/net/i2p/router/tunnel/BuildMessageTestStandalone.java

    r2becaaa re6f17ec1  
    5757        TunnelBuildMessage msg = new TunnelBuildMessage(ctx);
    5858        for (int i = 0; i < order.size(); i++) {
    59             int hop = ((Integer)order.get(i)).intValue();
     59            int hop = order.get(i).intValue();
    6060            PublicKey key = null;
    6161            if (hop < _pubKeys.length)
     
    120120        for (int i = 0; i < cfg.getLength(); i++) {
    121121            Hash peer = cfg.getPeer(i);
    122             int record = ((Integer)order.get(i)).intValue();
     122            int record = order.get(i).intValue();
    123123            if (statuses[record] != 0)
    124124                allAgree = false;
  • router/java/test/junit/net/i2p/router/tunnel/GatewayTestBase.java

    r2becaaa re6f17ec1  
    11package net.i2p.router.tunnel;
    22
    3 import static junit.framework.Assert.assertTrue;
     3import static org.junit.Assert.assertTrue;
    44
    55import java.util.ArrayList;
     
    155155            _received = new ArrayList<I2NPMessage>(1000);
    156156        }
     157
     158        @SuppressWarnings("deprecation")
    157159        public long receiveEncrypted(byte[] encrypted) {
    158160            // fake all the hops...
  • router/java/test/junit/net/i2p/router/tunnel/InboundGatewayTest.java

    r2becaaa re6f17ec1  
    3636       
    3737        @Override
     38        @SuppressWarnings("deprecation")
    3839        protected void handleAtEndpoint(byte []encrypted) {
    3940            // now handle it at the endpoint
  • router/java/test/junit/net/i2p/router/tunnel/InboundTest.java

    r2becaaa re6f17ec1  
    1414import net.i2p.data.Hash;
    1515
    16 import static junit.framework.Assert.assertTrue;
     16import static org.junit.Assert.assertTrue;
    1717
    1818/**
     
    2424   
    2525    @Test
     26    @SuppressWarnings("deprecation")
    2627    public void testInbound() {
    2728        int numHops = 8;
  • router/java/test/junit/net/i2p/router/tunnel/OutboundTest.java

    r2becaaa re6f17ec1  
    2626    }
    2727   
     28    @SuppressWarnings("deprecation")
    2829    public void testOutbound() {
    2930        int numHops = 8;
Note: See TracChangeset for help on using the changeset viewer.