conversion from Java to Scala
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import com.oggio88.jpacrepo.service.PacmanServiceRemote;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
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 org.jboss.resteasy.plugins.providers.RegisterBuiltin;
|
||||
import org.jboss.resteasy.plugins.providers.jackson.ResteasyJacksonProvider;
|
||||
import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
import com.oggio88.jpacrepo.model.PkgData;
|
||||
import com.oggio88.jpacrepo.pacbase.Hasher;
|
||||
import com.oggio88.jpacrepo.pacbase.MD5InputStream;
|
||||
import com.oggio88.jpacrepo.pacbase.Parser;
|
||||
import com.oggio88.jpacrepo.service.PacmanServiceView;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.naming.*;
|
||||
@@ -22,16 +21,12 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by walter on 29/03/15.
|
||||
*/
|
||||
public class ClientTest
|
||||
{
|
||||
@Test
|
||||
public void testGET() throws Exception
|
||||
public void testGET()
|
||||
{
|
||||
ResteasyProviderFactory instance = ResteasyProviderFactory.getInstance();
|
||||
RegisterBuiltin.register(instance);
|
||||
@@ -92,14 +87,14 @@ public class ClientTest
|
||||
System.out.println(Hasher.computeMD5(new FileInputStream(file)));
|
||||
|
||||
InputStream fis = new FileInputStream(file);
|
||||
MD5InputStream h = Hasher.createMD5InputStream(fis);
|
||||
MD5InputStream h = new MD5InputStream(fis);
|
||||
long a = new File(file).length();
|
||||
byte[] out = new byte[(int)a];
|
||||
h.read(out, 0, (int) a);
|
||||
System.out.println(h.digest());
|
||||
|
||||
PkgData p = new Parser().parseFile(new File(file));
|
||||
System.out.println(p.md5sum);
|
||||
PkgData p = Parser.parseFile(new File(file));
|
||||
System.out.println(p.md5sum());
|
||||
|
||||
}
|
||||
|
||||
@@ -125,26 +120,27 @@ public class ClientTest
|
||||
@Test
|
||||
public void invokeStatelessBean() throws Exception
|
||||
{
|
||||
// Let's lookup the remote stateless calculator
|
||||
|
||||
Properties prop = new Properties();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("jboss-ejb-client.properties");
|
||||
prop.load(in);
|
||||
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
|
||||
|
||||
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
|
||||
// prop.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
|
||||
prop.put(Context.PROVIDER_URL, "http-remoting://nuc:8080");
|
||||
prop.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
|
||||
// prop.put(Context.PROVIDER_URL, "http-remoting://nuc:8080");
|
||||
// prop.put(Context.PROVIDER_URL, "remote://odroid-u3:4447");
|
||||
prop.put(Context.SECURITY_PRINCIPAL, "walter");
|
||||
prop.put(Context.SECURITY_CREDENTIALS, "27ff5990757d1d");
|
||||
// prop.put(Context.SECURITY_PRINCIPAL, "admin");
|
||||
// prop.put(Context.SECURITY_CREDENTIALS, "123456");
|
||||
|
||||
prop.put("jboss.naming.client.ejb.context", true);
|
||||
Context context = new InitialContext(prop);
|
||||
Context ctx = new InitialContext(prop);
|
||||
traverseJndiNode("/", context);
|
||||
// final PacmanService stateService = (PacmanService) ctx.lookup("/jpacrepo-1.0/remote/PacmanServiceEJB!service.PacmanService");
|
||||
final PacmanServiceRemote service = (PacmanServiceRemote) ctx.lookup(
|
||||
"/jpacrepo-2.0/PacmanServiceEJB!com.oggio88.jpacrepo.service.PacmanServiceRemote"
|
||||
"/jpacrepo_2.12-2.0/PacmanServiceEJB!net.woggioni.jpacrepo.service.PacmanServiceRemote"
|
||||
);
|
||||
// List<PkgData> pkgs = service.searchPackage("google-earth", null, null, 1, 10);
|
||||
// System.out.println(new XStream().toXML(pkgs));
|
||||
|
Reference in New Issue
Block a user