本文整理汇总了Java中i5.las2peer.webConnector.client.MiniClient.setAddressPort方法的典型用法代码示例。如果您正苦于以下问题:Java MiniClient.setAddressPort方法的具体用法?Java MiniClient.setAddressPort怎么用?Java MiniClient.setAddressPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i5.las2peer.webConnector.client.MiniClient
的用法示例。
在下文中一共展示了MiniClient.setAddressPort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetCollections
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
/**
* Tests the AnnotationService for getting all collections
*/
@Test
public void testGetCollections()
{
//AnnotationsClass cl = new AnnotationsClass();
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try
{
c.setLogin(Long.toString(testAgent.getId()), testPass);
//retrieve the collection information
ClientResponse select=c.sendRequest("GET", mainPath +"collections", "");
assertEquals(200, select.getHttpCode());
assertTrue(select.getResponse().trim().contains(objectCollection));
System.out.println("Result of select in 'testGetCollections': " + select.getResponse().trim());
}
catch(Exception e)
{
e.printStackTrace();
fail ( "Exception: " + e );
}
}
示例2: testDuringDevelopment
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Ignore
@Test
public void testDuringDevelopment() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result=c.sendRequest("POST", mainPath+"datasets/1/parse?format=xml", "C:\\Users\\gulyabani\\Downloads\\fitness.stackexchange.com\\Posts.xml,C:\\Users\\gulyabani\\Downloads\\fitness.stackexchange.com\\Users.xml");
System.out.println("Result of 'testExampleMethod': " +result.getResponse().trim());
assertEquals(200, result.getHttpCode());
assertTrue(result.getResponse().trim().contains("testInput"));
//"testInput" name is part of response
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例3: testCrossOriginHeader
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testCrossOriginHeader() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
// this test should work for an unknown function, too
ClientResponse response = c.sendRequest("GET", "asdag", "");
assertEquals(connector.crossOriginResourceDomain, response.getHeader("Access-Control-Allow-Origin"));
assertEquals(String.valueOf(connector.crossOriginResourceMaxAge),
response.getHeader("Access-Control-Max-Age"));
} catch (Exception e) {
fail("Not existing service caused wrong exception");
}
}
示例4: testSwagger
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testSwagger() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("GET", "swaggertest/swagger.json", "");
assertTrue(result.getResponse().trim().contains("createSomething"));
assertTrue(result.getResponse().trim().contains("subresource/content"));
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例5: testValidateLogin
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testValidateLogin()
{
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try
{
c.setLogin(Long.toString(testAgent.getId()), testPass);
// ClientResponse result=c.sendRequest("GET", mainPath +"validate", "");
// assertEquals(HttpURLConnection.HTTP_OK, result.getHttpCode());
} catch (Exception e)
{
e.printStackTrace();
fail("Exception: " + e);
}
}
示例6: testSubresource
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testSubresource() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("GET", "swaggertest/subresource/content", "");
assertEquals(200, result.getHttpCode());
assertEquals("test", result.getResponse().trim());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例7: testUploadLimit
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testUploadLimit() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
byte[] testContent = new byte[WebConnector.DEFAULT_MAX_REQUEST_BODY_SIZE];
new Random().nextBytes(testContent);
String base64 = Base64.getEncoder().encodeToString(testContent);
ClientResponse result = c.sendRequest("POST", "test", base64);
assertEquals(HttpURLConnection.HTTP_ENTITY_TOO_LARGE, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例8: startSimulation
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void startSimulation() throws AdapterException, FileNotFoundException {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("POST",
mainPath + "simulation" , "{\"graphId\":2,\"dynamic\":\"Moran\",\"dynamicValues\":[],\"payoffCC\":1.0,\"payoffCD\":1.0,\"payoffDC\":1.0,\"payoffDD\":1.0,\"iterations\":20}", "application/json", "", new HashMap<>());
System.out.println("Result of 'startSimulation' " + result.getResponse().trim());
assertEquals(400, result.getHttpCode());
c.setLogin(Long.toString(testAgent.getId()), testPass);
result = c.sendRequest("POST",
mainPath + "simulation" , "{\"graphId\":2,\"dynamic\":\"Moran\",\"dynamicValues\":[],\"payoffValues\":[1.0,2.0,3.1,0.0],\"iterations\":20}", "application/json", "", new HashMap<>());
System.out.println("Result of 'startSimulation' " + result.getResponse().trim());
assertEquals(400, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例9: testAuthParamSanitization
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void testAuthParamSanitization() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
// test auth params in GET
ClientResponse result = c.sendRequest("GET", "test/requesturi?param1=sadf&access_token=secret", "");
assertEquals(200, result.getHttpCode());
assertTrue(result.getResponse().contains("param1"));
assertFalse(result.getResponse().contains("secret"));
assertFalse(result.getResponse().contains("access_token"));
// test auth params in header
HashMap<String, String> headers = new HashMap<>();
headers.put("param1", "asdf");
result = c.sendRequest("GET", "test/headers", "", headers);
assertEquals(200, result.getHttpCode());
assertTrue(result.getResponse().toLowerCase().contains("param1"));
assertFalse(result.getResponse().toLowerCase().contains("authorization"));
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例10: validateLogin
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
/**
*
* Tests the validate method.
*
*/
@Test
public void validateLogin() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("GET", mainPath + "validate", "");
assertEquals(200, result.getHttpCode());
System.out.println("Result of 'testValidateLogin': " + result.getResponse().trim());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例11: testIndexerXML
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Ignore
@Test
public void testIndexerXML() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("POST", mainPath + "indexer?inputFormat=xml", "reqbazaar");
assertEquals(200, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例12: testExampleMethod
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
/**
*
* Test the example method that consumes one path parameter
* which we give the value "testInput" in this test.
*
*/
@Test
public void testExampleMethod() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
// ClientResponse result=c.sendRequest("POST", mainPath
// +"myResourcePath/testInput", ""); //testInput is the pathParam
// ClientResponse result=c.sendRequest("POST", mainPath
// +"recommender", "Who is the expert in compiler?"); //testInput is
// the pathParam
// System.out.println("Result of 'testExampleMethod': " +
// result.getResponse().trim());
// assertEquals(200, result.getHttpCode());
// assertTrue(result.getResponse().trim().contains("testInput"));
// //"testInput" name is part of response
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例13: getGraphMetaXMLFormat
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void getGraphMetaXMLFormat() throws AdapterException, FileNotFoundException {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("GET",
mainPath + "graphs/" + SawmillGraphId + "?outputFormat=META_XML", "");
System.out.println("Result of 'testGetGraphs' on Sawmill: " + result.getResponse().trim());
assertEquals(200, result.getHttpCode());
result = c.sendRequest("GET", mainPath + "graphs/" + DolphinsGraphId + "?outputFormat=META_XML", "");
System.out.println("Result of 'testGetGraphs' on Dolphins: " + result.getResponse().trim());
assertEquals(200, result.getHttpCode());
result = c.sendRequest("GET",
mainPath + "graphs/" + AperiodicTwoCommunitiesGraphId + "?outputFormat=META_XML", "");
System.out.println("Result of 'testGetGraphs' on AperiodicTwoCommunities: " + result.getResponse().trim());
assertEquals(200, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例14: getGraphInvalidID
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Test
public void getGraphInvalidID() throws AdapterException, FileNotFoundException {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("GET", mainPath + "graphs/" + 999 + "?outputFormat=META_XML", "");
System.out.println("Result of 'testGetGraphs' on Sawmill: " + result.getResponse().trim());
assertEquals(400, result.getHttpCode());
result = c.sendRequest("GET", mainPath + "graphs/" + -4 + "?outputFormat=META_XML", "");
System.out.println("Result of 'testGetGraphs' on Sawmill: " + result.getResponse().trim());
assertEquals(400, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}
示例15: testIndexerCSV
import i5.las2peer.webConnector.client.MiniClient; //导入方法依赖的package包/类
@Ignore
@Test
public void testIndexerCSV() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
try {
c.setLogin(Long.toString(testAgent.getId()), testPass);
ClientResponse result = c.sendRequest("POST", mainPath + "indexer?inputFormat=csv", "nature");
assertEquals(200, result.getHttpCode());
} catch (Exception e) {
e.printStackTrace();
fail("Exception: " + e);
}
}