Commit 709db096 by Madhan Neethiraj

ATLAS-3067: fixed failure in EntityJerseyResourceIT.testUTF8()

parent bd31c505
...@@ -46,6 +46,8 @@ import org.testng.annotations.Test; ...@@ -46,6 +46,8 @@ import org.testng.annotations.Test;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import static com.sun.jersey.api.client.ClientResponse.Status.BAD_REQUEST; import static com.sun.jersey.api.client.ClientResponse.Status.BAD_REQUEST;
...@@ -818,11 +820,21 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -818,11 +820,21 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
return RandomStringUtils.random(10); return RandomStringUtils.random(10);
} }
private String randomUTF8() throws Exception {
String ret = random();
if (!StandardCharsets.UTF_8.equals(Charset.defaultCharset())) {
ret = new String(ret.getBytes(), StandardCharsets.UTF_8.name());
}
return ret;
}
@Test @Test
public void testUTF8() throws Exception { public void testUTF8() throws Exception {
String attrName = randomUTF8();
String attrValue = randomUTF8();
String classType = randomString(); //Type names cannot be arbitrary UTF8 characters. See org.apache.atlas.type.AtlasTypeUtil#validateType() String classType = randomString(); //Type names cannot be arbitrary UTF8 characters. See org.apache.atlas.type.AtlasTypeUtil#validateType()
String attrName = random();
String attrValue = random();
ClassTypeDefinition classTypeDefinition = TypesUtil.createClassTypeDef(classType, null, Collections.<String>emptySet(), TypesUtil.createUniqueRequiredAttrDef(attrName, AtlasBaseTypeDef.ATLAS_TYPE_STRING)); ClassTypeDefinition classTypeDefinition = TypesUtil.createClassTypeDef(classType, null, Collections.<String>emptySet(), TypesUtil.createUniqueRequiredAttrDef(attrName, AtlasBaseTypeDef.ATLAS_TYPE_STRING));
TypesDef typesDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(), Collections.<TraitTypeDefinition>emptyList(), Collections.singletonList(classTypeDefinition)); TypesDef typesDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(), Collections.<TraitTypeDefinition>emptyList(), Collections.singletonList(classTypeDefinition));
......
...@@ -46,6 +46,8 @@ import org.testng.Assert; ...@@ -46,6 +46,8 @@ 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 java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import static org.testng.Assert.*; import static org.testng.Assert.*;
...@@ -615,11 +617,21 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT { ...@@ -615,11 +617,21 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
return RandomStringUtils.random(10); return RandomStringUtils.random(10);
} }
private String randomUTF8() throws Exception {
String ret = random();
if (!StandardCharsets.UTF_8.equals(Charset.defaultCharset())) {
ret = new String(ret.getBytes(), StandardCharsets.UTF_8.name());
}
return ret;
}
@Test @Test
public void testUTF8() throws Exception { public void testUTF8() throws Exception {
String classType = randomString(); String classType = randomString();
String attrName = random(); String attrName = randomUTF8();
String attrValue = random(); String attrValue = randomUTF8();
AtlasEntityDef classTypeDef = AtlasTypeUtil AtlasEntityDef classTypeDef = AtlasTypeUtil
.createClassTypeDef(classType, Collections.<String>emptySet(), .createClassTypeDef(classType, Collections.<String>emptySet(),
...@@ -772,7 +784,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT { ...@@ -772,7 +784,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
@Test @Test
public void testDeleteEntityByUniqAttribute() throws Exception { public void testDeleteEntityByUniqAttribute() throws Exception {
// Create database entity // Create database entity
AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + random()); AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + randomUTF8());
// Delete the database entity // Delete the database entity
EntityMutationResponse deleteResponse = atlasClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) hiveDB.getAttribute(NAME))); EntityMutationResponse deleteResponse = atlasClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) hiveDB.getAttribute(NAME)));
......
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