//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";

            NumericPayloadTokenFilter nptf = new NumericPayloadTokenFilter(new WordTokenFilter(this, new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false)), 3, "D");
            bool seenDogs = false;
            CharTermAttribute termAtt = nptf.getAttribute(typeof(CharTermAttribute));
            TypeAttribute typeAtt = nptf.getAttribute(typeof(TypeAttribute));
            PayloadAttribute payloadAtt = nptf.getAttribute(typeof(PayloadAttribute));
            nptf.reset();
            while (nptf.incrementToken())
            {
              if (termAtt.ToString().Equals("dogs"))
              {
            seenDogs = true;
            assertTrue(typeAtt.type() + " is not equal to " + "D", typeAtt.type().Equals("D") == true);
            assertTrue("payloadAtt.getPayload() is null and it shouldn't be", payloadAtt.Payload != null);
            sbyte[] bytes = payloadAtt.Payload.bytes; //safe here to just use the bytes, otherwise we should use offset, length
            assertTrue(bytes.Length + " does not equal: " + payloadAtt.Payload.length, bytes.Length == payloadAtt.Payload.length);
            assertTrue(payloadAtt.Payload.offset + " does not equal: " + 0, payloadAtt.Payload.offset == 0);
            float pay = PayloadHelper.decodeFloat(bytes);
            assertTrue(pay + " does not equal: " + 3, pay == 3);
              }
              else
              {
            assertTrue(typeAtt.type() + " is not null and it should be", typeAtt.type().Equals("word"));
              }
            }
            assertTrue(seenDogs + " does not equal: " + true, seenDogs == true);
        }
Esempio n. 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";

            NumericPayloadTokenFilter nptf = new NumericPayloadTokenFilter(new WordTokenFilter(this, new MockTokenizer(new StringReader(test), MockTokenizer.WHITESPACE, false)), 3, "D");
            bool seenDogs                = false;
            CharTermAttribute termAtt    = nptf.getAttribute(typeof(CharTermAttribute));
            TypeAttribute     typeAtt    = nptf.getAttribute(typeof(TypeAttribute));
            PayloadAttribute  payloadAtt = nptf.getAttribute(typeof(PayloadAttribute));

            nptf.reset();
            while (nptf.incrementToken())
            {
                if (termAtt.ToString().Equals("dogs"))
                {
                    seenDogs = true;
                    assertTrue(typeAtt.type() + " is not equal to " + "D", typeAtt.type().Equals("D") == true);
                    assertTrue("payloadAtt.getPayload() is null and it shouldn't be", payloadAtt.Payload != null);
                    sbyte[] bytes = payloadAtt.Payload.bytes;     //safe here to just use the bytes, otherwise we should use offset, length
                    assertTrue(bytes.Length + " does not equal: " + payloadAtt.Payload.length, bytes.Length == payloadAtt.Payload.length);
                    assertTrue(payloadAtt.Payload.offset + " does not equal: " + 0, payloadAtt.Payload.offset == 0);
                    float pay = PayloadHelper.decodeFloat(bytes);
                    assertTrue(pay + " does not equal: " + 3, pay == 3);
                }
                else
                {
                    assertTrue(typeAtt.type() + " is not null and it should be", typeAtt.type().Equals("word"));
                }
            }
            assertTrue(seenDogs + " does not equal: " + true, seenDogs == true);
        }