当前位置: 首页>>代码示例>>Java>>正文


Java ClientResponse类代码示例

本文整理汇总了Java中i5.las2peer.webConnector.client.ClientResponse的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse类的具体用法?Java ClientResponse怎么用?Java ClientResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClientResponse类属于i5.las2peer.webConnector.client包,在下文中一共展示了ClientResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetCollections

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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 );
	}
	
}
 
开发者ID:rwth-acis,项目名称:LAS2peer-AnnotationService,代码行数:28,代码来源:ServiceTest.java

示例2: testDuringDevelopment

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
}
  }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:20,代码来源:ServiceTest.java

示例3: testExceptions

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的package包/类
@Test
public void testExceptions() {
	MiniClient c = new MiniClient();
	c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);
	try {
		// unknown service
		c.setLogin(Long.toString(testAgent.getId()), testPass);
		ClientResponse result = c.sendRequest("GET", "doesNotExist", "");
		assertEquals(404, result.getHttpCode());

		// exception in invocation
		result = c.sendRequest("GET", "test/exception", "");
		assertEquals(500, result.getHttpCode());
	} catch (Exception e) {
		e.printStackTrace();
		fail("Exception: " + e);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:19,代码来源:WebConnectorTest.java

示例4: testCrossOriginHeader

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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");
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:17,代码来源:WebConnectorTest.java

示例5: testPath

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的package包/类
@Test
public void testPath() {
	MiniClient c = new MiniClient();
	c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);

	try {
		c.setLogin(Long.toString(testAgent.getId()), testPass);

		ClientResponse result = c.sendRequest("GET", "version/path", "");
		assertTrue(result.getResponse().trim().endsWith("version/"));

		result = c.sendRequest("GET", "version/v1/path", "");
		assertTrue(result.getResponse().trim().endsWith("version/v1/"));
	} catch (Exception e) {
		e.printStackTrace();
		fail("Exception: " + e);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:19,代码来源:WebConnectorTest.java

示例6: testSwagger

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:17,代码来源:WebConnectorTest.java

示例7: testResponseCode

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的package包/类
@Test
public void testResponseCode() {
	MiniClient c = new MiniClient();
	c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);

	try {
		c.setLogin(Long.toString(testAgent.getId()), testPass);

		ClientResponse result = c.sendRequest("PUT", "swaggertest/create/notfound", "");
		assertEquals(404, result.getHttpCode());

		result = c.sendRequest("PUT", "swaggertest/create/asdf", "");
		assertEquals(200, result.getHttpCode());

	} catch (Exception e) {
		e.printStackTrace();
		fail("Exception: " + e);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:20,代码来源:WebConnectorTest.java

示例8: testSubresource

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:17,代码来源:WebConnectorTest.java

示例9: testUploadLimit

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:18,代码来源:WebConnectorTest.java

示例10: testAuthParamSanitization

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
	}
}
 
开发者ID:rwth-acis,项目名称:las2peer-WebConnector,代码行数:27,代码来源:WebConnectorTest.java

示例11: testIndexerCSV

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
}

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:17,代码来源:ServiceTest.java

示例12: testIndexerXML

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
}

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:17,代码来源:ServiceTest.java

示例13: testStemmerMethod

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的package包/类
@Ignore
   @Test
   public void testStemmerMethod() {
MiniClient c = new MiniClient();
c.setAddressPort(HTTP_ADDRESS, HTTP_PORT);

try {
    c.setLogin(Long.toString(testAgent.getId()), testPass);
    ClientResponse result = c.sendRequest("POST", mainPath + "stemmer", "Who is the expert in compiler catty?"); // testInput
														 // is
														 // the
														 // pathParam
    System.out.println("Result of 'testExampleMethod': " + result.getResponse().trim());

    assertEquals(200, result.getHttpCode());
} catch (Exception e) {
    e.printStackTrace();
    fail("Exception: " + e);
}

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:22,代码来源:ServiceTest.java

示例14: testSemantics

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的package包/类
@Ignore
   @Test
   public void testSemantics() {
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/5/semantics", "");
    assertEquals(200, result.getHttpCode());
} catch (Exception e) {
    e.printStackTrace();
    fail("Exception: " + e);
}

   }
 
开发者ID:rwth-acis,项目名称:Expert-Recommender-Service,代码行数:17,代码来源:ServiceTest.java

示例15: validateLogin

import i5.las2peer.webConnector.client.ClientResponse; //导入依赖的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);
	}

}
 
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:22,代码来源:ServiceTest.java


注:本文中的i5.las2peer.webConnector.client.ClientResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。