add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / backwards / src / test / org / apache / lucene / TestAssertions.java
1 package org.apache.lucene;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import java.io.Reader;
21
22 import org.apache.lucene.util.LuceneTestCase;
23 import org.apache.lucene.analysis.Analyzer;
24 import org.apache.lucene.analysis.TokenStream;
25
26 public class TestAssertions extends LuceneTestCase {
27
28   public void testBasics() {
29     try {
30       assert Boolean.FALSE.booleanValue();
31       fail("assertions are not enabled!");
32     } catch (AssertionError e) {
33       assert Boolean.TRUE.booleanValue();
34     }
35   }
36   
37   static class TestAnalyzer1 extends Analyzer {
38     @Override
39     public final TokenStream tokenStream(String s, Reader r) { return null; }
40     @Override
41     public final TokenStream reusableTokenStream(String s, Reader r) { return null; }
42   }
43
44   static final class TestAnalyzer2 extends Analyzer {
45     @Override
46     public TokenStream tokenStream(String s, Reader r) { return null; }
47     @Override
48     public TokenStream reusableTokenStream(String s, Reader r) { return null; }
49   }
50
51   static class TestAnalyzer3 extends Analyzer {
52     @Override
53     public TokenStream tokenStream(String s, Reader r) { return null; }
54     @Override
55     public TokenStream reusableTokenStream(String s, Reader r) { return null; }
56   }
57
58   static class TestAnalyzer4 extends Analyzer {
59     @Override
60     public final TokenStream tokenStream(String s, Reader r) { return null; }
61     @Override
62     public TokenStream reusableTokenStream(String s, Reader r) { return null; }
63   }
64
65   static class TestTokenStream1 extends TokenStream {
66     @Override
67     public final boolean incrementToken() { return false; }
68   }
69
70   static final class TestTokenStream2 extends TokenStream {
71     @Override
72     public boolean incrementToken() { return false; }
73   }
74
75   static class TestTokenStream3 extends TokenStream {
76     @Override
77     public boolean incrementToken() { return false; }
78   }
79
80   public void testTokenStreams() {
81     new TestAnalyzer1();
82     
83     new TestAnalyzer2();
84     
85     try {
86       new TestAnalyzer3();
87       fail("TestAnalyzer3 should fail assertion");
88     } catch (AssertionError e) {
89     }
90     
91     try {
92       new TestAnalyzer4();
93       fail("TestAnalyzer4 should fail assertion");
94     } catch (AssertionError e) {
95     }
96     
97     new TestTokenStream1();
98     
99     new TestTokenStream2();
100     
101     try {
102       new TestTokenStream3();
103       fail("TestTokenStream3 should fail assertion");
104     } catch (AssertionError e) {
105     }
106   }
107
108 }