Search in sources :

Example 1 with Registrar

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

the class JAXRSClientIT method getContractsTest.

/*
     * @testName: getContractsTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:993;
     * 
     * @test_Strategy: Get the extension contract registration information for a
     * component of a given class.
     */
@Test
public void getContractsTest() throws Fault {
    final int priority = 124;
    Assertable assertable = new SingleCheckAssertable() {

        void assertNotNullAndLog(Configurable<?> config) throws Fault {
            Map<Class<?>, Integer> map = config.getConfiguration().getContracts(CallableProvider.class);
            assertEqualsInt(1, map.size(), "Unexpected contract size", map.size());
            Class<?> contract = map.entrySet().iterator().next().getKey();
            assertEquals(MessageBodyReader.class, contract, "Unexpected contract", contract, getLocation());
            logMsg("#getContracts() is", contract, "as expected", getLocation());
            int p = map.get(contract);
            assertEqualsInt(priority, p, "Unexpected priority", p);
            logMsg("Found expected priority", p);
        }

        @Override
        protected void check(Configurable<?> configurable) throws Fault {
            assertNotNullAndLog(configurable);
        }
    };
    Registrar registrar = new Registrar() {

        @Override
        public void register(Configurable<?> config, Object registerable) {
            Map<Class<?>, Integer> map = new HashMap<Class<?>, Integer>();
            map.put(MessageBodyReader.class, priority);
            config.register(CallableProvider.class, map);
        }
    };
    checkConfigWithProperties(registrar, assertable);
}
Also used : SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) HashMap(java.util.HashMap) Registrar(ee.jakarta.tck.ws.rs.api.rs.core.configurable.Registrar) 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)

Aggregations

Assertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable)1 Registrar (ee.jakarta.tck.ws.rs.api.rs.core.configurable.Registrar)1 SingleCheckAssertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable)1 Configurable (jakarta.ws.rs.core.Configurable)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1