Search in sources :

Example 96 with StringReader

use of java.io.StringReader in project tomcat by apache.

the class TestAcceptLanguage method testMalformed08.

@Test
public void testMalformed08() throws Exception {
    List<AcceptLanguage> actual = AcceptLanguage.parse(new StringReader(",en,"));
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(L_EN, actual.get(0).getLocale());
    Assert.assertEquals(Q1_000, actual.get(0).getQuality(), 0.0001);
}
Also used : StringReader(java.io.StringReader) Test(org.junit.Test)

Example 97 with StringReader

use of java.io.StringReader in project tomcat by apache.

the class TestAcceptLanguage method bug56848.

@Test
public void bug56848() throws Exception {
    List<AcceptLanguage> actual = AcceptLanguage.parse(new StringReader("zh-hant-CN;q=0.5,zh-hans-TW;q=0.05"));
    Assert.assertEquals(2, actual.size());
    Locale.Builder b = new Locale.Builder();
    b.setLanguage("zh").setRegion("CN").setScript("hant");
    Locale l1 = b.build();
    b.clear().setLanguage("zh").setRegion("TW").setScript("hans");
    Locale l2 = b.build();
    Assert.assertEquals(l1, actual.get(0).getLocale());
    Assert.assertEquals(Q0_500, actual.get(0).getQuality(), 0.0001);
    Assert.assertEquals(l2, actual.get(1).getLocale());
    Assert.assertEquals(Q0_050, actual.get(1).getQuality(), 0.0001);
}
Also used : Locale(java.util.Locale) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 98 with StringReader

use of java.io.StringReader in project tomcat by apache.

the class TestAcceptLanguage method testMalformed02.

@Test
public void testMalformed02() throws Exception {
    List<AcceptLanguage> actual = AcceptLanguage.parse(new StringReader("en-gb;q=a,en-gb;q=0.5"));
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(L_EN_GB, actual.get(0).getLocale());
    Assert.assertEquals(Q0_500, actual.get(0).getQuality(), 0.0001);
}
Also used : StringReader(java.io.StringReader) Test(org.junit.Test)

Example 99 with StringReader

use of java.io.StringReader in project tomcat by apache.

the class TestAcceptLanguage method testMalformed04.

@Test
public void testMalformed04() throws Exception {
    List<AcceptLanguage> actual = AcceptLanguage.parse(new StringReader("en-gb;q=0.05a,en-gb;q=0.5"));
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals(L_EN_GB, actual.get(0).getLocale());
    Assert.assertEquals(Q0_500, actual.get(0).getQuality(), 0.0001);
}
Also used : StringReader(java.io.StringReader) Test(org.junit.Test)

Example 100 with StringReader

use of java.io.StringReader in project tomcat by apache.

the class TestAcceptLanguage method testMultiple02.

@Test
public void testMultiple02() throws Exception {
    List<AcceptLanguage> actual = AcceptLanguage.parse(new StringReader("en; q= 0.05,fr;q=0.5"));
    Assert.assertEquals(2, actual.size());
    Assert.assertEquals(L_EN, actual.get(0).getLocale());
    Assert.assertEquals(Q0_050, actual.get(0).getQuality(), 0.0001);
    Assert.assertEquals(L_FR, actual.get(1).getLocale());
    Assert.assertEquals(Q0_500, actual.get(1).getQuality(), 0.0001);
}
Also used : StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)3695 Test (org.junit.Test)837 IOException (java.io.IOException)488 Reader (java.io.Reader)402 InputSource (org.xml.sax.InputSource)369 TokenStream (org.apache.lucene.analysis.TokenStream)298 BufferedReader (java.io.BufferedReader)277 Tokenizer (org.apache.lucene.analysis.Tokenizer)238 StringWriter (java.io.StringWriter)226 ArrayList (java.util.ArrayList)225 JSONReader (com.alibaba.fastjson.JSONReader)195 Document (org.w3c.dom.Document)181 DocumentBuilder (javax.xml.parsers.DocumentBuilder)165 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)141 Map (java.util.Map)139 ParserResult (org.jabref.logic.importer.ParserResult)130 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)120 HashMap (java.util.HashMap)117 Element (org.w3c.dom.Element)108 StreamSource (javax.xml.transform.stream.StreamSource)106