public class TestJapaneseEncodings extends TestCase
{
byte[] fullWidthKa = new byte[]{(byte) 0xE3, (byte) 0x82, (byte) 0xAB};
byte[] halfWidthKa = new byte[]{(byte) 0xEF, (byte) 0xBD, (byte) 0xB6};
public void testAnalyzerWithHalfWidth() throws IOException
{
Reader r1 = new StringReader(makeHalfWidthKa());
TokenStream stream = new CJKAnalyzer().tokenStream("foo", r1);
assertNotNull(stream);
Token token = stream.next();
assertNotNull(token);
assertEquals(makeFullWidthKa(), token.termText());
}
public void testAnalyzerWithFullWidth() throws IOException
{
Reader r1 = new StringReader(makeFullWidthKa());
TokenStream stream = new CJKAnalyzer().tokenStream("foo", r1);
assertEquals(makeFullWidthKa(), stream.next().termText());
}
private String makeFullWidthKa() throws UnsupportedEncodingException
{
return new String(fullWidthKa, "UTF-8");
}
private String makeHalfWidthKa() throws UnsupportedEncodingException
{
return new String(halfWidthKa, "UTF-8");
}
}