-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase user attribute value length limit
- Loading branch information
Sam Dozor
committed
Apr 27, 2016
1 parent
6c0932b
commit 4e0988e
Showing
7 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
sdk/src/test/java/com/mparticle/internal/MPUtilityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.mparticle.internal; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class MPUtilityTest { | ||
|
||
@Test | ||
public void testSetCheckedAttribute() throws Exception { | ||
JSONObject attributes = new JSONObject(); | ||
|
||
MPUtility.setCheckedAttribute(attributes, "some key", "some value", false, true); | ||
assertEquals("some value", attributes.getString("some key")); | ||
|
||
|
||
MPUtility.setCheckedAttribute(attributes, "some key 2", "some value 2", false, false); | ||
assertEquals("some value 2", attributes.getString("some key 2")); | ||
|
||
} | ||
|
||
@Test | ||
public void testSetKeyThatsTooLong() throws Exception { | ||
JSONObject attributes = new JSONObject(); | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < 257; i++) { | ||
builder.append("a"); | ||
} | ||
String keyThatsTooLong = builder.toString(); | ||
MPUtility.setCheckedAttribute(attributes, keyThatsTooLong, "some value 2", false, true); | ||
|
||
assertFalse(attributes.has(keyThatsTooLong)); | ||
|
||
} | ||
|
||
|
||
@Test | ||
public void testSetValueThatsTooLong() throws Exception { | ||
JSONObject attributes = new JSONObject(); | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < 257; i++) { | ||
builder.append("a"); | ||
} | ||
String valueThatsTooLong = builder.toString(); | ||
MPUtility.setCheckedAttribute(attributes, "mykey", valueThatsTooLong, false, false); | ||
|
||
assertFalse(attributes.has("mykey")); | ||
|
||
} | ||
|
||
@Test | ||
public void testSetUserValueThatsTooLong() throws Exception { | ||
JSONObject attributes = new JSONObject(); | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < 4097; i++) { | ||
builder.append("a"); | ||
} | ||
String valueThatsTooLong = builder.toString(); | ||
MPUtility.setCheckedAttribute(attributes, "mykey", valueThatsTooLong, false, true); | ||
|
||
assertFalse(attributes.has("mykey")); | ||
|
||
} | ||
} |