apply line ending fix only on Windows

fix for #4785
This commit is contained in:
Costin Leau 2014-01-17 17:00:32 +02:00
parent de893d80de
commit 16a70d6005
1 changed files with 6 additions and 0 deletions

View File

@ -20,9 +20,11 @@
package org.elasticsearch.action.bulk;
import com.google.common.base.Charsets;
import org.apache.lucene.util.Constants;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;
@ -36,6 +38,10 @@ public class BulkRequestTests extends ElasticsearchTestCase {
@Test
public void testSimpleBulk1() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
// translate Windows line endings (\r\n) to standard ones (\n)
if (Constants.WINDOWS) {
bulkAction = Strings.replace(bulkAction, "\r\n", "\n");
}
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
assertThat(bulkRequest.numberOfActions(), equalTo(3));