Search in sources :

Example 1 with PushWriter

use of org.apache.solr.common.PushWriter in project lucene-solr by apache.

the class TestPushWriter method testStandardResponse.

public void testStandardResponse() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStreamWriter osw = new OutputStreamWriter(baos, UTF_8);
    PushWriter pw = new JSONWriter(osw, new LocalSolrQueryRequest(null, new ModifiableSolrParams()), new SolrQueryResponse());
    writeData(pw);
    osw.flush();
    log.info(new String(baos.toByteArray(), "UTF-8"));
    Map m = (Map) Utils.fromJSON(baos.toByteArray());
    checkValues(m);
    writeData(new JavaBinCodec(baos = new ByteArrayOutputStream(), null));
    m = (Map) new JavaBinCodec().unmarshal(new ByteArrayInputStream(baos.toByteArray()));
    checkValues(m);
}
Also used : LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PushWriter(org.apache.solr.common.PushWriter) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) JavaBinCodec(org.apache.solr.common.util.JavaBinCodec)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Map (java.util.Map)1 PushWriter (org.apache.solr.common.PushWriter)1 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)1 JavaBinCodec (org.apache.solr.common.util.JavaBinCodec)1 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)1