mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-19 13:45:48 +00:00
Utils: Inline getResourceAsString() into DeterministicKeyChainTest, as it's only being used there.
This commit is contained in:
parent
84048b565b
commit
4daac38758
@ -17,12 +17,10 @@
|
|||||||
|
|
||||||
package org.bitcoinj.core;
|
package org.bitcoinj.core;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.common.io.Resources;
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.common.primitives.UnsignedLongs;
|
import com.google.common.primitives.UnsignedLongs;
|
||||||
import org.spongycastle.crypto.digests.RIPEMD160Digest;
|
import org.spongycastle.crypto.digests.RIPEMD160Digest;
|
||||||
@ -30,7 +28,6 @@ import org.spongycastle.crypto.digests.RIPEMD160Digest;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.URL;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -499,12 +496,4 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return maxItem;
|
return maxItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads and joins together with LF char (\n) all the lines from given file. It's assumed that file is in UTF-8.
|
|
||||||
*/
|
|
||||||
public static String getResourceAsString(URL url) throws IOException {
|
|
||||||
List<String> lines = Resources.readLines(url, Charsets.UTF_8);
|
|
||||||
return Joiner.on('\n').join(lines);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Google Inc.
|
* Copyright 2013 Google Inc.
|
||||||
|
* Copyright 2018 Andreas Schildbach
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,8 +25,12 @@ import org.bitcoinj.utils.BriefLogFormatter;
|
|||||||
import org.bitcoinj.utils.Threading;
|
import org.bitcoinj.utils.Threading;
|
||||||
import org.bitcoinj.wallet.listeners.AbstractKeyChainEventListener;
|
import org.bitcoinj.wallet.listeners.AbstractKeyChainEventListener;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.io.Resources;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.crypto.params.KeyParameter;
|
import org.spongycastle.crypto.params.KeyParameter;
|
||||||
@ -522,7 +527,8 @@ public class DeterministicKeyChainTest {
|
|||||||
private String checkSerialization(List<Protos.Key> keys, String filename) {
|
private String checkSerialization(List<Protos.Key> keys, String filename) {
|
||||||
try {
|
try {
|
||||||
String sb = protoToString(keys);
|
String sb = protoToString(keys);
|
||||||
String expected = Utils.getResourceAsString(getClass().getResource(filename));
|
List<String> lines = Resources.readLines(getClass().getResource(filename), Charsets.UTF_8);
|
||||||
|
String expected = Joiner.on('\n').join(lines);
|
||||||
assertEquals(expected, sb);
|
assertEquals(expected, sb);
|
||||||
return expected;
|
return expected;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user