Search in sources :

Example 6 with SingleCheckAssertable

use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable 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 7 with SingleCheckAssertable

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

the class JAXRSClientIT method getContractsIsNeverNullTest.

/*
     * @testName: getContractsIsNeverNullTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:993;
     * 
     * @test_Strategy: Get the extension contract registration information for a
     * component of a given class. Method does not return null.
     */
@Test
public void getContractsIsNeverNullTest() throws Fault {
    Assertable assertable = new SingleCheckAssertable() {

        void assertNotNullAndLog(Configurable<?> config) throws Fault {
            Map<Class<?>, Integer> map = config.getConfiguration().getContracts(MessageBodyReader.class);
            assertNotNull(map, "getContracts is null", getLocation());
            logMsg("#getContracts() is not null as expected", getLocation());
        }

        @Override
        protected void check(Configurable<?> configurable) throws Fault {
            assertNotNullAndLog(configurable);
        }
    };
    checkConfigWithProperties(assertable);
}
Also used : SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) 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 8 with SingleCheckAssertable

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

the class JAXRSClientIT method getPropertyIsNullTest.

/*
     * @testName: getPropertyIsNullTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:996; JAXRS:JAVADOC:758;
     * 
     * @test_Strategy: null if the property with such name is not configured.
     */
@Test
public void getPropertyIsNullTest() throws Fault {
    Assertable assertable = new SingleCheckAssertable() {

        void assertPropertyIsNull(Configurable<?> config) throws Fault {
            assertTrue(config.getConfiguration().getProperty("property88") == null, "#getProperty('nonexisting') != null " + getLocation());
            logMsg("#getProperty('nonexisting') is null as expected");
        }

        @Override
        protected void check(Configurable<?> configurable) throws Fault {
            assertPropertyIsNull(configurable);
        }
    };
    checkConfigWithProperties(assertable);
}
Also used : SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) 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 9 with SingleCheckAssertable

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

the class JAXRSClientIT method getAssertableWithRegisteredProviderClassesOnConfigurable.

// ///////////////////////////////////////////////////////////////////////
private Assertable getAssertableWithRegisteredProviderClassesOnConfigurable(final int configurableIndex, final int numberOfRegisteredClasses) {
    Assertable assertable = new SingleCheckAssertable() {

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

        void assertSizeAndLog(Configurable<?> config) throws Fault {
            int size = config.getConfiguration().getClasses().size();
            int shouldBe = getLocationIndex() >= configurableIndex ? numberOfRegisteredClasses : 0;
            shouldBe += registeredClassesCnt;
            assertEqualsInt(size, shouldBe, "unexpected number of registered classes found:", size, getLocation());
            logMsg("Found", size, "provider(s) as expected");
        }
    };
    return assertable;
}
Also used : SingleCheckAssertable(ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable) 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)

Aggregations

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