/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.solr.handler; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.util.NamedList; import static org.junit.Assert.*; /** * A base class for all analysis request handler tests. * * @version $Id: AnalysisRequestHandlerTestBase.java 965330 2010-07-19 00:06:18Z rmuir $ * @since solr 1.4 */ public abstract class AnalysisRequestHandlerTestBase extends SolrTestCaseJ4 { protected void assertToken(NamedList token, TokenInfo info) { assertEquals(info.getText(), token.get("text")); if (info.getRawText() != null) { assertEquals(info.getRawText(), token.get("raw_text")); } assertEquals(info.getType(), token.get("type")); assertEquals(new Integer(info.getStart()), token.get("start")); assertEquals(new Integer(info.getEnd()), token.get("end")); assertEquals(new Integer(info.getPosition()), token.get("position")); if (info.isMatch()) { assertEquals(Boolean.TRUE, token.get("match")); } if (info.getPayload() != null) { assertEquals(info.getPayload(), token.get("payload")); } } //================================================= Inner Classes ================================================== protected class TokenInfo { private String text; private String rawText; private String type; private int start; private int end; private String payload; private int position; private boolean match; public TokenInfo( String text, String rawText, String type, int start, int end, int position, String payload, boolean match) { this.text = text; this.rawText = rawText; this.type = type; this.start = start; this.end = end; this.position = position; this.payload = payload; this.match = match; } public String getText() { return text; } public String getRawText() { return rawText; } public String getType() { return type; } public int getStart() { return start; } public int getEnd() { return end; } public String getPayload() { return payload; } public int getPosition() { return position; } public boolean isMatch() { return match; } } }