Skip to content

Commit

Permalink
fixed more tests that depend on serialized output
Browse files Browse the repository at this point in the history
  • Loading branch information
javasoze committed Nov 2, 2011
1 parent 6718f1c commit 91f2f6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
@@ -1,38 +1,20 @@
package com.kamikaze.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;

import junit.framework.TestCase;

import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.OpenBitSet;
import org.junit.Test;
import junit.framework.TestCase;

import com.kamikaze.docidset.api.DocSet;
import com.kamikaze.docidset.api.StatefulDSIterator;
import com.kamikaze.docidset.bitset.MyOpenBitSet;
import com.kamikaze.docidset.impl.AndDocIdSet;
import com.kamikaze.docidset.impl.IntArrayDocIdSet;
import com.kamikaze.docidset.impl.NotDocIdSet;
import com.kamikaze.docidset.impl.OBSDocIdSet;
import com.kamikaze.docidset.impl.OrDocIdSet;
import com.kamikaze.docidset.impl.PForDeltaDocIdSet;

public class PForDeltaTestDocSetSerializationTest extends TestCase {
Expand Down Expand Up @@ -81,12 +63,14 @@ public void testNotDocSetSerialization() throws Exception {

DocIdSet not = new NotDocIdSet(docSet, max);

byte[] serialized = null;
try {
File f = new File(serial);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bout);
oos.writeObject(not);
oos.flush();
oos.close();
serialized = bout.toByteArray();

} catch (Exception e) {
e.printStackTrace();
Expand All @@ -96,8 +80,7 @@ public void testNotDocSetSerialization() throws Exception {
NotDocIdSet not2 = null;

try {
InputStream f = new FileInputStream(new File(serial));
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(f));
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serialized));
not2 = (NotDocIdSet) (ois.readObject());
} catch (Exception e) {
e.printStackTrace();
Expand Down
Binary file removed src/test/test-data/SerialDocSet
Binary file not shown.

0 comments on commit 91f2f6e

Please sign in to comment.