Commit 3943a640 by Venkatesh Seetharam

BUG-38897 return consistent content type header for all calls

parent 666d92e9
...@@ -75,6 +75,8 @@ public class MetadataServiceClient { ...@@ -75,6 +75,8 @@ public class MetadataServiceClient {
public static final String DATA_SET_SUPER_TYPE = "DataSet"; public static final String DATA_SET_SUPER_TYPE = "DataSet";
public static final String PROCESS_SUPER_TYPE = "Process"; public static final String PROCESS_SUPER_TYPE = "Process";
public static final String JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON + "; charset=UTF-8";
private WebResource service; private WebResource service;
public MetadataServiceClient(String baseUrl) { public MetadataServiceClient(String baseUrl) {
...@@ -213,9 +215,9 @@ public class MetadataServiceClient { ...@@ -213,9 +215,9 @@ public class MetadataServiceClient {
/** /**
* Updates property for the entity corresponding to guid * Updates property for the entity corresponding to guid
* @param guid * @param guid guid
* @param property * @param property property key
* @param value * @param value property value
*/ */
public JSONObject updateEntity(String guid, String property, String value) throws MetadataServiceException { public JSONObject updateEntity(String guid, String property, String value) throws MetadataServiceException {
WebResource resource = getResource(API.UPDATE_ENTITY, guid); WebResource resource = getResource(API.UPDATE_ENTITY, guid);
...@@ -314,11 +316,11 @@ public class MetadataServiceClient { ...@@ -314,11 +316,11 @@ public class MetadataServiceClient {
private JSONObject callAPIWithResource(API api, WebResource resource, Object requestObject) private JSONObject callAPIWithResource(API api, WebResource resource, Object requestObject)
throws MetadataServiceException { throws MetadataServiceException {
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(JSON_MEDIA_TYPE)
.method(api.getMethod(), ClientResponse.class, requestObject); .method(api.getMethod(), ClientResponse.class, requestObject);
Response.Status expectedStatus = (api.getMethod() == HttpMethod.POST) Response.Status expectedStatus = HttpMethod.POST.equals(api.getMethod())
? Response.Status.CREATED : Response.Status.OK; ? Response.Status.CREATED : Response.Status.OK;
if (clientResponse.getStatus() == expectedStatus.getStatusCode()) { if (clientResponse.getStatus() == expectedStatus.getStatusCode()) {
String responseAsString = clientResponse.getEntity(String.class); String responseAsString = clientResponse.getEntity(String.class);
......
...@@ -76,7 +76,7 @@ public class AdminResource { ...@@ -76,7 +76,7 @@ public class AdminResource {
*/ */
@GET @GET
@Path("version") @Path("version")
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getVersion() { public Response getVersion() {
if (version == null) { if (version == null) {
try { try {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
package org.apache.hadoop.metadata.web.util; package org.apache.hadoop.metadata.web.util;
import com.google.common.base.Preconditions;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -41,14 +40,13 @@ import java.io.StringWriter; ...@@ -41,14 +40,13 @@ import java.io.StringWriter;
*/ */
public final class Servlets { public final class Servlets {
public static final String QUOTE = "\"";
private static final Logger LOG = LoggerFactory.getLogger(Servlets.class); private static final Logger LOG = LoggerFactory.getLogger(Servlets.class);
private Servlets() { private Servlets() {
/* singleton */ /* singleton */
} }
public static final String JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON + "; charset=UTF-8"; public static final String JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON + "; charset=UTF-8";
/** /**
* Returns the user of the given request. * Returns the user of the given request.
* *
...@@ -133,7 +131,7 @@ public final class Servlets { ...@@ -133,7 +131,7 @@ public final class Servlets {
return Response return Response
.status(status) .status(status)
.entity(errorEntity) .entity(errorEntity)
.type(MediaType.APPLICATION_JSON) .type(JSON_MEDIA_TYPE)
.build(); .build();
} }
......
...@@ -21,13 +21,13 @@ package org.apache.hadoop.metadata.web.resources; ...@@ -21,13 +21,13 @@ package org.apache.hadoop.metadata.web.resources;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
...@@ -46,8 +46,8 @@ public class AdminJerseyResourceIT extends BaseResourceIT { ...@@ -46,8 +46,8 @@ public class AdminJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/admin/version"); .path("api/metadata/admin/version");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
......
...@@ -30,12 +30,12 @@ import org.apache.hadoop.metadata.typesystem.json.TypesSerialization; ...@@ -30,12 +30,12 @@ import org.apache.hadoop.metadata.typesystem.json.TypesSerialization;
import org.apache.hadoop.metadata.typesystem.persistence.Id; import org.apache.hadoop.metadata.typesystem.persistence.Id;
import org.apache.hadoop.metadata.typesystem.types.ClassType; import org.apache.hadoop.metadata.typesystem.types.ClassType;
import org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition; import org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
...@@ -73,8 +73,8 @@ public abstract class BaseResourceIT { ...@@ -73,8 +73,8 @@ public abstract class BaseResourceIT {
.path("api/metadata/types"); .path("api/metadata/types");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, typesAsJSON); .method(HttpMethod.POST, ClientResponse.class, typesAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
......
...@@ -33,8 +33,18 @@ import org.apache.hadoop.metadata.typesystem.json.InstanceSerialization$; ...@@ -33,8 +33,18 @@ import org.apache.hadoop.metadata.typesystem.json.InstanceSerialization$;
import org.apache.hadoop.metadata.typesystem.json.TypesSerialization; import org.apache.hadoop.metadata.typesystem.json.TypesSerialization;
import org.apache.hadoop.metadata.typesystem.json.TypesSerialization$; import org.apache.hadoop.metadata.typesystem.json.TypesSerialization$;
import org.apache.hadoop.metadata.typesystem.persistence.Id; import org.apache.hadoop.metadata.typesystem.persistence.Id;
import org.apache.hadoop.metadata.typesystem.types.*; import org.apache.hadoop.metadata.typesystem.types.AttributeDefinition;
import org.apache.hadoop.metadata.typesystem.types.ClassType;
import org.apache.hadoop.metadata.typesystem.types.DataTypes;
import org.apache.hadoop.metadata.typesystem.types.EnumTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.EnumValue;
import org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.Multiplicity;
import org.apache.hadoop.metadata.typesystem.types.StructTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.TraitType;
import org.apache.hadoop.metadata.typesystem.types.TypeUtils;
import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil; import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -44,7 +54,6 @@ import org.testng.annotations.BeforeClass; ...@@ -44,7 +54,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -209,8 +218,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -209,8 +218,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path(guid); .path(guid);
return resource.queryParam("property", property).queryParam("value", value) return resource.queryParam("property", property).queryParam("value", value)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.PUT, ClientResponse.class); .method(HttpMethod.PUT, ClientResponse.class);
} }
...@@ -218,8 +227,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -218,8 +227,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
WebResource resource = service WebResource resource = service
.path("api/metadata/entities") .path("api/metadata/entities")
.path(guid); .path(guid);
return resource.accept(MediaType.APPLICATION_JSON) return resource.accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
} }
...@@ -239,8 +248,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -239,8 +248,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("blah"); .path("blah");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
...@@ -257,8 +266,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -257,8 +266,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
ClientResponse clientResponse = service ClientResponse clientResponse = service
.path("api/metadata/entities") .path("api/metadata/entities")
.queryParam("type", TABLE_TYPE) .queryParam("type", TABLE_TYPE)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -278,8 +287,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -278,8 +287,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
ClientResponse clientResponse = service ClientResponse clientResponse = service
.path("api/metadata/entities") .path("api/metadata/entities")
.queryParam("type", "blah") .queryParam("type", "blah")
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
...@@ -299,8 +308,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -299,8 +308,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
ClientResponse clientResponse = service ClientResponse clientResponse = service
.path("api/metadata/entities") .path("api/metadata/entities")
.queryParam("type", "test") .queryParam("type", "test")
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -331,8 +340,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -331,8 +340,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/entities") .path("api/metadata/entities")
.path(guid) .path(guid)
.path(TRAITS) .path(TRAITS)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -365,8 +374,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -365,8 +374,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/entities") .path("api/metadata/entities")
.path(guid) .path(guid)
.path(TRAITS) .path(TRAITS)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
...@@ -391,8 +400,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -391,8 +400,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/entities") .path("api/metadata/entities")
.path(guid) .path(guid)
.path(TRAITS) .path(TRAITS)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
} }
...@@ -417,8 +426,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -417,8 +426,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/entities") .path("api/metadata/entities")
.path(guid) .path(guid)
.path(TRAITS) .path(TRAITS)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
...@@ -461,8 +470,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -461,8 +470,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/entities") .path("api/metadata/entities")
.path("random") .path("random")
.path(TRAITS) .path(TRAITS)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON); .method(HttpMethod.POST, ClientResponse.class, traitInstanceAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
} }
...@@ -476,8 +485,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -476,8 +485,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path(guid) .path(guid)
.path(TRAITS) .path(TRAITS)
.path(traitName) .path(traitName)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.DELETE, ClientResponse.class); .method(HttpMethod.DELETE, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -499,8 +508,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -499,8 +508,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.path("random") .path("random")
.path(TRAITS) .path(TRAITS)
.path(traitName) .path(traitName)
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.DELETE, ClientResponse.class); .method(HttpMethod.DELETE, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
......
...@@ -37,6 +37,7 @@ import org.apache.hadoop.metadata.typesystem.types.StructTypeDefinition; ...@@ -37,6 +37,7 @@ import org.apache.hadoop.metadata.typesystem.types.StructTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.TraitType; import org.apache.hadoop.metadata.typesystem.types.TraitType;
import org.apache.hadoop.metadata.typesystem.types.TypeUtils; import org.apache.hadoop.metadata.typesystem.types.TypeUtils;
import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil; import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
...@@ -44,7 +45,6 @@ import org.testng.annotations.BeforeClass; ...@@ -44,7 +45,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
...@@ -72,8 +72,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { ...@@ -72,8 +72,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT {
.path("graph"); .path("graph");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -106,8 +106,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { ...@@ -106,8 +106,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT {
.path("graph"); .path("graph");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -139,8 +139,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { ...@@ -139,8 +139,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT {
.path("schema"); .path("schema");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -174,8 +174,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { ...@@ -174,8 +174,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT {
.path("schema"); .path("schema");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Assert.assertEquals(clientResponse.getStatus(),
Response.Status.NOT_FOUND.getStatusCode()); Response.Status.NOT_FOUND.getStatusCode());
...@@ -189,8 +189,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT { ...@@ -189,8 +189,8 @@ public class HiveLineageJerseyResourceIT extends BaseResourceIT {
.path("schema"); .path("schema");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Assert.assertEquals(clientResponse.getStatus(),
Response.Status.NOT_FOUND.getStatusCode()); Response.Status.NOT_FOUND.getStatusCode());
......
...@@ -34,6 +34,7 @@ import org.apache.hadoop.metadata.typesystem.types.StructTypeDefinition; ...@@ -34,6 +34,7 @@ import org.apache.hadoop.metadata.typesystem.types.StructTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.TraitType; import org.apache.hadoop.metadata.typesystem.types.TraitType;
import org.apache.hadoop.metadata.typesystem.types.TypeUtils; import org.apache.hadoop.metadata.typesystem.types.TypeUtils;
import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil; import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
...@@ -41,7 +42,6 @@ import org.testng.annotations.BeforeClass; ...@@ -41,7 +42,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
...@@ -66,8 +66,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -66,8 +66,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
.queryParam("query", dslQuery); .queryParam("query", dslQuery);
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -99,8 +99,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -99,8 +99,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
.queryParam("query", dslQuery); .queryParam("query", dslQuery);
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Assert.assertEquals(clientResponse.getStatus(),
Response.Status.BAD_REQUEST.getStatusCode()); Response.Status.BAD_REQUEST.getStatusCode());
...@@ -114,8 +114,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -114,8 +114,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
.queryParam("query", query); .queryParam("query", query);
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -137,8 +137,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT { ...@@ -137,8 +137,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
.queryParam("query", query); .queryParam("query", query);
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
......
...@@ -20,12 +20,12 @@ package org.apache.hadoop.metadata.web.resources; ...@@ -20,12 +20,12 @@ package org.apache.hadoop.metadata.web.resources;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
...@@ -49,8 +49,8 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT { ...@@ -49,8 +49,8 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT {
.path("0"); .path("0");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
String response = clientResponse.getEntity(String.class); String response = clientResponse.getEntity(String.class);
...@@ -62,8 +62,8 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT { ...@@ -62,8 +62,8 @@ public class RexsterGraphJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/graph/vertices/blah"); .path("api/metadata/graph/vertices/blah");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
} }
......
...@@ -32,6 +32,7 @@ import org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition; ...@@ -32,6 +32,7 @@ import org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition;
import org.apache.hadoop.metadata.typesystem.types.Multiplicity; import org.apache.hadoop.metadata.typesystem.types.Multiplicity;
import org.apache.hadoop.metadata.typesystem.types.TraitType; import org.apache.hadoop.metadata.typesystem.types.TraitType;
import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil; import org.apache.hadoop.metadata.typesystem.types.utils.TypesUtil;
import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
...@@ -40,7 +41,6 @@ import org.testng.annotations.BeforeClass; ...@@ -40,7 +41,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -74,8 +74,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -74,8 +74,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/types"); .path("api/metadata/types");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.POST, ClientResponse.class, typesAsJSON); .method(HttpMethod.POST, ClientResponse.class, typesAsJSON);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
...@@ -98,8 +98,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -98,8 +98,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
.path(typeDefinition.typeName); .path(typeDefinition.typeName);
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -130,8 +130,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -130,8 +130,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
.path("blah"); .path("blah");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
} }
...@@ -142,8 +142,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -142,8 +142,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
.path("api/metadata/types"); .path("api/metadata/types");
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
...@@ -166,8 +166,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -166,8 +166,8 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
ClientResponse clientResponse = resource ClientResponse clientResponse = resource
.queryParam("type", DataTypes.TypeCategory.TRAIT.name()) .queryParam("type", DataTypes.TypeCategory.TRAIT.name())
.accept(MediaType.APPLICATION_JSON) .accept(Servlets.JSON_MEDIA_TYPE)
.type(MediaType.APPLICATION_JSON) .type(Servlets.JSON_MEDIA_TYPE)
.method(HttpMethod.GET, ClientResponse.class); .method(HttpMethod.GET, ClientResponse.class);
Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment