Changeset 2e88850 for core/java


Ignore:
Timestamp:
Dec 2, 2017 2:28:03 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1ff9e6e
Parents:
e6f17ec1
Message:

Core tests: Remove or suppress deprecation warnings
Remove unchecked warnings
Fix HMACSHA256Test and HMACSHA256Bench?

Location:
core/java
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/Lease.java

    re6f17ec1 r2e88850  
    7373     * to the destination through the current lease were successful.
    7474     *
    75      * @deprecated unused
    7675     */
    7776/****
     
    8180****/
    8281
    83     /** @deprecated unused */
    8482/****
    8583    public void setNumSuccess(int num) {
     
    9290     * to the destination through the current lease failed.
    9391     *
    94      * @deprecated unused
    9592     */
    9693/****
     
    10097****/
    10198
    102     /** @deprecated unused */
    10399/****
    104100    public void setNumFailure(int num) {
  • core/java/test/junit/net/i2p/crypto/AES256Test.java

    re6f17ec1 r2e88850  
    4646    }
    4747   
     48    @SuppressWarnings("deprecation")
    4849    public void testLong(){
    4950        I2PAppContext ctx = new I2PAppContext();
  • core/java/test/junit/net/i2p/crypto/ElGamalTest.java

    re6f17ec1 r2e88850  
    181181        if (key == null)
    182182            key = _context.sessionKeyManager().createSession(pubKey);
    183         byte[] encrypted = _context.elGamalAESEngine().encrypt(DataHelper.getASCII(msg), pubKey, key, 64);
     183        byte[] encrypted = _context.elGamalAESEngine().encrypt(DataHelper.getASCII(msg), pubKey, key, null, null, 64);
    184184        byte[] decrypted = null;
    185185        try{
    186             decrypted = _context.elGamalAESEngine().decrypt(encrypted, privKey);
     186            decrypted = _context.elGamalAESEngine().decrypt(encrypted, privKey, _context.sessionKeyManager());
    187187        }catch(DataFormatException dfe){
    188188            dfe.printStackTrace();
     
    268268                key = _context.sessionKeyManager().createSession(pubKey);
    269269           
    270             byte[] encrypted = _context.elGamalAESEngine().encrypt(msg, pubKey, key, 1024);
     270            byte[] encrypted = _context.elGamalAESEngine().encrypt(msg, pubKey, key, null, null, 1024);
    271271            byte[] decrypted = null;
    272272            try{
    273                 decrypted = _context.elGamalAESEngine().decrypt(encrypted, privKey);
     273                decrypted = _context.elGamalAESEngine().decrypt(encrypted, privKey, _context.sessionKeyManager());
    274274            }catch(DataFormatException dfe){
    275275                dfe.printStackTrace();
     
    344344                    tags.add(new SessionTag(true));
    345345            }
    346             byte encrypted[] = e.encrypt(DataHelper.getASCII("blah"), pubKey, sessionKey, tags, 1024);
    347             byte decrypted[] = e.decrypt(encrypted, privKey);
     346            byte encrypted[] = e.encrypt(DataHelper.getASCII("blah"), pubKey, sessionKey, tags, null, 1024);
     347            byte decrypted[] = e.decrypt(encrypted, privKey, _context.sessionKeyManager());
    348348            assertEquals("blah", new String(decrypted));
    349349               
  • core/java/test/junit/net/i2p/crypto/HMACSHA256Bench.java

    re6f17ec1 r2e88850  
    4848        private static void runTest(I2PAppContext ctx) {
    4949        SessionKey key = ctx.keyGenerator().generateSessionKey();
    50                 Hash asdfs = ctx.hmac().calculate(key, "qwerty".getBytes());
     50        byte[] output = new byte[32];
     51                ctx.hmac().calculate(key, "qwerty".getBytes(), 0, 6, output, 0);
    5152                       
    5253                int times = 100000;
     
    7172                long maxLong1 = 0;
    7273       
    73                 byte[] smess = new String("abc").getBytes();
     74                byte[] smess = "abc".getBytes();
    7475                StringBuilder buf = new StringBuilder();
    7576                for (int x = 0; x < 2*1024; x++) {
     
    8485
    8586                // warm up the engines
    86         ctx.hmac().calculate(key, smess);
    87         ctx.hmac().calculate(key, mmess);
    88         ctx.hmac().calculate(key, lmess);
     87        ctx.hmac().calculate(key, smess, 0, smess.length, output, 0);
     88        ctx.hmac().calculate(key, mmess, 0, mmess.length, output, 0);
     89        ctx.hmac().calculate(key, lmess, 0, lmess.length, output, 0);
    8990       
    9091        long before = System.currentTimeMillis();
    9192        for (int x = 0; x < times; x++)
    92             ctx.hmac().calculate(key, smess);
     93            ctx.hmac().calculate(key, smess, 0, smess.length, output, 0);
    9394        long after = System.currentTimeMillis();
    9495       
     
    9798        before = System.currentTimeMillis();
    9899        for (int x = 0; x < times; x++)
    99             ctx.hmac().calculate(key, mmess);
     100            ctx.hmac().calculate(key, mmess, 0, mmess.length, output, 0);
    100101        after = System.currentTimeMillis();
    101102
     
    104105        before = System.currentTimeMillis();
    105106        for (int x = 0; x < times; x++)
    106             ctx.hmac().calculate(key, lmess);
     107            ctx.hmac().calculate(key, lmess, 0, lmess.length, output, 0);
    107108        after = System.currentTimeMillis();
    108109
  • core/java/test/junit/net/i2p/crypto/HMACSHA256Test.java

    re6f17ec1 r2e88850  
    2929            _context.random().nextBytes(message);
    3030           
    31             _context.hmac().calculate(key, message);
     31            byte[] output = new byte[32];
     32            _context.hmac().calculate(key, message, 0, message.length, output, 0);
    3233        }
    3334    }
  • core/java/test/junit/net/i2p/data/BooleanTest.java

    re6f17ec1 r2e88850  
    2121public class BooleanTest extends TestCase{
    2222   
     23    @SuppressWarnings("deprecation")
    2324    public void testBoolean() throws Exception{
    2425        byte[] temp = null;
  • core/java/test/junit/net/i2p/data/DataHelperTest.java

    re6f17ec1 r2e88850  
    107107    }
    108108   
     109    @SuppressWarnings("deprecation")
    109110    private void checkDate(Date when) throws Exception{
    110111        byte buf[] = new byte[DataHelper.DATE_LENGTH];
  • core/java/test/junit/net/i2p/kademlia/KBucketSetTest.java

    re6f17ec1 r2e88850  
    130130    public void testGenRandom() {
    131131        int errors = 0;
    132         for (KBucket b : set.getBuckets()) {
     132        for (KBucket<Hash> b : set.getBuckets()) {
    133133            for (int j = 0; j < 4000; j++) {
    134134                Hash rand = set.generateRandomKey(b);
  • core/java/test/junit/net/i2p/stat/SimpleStatDumper.java

    re6f17ec1 r2e88850  
    2020    }
    2121
     22    @SuppressWarnings("deprecation")
    2223    private static void dumpFrequencies(I2PAppContext ctx, StringBuilder buf) {
    2324        Set<String> frequencies = new TreeSet<String>(ctx.statManager().getFrequencyNames());
Note: See TracChangeset for help on using the changeset viewer.