Search in sources :

Example 1 with Feature

use of jakarta.ws.rs.core.Feature in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method registerFeatureInstanceReturningFalseTest.

/*
     * @testName: registerFeatureInstanceReturningFalseTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:758;
     * 
     * @test_Strategy: Register a feature. In case the registered provider is a
     * client-side Feature feature, this object instantiates the feature and invokes
     * the Feature#configure(FeatureContext) method and lets the feature update it's
     * internal configuration state.
     */
@Test
public void registerFeatureInstanceReturningFalseTest() throws Fault {
    final Feature feature = new FeatureReturningFalse();
    Assertable assertable = new SingleCheckAssertable() {

        @Override
        protected void check(Configurable<?> configurable) throws Fault {
            assertSizeAndLog(configurable);
        }

        void assertSizeAndLog(Configurable<?> config) throws Fault {
            int cnt = config.getConfiguration().getInstances().size();
            assertEqualsInt(cnt, 1 + registeredInstancesCnt, "unexpected number of registered instances found:", cnt, getLocation());
            logMsg("Found", cnt, "features");
        }
    };
    Object[] features = new Object[] { feature, feature };
    checkConfig(assertable, features);
}
Also used : Configurable(jakarta.ws.rs.core.Configurable) Feature(jakarta.ws.rs.core.Feature) Test(org.junit.jupiter.api.Test)

Example 2 with Feature

use of jakarta.ws.rs.core.Feature 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)

Aggregations

Feature (jakarta.ws.rs.core.Feature)2 Test (org.junit.jupiter.api.Test)2 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)1 StringBeanEntityProvider (ee.jakarta.tck.ws.rs.common.provider.StringBeanEntityProvider)1 Client (jakarta.ws.rs.client.Client)1 Configurable (jakarta.ws.rs.core.Configurable)1 FeatureContext (jakarta.ws.rs.core.FeatureContext)1