![JAR search and dependency download from the Maven repository](/logo.png)
test.it.unimi.dsi.big.mg4j.index.payload.PayloadTestCase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mg4j-big Show documentation
Show all versions of mg4j-big Show documentation
MG4J (Managing Gigabytes for Java) is a free full-text search engine for large document collections written in Java. The big version is a fork of the original MG4J that can handle more than 2^31 terms and documents.
The newest version!
package it.unimi.dsi.big.mg4j.index.payload;
import static org.junit.Assert.assertEquals;
import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream;
import it.unimi.dsi.io.InputBitStream;
import it.unimi.dsi.io.OutputBitStream;
import java.io.IOException;
public abstract class PayloadTestCase {
/** Checks that a given payload serialises correctly.
*
* @param payload a payload containing a current value.
*/
public static void testWriteAndRead( Payload payload ) throws IOException {
final FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
final OutputBitStream obs = new OutputBitStream( fbos );
Object o = payload.get();
payload.write( obs );
obs.flush();
final InputBitStream ibs = new InputBitStream( fbos.array );
payload.read( ibs );
assertEquals( o, payload.get() );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy