added support for zstd packages
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
|
||||
import lombok.SneakyThrows;
|
||||
import net.woggioni.jpacrepo.model.Hasher;
|
||||
import net.woggioni.jpacrepo.model.MD5InputStream;
|
||||
import net.woggioni.jpacrepo.model.Parser;
|
||||
import net.woggioni.jpacrepo.pacbase.PkgData;
|
||||
import net.woggioni.jpacrepo.service.PacmanServiceRemote;
|
||||
import net.woggioni.jwo.JWO;
|
||||
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
|
||||
import org.jboss.resteasy.plugins.providers.jackson.ResteasyJacksonProvider;
|
||||
import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.naming.*;
|
||||
import javax.ws.rs.client.*;
|
||||
@@ -23,30 +24,39 @@ import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ClientTest
|
||||
{
|
||||
@Test
|
||||
public void testGET()
|
||||
{
|
||||
public class ClientTest {
|
||||
|
||||
private static ObjectMapper om;
|
||||
|
||||
static {
|
||||
om = new ObjectMapper();
|
||||
JaxbAnnotationModule module = new JaxbAnnotationModule();
|
||||
om.registerModule(module);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void testGET() {
|
||||
ResteasyProviderFactory instance = ResteasyProviderFactory.getInstance();
|
||||
RegisterBuiltin.register(instance);
|
||||
instance.registerProvider(ResteasyJacksonProvider.class);
|
||||
// instance.registerProvider(ResteasyJacksonProvider.class);
|
||||
Client client = ClientBuilder.newClient();
|
||||
UriBuilder builder = UriBuilder.fromUri("http://odroid-u3:8080/").path("jpacrepo/rest/pkg/search");
|
||||
UriBuilder builder = UriBuilder.fromUri("http://woggioni.net/").path("jpacrepo/rest/pkg/search");
|
||||
// builder.queryParam("name", "linux");
|
||||
// builder.queryParam("version", "324");
|
||||
builder.queryParam("md5sum", "19787793429AF74D4D2D09890247E2EC");
|
||||
WebTarget target = client.target(builder.build());
|
||||
Invocation invocation = target.request().accept("application/xml").buildGet();
|
||||
Response response = invocation.invoke();
|
||||
if (response.getStatusInfo() == Response.Status.OK)
|
||||
{
|
||||
if (response.getStatusInfo() == Response.Status.OK) {
|
||||
PkgData pkg = response.readEntity(PkgData.class);
|
||||
System.out.println(new XStream().toXML(pkg));
|
||||
om.writeValue(System.out, pkg);
|
||||
} else {
|
||||
throw JWO.newThrowable(RuntimeException.class,
|
||||
"Server returned %d",
|
||||
response.getStatusInfo().getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUT() throws Exception
|
||||
{
|
||||
ResteasyProviderFactory instance = ResteasyProviderFactory.getInstance();
|
||||
@@ -65,7 +75,6 @@ public class ClientTest
|
||||
assert Response.Status.CREATED.getStatusCode() == response.getStatus();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hashTest() 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"};
|
||||
@@ -93,7 +102,7 @@ public class ClientTest
|
||||
h.read(out, 0, (int) a);
|
||||
System.out.println(h.digest());
|
||||
|
||||
PkgData p = Parser.parseFile(new File(file));
|
||||
PkgData p = Parser.parseFile(Paths.get(file));
|
||||
System.out.println(p.md5sum());
|
||||
|
||||
}
|
||||
@@ -117,7 +126,6 @@ public class ClientTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeStatelessBean() throws Exception
|
||||
{
|
||||
Properties prop = new Properties();
|
||||
|
Reference in New Issue
Block a user