Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cannotProvideStreamingForOtherMediaTypes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CannotProvideStreamingForOtherMediaTypes()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mock(javax.ws.rs.core.Response.ResponseBuilder.class);
            Response.ResponseBuilder responseBuilder = mock(typeof(Response.ResponseBuilder));
            // no streaming
            when(responseBuilder.entity(any(typeof(sbyte[])))).thenReturn(responseBuilder);
            Mockito.verify(responseBuilder, never()).entity(isA(typeof(StreamingOutput)));
            when(responseBuilder.type(ArgumentMatchers.any <MediaType>())).thenReturn(responseBuilder);
            when(responseBuilder.build()).thenReturn(null);
            OutputFormat format = _repository.outputFormat(new IList <MediaType> {
                MediaType.TEXT_HTML_TYPE
            }, new URI("http://some.host"), StreamingHeader());

            assertNotNull(format);
            format.Response(responseBuilder, new ExceptionRepresentation(new Exception()));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canProvideStreamingJsonOutputFormat() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanProvideStreamingJsonOutputFormat()
        {
            Response response = mock(typeof(Response));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<javax.ws.rs.core.StreamingOutput> ref = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <StreamingOutput> @ref = new AtomicReference <StreamingOutput>();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.Response.ResponseBuilder responseBuilder = mockResponseBuilder(response, ref);
            Response.ResponseBuilder responseBuilder = MockResponseBuilder(response, @ref);
            OutputFormat             format          = _repository.outputFormat(new IList <MediaType> {
                MediaType.APPLICATION_JSON_TYPE
            }, null, StreamingHeader());

            assertNotNull(format);
            Response returnedResponse = format.Response(responseBuilder, new MapRepresentation(map("a", "test")));

            assertSame(response, returnedResponse);
            StreamingOutput streamingOutput = @ref.get();
            MemoryStream    baos            = new MemoryStream();

            streamingOutput.write(baos);
            assertEquals("{\"a\":\"test\"}", baos.ToString());
        }