Search in sources :

Example 6 with StringBeanEntityProvider

use of ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientConfiguredTest.

/*
   * @testName: clientConfiguredTest
   * 
   * @assertion_ids: JAXRS:SPEC:73;
   * 
   * @test_Strategy: This interface supports configuration of: Features,
   * Properties, Providers
   */
@Test
public void clientConfiguredTest() throws Fault {
    Client client = ClientBuilder.newClient();
    client.register(new StringBeanEntityProvider());
    checkConfig(client, 1 + registeredProviderCnt, registeredPropertyCnt);
    client = ClientBuilder.newClient();
    client.property(getClass().getName(), getClass().getName());
    checkConfig(client, registeredProviderCnt, 1 + registeredPropertyCnt);
    client = ClientBuilder.newClient();
    client.register(new Feature() {

        @Override
        public boolean configure(FeatureContext context) {
            return true;
        }
    });
    checkConfig(client, 1 + registeredProviderCnt, registeredPropertyCnt);
}
Also used : JAXRSCommonClient(ee.jakarta.tck.ws.rs.common.JAXRSCommonClient) Client(jakarta.ws.rs.client.Client) StringBeanEntityProvider(ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider) Feature(jakarta.ws.rs.core.Feature) FeatureContext(jakarta.ws.rs.core.FeatureContext) Test(org.junit.jupiter.api.Test)

Example 7 with StringBeanEntityProvider

use of ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method closeOnClientRegisterObjectWithMapTest.

/*
   * @testName: closeOnClientRegisterObjectWithMapTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:409;
   * 
   * @test_Strategy: Close client instance and all it's associated resources.
   * Subsequent calls have no effect and are ignored. Once the client is closed,
   * invoking any other method on the client instance would result in an
   * IllegalStateException being thrown. Calling this method effectively
   * invalidates all WebTarget resource targets produced by the client instance.
   * Invoking any method on such targets once the client is closed would result
   * in an IllegalStateException being thrown.
   */
@Test
public void closeOnClientRegisterObjectWithMapTest() throws Fault {
    client.close();
    Map<Class<?>, Integer> contracts = new HashMap<Class<?>, Integer>();
    contracts.put(MessageBodyReader.class, 100);
    assertException(IllegalStateException.class, client, "register", new StringBeanEntityProvider(), contracts);
}
Also used : HashMap(java.util.HashMap) StringBeanEntityProvider(ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider) Test(org.junit.jupiter.api.Test)

Example 8 with StringBeanEntityProvider

use of ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method closeOnWebTargetRegisterObjectWithMapTest.

/*
   * @testName: closeOnWebTargetRegisterObjectWithMapTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:409;
   * 
   * @test_Strategy: Close client instance and all it's associated resources.
   * Subsequent calls have no effect and are ignored. Once the client is closed,
   * invoking any other method on the client instance would result in an
   * IllegalStateException being thrown. Calling this method effectively
   * invalidates all WebTarget resource targets produced by the client instance.
   * Invoking any method on such targets once the client is closed would result
   * in an IllegalStateException being thrown.
   */
@Test
public void closeOnWebTargetRegisterObjectWithMapTest() throws Fault {
    client.close();
    Map<Class<?>, Integer> contracts = new HashMap<Class<?>, Integer>();
    contracts.put(MessageBodyReader.class, 100);
    assertException(IllegalStateException.class, target, "register", new StringBeanEntityProvider(), contracts);
}
Also used : HashMap(java.util.HashMap) StringBeanEntityProvider(ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider) Test(org.junit.jupiter.api.Test)

Example 9 with StringBeanEntityProvider

use of ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method closeOnClientRegisterObjectWithContractsTest.

/*
   * @testName: closeOnClientRegisterObjectWithContractsTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:409;
   * 
   * @test_Strategy: Close client instance and all it's associated resources.
   * Subsequent calls have no effect and are ignored. Once the client is closed,
   * invoking any other method on the client instance would result in an
   * IllegalStateException being thrown. Calling this method effectively
   * invalidates all WebTarget resource targets produced by the client instance.
   * Invoking any method on such targets once the client is closed would result
   * in an IllegalStateException being thrown.
   */
@Test
public void closeOnClientRegisterObjectWithContractsTest() throws Fault {
    client.close();
    assertException(IllegalStateException.class, client, "register", new StringBeanEntityProvider(), new Class[] { MessageBodyReader.class });
}
Also used : StringBeanEntityProvider(ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider) Test(org.junit.jupiter.api.Test)

Example 10 with StringBeanEntityProvider

use of ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method deepCopyConfigWebTargetLevelTest.

/*
   * @testName: deepCopyConfigWebTargetLevelTest
   * 
   * @assertion_ids: JAXRS:SPEC:68; JAXRS:SPEC:72; JAXRS:JAVADOC:988;
   * 
   * @test_Strategy: Note that changes to hello's configuration do not affect
   * base, i.e. configuration inheritance requires performing a deep copy of the
   * configuration.
   * 
   * The following Client API types are configurable: Client, Invocation,
   * Invocation.Builder and WebTarget.
   * 
   * Get access to the underlying Configuration configuration.
   */
@Test
public void deepCopyConfigWebTargetLevelTest() throws Fault {
    Client client = ClientBuilder.newClient();
    Configuration config = client.getConfiguration();
    int registeredInstances = config.getInstances().size();
    // WebTarget level inheritance
    WebTarget target1 = client.target("");
    WebTarget target2 = client.target("");
    target1.register(new StringBeanEntityProvider());
    config = target2.getConfiguration();
    assertTrue(config.getInstances().size() == registeredInstances, "configuration() does not perform deep copy");
}
Also used : Configuration(jakarta.ws.rs.core.Configuration) WebTarget(jakarta.ws.rs.client.WebTarget) JAXRSCommonClient(ee.jakarta.tck.ws.rs.common.JAXRSCommonClient) Client(jakarta.ws.rs.client.Client) StringBeanEntityProvider(ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider) Test(org.junit.jupiter.api.Test)

Aggregations

StringBeanEntityProvider (ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider)10 Test (org.junit.jupiter.api.Test)10 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)2 Client (jakarta.ws.rs.client.Client)2 HashMap (java.util.HashMap)2 WebTarget (jakarta.ws.rs.client.WebTarget)1 Configuration (jakarta.ws.rs.core.Configuration)1 Feature (jakarta.ws.rs.core.Feature)1 FeatureContext (jakarta.ws.rs.core.FeatureContext)1