This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new 709db09  ATLAS-3067: fixed failure in EntityJerseyResourceIT.testUTF8()
709db09 is described below

commit 709db096badfad3c17cf3adf9d65585bf1c0bc04
Author: Madhan Neethiraj <[email protected]>
AuthorDate: Thu Jul 18 16:57:38 2019 -0700

    ATLAS-3067: fixed failure in EntityJerseyResourceIT.testUTF8()
---
 .../atlas/web/integration/EntityJerseyResourceIT.java  | 16 ++++++++++++++--
 .../web/integration/EntityV2JerseyResourceIT.java      | 18 +++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git 
a/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
index b3be8ef..f5abb7c 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
@@ -46,6 +46,8 @@ import org.testng.annotations.Test;
 
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 import static com.sun.jersey.api.client.ClientResponse.Status.BAD_REQUEST;
@@ -818,11 +820,21 @@ public class EntityJerseyResourceIT extends 
BaseResourceIT {
         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
     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              attrName            = random();
-        String              attrValue           = random();
         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));
 
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
index 8d6f153..5d506bb 100755
--- 
a/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
@@ -46,6 +46,8 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 import static org.testng.Assert.*;
@@ -615,11 +617,21 @@ public class EntityV2JerseyResourceIT extends 
BaseResourceIT {
         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
     public void testUTF8() throws Exception {
         String classType = randomString();
-        String attrName = random();
-        String attrValue = random();
+        String attrName = randomUTF8();
+        String attrValue = randomUTF8();
 
         AtlasEntityDef classTypeDef = AtlasTypeUtil
                 .createClassTypeDef(classType, Collections.<String>emptySet(),
@@ -772,7 +784,7 @@ public class EntityV2JerseyResourceIT extends 
BaseResourceIT {
     @Test
     public void testDeleteEntityByUniqAttribute() throws Exception {
         // Create database entity
-        AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + random());
+        AtlasEntity hiveDB = createHiveDB(DATABASE_NAME + randomUTF8());
 
         // Delete the database entity
         EntityMutationResponse deleteResponse = 
atlasClientV2.deleteEntityByAttribute(DATABASE_TYPE_V2, toMap(NAME, (String) 
hiveDB.getAttribute(NAME)));

Reply via email to