package eu.dnetlib.download.plugin;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import eu.dnetlib.data.download.rmi.DownloadItem;

public class ArxivImportFromFileTest {

	@Before
	public void setUp() throws Exception {}

	@Test
	public void testREgEx() {
		String regExp = "\\d{4}\\.\\d{4}";

		String input = "1308.0021";

		Assert.assertTrue(input.matches(regExp));

	}

	@Test
	public void testPlugin() {
		DownloadItem item = new DownloadItem();
		item.setOpenAccess("OPEN");
		String[] myList = new String[] { "http://arxiv.org/abs/1308.0001", "b" };
		Gson g = new GsonBuilder().disableHtmlEscaping().create();
		item.setUrl(g.toJson(myList));

		ArxivImportFromFile plugin = new ArxivImportFromFile();
		plugin.setBasePath("/test/path");

		plugin.retrieveUrl(item);

		Assert.assertNotNull(item);

	}

}
