Revision 53120
Added by Michele Artini over 4 years ago
modules/dnet-grid-application/trunk/src/test/java/eu/dnetlib/grid/process/utils/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 |
} |
modules/dnet-grid-application/trunk/src/main/java/eu/dnetlib/grid/process/GridOrganizationsApplication.java | ||
---|---|---|
15 | 15 |
import eu.dnetlib.grid.process.utils.Datasource; |
16 | 16 |
import eu.dnetlib.grid.process.utils.GridCleaner; |
17 | 17 |
import eu.dnetlib.grid.process.utils.GridUtils; |
18 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
18 | 19 |
|
19 | 20 |
@SpringBootApplication |
20 | 21 |
public class GridOrganizationsApplication implements CommandLineRunner { |
21 | 22 |
|
22 |
private static final Datasource gridDs = new Datasource("openaire____::grid", "GRID - Global Research Identifier Database", "grid________"); |
|
23 |
private static final Datasource gridDs = |
|
24 |
new Datasource("10|openaire____::" + Hashing.md5("grid"), "GRID - Global Research Identifier Database", "grid________"); |
|
23 | 25 |
|
24 | 26 |
public static void main(final String[] args) { |
25 | 27 |
SpringApplication.run(GridOrganizationsApplication.class, args); |
... | ... | |
27 | 29 |
|
28 | 30 |
@Override |
29 | 31 |
public void run(final String... args) throws Exception { |
32 |
|
|
30 | 33 |
if (args.length == 1) { |
31 | 34 |
processFile(args[0]); |
32 | 35 |
} else { |
modules/dnet-grid-application/trunk/pom.xml | ||
---|---|---|
84 | 84 |
<artifactId>protobuf-java-format</artifactId> |
85 | 85 |
<version>1.4</version> |
86 | 86 |
</dependency> |
87 |
<dependency> |
|
88 |
<groupId>junit</groupId> |
|
89 |
<artifactId>junit</artifactId> |
|
90 |
<version>4.12</version> |
|
91 |
<scope>test</scope> |
|
92 |
</dependency> |
|
87 | 93 |
</dependencies> |
88 | 94 |
|
89 | 95 |
<build> |
Also available in: Unified diff