lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r799359 - /lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
Date Thu, 30 Jul 2009 16:45:43 GMT
Author: uschindler
Date: Thu Jul 30 16:45:43 2009
New Revision: 799359

URL: http://svn.apache.org/viewvc?rev=799359&view=rev
Log:
Add extra test for new TokenStream API backwards layer

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java?rev=799359&r1=799358&r2=799359&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java Thu Jul
30 16:45:43 2009
@@ -267,6 +267,23 @@
         stream.addAttribute(PositionIncrementAttribute.class) instanceof PositionIncrementAttributeImpl);
       assertTrue("TypeAttribute is implemented by TypeAttributeImpl",
         stream.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
+        
+      // try to call old API, this should fail
+      try {
+        stream.reset();
+        Token reusableToken = new Token();
+        while ((reusableToken = stream.next(reusableToken)) != null);
+        fail("If only the new API is allowed, this should fail with an UOE");
+      } catch (UnsupportedOperationException uoe) {
+        assertTrue("This TokenStream only supports the new Attributes API.".equals(uoe.getMessage()));
+      }
+      try {
+        stream.reset();
+        while (stream.next() != null);
+        fail("If only the new API is allowed, this should fail with an UOE");
+      } catch (UnsupportedOperationException uoe) {
+        assertTrue("This TokenStream only supports the new Attributes API.".equals(uoe.getMessage()));
+      }
       
       // Test if the wrapper API (onlyUseNewAPI==false) uses TokenWrapper
       // as attribute instance.



Mime
View raw message