Package org.apache.pivot.web

Examples of org.apache.pivot.web.BasicAuthentication


    final static int PORT = 8080;
    final static boolean SECURE = false;

    @Test
    public void basicTest() throws SerializationException {
        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        TaskGroup queryGroup = new TaskGroup();

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);
        queryGroup.add(getQuery);

        // POST
        final PostQuery postQuery = new PostQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(postQuery);
        postQuery.setValue(JSONSerializer.parseList("[1, 2, 3]"));
        queryGroup.add(postQuery);

        // PUT
        final PutQuery putQuery = new PutQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(putQuery);
        putQuery.setValue(JSONSerializer.parseMap("{a:100, b:200, c:300}"));
        queryGroup.add(putQuery);

        // POST
        final DeleteQuery deleteQuery = new DeleteQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(deleteQuery);
        queryGroup.add(deleteQuery);

        queryGroup.execute(new TaskListener<Void>() {
            @SuppressWarnings("unchecked")
            @Override
View Full Code Here

TOP

Related Classes of org.apache.pivot.web.BasicAuthentication

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.