public virtual void Test() { string test = "The quick red fox jumped over the lazy brown dogs"; TypeAsPayloadTokenFilter nptf = new TypeAsPayloadTokenFilter(new WordTokenFilter(this, new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false))); int count = 0; ICharTermAttribute termAtt = nptf.GetAttribute<ICharTermAttribute>(); ITypeAttribute typeAtt = nptf.GetAttribute<ITypeAttribute>(); IPayloadAttribute payloadAtt = nptf.GetAttribute<IPayloadAttribute>(); nptf.Reset(); while (nptf.IncrementToken()) { assertTrue(typeAtt.Type + " is not null and it should be", typeAtt.Type.Equals(char.ToUpper(termAtt.Buffer()[0]).ToString())); assertTrue("nextToken.getPayload() is null and it shouldn't be", payloadAtt.Payload != null); string type = payloadAtt.Payload.Utf8ToString(); assertTrue(type + " is not equal to " + typeAtt.Type, type.Equals(typeAtt.Type)); count++; } assertTrue(count + " does not equal: " + 10, count == 10); }
public virtual void Test() { string test = "The quick red fox jumped over the lazy brown dogs"; TypeAsPayloadTokenFilter nptf = new TypeAsPayloadTokenFilter(new WordTokenFilter(this, new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false))); int count = 0; ICharTermAttribute termAtt = nptf.GetAttribute <ICharTermAttribute>(); ITypeAttribute typeAtt = nptf.GetAttribute <ITypeAttribute>(); IPayloadAttribute payloadAtt = nptf.GetAttribute <IPayloadAttribute>(); nptf.Reset(); while (nptf.IncrementToken()) { assertTrue(typeAtt.Type + " is not null and it should be", typeAtt.Type.Equals(char.ToUpper(termAtt.Buffer()[0]).ToString())); assertTrue("nextToken.getPayload() is null and it shouldn't be", payloadAtt.Payload != null); string type = payloadAtt.Payload.Utf8ToString(); assertTrue(type + " is not equal to " + typeAtt.Type, type.Equals(typeAtt.Type)); count++; } assertTrue(count + " does not equal: " + 10, count == 10); }
public void test() { String test = "The quick red fox jumped over the lazy brown dogs"; TypeAsPayloadTokenFilter nptf = new TypeAsPayloadTokenFilter(new WordTokenFilter(new WhitespaceTokenizer(new StringReader(test)))); int count = 0; ITermAttribute termAtt = nptf.GetAttribute<ITermAttribute>(); ITypeAttribute typeAtt = nptf.GetAttribute<ITypeAttribute>(); IPayloadAttribute payloadAtt = nptf.GetAttribute<IPayloadAttribute>(); while (nptf.IncrementToken()) { Assert.True(typeAtt.Type.Equals(char.ToUpper(termAtt.TermBuffer()[0]).ToString()), typeAtt.Type + " is not null and it should be"); Assert.True(payloadAtt.Payload != null, "nextToken.getPayload() is null and it shouldn't be"); String type = Encoding.UTF8.GetString(payloadAtt.Payload.GetData()); ; Assert.True(type != null, "type is null and it shouldn't be"); Assert.True(type.Equals(typeAtt.Type) == true, type + " is not equal to " + typeAtt.Type); count++; } Assert.True(count == 10, count + " does not equal: " + 10); }