コード例 #1
0
 @Test
 public void testToResponseWithUnhandledRepositoryException() {
   when(mockProviders.getExceptionMapper(Exception.class)).thenReturn(null);
   final Exception cause = new Exception("xyz");
   final RepositoryRuntimeException ex = new RepositoryRuntimeException(cause);
   final Response response = testObj.toResponse(ex);
   assertEquals(500, response.getStatus());
 }
コード例 #2
0
 @Test
 public void testToResponseWithHandledRepositoryException() {
   when(mockProviders.getExceptionMapper(RepositoryException.class)).thenReturn(mockProvider);
   final RepositoryException cause = new RepositoryException("xyz");
   final RepositoryRuntimeException ex = new RepositoryRuntimeException(cause);
   testObj.toResponse(ex);
   verify(mockProvider).toResponse(cause);
 }
コード例 #3
0
 @GET
 public StreamingOutput m0() {
   ContextResolver<XSLTTemplatesContextResolver> resolverWrapper =
       providers.getContextResolver(
           XSLTTemplatesContextResolver.class, MediaType.APPLICATION_XML_TYPE);
   XSLTTemplatesContextResolver resolver = resolverWrapper.getContext(null);
   Templates templates = resolver.getTemplates("test.template");
   return new XSLTStreamingOutput(
       new StreamSource(
           Thread.currentThread().getContextClassLoader().getResourceAsStream("book-in.xml")),
       templates);
 }
コード例 #4
0
  private Map<String, Object> getProperties(final boolean forMarshaller) {
    final Map<String, Object> properties =
        Maps.newHashMap(
            forMarshaller
                ? getGlobalConfig().getMarshallerProperties()
                : getGlobalConfig().getUnmarshallerProperties());

    final ContextResolver<MoxyJsonConfig> contextResolver =
        providers.getContextResolver(MoxyJsonConfig.class, MediaType.APPLICATION_JSON_TYPE);
    if (contextResolver != null) {
      final MoxyJsonConfig jsonConfiguration = contextResolver.getContext(MoxyJsonConfig.class);

      if (jsonConfiguration != null) {
        properties.putAll(
            forMarshaller
                ? jsonConfiguration.getMarshallerProperties()
                : jsonConfiguration.getUnmarshallerProperties());
      }
    }

    return properties;
  }
コード例 #5
0
 protected JAXBContextFinder getFinder(MediaType type) {
   ContextResolver<JAXBContextFinder> resolver =
       providers.getContextResolver(JAXBContextFinder.class, type);
   if (resolver == null) return null;
   return resolver.getContext(null);
 }