//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void test() throws java.io.IOException
        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;
            CharTermAttribute termAtt = nptf.getAttribute(typeof(CharTermAttribute));
            TypeAttribute typeAtt = nptf.getAttribute(typeof(TypeAttribute));
            PayloadAttribute payloadAtt = nptf.getAttribute(typeof(PayloadAttribute));
            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);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void test() throws java.io.IOException
        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;
            CharTermAttribute termAtt    = nptf.getAttribute(typeof(CharTermAttribute));
            TypeAttribute     typeAtt    = nptf.getAttribute(typeof(TypeAttribute));
            PayloadAttribute  payloadAtt = nptf.getAttribute(typeof(PayloadAttribute));

            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);
        }