aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-09 17:04:10 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-09 17:04:10 +0100
commitbc54871dac7ef10102edecf91a747d6595a4640f (patch)
tree4cf4aaf0875497359534a9521ba785a7476fa7a5 /src/test/java
parent8f027c74517e1cf2c8fc13f86da80e8e8f1c0148 (diff)
downloadesper-testing-bc54871dac7ef10102edecf91a747d6595a4640f.tar.gz
esper-testing-bc54871dac7ef10102edecf91a747d6595a4640f.tar.bz2
esper-testing-bc54871dac7ef10102edecf91a747d6595a4640f.tar.xz
esper-testing-bc54871dac7ef10102edecf91a747d6595a4640f.zip
o Adding basic build list in the front page application.
Diffstat (limited to 'src/test/java')
-rwxr-xr-xsrc/test/java/io/trygvis/esper/testing/UuidTest.java66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/test/java/io/trygvis/esper/testing/UuidTest.java b/src/test/java/io/trygvis/esper/testing/UuidTest.java
index 1efec73..8d36177 100755
--- a/src/test/java/io/trygvis/esper/testing/UuidTest.java
+++ b/src/test/java/io/trygvis/esper/testing/UuidTest.java
@@ -10,6 +10,8 @@ import static org.junit.Assert.*;
public class UuidTest {
+ boolean silent = System.getProperty("idea.launcher") != null;
+
@Test
public void testToString() {
String s = "fedcba98-7654-3210-fedc-ba9876543210";
@@ -34,15 +36,55 @@ public class UuidTest {
}
@Test
+ public void test2_() {
+ UUID uuid = UUID.fromString("01234567-89ab-cdef-0123-456789abcdef");
+
+ String base64 = new Uuid(uuid).toStringBase64();
+
+ assertEquals(toBase64(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()), base64);
+
+ assertEquals(uuid, Uuid.parseBase64(base64).toUUID());
+ }
+
+ @Test
+ public void test3() {
+ Uuid uuid = Uuid.fromString("3f4fc3bc-967a-40a7-9fc2-46398d35fa25");
+
+ UUID x = UUID.fromString(uuid.toUuidString());
+ String s = toBase64(x.getMostSignificantBits(), x.getLeastSignificantBits());
+ System.out.println(s);
+
+ System.out.println("uuid.toUuidString() = " + uuid.toUuidString());
+ System.out.println("uuid.toStringBase64() = " + uuid.toStringBase64());
+
+ assertEquals(uuid, Uuid.fromString(uuid.toUuidString()));
+
+ assertEquals(uuid.toUuidString(), Uuid.fromString(uuid.toStringBase64()).toUuidString());
+ }
+
+ @Test
+ public void test4() {
+ Uuid uuid = Uuid.fromString("c541ff9e-e0a6-4eda-8eea-3f19e5ef893a");
+
+ System.out.println(System.getProperties());
+
+ assertEquals(uuid, Uuid.fromString(uuid.toUuidString()));
+
+ assertEquals(uuid.toUuidString(), Uuid.fromString(uuid.toStringBase64()).toUuidString());
+ }
+
+ @Test
public void random() {
Random random = new Random(0);
for(int i = 0; i < 100; i++) {
long most = random.nextLong();
long least = random.nextLong();
- System.out.println(format("i=%2d, most=%08x, least=%08x", i, most, least));
+ if(!silent)
+ System.out.println(format("i=%2d, most=%08x, least=%08x", i, most, least));
UUID s = new UUID(most, least);
+ System.out.println("s = " + s);
Uuid uuid = Uuid.fromString(s.toString());
assertEquals(s.toString(), uuid.toUuidString());
@@ -52,16 +94,34 @@ public class UuidTest {
private String toBase64(long most, long least) {
String x = StringUtils.leftPad(Long.toBinaryString(most), 64, '0') + StringUtils.leftPad(Long.toBinaryString(least), 64, '0');
- System.out.println(x);
+ if(!silent)
+ System.out.println(x);
String r = "";
for (int i = 0; i < 22; i++) {
int end = Math.min((i + 1) * 6, x.length());
String y = x.substring(i * 6, end);
int number = Integer.parseInt(y, 2);
- System.out.println(format("% 4d % 4d binary=%8s, dec=%2d %c", i, end, y, number, Uuid.alphabet[number]));
+ if(!silent)
+ System.out.println(format("% 4d % 4d binary=%8s, dec=%2d %c", i, end, y, number, Uuid.alphabet[number]));
r += Uuid.alphabet[number];
}
return r;
}
+
+ /*
+ private UUID fromBase64(String s) {
+ assertEquals(22, s.length());
+
+ int shift = 60;
+ long most = 0, least = 0;
+
+ for (int i = 0; i < 22; i += 6) {
+ String x = s.substring(i, Math.min(s.length(), i + 6));
+ System.out.println("x = " + x);
+ Integer.parseInt(x);
+
+ }
+ }
+ */
}