本文整理汇总了Java中javax.ws.rs.ext.Providers.getMessageBodyReader方法的典型用法代码示例。如果您正苦于以下问题:Java Providers.getMessageBodyReader方法的具体用法?Java Providers.getMessageBodyReader怎么用?Java Providers.getMessageBodyReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.ext.Providers
的用法示例。
在下文中一共展示了Providers.getMessageBodyReader方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLocateMostRelevantConstructor
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateMostRelevantConstructor() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
ProviderFilter providerFilter = instance(ProviderFilter.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField3");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);
assertNotNull(messageBodyReader);
assertEquals(PersonMessageBodyReader.class, messageBodyReader.getClass());
Constructor<?> c = providerFilter.mostRelevantConstructor(messageBodyReader.getClass());
assertEquals(4, c.getParameterCount());
assertEquals("public com.geemvc.jaxrs.PersonMessageBodyReader(javax.ws.rs.core.Application,javax.ws.rs.core.UriInfo,javax.ws.rs.core.HttpHeaders,javax.ws.rs.ext.Providers)", c.toString());
}
示例2: testLocateClosestPersonMapMessageBodyReaderJSON
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMapMessageBodyReaderJSON() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField1");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);
assertNotNull(messageBodyReader);
assertEquals(ModelMapMessageBodyReader.class, messageBodyReader.getClass());
}
示例3: testLocateClosestPersonMapMessageBodyReaderXML
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMapMessageBodyReaderXML() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField1");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);
assertNotNull(messageBodyReader);
assertEquals(PersonMapMessageBodyReader.class, messageBodyReader.getClass());
}
示例4: testLocateModelMapMessageBodyReader
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateModelMapMessageBodyReader() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField1");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);
assertNotNull(messageBodyReader);
assertEquals(ModelMapMessageBodyReader.class, messageBodyReader.getClass());
}
示例5: testLocateStringMapMessageBodyReader
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateStringMapMessageBodyReader() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField2");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);
assertNotNull(messageBodyReader);
assertEquals(MapMessageBodyReader.class, messageBodyReader.getClass());
}
示例6: testLocateClosestPersonMessageBodyReaderJSON
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderJSON() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField3");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);
assertNotNull(messageBodyReader);
assertEquals(AbstractModelMessageBodyReader.class, messageBodyReader.getClass());
}
示例7: testLocateClosestPersonMessageBodyReaderXML
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderXML() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField3");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);
assertNotNull(messageBodyReader);
assertEquals(PersonMessageBodyReader.class, messageBodyReader.getClass());
}
示例8: testLocateClosestPersonMessageBodyReaderTextPlain
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderTextPlain() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField3");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.TEXT_PLAIN_TYPE);
assertNotNull(messageBodyReader);
assertEquals(AbstractModelMessageBodyReader.class, messageBodyReader.getClass());
}
示例9: testLocateClosestAddressMessageBodyReaderJSON
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderJSON() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField4");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);
assertNotNull(messageBodyReader);
assertEquals(ObjectMessageBodyReaderJSON.class, messageBodyReader.getClass());
}
示例10: testLocateClosestAddressMessageBodyReaderXML
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderXML() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField4");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);
assertNotNull(messageBodyReader);
assertEquals(ObjectMessageBodyReaderXML.class, messageBodyReader.getClass());
}
示例11: testLocateClosestAddressMessageBodyReaderTextPlain
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderTextPlain() {
ReflectionProvider rp = instance(ReflectionProvider.class);
Providers providers = instance(Providers.class);
Field f = rp.getField(JaxRsResolverTest.class, "genericField4");
RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());
MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.TEXT_PLAIN_TYPE);
assertNotNull(messageBodyReader);
assertEquals(ObjectMessageBodyReaderWildCard.class, messageBodyReader.getClass());
}
示例12: getContent
import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
/**
* @param inputStream
* @param providers
* @param httpHeaders
* @param type
* @param genericType
* @param annotations
* @return
*/
public static <T> T getContent(InputStream inputStream, Providers providers, HttpHeaders httpHeaders, Class<T> type, Type genericType, Annotation[] annotations) {
MessageBodyReader<T> reader = providers.getMessageBodyReader(type, genericType, annotations, httpHeaders.getMediaType());
try {
return reader.readFrom(type, genericType, annotations, httpHeaders.getMediaType(), httpHeaders.getRequestHeaders(), inputStream);
} catch (Exception e) {e.printStackTrace();
throw new MinnalInstrumentationException("Failed while getting the content from the request stream", e);
}
}