fix formatting

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1667347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2015-03-17 16:13:16 +00:00
parent 4c4d8ee994
commit fd8a588bc5
1 changed files with 16 additions and 16 deletions

View File

@ -55,7 +55,7 @@ import java.util.Map;
import static org.apache.solr.core.ConfigOverlay.getObjectByPath; import static org.apache.solr.core.ConfigOverlay.getObjectByPath;
public class TestBlobHandler extends AbstractFullDistribZkTestBase { public class TestBlobHandler extends AbstractFullDistribZkTestBase {
static final Logger log = LoggerFactory.getLogger(TestBlobHandler.class); static final Logger log = LoggerFactory.getLogger(TestBlobHandler.class);
@Test @Test
public void doBlobHandlerTest() throws Exception { public void doBlobHandlerTest() throws Exception {
@ -82,24 +82,24 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
"/blob", "/blob",
"class"))); "class")));
byte[] bytarr = new byte[1024]; byte[] bytarr = new byte[1024];
for (int i = 0; i < bytarr.length; i++) bytarr[i]= (byte) (i % 127); for (int i = 0; i < bytarr.length; i++) bytarr[i] = (byte) (i % 127);
byte[] bytarr2 = new byte[2048]; byte[] bytarr2 = new byte[2048];
for (int i = 0; i < bytarr2.length; i++) bytarr2[i]= (byte) (i % 127); for (int i = 0; i < bytarr2.length; i++) bytarr2[i] = (byte) (i % 127);
String blobName = "test"; String blobName = "test";
postAndCheck(cloudClient, baseUrl, blobName, ByteBuffer.wrap(bytarr), 1); postAndCheck(cloudClient, baseUrl, blobName, ByteBuffer.wrap(bytarr), 1);
postAndCheck(cloudClient, baseUrl, blobName, ByteBuffer.wrap(bytarr2), 2); postAndCheck(cloudClient, baseUrl, blobName, ByteBuffer.wrap(bytarr2), 2);
url = baseUrl + "/.system/blob/test/1"; url = baseUrl + "/.system/blob/test/1";
map = TestSolrConfigHandlerConcurrent.getAsMap(url,cloudClient); map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient);
List l = (List) ConfigOverlay.getObjectByPath(map, false, Arrays.asList("response", "docs")); List l = (List) ConfigOverlay.getObjectByPath(map, false, Arrays.asList("response", "docs"));
assertNotNull(""+map, l); assertNotNull("" + map, l);
assertTrue("" + map, l.size() > 0); assertTrue("" + map, l.size() > 0);
map = (Map) l.get(0); map = (Map) l.get(0);
assertEquals(""+bytarr.length,String.valueOf(map.get("size"))); assertEquals("" + bytarr.length, String.valueOf(map.get("size")));
compareInputAndOutput(baseUrl+"/.system/blob/test?wt=filestream", bytarr2); compareInputAndOutput(baseUrl + "/.system/blob/test?wt=filestream", bytarr2);
compareInputAndOutput(baseUrl+"/.system/blob/test/1?wt=filestream", bytarr); compareInputAndOutput(baseUrl + "/.system/blob/test/1?wt=filestream", bytarr);
} }
} }
@ -131,12 +131,12 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
Map map = null; Map map = null;
List l; List l;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
int i=0; int i = 0;
for(;i<150;i++) {//15 secs for (; i < 150; i++) {//15 secs
url = baseUrl + "/.system/blob/" + blobName; url = baseUrl + "/.system/blob/" + blobName;
map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient); map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient);
String numFound = String.valueOf(ConfigOverlay.getObjectByPath(map, false, Arrays.asList("response", "numFound"))); String numFound = String.valueOf(ConfigOverlay.getObjectByPath(map, false, Arrays.asList("response", "numFound")));
if(!(""+count).equals(numFound)) { if (!("" + count).equals(numFound)) {
Thread.sleep(100); Thread.sleep(100);
continue; continue;
} }
@ -147,7 +147,7 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
return; return;
} }
fail(MessageFormat.format("Could not successfully add blob after {0} attempts. Expecting {1} items. time elapsed {2} output for url is {3}", fail(MessageFormat.format("Could not successfully add blob after {0} attempts. Expecting {1} items. time elapsed {2} output for url is {3}",
i,count, System.currentTimeMillis()-start, getAsString(map))); i, count, System.currentTimeMillis() - start, getAsString(map)));
} }
public static String getAsString(Map map) { public static String getAsString(Map map) {
@ -178,13 +178,13 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
String response = null; String response = null;
try { try {
httpPost = new HttpPost(baseUrl + "/.system/blob/" + blobName); httpPost = new HttpPost(baseUrl + "/.system/blob/" + blobName);
httpPost.setHeader("Content-Type","application/octet-stream"); httpPost.setHeader("Content-Type", "application/octet-stream");
httpPost.setEntity(new ByteArrayEntity(bytarr.array(), bytarr.arrayOffset(), bytarr.limit())); httpPost.setEntity(new ByteArrayEntity(bytarr.array(), bytarr.arrayOffset(), bytarr.limit()));
entity = cloudClient.getLbClient().getHttpClient().execute(httpPost).getEntity(); entity = cloudClient.getLbClient().getHttpClient().execute(httpPost).getEntity();
try { try {
response = EntityUtils.toString(entity, StandardCharsets.UTF_8); response = EntityUtils.toString(entity, StandardCharsets.UTF_8);
Map m = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response))); Map m = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
assertFalse("Error in posting blob "+ getAsString(m),m.containsKey("error")); assertFalse("Error in posting blob " + getAsString(m), m.containsKey("error"));
} catch (JSONParser.ParseException e) { } catch (JSONParser.ParseException e) {
log.error("$ERROR$", response, e); log.error("$ERROR$", response, e);
fail(); fail();