Package org.vertx.java.core.buffer

Examples of org.vertx.java.core.buffer.Buffer


    public void testJsonSchemaProcessing() {
        Yoke yoke = new Yoke(this);
        yoke.use(new BodyParser());
        yoke.use(com.jetdrone.vertx.yoke.middleware.Router.from(new R3()));

        Buffer body = new Buffer("{}");

        MultiMap headers = new CaseInsensitiveMultiMap();
        headers.add("content-type", "application/json");
        headers.add("content-length", Integer.toString(body.length()));

        new YokeTester(yoke).request("POST", "/api", headers, body, new Handler<Response>() {
            @Override
            public void handle(Response resp) {
                assertEquals(400, resp.getStatusCode());
View Full Code Here


                assertEquals("DELETE", request.method());
                request.response().end();
            }
        });

        Buffer body = new Buffer("_method=delete");

        MultiMap headers = new CaseInsensitiveMultiMap();
        headers.add("content-type", "application/x-www-form-urlencoded");
        headers.add("content-length", Integer.toString(body.length()));

        new YokeTester(yoke).request("POST", "/upload", headers, body, new Handler<Response>() {
            @Override
            public void handle(Response resp) {
                assertEquals(200, resp.getStatusCode());
View Full Code Here

                assertEquals("DELETE", request.method());
                request.response().end();
            }
        });

        Buffer body = new Buffer(json.encode());

        MultiMap headers = new CaseInsensitiveMultiMap();
        headers.add("content-type", "application/json");
        headers.add("content-length", Integer.toString(body.length()));

        new YokeTester(yoke).request("POST", "/upload", headers, body, new Handler<Response>() {
            @Override
            public void handle(Response resp) {
                assertEquals(200, resp.getStatusCode());
View Full Code Here

                if (asyncResult.failed()) {
                    next.handle(new YokeAsyncResult<Buffer>(asyncResult.cause()));
                } else {
                    try {
                        CompiledTemplate template = compile(prefix + filename, asyncResult.result());
                        next.handle(new YokeAsyncResult<>(new Buffer((String) TemplateRuntime.execute(template, context))));
                    } catch (IOException ex) {
                        next.handle(new YokeAsyncResult<Buffer>(ex));
                    }
                }
            }
View Full Code Here

                // real compile
                template = config.getTemplate(filename);
                putTemplateToCache(resolve(filename), template);
            }

            next.handle(new YokeAsyncResult<>(new Buffer(config.renderTemplate(template, context))));
        } catch (Exception ex) {
            ex.printStackTrace();
            next.handle(new YokeAsyncResult<Buffer>(ex));
        }
    }
View Full Code Here

            else {
                startIndex = -1;
            }
        }

        return new Buffer(buf.toString());
    }
View Full Code Here

        if (fileSystem.existsSync(filename)) {
            FileProps fileProps = fileSystem.propsSync(filename);
            final Date lastModified = fileProps.lastModifiedTime();
            // load from the file system
            Buffer content = fileSystem.readFileSync(filename);
            // cache the result
            cache.put(filename, new LRUCache.CacheEntry<String, T>(lastModified, content.toString(contentEncoding())));
        }
    }
View Full Code Here

            public void handle(AsyncResult<String> asyncResult) {
                if (asyncResult.failed()) {
                    next.handle(new YokeAsyncResult<Buffer>(asyncResult.cause()));
                } else {
                    try {
                        Buffer result = internalRender(compile(prefix + filename, asyncResult.result()), context);
                        next.handle(new YokeAsyncResult<>(result));
                    } catch (CompilationFailedException | ClassNotFoundException | MissingPropertyException | IOException ex) {
                        next.handle(new YokeAsyncResult<Buffer>(ex));
                    }
                }
View Full Code Here

            public void close() throws IOException {
                // noop
            }
        });

        return new Buffer(buffer.toString());
    }
View Full Code Here

                if (!fs.existsSync(resourceName)) {
                    return null;
                }

                final Buffer buffer = fs.readFileSync(resourceName);

                return new InputStream() {
                    int pos = 0;

                    @Override
                    public int read() throws IOException {
                        if (pos == buffer.length()) {
                            return -1;
                        }

                        return buffer.getByte(pos++);
                    }
                };
            }
        });
View Full Code Here

TOP

Related Classes of org.vertx.java.core.buffer.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.