Search in sources :

Example 1 with CallableProvider

use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method isRegisteredProviderRegisteredInstanceTest.

/*
     * @testName: isRegisteredProviderRegisteredInstanceTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1001; JAXRS:JAVADOC:1002;
     * 
     * @test_Strategy: Check if a particular JAX-RS component instance (such as
     * providers or features) has been previously registered in the runtime
     * configuration context.
     * 
     * Method returns true only in case an instance equal to the component instance
     * is already present among the components previously registered in the
     * configuration context.
     */
@Test
public void isRegisteredProviderRegisteredInstanceTest() throws Fault {
    Assertable assertable = new Assertable() {

        CallableProvider1 p1 = new CallableProvider1();

        CallableProvider2 p2 = new CallableProvider2();

        @Override
        public void check1OnClient(Client client) throws Fault {
            client.register(p1);
            assertSizeAndLog(client.getConfiguration(), 1);
        }

        @Override
        public void check2OnTarget(WebTarget target) throws Fault {
            target.register(p2);
            assertSizeAndLog(target.getConfiguration(), 2);
        }

        void assertSizeAndLog(Configuration config, int size) throws Fault {
            assertFalse(config.isRegistered(CallableProvider.class), "CallableProvider is unexpectedly registered");
            switch(size) {
                case 2:
                    assertFalse(config.isRegistered(new CallableProvider2()), "CallableProvider2 is registered " + getLocation());
                    assertTrue(config.isRegistered(p2), "CallableProvider2.class is NOT registered " + getLocation());
                    assertTrue(config.isRegistered(CallableProvider2.class), "CallableProvider2.class is NOT registered " + getLocation());
                    logMsg("Found registered CallableProvider2 as expected", getLocation());
                case 1:
                    assertFalse(config.isRegistered(new CallableProvider1()), "CallableProvider1 is registered " + getLocation());
                    assertTrue(config.isRegistered(p1), "CallableProvider1.class is NOT registered " + getLocation());
                    assertTrue(config.isRegistered(CallableProvider1.class), "CallableProvider1.class is NOT registered " + getLocation());
                    logMsg("Found registered CallableProvider1 as expected", getLocation());
            }
        }
    };
    checkConfigWithProperties(assertable);
}
Also used : Configuration(jakarta.ws.rs.core.Configuration) CallableProvider(ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider) Assertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable) SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) WebTarget(jakarta.ws.rs.client.WebTarget) JAXRSCommonClient(ee.jakarta.tck.ws.rs.common.JAXRSCommonClient) Client(jakarta.ws.rs.client.Client) Test(org.junit.jupiter.api.Test)

Example 2 with CallableProvider

use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method getInstancesIsImmutableTest.

/*
     * @testName: getInstancesIsImmutableTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:994; JAXRS:JAVADOC:758;
     * 
     * @test_Strategy: Get the immutable set of registered provider instances to be
     * utilized by the configurable instance.
     * 
     * Register a provider ("singleton") instance
     */
@Test
public void getInstancesIsImmutableTest() throws Fault {
    Assertable assertable = new SingleCheckAssertable() {

        @Override
        protected void check(Configurable<?> configurable) throws Fault {
            registerNewProviderInstance(configurable.getConfiguration());
            assertSizeAndLog(configurable.getConfiguration(), 0);
        }

        void assertSizeAndLog(Configuration config, int count) throws Fault {
            assertTrue(config.getClasses().size() == count + registeredClassesCnt, "config.getClasses() return unexcepted size " + getLocation() + " : " + config.getClasses().size());
            logMsg("Found", config.getClasses().size(), "providers");
        }

        void registerNewProviderInstance(Configuration config) {
            try {
                config.getInstances().add(new CallableProvider());
            } catch (Exception e) {
            // can throw exception or do nothing
            // when adding to this immutable set
            // or it can be a new hard copied set
            }
        }
    };
    checkConfigWithProperties(assertable);
}
Also used : SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) Configuration(jakarta.ws.rs.core.Configuration) CallableProvider(ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider) Assertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable) SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) Configurable(jakarta.ws.rs.core.Configurable) Test(org.junit.jupiter.api.Test)

Example 3 with CallableProvider

use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method isRegisteredProviderRegisteredClassTest.

/*
     * @testName: isRegisteredProviderRegisteredClassTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1001; JAXRS:JAVADOC:1002;
     * 
     * @test_Strategy: Check if a particular JAX-RS component instance (such as
     * providers or features) has been previously registered in the runtime
     * configuration context.
     */
@Test
public void isRegisteredProviderRegisteredClassTest() throws Fault {
    Assertable assertable = new Assertable() {

        @Override
        public void check1OnClient(Client client) throws Fault {
            client.register(CallableProvider1.class);
            assertSizeAndLog(client.getConfiguration(), 1);
        }

        @Override
        public void check2OnTarget(WebTarget target) throws Fault {
            target.register(CallableProvider2.class);
            assertSizeAndLog(target.getConfiguration(), 2);
        }

        void assertSizeAndLog(Configuration config, int size) throws Fault {
            assertFalse(config.isRegistered(new CallableProvider()), "CallableProvider is unexpectedly registered");
            assertFalse(config.isRegistered(CallableProvider.class), "CallableProvider is unexpectedly registered");
            switch(size) {
                case 2:
                    assertFalse(config.isRegistered(new CallableProvider2()), "CallableProvider2 is registered " + getLocation());
                    assertTrue(config.isRegistered(CallableProvider2.class), "CallableProvider2.class is NOT registered " + getLocation());
                    logMsg("Found registered CallableProvider2 as expected", getLocation());
                case 1:
                    assertFalse(config.isRegistered(new CallableProvider1()), "CallableProvider1 is registered " + getLocation());
                    assertTrue(config.isRegistered(CallableProvider1.class), "CallableProvider1.class is NOT registered " + getLocation());
                    logMsg("Found registered CallableProvider1 as expected", getLocation());
            }
        }
    };
    checkConfigWithProperties(assertable);
}
Also used : Configuration(jakarta.ws.rs.core.Configuration) CallableProvider(ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider) Assertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable) SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) WebTarget(jakarta.ws.rs.client.WebTarget) JAXRSCommonClient(ee.jakarta.tck.ws.rs.common.JAXRSCommonClient) Client(jakarta.ws.rs.client.Client) Test(org.junit.jupiter.api.Test)

Aggregations

Assertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable)3 CallableProvider (ee.jakarta.tck.ws.rs.api.rs.core.configurable.CallableProvider)3 SingleCheckAssertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable)3 Configuration (jakarta.ws.rs.core.Configuration)3 Test (org.junit.jupiter.api.Test)3 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)2 Client (jakarta.ws.rs.client.Client)2 WebTarget (jakarta.ws.rs.client.WebTarget)2 Configurable (jakarta.ws.rs.core.Configurable)1