Project

General

Profile

« Previous | Next » 

Revision 57627

testing for parthenost

View differences:

IterableXmlParserTest.java
3 3
import static org.junit.Assert.assertNotNull;
4 4
import static org.junit.Assert.assertTrue;
5 5

  
6
import java.io.ByteArrayInputStream;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.io.StringReader;
10
import java.io.StringWriter;
6
import java.io.*;
7
import java.net.URI;
8
import java.nio.charset.StandardCharsets;
9
import java.nio.file.*;
10
import java.util.Iterator;
11 11
import java.util.zip.GZIPInputStream;
12 12
import java.util.zip.ZipInputStream;
13 13

  
14
import eu.dnetlib.rmi.data.CollectorServiceException;
14 15
import org.apache.commons.io.IOUtils;
16
import org.apache.http.HttpStatus;
17
import org.apache.http.client.methods.CloseableHttpResponse;
18
import org.apache.http.client.methods.HttpGet;
19
import org.apache.http.impl.client.CloseableHttpClient;
20
import org.apache.http.impl.client.HttpClients;
15 21
import org.dom4j.Document;
16 22
import org.dom4j.DocumentException;
17 23
import org.dom4j.io.SAXReader;
18 24
import org.junit.Before;
25
import org.junit.Ignore;
19 26
import org.junit.Test;
20 27
import org.springframework.core.io.ClassPathResource;
21 28
import org.springframework.core.io.Resource;
29
import sun.nio.ch.IOUtil;
22 30

  
23 31
public class IterableXmlParserTest {
24 32

  
......
30 38

  
31 39
	private Resource xmlSingle = new ClassPathResource("eu/dnetlib/miscutils/iterators/xml/singleRepo.xml");
32 40

  
41
	private Resource xmlBig = new ClassPathResource("eu/dnetlib/miscutils/iterators/xml/big.xml");
42

  
33 43
	private String element = "repository";
34 44

  
35 45
	private IterableXmlParser parser;
......
79 89
		assertTrue(count == 3);
80 90
	}
81 91

  
92
	@Test
93
	public void testBig() throws Exception {
94
		int count = doTest(xmlBig.getInputStream(), "Entry");
95
		System.out.println(count);
96
	}
97

  
98
	@Test
99
	public void testBigRemote() throws Exception {
100
		Iterator<String> s = new XMLIterator("Entry", xmlBig.getInputStream());
101
		int i =0;
102
		Path dir = Paths.get("/tmp/foresight");
103
		Files.createDirectories(dir);
104
		while(s.hasNext()){
105
			System.out.println(++i);
106

  
107
			final Path path = Files.createTempFile(dir,"foresight", i+".xml");
108
			System.out.println("Temp file : " + path);
109

  
110
			//Writing data here
111
			byte[] strToBytes = s.next().getBytes();
112
			Files.write(path, strToBytes);
113

  
114
		}
115
	}
116

  
82 117
	private int doTest(final InputStream stream, final String element) throws DocumentException {
83 118
		parser = new IterableXmlParser(element, stream);
84 119
		int count = 0;

Also available in: Unified diff