Search in sources :

Example 66 with ResteasyClient

use of org.jboss.resteasy.client.jaxrs.ResteasyClient in project keycloak by keycloak.

the class LoginPageTest method realmLocalizationMessagesAreNotCachedWithinTheTheme.

// KEYCLOAK-18590
@Test
public void realmLocalizationMessagesAreNotCachedWithinTheTheme() throws IOException {
    final String locale = Locale.ENGLISH.toLanguageTag();
    final String realmLocalizationMessageKey = "loginAccountTitle";
    final String realmLocalizationMessageValue = "Localization Test";
    try (CloseableHttpClient httpClient = (CloseableHttpClient) new HttpClientBuilder().build()) {
        ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
        testRealm().localization().saveRealmLocalizationText(locale, realmLocalizationMessageKey, realmLocalizationMessageValue);
        ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
        loginPage.open();
        try (Response responseWithLocalization = client.target(driver.getCurrentUrl()).request().acceptLanguage(locale).get()) {
            assertThat(responseWithLocalization.readEntity(String.class), Matchers.containsString(realmLocalizationMessageValue));
            testRealm().localization().deleteRealmLocalizationText(locale, realmLocalizationMessageKey);
            loginPage.open();
            try (Response responseWithoutLocalization = client.target(driver.getCurrentUrl()).request().acceptLanguage(locale).get()) {
                assertThat(responseWithoutLocalization.readEntity(String.class), Matchers.not(Matchers.containsString(realmLocalizationMessageValue)));
            }
        }
        client.close();
    }
}
Also used : Response(javax.ws.rs.core.Response) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ApacheHttpClient4Engine(org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine) HttpClientBuilder(org.keycloak.adapters.HttpClientBuilder) Test(org.junit.Test)

Aggregations

ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)66 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)42 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)28 Response (javax.ws.rs.core.Response)17 Test (org.junit.Test)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)10 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)8 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)7 ServicesInterface (com.baeldung.client.ServicesInterface)6 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)6 ProcessingException (javax.ws.rs.ProcessingException)5 IOException (java.io.IOException)4 Map (java.util.Map)4 WebTarget (javax.ws.rs.client.WebTarget)4 RequestConfig (org.apache.http.client.config.RequestConfig)4 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)4 ClientHttpEngine (org.jboss.resteasy.client.jaxrs.ClientHttpEngine)4 Locale (java.util.Locale)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 ApacheHttpClient4Resource (org.jboss.additional.testsuite.jdkall.present.jaxrs.client.resource.ApacheHttpClient4Resource)3