added ParseTest
This commit is contained in:
51
src/test/java/ParseTest.java
Normal file
51
src/test/java/ParseTest.java
Normal file
@@ -0,0 +1,51 @@
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.DirectoryFileFilter;
|
||||
import org.apache.commons.io.filefilter.RegexFileFilter;
|
||||
import org.jpacrepo.model.PkgData;
|
||||
import org.jpacrepo.pacbase.Parser;
|
||||
import org.jpacrepo.service.PacmanService;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.naming.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by walter on 22/03/15.
|
||||
*/
|
||||
public class ParseTest
|
||||
{
|
||||
// @Test
|
||||
public void test() throws Exception
|
||||
{
|
||||
|
||||
Collection<File> ls = FileUtils.listFiles(new File("/var/cache/pacman/pkg"), new RegexFileFilter(".*\\.pkg\\.tar\\.xz"), DirectoryFileFilter.DIRECTORY);
|
||||
int i = 0;
|
||||
List<PkgData> lista = new ArrayList<>();
|
||||
for (File file : ls)
|
||||
{
|
||||
PkgData data = new Parser().parseFile(file);
|
||||
lista.add(data);
|
||||
//System.out.println(new XStream().toXML(data));
|
||||
// if(i++>10) break;
|
||||
}
|
||||
System.out.print(lista);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseTest() throws Exception
|
||||
{
|
||||
String[] files = new String[]{"/var/cache/pacman/pkg/mesa-10.4.5-1-x86_64.pkg.tar.xz", "/var/cache/pacman/pkg/mesa-10.5.3-1-x86_64.pkg.tar.xz"};
|
||||
|
||||
for (String file : files)
|
||||
{
|
||||
PkgData data = new Parser().parseFile(new File(file));
|
||||
System.out.println(new XStream().toXML(data));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user