From a169d7e7c194710744f56e99ec4d9eb300d4156c Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 11 Aug 2020 15:40:41 +0200 Subject: [PATCH] added test file for the MakeTar class --- .../dhp/oa/graph/dump/MakeTarTest.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java new file mode 100644 index 000000000..4d1ecfbc6 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/MakeTarTest.java @@ -0,0 +1,58 @@ + +package eu.dnetlib.dhp.oa.graph.dump; + +import java.io.IOException; +import java.nio.file.Files; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class MakeTarTest { + private static String workingDir; + + @BeforeAll + public static void beforeAll() throws IOException { + workingDir = Files + .createTempDirectory(MakeTarTest.class.getSimpleName()) + .toString(); + } + + @Test + public void testTar() throws IOException { + LocalFileSystem fs = FileSystem.getLocal(new Configuration()); + + fs + .copyFromLocalFile( + false, new Path(getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/zenodo/ni") + .getPath()), + new Path(workingDir + "/zenodo/ni/part-00000")); + + fs + .copyFromLocalFile( + false, new Path(getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/zenodo/egi") + .getPath()), + new Path(workingDir + "/zenodo/ni/part-00001")); + + fs + .copyFromLocalFile( + false, new Path(getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/zenodo/dh-ch") + .getPath()), + new Path(workingDir + "/zenodo/dh-ch/part-00000")); + fs + .copyFromLocalFile( + false, new Path(getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/zenodo/science-innovation-policy") + .getPath()), + new Path(workingDir + "/zenodo/ni/part-00002")); + + String inputPath = workingDir + "/zenodo/"; + + MakeTar.makeTArArchive(fs, inputPath, "/tmp/out"); + + } +}