本文整理汇总了Java中org.apache.http.entity.SerializableEntity类的典型用法代码示例。如果您正苦于以下问题:Java SerializableEntity类的具体用法?Java SerializableEntity怎么用?Java SerializableEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializableEntity类属于org.apache.http.entity包,在下文中一共展示了SerializableEntity类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: submitRoutedRequest
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
@Override
public Observable<AstrixServiceInvocationResponse> submitRoutedRequest(
final AstrixServiceInvocationRequest request, final RoutingKey routingKey) {
ClusterMember clusterMember = getTargetMember(routingKey);
final HttpPost postRequest = new HttpPost(clusterMember.getRemoteEndpointUri());
postRequest.setEntity(new SerializableEntity(request));
return Observable.create(new OnSubscribe<AstrixServiceInvocationResponse>() {
@Override
public void call(final Subscriber<? super AstrixServiceInvocationResponse> t1) {
try {
httpclient.execute(postRequest, serviceResponseCallback(t1));
} catch (Exception e) {
t1.onError(e);
}
}
});
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:19,代码来源:HttpRemotingTransport.java
示例2: submitBroadcastRequest
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
@Override
public Observable<List<AstrixServiceInvocationResponse>> submitBroadcastRequest(
AstrixServiceInvocationRequest request) {
Observable<AstrixServiceInvocationResponse> result = Observable.empty();
for (ClusterMember clusterMember : getAllClusterMembers()) {
final HttpPost postRequest = new HttpPost(clusterMember.getRemoteEndpointUri());
postRequest.setEntity(new SerializableEntity(request));
result = result.mergeWith(Observable.create(new OnSubscribe<AstrixServiceInvocationResponse>() {
@Override
public void call(final Subscriber<? super AstrixServiceInvocationResponse> t1) {
try {
httpclient.execute(postRequest, serviceResponseCallback(t1));
} catch (Exception e) {
t1.onError(e);
}
}
}));
}
return result.toList();
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:22,代码来源:HttpRemotingTransport.java
示例3: handle
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
@Override
public void handle(final HttpRequest request,
final HttpResponse response, final HttpContext context) {
response.setStatusCode(HttpStatus.SC_OK);
final Map<String, String> parameters = RequestHandlingUtilities
.parseParameter(request);
try {
response.setEntity(new SerializableEntity(
(HashMap<String, String>) parameters, false));
} catch (final Exception e) {
response.setEntity(new StringEntity("ERROR",
ContentType.DEFAULT_TEXT));
}
}
开发者ID:pmeisen,项目名称:gen-server-http-listener,代码行数:17,代码来源:TestRequestHandlingUtilities.java
示例4: handle
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
@Override
public void handle(final HttpRequest request,
final HttpResponse response, final HttpContext context) {
try {
final List<FileItem> files = RequestFileHandlingUtilities
.handleFileUpload(request);
final HashMap<String, String> fileMap = new HashMap<String, String>();
for (final FileItem fileItem : files) {
fileMap.put(fileItem.getName(), Files
.getCanonicalPath(((DiskFileItem) fileItem)
.getStoreLocation()));
}
response.setEntity(new SerializableEntity(fileMap, false));
fileItems.addAll(files);
} catch (Exception e) {
response.setEntity(new StringEntity("ERROR",
ContentType.DEFAULT_TEXT));
}
}
开发者ID:pmeisen,项目名称:gen-server-http-listener,代码行数:22,代码来源:TestRequestFileHandlingUtilities.java
示例5: testDetachSerializer
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* <p>Test for detachment of the inherited serializer.</p>
*
* @since 1.3.0
*/
@Test
public final void testDetachSerializer() throws ParseException, IOException {
String subpath = "/detach";
User user = new User(1, "Roy", "Mustang", 30, false);
stubFor(put(urlEqualTo(subpath))
.willReturn(aResponse()
.withStatus(200)));
serializerEndpoint.detachSerializer(user);
verify(putRequestedFor(urlEqualTo(subpath))
.withRequestBody(equalTo(EntityUtils.toString(new SerializableEntity(user, true)))));
}
开发者ID:sahan,项目名称:ZombieLink,代码行数:22,代码来源:SerializerEndpointTest.java
示例6: testSerializableEntity
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* <p>Test for a {@link Request} with a {@link Serializable} entity.</p>
*
* @since 1.3.0
*/
@Test
public final void testSerializableEntity() throws ParseException, IOException {
String subpath = "/serializableentity";
User entity = new User(1L, "Eren", "Yeager", 15, false);
SerializableEntity se = new SerializableEntity(entity, true);
stubFor(put(urlEqualTo(subpath))
.willReturn(aResponse()
.withStatus(200)));
requestEndpoint.serializableEntity(entity);
verify(putRequestedFor(urlEqualTo(subpath))
.withRequestBody(equalTo(EntityUtils.toString(se))));
}
开发者ID:sahan,项目名称:ZombieLink,代码行数:22,代码来源:RequestParamEndpointTest.java
示例7: testSerializableEntity
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* <p>Test for a {@link Request} with a {@link Serializable} entity.</p>
*
* @since 1.3.0
*/
@Test
public final void testSerializableEntity() throws ParseException, IOException {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/serializableentity";
User entity = new User(1L, "Eren", "Yeager", 15, false);
SerializableEntity se = new SerializableEntity(entity, true);
stubFor(put(urlEqualTo(subpath))
.willReturn(aResponse()
.withStatus(200)));
requestEndpoint.serializableEntity(entity);
verify(putRequestedFor(urlEqualTo(subpath))
.withRequestBody(equalTo(EntityUtils.toString(se))));
}
开发者ID:sahan,项目名称:RoboZombie,代码行数:24,代码来源:RequestParamEndpointTest.java
示例8: populateTest
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* This method tests the @link{HouseRestController#populate()} API with a valid client token
* token
* @throws ClientProtocolException
* @throws IOException
*/
@Test(groups="rest")
public void populateTest() throws ClientProtocolException, IOException {
String token = "abcebb42-af86-11e1-ad74-005056b4006f";
String url = TestServers.getHouse() + "devices/populate/" + token;
HttpPost method = new HttpPost(url);
HttpEntity entity = new SerializableEntity(
(Serializable) new HashMap<String, Object>(), false);
method.setEntity(entity);
HttpClient httpClient = new DefaultHttpClient();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpClient.execute(method, responseHandler);
Assert.assertTrue(!responseBody.isEmpty());
}
开发者ID:Comcast,项目名称:dawg,代码行数:21,代码来源:DawgHouseIT.java
示例9: populateInvalidTest
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* This method tests the @link{HouseRestController#populate()} API with a invalid
* client token
* @throws ClientProtocolException
* @throws IOException
*/
@Test(groups="rest")
public void populateInvalidTest() throws ClientProtocolException, IOException {
String invalidClientToken = "xyz";
String url = TestServers.getHouse() + "devices/populate/" + invalidClientToken;
HttpPost method = new HttpPost(url);
HttpEntity entity = new SerializableEntity(
(Serializable) new HashMap<String, Object>(), false);
method.setEntity(entity);
HttpClient httpClient = new DefaultHttpClient();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpClient.execute(method, responseHandler);
Assert.assertEquals(responseBody, "0");
}
开发者ID:Comcast,项目名称:dawg,代码行数:21,代码来源:DawgHouseIT.java
示例10: resolve
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* <p>Discovers the {@link HttpEntity} which is suitable for wrapping an instance of the given {@link Class}.
* This discovery proceeds in the following order by checking the provided generic type:</p>
*
* <ol>
* <li>org.apache.http.{@link HttpEntity} --> returned as-is.</li>
* <li>{@code byte[]}, {@link Byte}[] --> {@link ByteArrayEntity}</li>
* <li>java.io.{@link File} --> {@link FileEntity}</li>
* <li>java.io.{@link InputStream} --> {@link BufferedHttpEntity}</li>
* <li>{@link CharSequence} --> {@link StringEntity}</li>
* <li>java.io.{@link Serializable} --> {@link SerializableEntity} (with an internal buffer)</li>
* </ol>
*
* @param genericType
* a generic {@link Class} to be translated to an {@link HttpEntity} type
* <br><br>
* @return the {@link Class} of the translated {@link HttpEntity}
* <br><br>
* @throws NullPointerException
* if the supplied generic type was {@code null}
* <br><br>
* @throws EntityResolutionFailedException
* if the given generic {@link Class} failed to be translated to an {@link HttpEntity} type
* <br><br>
* @since 1.3.0
*/
public static final Class<?> resolve(Class<?> genericType) {
assertNotNull(genericType);
try {
Class<?> entityType = HttpEntity.class.isAssignableFrom(genericType)? HttpEntity.class :
(byte[].class.isAssignableFrom(genericType)
|| Byte[].class.isAssignableFrom(genericType))? ByteArrayEntity.class:
File.class.isAssignableFrom(genericType)? FileEntity.class :
InputStream.class.isAssignableFrom(genericType)? BufferedHttpEntity.class :
CharSequence.class.isAssignableFrom(genericType)? StringEntity.class :
Serializable.class.isAssignableFrom(genericType)? SerializableEntity.class: null;
if(entityType == null) {
throw new EntityResolutionFailedException(genericType);
}
return entityType;
}
catch(Exception e) {
throw (e instanceof EntityResolutionFailedException)?
(EntityResolutionFailedException)e :new EntityResolutionFailedException(genericType, e);
}
}
开发者ID:sahan,项目名称:ZombieLink,代码行数:54,代码来源:Entities.java
示例11: testDetachSerializer
import org.apache.http.entity.SerializableEntity; //导入依赖的package包/类
/**
* <p>Test for detachment of the inherited serializer.</p>
*
* @since 1.3.0
*/
@Test
public final void testDetachSerializer() throws ParseException, IOException {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/detach";
User user = new User(1, "Roy", "Mustang", 30, false);
stubFor(put(urlEqualTo(subpath))
.willReturn(aResponse()
.withStatus(200)));
serializerEndpoint.detachSerializer(user);
verify(putRequestedFor(urlEqualTo(subpath))
.withRequestBody(equalTo(EntityUtils.toString(new SerializableEntity(user, true)))));
}
开发者ID:sahan,项目名称:RoboZombie,代码行数:24,代码来源:SerializerEndpointTest.java
注:本文中的org.apache.http.entity.SerializableEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论