ReadWypluwkaBenchmarkTest.java 1.57 KB
package ipipan.clarin.tei.impl.io;

import ipipan.clarin.tei.api.exceptions.TEIException;
import ipipan.clarin.tei.api.io.TEI_IO;
import java.io.File;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 *
 * @author lennyn
 */
public class ReadWypluwkaBenchmarkTest {

	// private final static File wypluwkaRoot = new
	// File("/home/mlenart/storage/NKJP_1M_roboczy");
	private final static File wypluwkaRoot = new File(
			"src/test/resources/nkjp1m_test");
	private final static TEI_IO teiIO = TEI_IO.getInstance();

	private List<File> getLeaves(File root) {
		List<File> res = new LinkedList<File>();
		for (File f : root.listFiles()) {
			if (f.isDirectory()) {
				res.addAll(getLeaves(f));
			} else if (f.isFile()
					&& Arrays.asList("header.xml").contains(f.getName())) {
				res.add(root);
			}
		}
		return res;
	}

	public ReadWypluwkaBenchmarkTest() {
	}

	@BeforeClass
	public static void setUpClass() throws Exception {
		BasicConfigurator.configure();
		Logger.getRootLogger().setLevel(Level.ALL);
	}

	@AfterClass
	public static void tearDownClass() throws Exception {
	}

	@Before
	public void setUp() {
	}

	@After
	public void tearDown() {
	}

	@Test
	public void doTest() throws TEIException {
		for (File d : getLeaves(wypluwkaRoot)) {
			System.out.println(d.getPath());
			teiIO.readFromNKJPDirectory(d);
		}
	}
}