1 package org.apache.lucene.store.instantiated;
4 * Copyright 2006 The Apache Software Foundation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 import org.apache.lucene.store.Directory;
21 import org.apache.lucene.util.LuceneTestCase;
22 import org.apache.lucene.index.IndexWriter;
23 import org.apache.lucene.index.IndexReader;
24 import org.apache.lucene.analysis.WhitespaceAnalyzer;
25 import org.apache.lucene.document.Document;
26 import org.apache.lucene.document.Field;
28 import java.io.ByteArrayOutputStream;
29 import java.io.ObjectOutputStream;
31 public class TestSerialization extends LuceneTestCase {
33 public void test() throws Exception {
34 Directory dir = newDirectory();
36 IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new WhitespaceAnalyzer(TEST_VERSION_CURRENT)));
37 Document doc = new Document();
38 doc.add(new Field("foo", "bar rab abr bra rba", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
39 doc.add(new Field("moo", "bar rab abr bra rba", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
43 IndexReader ir = IndexReader.open(dir, false);
44 InstantiatedIndex ii = new InstantiatedIndex(ir);
47 ByteArrayOutputStream baos = new ByteArrayOutputStream(5000);
48 ObjectOutputStream oos = new ObjectOutputStream(baos);