Search in sources :

Example 11 with Variant

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

the class JAXRSClientIT method constructorTest2.

/*
     * @testName: constructorTest2
     * 
     * @assertion_ids: JAXRS:JAVADOC:255; JAXRS:JAVADOC:256; JAXRS:JAVADOC:257;
     * JAXRS:JAVADOC:261; JAXRS:JAVADOC:262;
     * 
     * @test_Strategy: Create an MediaType instance using MediaType(String,
     * String)
     */
@Test
public void constructorTest2() throws Fault {
    String type = "application";
    String subtype = "atom+xml";
    String encoding = "";
    Locale lang = null;
    MediaType mt2 = new MediaType(type, subtype);
    Variant vt = new Variant(mt2, lang, encoding);
    verifyVariant(vt, type, subtype, lang, encoding);
}
Also used : Locale(java.util.Locale) Variant(jakarta.ws.rs.core.Variant) MediaType(jakarta.ws.rs.core.MediaType) Test(org.junit.jupiter.api.Test)

Example 12 with Variant

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

the class JAXRSClientIT method equalsTest2.

/*
     * @testName: equalsTest2
     * 
     * @assertion_ids: JAXRS:JAVADOC:262; JAXRS:JAVADOC:254; JAXRS:JAVADOC:258;
     * 
     * @test_Strategy: Create two Variants with different MediaType. Verify
     * Variant.equals and Variant.hasCode methods work properly using those two
     * Variant objects.
     */
@Test
public void equalsTest2() throws Fault {
    StringBuffer sb = new StringBuffer();
    Boolean pass = true;
    String type = "application";
    String subtype = "atom+xml";
    String subtype1 = "xml";
    String encoding = "";
    Locale lang = null;
    MediaType mt1 = new MediaType(type, subtype);
    MediaType mt2 = new MediaType(type, subtype1);
    Variant vt1 = new Variant(mt1, lang, encoding);
    Variant vt2 = new Variant(mt2, lang, encoding);
    if (vt1.equals(vt2)) {
        pass = false;
        sb.append("Equals Test2 Failed" + newline);
    }
    if (vt1.hashCode() == vt2.hashCode()) {
        sb.append("hasCode Test2 Failed: vt1.hashCode()=" + vt1.hashCode() + newline);
        sb.append("                      vt2.hashCode()=" + vt2.hashCode() + newline);
        pass = false;
    }
    assertTrue(pass, "At least one assertion failed: " + sb.toString());
}
Also used : Locale(java.util.Locale) Variant(jakarta.ws.rs.core.Variant) MediaType(jakarta.ws.rs.core.MediaType) Test(org.junit.jupiter.api.Test)

Example 13 with Variant

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

the class JAXRSClientIT method constructorTest1.

/* Run test */
/*
     * @testName: constructorTest1
     * 
     * @assertion_ids: JAXRS:JAVADOC:255; JAXRS:JAVADOC:256; JAXRS:JAVADOC:257;
     * JAXRS:JAVADOC:261; JAXRS:JAVADOC:262;
     * 
     * @test_Strategy: Create an MediaType instance using MediaType()
     */
@Test
public void constructorTest1() throws Fault {
    String type = jakarta.ws.rs.core.MediaType.MEDIA_TYPE_WILDCARD;
    String subtype = jakarta.ws.rs.core.MediaType.MEDIA_TYPE_WILDCARD;
    String encoding = "ISO8859-15";
    Locale lang = new Locale("en", "US");
    MediaType mt1 = new MediaType();
    Variant vt = new Variant(mt1, lang, encoding);
    verifyVariant(vt, type, subtype, lang, encoding);
}
Also used : Locale(java.util.Locale) Variant(jakarta.ws.rs.core.Variant) MediaType(jakarta.ws.rs.core.MediaType) Test(org.junit.jupiter.api.Test)

Example 14 with Variant

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

the class JAXRSClientIT method constructorMediaStringStringStringTest.

/*
     * @testName: constructorMediaStringStringStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:901;
     * 
     * @test_Strategy: Create a Variant(MediaType, String, String, String)
     */
@Test
public void constructorMediaStringStringStringTest() throws Fault {
    Variant vt = null;
    String[] encodings = { null, "CP1250", "UTF8", "ISO8859-2" };
    Locale[] langs = { null, Locale.CANADA, Locale.FRENCH };
    for (String encoding : encodings) for (Locale lang : langs) {
        vt = new Variant(MediaType.APPLICATION_XHTML_XML_TYPE, lang == null ? null : lang.getLanguage(), lang == null ? null : lang.getCountry(), encoding);
        verifyVariant(vt, MediaType.APPLICATION_XHTML_XML_TYPE.getType(), MediaType.APPLICATION_XHTML_XML_TYPE.getSubtype(), lang, encoding);
    }
}
Also used : Variant(jakarta.ws.rs.core.Variant) Locale(java.util.Locale) Test(org.junit.jupiter.api.Test)

Example 15 with Variant

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

the class JAXRSClientIT method constructorMediaStringStringTest.

/*
     * @testName: constructorMediaStringStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:900;
     * 
     * @test_Strategy: Create a Variant(MediaType, String, String)
     */
@Test
public void constructorMediaStringStringTest() throws Fault {
    Variant vt = null;
    String[] encodings = { null, "CP1250", "UTF8", "ISO8859-2" };
    Locale[] langs = { null, Locale.CANADA, Locale.FRENCH };
    for (String encoding : encodings) for (Locale lang : langs) {
        vt = new Variant(MediaType.APPLICATION_XHTML_XML_TYPE, lang == null ? null : lang.toString(), encoding);
        verifyVariant(vt, MediaType.APPLICATION_XHTML_XML_TYPE.getType(), MediaType.APPLICATION_XHTML_XML_TYPE.getSubtype(), lang, encoding);
    }
}
Also used : Variant(jakarta.ws.rs.core.Variant) Locale(java.util.Locale) Test(org.junit.jupiter.api.Test)

Aggregations

Variant (jakarta.ws.rs.core.Variant)29 Test (org.junit.jupiter.api.Test)25 MediaType (jakarta.ws.rs.core.MediaType)21 Locale (java.util.Locale)13 Response (jakarta.ws.rs.core.Response)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)3 GET (jakarta.ws.rs.GET)1 Path (jakarta.ws.rs.Path)1 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)1 Invocation (jakarta.ws.rs.client.Invocation)1 Annotation (java.lang.annotation.Annotation)1 LinkedHashSet (java.util.LinkedHashSet)1