fix forbidden api usage

This commit is contained in:
Robert Muir 2015-05-26 09:54:31 -04:00
parent 2da374f39d
commit bac187c4dc
2 changed files with 6 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import org.elasticsearch.common.cli.CliTool;
import org.elasticsearch.common.cli.CliToolConfig; import org.elasticsearch.common.cli.CliToolConfig;
import org.elasticsearch.common.cli.Terminal; import org.elasticsearch.common.cli.Terminal;
import org.elasticsearch.common.cli.commons.CommandLine; import org.elasticsearch.common.cli.commons.CommandLine;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -39,7 +40,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Locale; import java.util.Locale;
import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd; import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd;
@ -83,7 +83,7 @@ public class StandaloneRunner extends CliTool {
this.size = size; this.size = size;
this.url = url; this.url = url;
this.base64text = base64text; this.base64text = base64text;
DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(Paths.get(".")); // use CWD b/c it won't be used DocumentMapperParser mapperParser = MapperTestUtils.newMapperParser(PathUtils.get(".")); // use CWD b/c it won't be used
mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser()); mapperParser.putTypeParser(AttachmentMapper.CONTENT_TYPE, new AttachmentMapper.TypeParser());
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/standalone/standalone-mapping.json"); String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/standalone/standalone-mapping.json");
@ -99,7 +99,7 @@ public class StandaloneRunner extends CliTool {
builder.field("_content", base64text); builder.field("_content", base64text);
} else { } else {
// A file is provided // A file is provided
byte[] bytes = copyToBytes(Paths.get(url)); byte[] bytes = copyToBytes(PathUtils.get(url));
builder.field("_content", bytes); builder.field("_content", bytes);
} }

View File

@ -19,6 +19,8 @@
package org.elasticsearch.index.mapper.attachment.test.unit; package org.elasticsearch.index.mapper.attachment.test.unit;
import java.nio.charset.StandardCharsets;
import org.elasticsearch.common.Base64; import org.elasticsearch.common.Base64;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapper;
@ -91,7 +93,7 @@ public class MultifieldAttachmentMapperTests extends AttachmentUnitTestCase {
String contentType = "text/plain; charset=ISO-8859-1"; String contentType = "text/plain; charset=ISO-8859-1";
String forcedName = "dummyname.txt"; String forcedName = "dummyname.txt";
String bytes = Base64.encodeBytes(originalText.getBytes()); String bytes = Base64.encodeBytes(originalText.getBytes(StandardCharsets.ISO_8859_1));
threadPool = new ThreadPool("testing-only"); threadPool = new ThreadPool("testing-only");
MapperService mapperService = MapperTestUtils.newMapperService(createTempDir(), threadPool); MapperService mapperService = MapperTestUtils.newMapperService(createTempDir(), threadPool);