2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.solr.handler;
20
import org.apache.solr.SolrTestCaseJ4;
21
import org.apache.solr.common.util.NamedList;
22
import org.apache.commons.lang.ArrayUtils;
25
* A base class for all analysis request handler tests.
27
* @version $Id: AnalysisRequestHandlerTestBase.java 1135156 2011-06-13 16:14:49Z uschindler $
30
public abstract class AnalysisRequestHandlerTestBase extends SolrTestCaseJ4 {
32
protected void assertToken(NamedList token, TokenInfo info) {
33
assertEquals(info.getText(), token.get("text"));
34
if (info.getRawText() != null) {
35
assertEquals(info.getRawText(), token.get("raw_text"));
37
assertEquals(info.getType(), token.get("type"));
38
assertEquals(new Integer(info.getStart()), token.get("start"));
39
assertEquals(new Integer(info.getEnd()), token.get("end"));
40
assertEquals(new Integer(info.getPosition()), token.get("position"));
41
assertArrayEquals(info.getPositionHistory(), ArrayUtils.toPrimitive((Integer[]) token.get("positionHistory")));
43
assertEquals(Boolean.TRUE, token.get("match"));
45
if (info.getPayload() != null) {
46
assertEquals(info.getPayload(), token.get("payload"));
51
//================================================= Inner Classes ==================================================
53
protected class TokenInfo {
56
private String rawText;
60
private String payload;
62
private int[] positionHistory;
63
private boolean match;
72
int[] positionHistory,
77
this.rawText = rawText;
81
this.position = position;
82
this.positionHistory = positionHistory;
83
this.payload = payload;
87
public String getText() {
91
public String getRawText() {
95
public String getType() {
99
public int getStart() {
103
public int getEnd() {
107
public String getPayload() {
111
public int getPosition() {
115
public int[] getPositionHistory() {
116
return positionHistory;
119
public boolean isMatch() {