From a9ebc1479619493e5bdd6cd17768cc0ea15334f4 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 6 Sep 2013 02:02:03 +0200 Subject: [PATCH] Add Base64 test. --- test/fr/devinsy/sikevadb/SQLSikevaDBTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/fr/devinsy/sikevadb/SQLSikevaDBTest.java b/test/fr/devinsy/sikevadb/SQLSikevaDBTest.java index a36c481..0a9e61f 100644 --- a/test/fr/devinsy/sikevadb/SQLSikevaDBTest.java +++ b/test/fr/devinsy/sikevadb/SQLSikevaDBTest.java @@ -5,6 +5,8 @@ import java.util.Date; import javax.naming.NamingException; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.RandomStringUtils; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -376,6 +378,31 @@ public class SQLSikevaDBTest { logger.debug("===== test done."); } + /** + * @throws Exception + * + */ + @Test + public void testRandom01() throws Exception { + // + logger.debug("===== test starting..."); + + database.clearDatabase(); + + String surSource = RandomStringUtils.random(128); + String source = org.apache.commons.codec.binary.Base64.encodeBase64String(surSource.getBytes()); + database.put("alpha01", null, source); + + String target = database.getValue("alpha01"); + Assert.assertEquals(source, target); + + String surTarget = new String(Base64.decodeBase64(target)); + Assert.assertEquals(surSource, surTarget); + + // + logger.debug("===== test done."); + } + /** * @throws Exception *