1
package org.apache.lucene;
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
11
* http://www.apache.org/licenses/LICENSE-2.0
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.
20
import java.io.Reader;
22
import org.apache.lucene.util.LuceneTestCase;
23
import org.apache.lucene.analysis.Analyzer;
24
import org.apache.lucene.analysis.TokenStream;
26
public class TestAssertions extends LuceneTestCase {
28
public void testBasics() {
30
assert Boolean.FALSE.booleanValue();
31
fail("assertions are not enabled!");
32
} catch (AssertionError e) {
33
assert Boolean.TRUE.booleanValue();
37
static class TestAnalyzer1 extends Analyzer {
39
public final TokenStream tokenStream(String s, Reader r) { return null; }
41
public final TokenStream reusableTokenStream(String s, Reader r) { return null; }
44
static final class TestAnalyzer2 extends Analyzer {
46
public TokenStream tokenStream(String s, Reader r) { return null; }
48
public TokenStream reusableTokenStream(String s, Reader r) { return null; }
51
static class TestAnalyzer3 extends Analyzer {
53
public TokenStream tokenStream(String s, Reader r) { return null; }
55
public TokenStream reusableTokenStream(String s, Reader r) { return null; }
58
static class TestAnalyzer4 extends Analyzer {
60
public final TokenStream tokenStream(String s, Reader r) { return null; }
62
public TokenStream reusableTokenStream(String s, Reader r) { return null; }
65
static class TestTokenStream1 extends TokenStream {
67
public final boolean incrementToken() { return false; }
70
static final class TestTokenStream2 extends TokenStream {
72
public boolean incrementToken() { return false; }
75
static class TestTokenStream3 extends TokenStream {
77
public boolean incrementToken() { return false; }
80
public void testTokenStreams() {
87
fail("TestAnalyzer3 should fail assertion");
88
} catch (AssertionError e) {
93
fail("TestAnalyzer4 should fail assertion");
94
} catch (AssertionError e) {
97
new TestTokenStream1();
99
new TestTokenStream2();
102
new TestTokenStream3();
103
fail("TestTokenStream3 should fail assertion");
104
} catch (AssertionError e) {