Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Additional test to make sure the trim is working properly

  • Loading branch information...
commit 8428d8a8a5ba3ca4442ebee80b7dfefb6574636f 1 parent c11ed70
jkew authored
View
48 src/test/java/com/springsource/insight/plugin/mongodb/MongoArgumentUtilsTest.java
@@ -4,83 +4,91 @@
import java.math.BigInteger;
import java.util.Random;
-import com.springsource.insight.plugin.mongodb.MongoArgumentUtils;
import org.bson.types.ObjectId;
-import org.junit.Assert;
+
+import static org.junit.Assert.*;
+
import org.junit.Test;
public class MongoArgumentUtilsTest {
+
+ @Test
+ public void testLongStringTruncatedToLimit() {
+ String bigRandom = new BigInteger(2048, new Random()).toString(32);
+ assertEquals(bigRandom.substring(0, 256) + "...", MongoArgumentUtils.toString(bigRandom));
+ }
+
@Test
public void testNullToString() {
- Assert.assertEquals("null", MongoArgumentUtils.toString((Object) null));
+ assertEquals("null", MongoArgumentUtils.toString((Object) null));
}
@Test
public void testStringValue() {
- Assert.assertEquals("Slartibartfast",
- MongoArgumentUtils.toString("Slartibartfast"));
+ assertEquals("Slartibartfast",
+ MongoArgumentUtils.toString("Slartibartfast"));
}
@Test
public void testBooleanValue() {
- Assert.assertEquals("true", MongoArgumentUtils.toString(Boolean.TRUE));
+ assertEquals("true", MongoArgumentUtils.toString(Boolean.TRUE));
}
@Test
public void testByteValue() {
- Assert.assertEquals("42", MongoArgumentUtils.toString((byte) 42));
+ assertEquals("42", MongoArgumentUtils.toString((byte) 42));
}
@Test
public void testCharacterValue() {
- Assert.assertEquals("A", MongoArgumentUtils.toString('A'));
+ assertEquals("A", MongoArgumentUtils.toString('A'));
}
@Test
public void testShortValue() {
- Assert.assertEquals("42", MongoArgumentUtils.toString((short) 42));
+ assertEquals("42", MongoArgumentUtils.toString((short) 42));
}
@Test
public void testIntegerValue() {
- Assert.assertEquals("42", MongoArgumentUtils.toString(42));
+ assertEquals("42", MongoArgumentUtils.toString(42));
}
@Test
public void testLongValue() {
- Assert.assertEquals("42", MongoArgumentUtils.toString((long) 42));
+ assertEquals("42", MongoArgumentUtils.toString((long) 42));
}
@Test
public void testFloatValue() {
- Assert.assertEquals("42.0", MongoArgumentUtils.toString((float) 42.0));
+ assertEquals("42.0", MongoArgumentUtils.toString((float) 42.0));
}
@Test
public void testDoubleValue() {
- Assert.assertEquals("42.0", MongoArgumentUtils.toString(42.0));
+ assertEquals("42.0", MongoArgumentUtils.toString(42.0));
}
@Test
public void testBigIntegerValue() {
- Assert.assertEquals("42424242",
- MongoArgumentUtils.toString(new BigInteger("42424242")));
+ assertEquals("42424242",
+ MongoArgumentUtils.toString(new BigInteger("42424242")));
}
@Test
public void testBigDecimalValue() {
- Assert.assertEquals("42.424242",
- MongoArgumentUtils.toString(new BigDecimal("42.424242")));
+ assertEquals("42.424242",
+ MongoArgumentUtils.toString(new BigDecimal("42.424242")));
}
@Test
public void testObjectIdValue() {
- Assert.assertEquals("0123456789abcd0123456789",
- MongoArgumentUtils.toString(new ObjectId("0123456789abcd0123456789")));
+ assertEquals("0123456789abcd0123456789",
+ MongoArgumentUtils.toString(new ObjectId("0123456789abcd0123456789")));
}
@Test
public void testUnknownClass() {
- Assert.assertEquals("Random", MongoArgumentUtils.toString(new Random()));
+ assertEquals("Random", MongoArgumentUtils.toString(new Random()));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.