public void testMetadataInvalidUrl() throws Exception {
registerGadgetsHandler(null);
String badUrl = "[moo]";
JSONObject request = makeMetadataRequest(null, null, null, badUrl);
RpcHandler operation = registry.getRpcHandler(request);
Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
JSONObject response = new JSONObject(converter.convertToString(responseObj));
JSONObject gadget = response.getJSONObject(badUrl);
assertEquals("Bad url - " + badUrl, gadget.getJSONObject("error").getString("message"));
assertEquals(400, gadget.getJSONObject("error").getInt("code"));
}