Package javax.ws.rs.core

Examples of javax.ws.rs.core.Variant$VariantListBuilder


        list = builder.encodings("UTF-8", "UTF-16").add().build();
        assertList(new Variant[] {variant1, variant2}, list);
    }

    public void testBuildMediaTypesAndLanguages() {
        Variant variant1 = new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.ENGLISH, null);
        Variant variant2 = new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.CHINESE, null);
        Variant variant3 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.ENGLISH, null);
        Variant variant4 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.CHINESE, null);

        VariantListBuilder builder = new VariantListBuilderImpl();
        List<Variant> list = null;

        list =
View Full Code Here


                .languages(Locale.ENGLISH, Locale.CHINESE).add().build();
        assertList(new Variant[] {variant1, variant2, variant3, variant4}, list);
    }

    public void testBuildMediaTypesAndEncodings() {
        Variant variant1 = new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, null, "UTF-8");
        Variant variant2 = new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, null, "UTF-16");
        Variant variant3 = new Variant(MediaType.APPLICATION_JSON_TYPE, null, "UTF-8");
        Variant variant4 = new Variant(MediaType.APPLICATION_JSON_TYPE, null, "UTF-16");

        VariantListBuilder builder = new VariantListBuilderImpl();
        List<Variant> list = null;

        list =
View Full Code Here

                .encodings("UTF-8", "UTF-16").add().build();
        assertList(new Variant[] {variant1, variant2, variant3, variant4}, list);
    }

    public void testBuildLanguagesAndEncodings() {
        Variant variant1 = new Variant(null, Locale.ENGLISH, "UTF-8");
        Variant variant2 = new Variant(null, Locale.ENGLISH, "UTF-16");
        Variant variant3 = new Variant(null, Locale.CHINESE, "UTF-8");
        Variant variant4 = new Variant(null, Locale.CHINESE, "UTF-16");

        VariantListBuilder builder = new VariantListBuilderImpl();
        List<Variant> list = null;

        list = builder.languages(Locale.ENGLISH).encodings("UTF-8").add().build();
View Full Code Here

                .build();
        assertList(new Variant[] {variant1, variant2, variant3, variant4}, list);
    }

    public void testBuildMediaTypesAndLanguagesAndEncodings() {
        Variant variant1 =
            new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.ENGLISH, "UTF-8");
        Variant variant2 =
            new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.ENGLISH, "UTF-16");
        Variant variant3 =
            new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.CHINESE, "UTF-8");
        Variant variant4 =
            new Variant(MediaType.APPLICATION_ATOM_XML_TYPE, Locale.CHINESE, "UTF-16");
        Variant variant5 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.ENGLISH, "UTF-8");
        Variant variant6 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.ENGLISH, "UTF-16");
        Variant variant7 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.CHINESE, "UTF-8");
        Variant variant8 = new Variant(MediaType.APPLICATION_JSON_TYPE, Locale.CHINESE, "UTF-16");

        VariantListBuilder builder = new VariantListBuilderImpl();
        List<Variant> list = null;

        list =
View Full Code Here

            handleMediaTypes();
        } else if (languages.size() > 0) {
            handleLanguages(null);
        } else if (encodings.size() > 0) {
            for (String enc : encodings) {
                variants.add(new Variant(null, null, enc));
            }
        }
    }
View Full Code Here

        for (MediaType type : mediaTypes) {
            if (languages.size() > 0) {
                handleLanguages(type);
            } else if (encodings.size() > 0) {
                for (String enc : encodings) {
                    variants.add(new Variant(type, null, enc));
                }
            } else {
                variants.add(new Variant(type, null, null));
            }
        }
    }
View Full Code Here

   
    private void handleLanguages(MediaType type) {
        for (Locale lang : languages) {
            if (encodings.size() > 0) {
                for (String enc : encodings) {
                    variants.add(new Variant(type, lang, enc));
                }   
            } else {
                variants.add(new Variant(type, lang, null));
            }
        }
    }
View Full Code Here

       
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.putSingle("Content-Type", MediaType.TEXT_XML_TYPE);
        m.putSingle("Content-Language", new Locale("en"));
        m.putSingle("Content-Encoding", "gzip");
        Variant v = new Variant(MediaType.TEXT_XML_TYPE, new Locale("en"), "gzip");
       
        checkBuild(Response.ok().variant(v).build(),
                   200, null, m);
    }
View Full Code Here

        m.add("Content-Language", new Locale("en_uk"));
        m.add("Content-Language", new Locale("en_gb"));
        m.add("Vary", "Accept");
        m.add("Vary", "Accept-Language");
       
        Variant json = new Variant(MediaType.APPLICATION_JSON_TYPE, new Locale("en_uk"), null);
        Variant xml = new Variant(MediaType.APPLICATION_JSON_TYPE, new Locale("en_gb"), null);

        checkBuild(Response.ok().variants(json, xml).build(), 200, null, m);
    }
View Full Code Here

        MediaType mt1 = new MediaType("*", "*");
        MediaType mt2 = new MediaType("text", "xml");
        List<Variant> variants = vb.mediaTypes(mt1, mt2)
            .languages(new Locale("en"), new Locale("fr")).encodings("zip", "identity").add().build();
        assertEquals("8 variants need to be created", 8, variants.size());
        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("en"), "zip")));
        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("en"), "identity")));
        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("fr"), "zip")));
        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("fr"), "identity")));
        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("en"), "zip")));
        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("en"), "identity")));
        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("fr"), "zip")));
        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("fr"), "identity")));
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Variant$VariantListBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.