Package javax.ws.rs.core

Examples of javax.ws.rs.core.Form.param()


    }

    protected Response executeGrantAccessTokenRequest(WebTarget grantTarget) {
        String header = BasicAuthHelper.createHeader("test-app", "password");
        Form form = new Form();
        form.param("username", "test-user@localhost")
                .param("password", "password");
        return grantTarget.request()
                .header(HttpHeaders.AUTHORIZATION, header)
                .post(Entity.form(form));
    }
View Full Code Here


        UriBuilder builder = UriBuilder.fromUri(org.keycloak.testsuite.Constants.AUTH_SERVER_ROOT);
        URI uri = OpenIDConnectService.grantAccessTokenUrl(builder).build("demo");
        WebTarget target = client.target(uri);
        String header = BasicAuthHelper.createHeader("customer-portal", "password");
        Form form = new Form();
        form.param("username", "monkey@redhat.com")
            .param("password", "password");
        Response response = target.request()
                .header(HttpHeaders.AUTHORIZATION, header)
                .post(Entity.form(form));
        Assert.assertEquals(400, response.getStatus());
View Full Code Here

            String actionUrl = matcher.group(1);
            if (!actionUrl.startsWith("http")) {
                actionUrl = UriBuilder.fromUri(actionUrl).scheme("http").host("localhost").port(8081).build().toString();
            }
            Form form = new Form();
            form.param("username", "test-user@localhost");
            form.param("password", "password");
            Response response = client.target(actionUrl).request().post(Entity.form(form));
            URI uri = null;
            Assert.assertEquals(302, response.getStatus());
            uri = response.getLocation();
View Full Code Here

            if (!actionUrl.startsWith("http")) {
                actionUrl = UriBuilder.fromUri(actionUrl).scheme("http").host("localhost").port(8081).build().toString();
            }
            Form form = new Form();
            form.param("username", "test-user@localhost");
            form.param("password", "password");
            Response response = client.target(actionUrl).request().post(Entity.form(form));
            URI uri = null;
            Assert.assertEquals(302, response.getStatus());
            uri = response.getLocation();
            for (String header : response.getHeaders().keySet()) {
View Full Code Here

            Assert.assertNotNull(uri);
            String code = getCode(uri);
            Assert.assertNotNull(code);

            form = new Form();
            form.param(OAuth2Constants.GRANT_TYPE, grantType)
                    .param(OAuth2Constants.CODE, code)
                    .param(OAuth2Constants.REDIRECT_URI, redirectUri);

            String authorization = BasicAuthHelper.createHeader(clientId, "password");
View Full Code Here

        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Form form = new Form();
        form.param("name", "CXF Rocks").param("id", Long.toString(139L));
        Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
        assertEquals(139, b.getId());
        assertEquals("CXF Rocks", b.getName());
    }
   
View Full Code Here

       
        String baseAddress = "http://localhost:" + PORT
            + "/test/services/rest/bookstore/books/679/subresource3";
        WebClient wc = WebClient.create(baseAddress);
        Form f = new Form(new MetadataMap<String, String>());
        f.param("id", "679").param("name", "CXF in Action - ")
            .param("name", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form(f).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
View Full Code Here

        /*
         * Add parameters as request body (form).
         */
        Form form = new Form();
        form.param(PARAM_NAME_EMPLOYEE_NAME, EMPLOYEE_NAME);
        form.param(PARAM_NAME_DATE_OF_BIRTH, EMPLOYEE_DATE_OF_BIRTH.format(DateTimeFormatter.ISO_LOCAL_DATE));

        // e.g. http://localhost:8081/tes/resources/employee/create?name=Darth%20Vader
        final String stringResponse = resource.path("create").request(MediaType.APPLICATION_JSON)
                .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class);
View Full Code Here

        /*
         * Add parameters as request body (form).
         */
        Form form = new Form();
        form.param(PARAM_NAME_EMPLOYEE_NAME, EMPLOYEE_NAME);
        form.param(PARAM_NAME_DATE_OF_BIRTH, EMPLOYEE_DATE_OF_BIRTH.format(DateTimeFormatter.ISO_LOCAL_DATE));

        // e.g. http://localhost:8081/tes/resources/employee/create?name=Darth%20Vader
        final String stringResponse = resource.path("create").request(MediaType.APPLICATION_JSON)
                .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class);

View Full Code Here

        /*
         * Add parameters as request body (form).
         */
        Form form = new Form();
        form.param(PARAM_NAME_EMPLOYEE_NAME, EMPLOYEE_NAME);
        form.param(PARAM_NAME_DATE_OF_BIRTH, EMPLOYEE_DATE_OF_BIRTH.toString());

        // e.g. http://localhost:8081/tes/resources/employee/create?name=Darth%20Vader
        final EmployeeEntity employeeResponse = resource.path("create").request(MediaType.APPLICATION_JSON)
                .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), EmployeeEntity.class);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.