io.undertow.util.FileUtils Java Examples
The following examples show how to use
io.undertow.util.FileUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResponseWriterTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@Test public void testWriterLargeResponse() throws Exception { TestHttpClient client = new TestHttpClient(); try { HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/large"); HttpResponse result = client.execute(get); Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode()); String data = FileUtils.readFile(result.getEntity().getContent()); String message = LargeResponseWriterServlet.getMessage(); //Assert.assertEquals(message.length(), data.length()); Assert.assertEquals(message, data); } finally { client.getConnectionManager().shutdown(); } }
Example #2
Source File: MultiPartServlet.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { Collection<Part> parts = req.getParts(); PrintWriter writer = resp.getWriter(); writer.println("PARAMS:"); for (Part part : parts) { writer.println("name: " + part.getName()); writer.println("filename: " + part.getSubmittedFileName()); writer.println("content-type: " + part.getContentType()); Collection<String> headerNames = new TreeSet<>(part.getHeaderNames()); for (String header : headerNames) { writer.println(header + ": " + part.getHeader(header)); } writer.println("size: " + part.getSize()); writer.println("content: " + FileUtils.readFile(part.getInputStream())); } } catch (Exception e) { resp.getWriter().write("EXCEPTION: " + e.getClass()); } }
Example #3
Source File: GetResourceTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@Test public void testSpecialCharacterInFileURL() throws IOException { String tmp = System.getProperty("java.io.tmpdir"); PathResourceManager pathResourceManager = new PathResourceManager(Paths.get(tmp), 1); Path file = Paths.get(tmp, "1#2.txt"); Files.write(file, "Hi".getBytes()); Resource res = pathResourceManager.getResource("1#2.txt"); try(InputStream in = res.getUrl().openStream()) { Assert.assertEquals("Hi", FileUtils.readFile(in)); } }
Example #4
Source File: ResponseWriterTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@Test public void testContentLengthBasedFlush() throws Exception { TestHttpClient client = new TestHttpClient(); try { HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/resp?test=" + ResponseWriterServlet.CONTENT_LENGTH_FLUSH); HttpResponse result = client.execute(get); Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode()); String data = FileUtils.readFile(result.getEntity().getContent()); Assert.assertEquals("first-aaaa", data); Assert.assertEquals(0, result.getHeaders("not-header").length); } finally { client.getConnectionManager().shutdown(); } }
Example #5
Source File: SimpleConfidentialRedirectTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@ProxyIgnore public void testRedirectWithFullURLInPath() throws IOException { DefaultServer.isProxy(); //now we need to test what happens if the client send a full URI //see UNDERTOW-874 try (Socket socket = new Socket(DefaultServer.getHostAddress(), DefaultServer.getHostPort())) { socket.getOutputStream().write(("GET " + DefaultServer.getDefaultServerURL() + "/foo HTTP/1.0\r\n\r\n").getBytes(StandardCharsets.UTF_8)); String result = FileUtils.readFile(socket.getInputStream()); Assert.assertTrue(result.contains("Location: " + DefaultServer.getDefaultServerSSLAddress() + "/foo")); } }
Example #6
Source File: DefaultServletCachingTestCase.java From quarkus-http with Apache License 2.0 | 4 votes |
@AfterClass public static void after() throws IOException{ FileUtils.deleteRecursive(tmpDir); }
Example #7
Source File: PredicatedHandlersParser.java From quarkus-http with Apache License 2.0 | 4 votes |
public static List<PredicatedHandler> parse(final InputStream inputStream, final ClassLoader classLoader) { return parse(FileUtils.readFile(inputStream), classLoader); }
Example #8
Source File: ExtendedAccessLogFileTestCase.java From quarkus-http with Apache License 2.0 | 4 votes |
@After public void after() throws IOException { DefaultServer.stopSSLServer(); FileUtils.deleteRecursive(logDirectory); logReceiver.close(); }
Example #9
Source File: AccessLogFileTestCase.java From quarkus-http with Apache License 2.0 | 4 votes |
@After public void after() throws IOException { FileUtils.deleteRecursive(logDirectory); }
Example #10
Source File: PredicatedHandlersParser.java From lams with GNU General Public License v2.0 | 4 votes |
public static List<PredicatedHandler> parse(final InputStream inputStream, final ClassLoader classLoader) { return parse(FileUtils.readFile(inputStream), classLoader); }