Search in sources :

Example 1 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project camel by apache.

the class CxfRsSpringConsumerTest method testInvokeCxfRsConsumer.

@Test
public void testInvokeCxfRsConsumer() throws Exception {
    String address = "http://localhost:" + port1 + "/CxfRsSpringConsumerInvokeService/customerservice/customers/123";
    WebClient wc = WebClient.create(address);
    Customer c = wc.accept("application/json").get(Customer.class);
    assertEquals(246L, c.getId());
}
Also used : Customer(org.apache.camel.component.cxf.jaxrs.testbean.Customer) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 2 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project fastjson by alibaba.

the class FastJsonProviderTest method test0.

@Test
public void test0() throws Exception {
    JSONObject json = new JSONObject();
    json.put("id", 123);
    json.put("name", "哈哈哈");
    WebClient client = WebClient.create(REST_SERVICE_URL);
    Response response = client.path("/fastjson/test1").accept("application/json").type("application/json; charset=UTF-8").post(json.toJSONString());
    System.out.println(response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(com.alibaba.fastjson.JSONObject) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 3 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project fastjson by alibaba.

the class FastJsonProviderTest method test2.

@Test
public void test2() throws Exception {
    String jsonStr = "[{\"name\":\"p1\",\"sonList\":[{\"name\":\"s1\"}]},{\"name\":\"p2\",\"sonList\":[{\"name\":\"s2\"},{\"name\":\"s3\"}]}]";
    WebClient client = WebClient.create(REST_SERVICE_URL);
    Response response = client.path("/fastjson/test2").accept("application/json").type("application/json; charset=UTF-8").post(jsonStr);
    System.out.println(response.readEntity(String.class));
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 4 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestRestServiceProxyAuthentication method test005getUserSelfByProxyHead.

/**
	 * even though head is a superuser, it is not allowed for service application to switch to this user,
	 * therefore head is not allowed to read user administrator using inpersonation
	 */
@Test
public void test005getUserSelfByProxyHead() {
    final String TEST_NAME = "test005getUserSelfByProxyHead";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_HEAD_OID);
    client.path("/self");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 403);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertFailedProxyLogin(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 5 with WebClient

use of org.apache.cxf.jaxrs.client.WebClient in project midpoint by Evolveum.

the class TestRestServiceProxyAuthentication method test001getUserSelfBySomebody.

@Test
public void test001getUserSelfBySomebody() {
    final String TEST_NAME = "test001getUserSelfBySomebody";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient(USER_SOMEBODY_OID);
    client.path("/self/");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.get();
    TestUtil.displayThen(TEST_NAME);
    assertStatus(response, 200);
    UserType userType = response.readEntity(UserType.class);
    assertNotNull("Returned entity in body must not be null.", userType);
    LOGGER.info("Returned entity: {}", userType.asPrismObject().debugDump());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

WebClient (org.apache.cxf.jaxrs.client.WebClient)107 Response (javax.ws.rs.core.Response)82 Test (org.testng.annotations.Test)46 Test (org.junit.Test)35 SourceResponse (ddf.catalog.operation.SourceResponse)16 Matchers.containsString (org.hamcrest.Matchers.containsString)14 ResourceResponse (ddf.catalog.operation.ResourceResponse)12 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 SecureCxfClientFactory (org.codice.ddf.cxf.SecureCxfClientFactory)11 QueryImpl (ddf.catalog.operation.impl.QueryImpl)10 Filter (org.opengis.filter.Filter)10 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)9 Metacard (ddf.catalog.data.Metacard)8 Subject (ddf.security.Subject)8 InputStream (java.io.InputStream)7 Result (ddf.catalog.data.Result)5 IOException (java.io.IOException)5 MalformedURLException (java.net.MalformedURLException)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)4