Revision 53120
Added by Michele Artini over 5 years ago
GridUtilsTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.grid.process.utils; |
2 | 2 |
|
3 |
import static org.junit.Assert.assertEquals; |
|
4 |
|
|
3 | 5 |
import java.io.FileInputStream; |
4 | 6 |
import java.io.FileNotFoundException; |
5 | 7 |
import java.io.InputStream; |
8 |
import java.io.UnsupportedEncodingException; |
|
9 |
import java.security.MessageDigest; |
|
10 |
import java.security.NoSuchAlgorithmException; |
|
6 | 11 |
import java.util.HashSet; |
7 | 12 |
import java.util.Set; |
8 | 13 |
import java.util.stream.Collectors; |
9 | 14 |
|
15 |
import org.apache.commons.codec.binary.Hex; |
|
10 | 16 |
import org.junit.Before; |
11 | 17 |
import org.junit.Ignore; |
12 | 18 |
import org.junit.Test; |
13 | 19 |
|
14 | 20 |
import eu.dnetlib.grid.process.model.GridOrganization; |
21 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
15 | 22 |
|
16 | 23 |
@Ignore |
17 | 24 |
public class GridUtilsTest { |
... | ... | |
20 | 27 |
public void setUp() throws Exception {} |
21 | 28 |
|
22 | 29 |
@Test |
30 |
@Ignore |
|
23 | 31 |
public void test() throws FileNotFoundException { |
24 | 32 |
// final InputStream is = getClass().getResourceAsStream("grid_example.json"); |
25 | 33 |
final InputStream is = new FileInputStream("/Users/michele/Desktop/grid.json"); |
... | ... | |
33 | 41 |
|
34 | 42 |
} |
35 | 43 |
|
44 |
@Test |
|
45 |
@Ignore |
|
46 |
public void testMd5() throws UnsupportedEncodingException, NoSuchAlgorithmException { |
|
47 |
final String md5_1 = Hashing.md5("grid"); |
|
48 |
|
|
49 |
final MessageDigest md = MessageDigest.getInstance("MD5"); |
|
50 |
md.update("grid".getBytes("UTF-8")); |
|
51 |
final String md5_2 = new String(Hex.encodeHex(md.digest())); |
|
52 |
|
|
53 |
assertEquals(md5_1, md5_2); |
|
54 |
} |
|
55 |
|
|
36 | 56 |
} |
Also available in: Unified diff