Commits

Luke Hoersten committed 01be435

Removed json.jar from build script and added some raw util unit tests.

  • Participants
  • Parent commits ac9aa1c

Comments (0)

Files changed (4)

File build/build.xml

 	<target name="libs">
 		<!-- Dependencies -->
 		<fileset dir="${lib.dir}" id="lib.jars">
-			<include name="${json.jar}" />
 		</fileset>
 
 		<!-- Test Dependencies -->

File build/lib.properties

-# Dependency Libraries
-json.jar=json.jar
-
 # Test Dependency Libraries
 junit.jar=junit-4.8.2.jar
 mockito.jar=mockito-all-1.8.5.jar

File src/org/discoproject/DiscoUtils.java

 		        + removeNewlines((new BASE64Encoder()).encode(str.getBytes()));
 	}
 
+	public static String decodeRaw(final String str) throws IOException {
+		return new String(new BASE64Decoder().decodeBuffer(str));
+	}
+
 	public static String decodeRaw(final ReadableByteChannel channel) throws IOException {
 		return new String(new BASE64Decoder().decodeBuffer(Channels.newInputStream(channel)));
 	}

File test/com/allstontrading/fx/rd/disco/worker/DiscoTest.java

 import org.junit.Test;
 import org.mockito.InOrder;
 
-
 /**
  * @author Luke Hoersten <lhoersten@allstontrading.com>
  * 
 	@Test
 	public void testB64Encoding() {
 		final String json = "{\"entryexitlevel\":[\"DEC\",1.5],\"qr2\":[\"DEC\",1],\"qr1\":[\"DEC\",1.0E-5],\"enterexitwindow\":[\"STR\",\"'2 hours'\"],\"VarientNumber\":1}";
-		final String expected = "eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVDIiwxLjBFLTVdLCJlbnRlcmV4aXR3aW5kb3ciOlsiU1RSIiwiJzIgaG91cnMnIl0sIlZhcmllbnROdW1iZXIiOjF9";
+		final String expected = "raw://eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVDIiwxLjBFLTVdLCJlbnRlcmV4aXR3aW5kb3ciOlsiU1RSIiwiJzIgaG91cnMnIl0sIlZhcmllbnROdW1iZXIiOjF9";
 
 		final String actual = DiscoUtils.encodeRaw(json);
+		assertEquals(expected, actual);
+	}
 
+	@Test
+	public void testB64Decoding() throws IOException {
+		final String raw = "eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVDIiwxLjBFLTVdLCJlbnRlcmV4aXR3aW5kb3ciOlsiU1RSIiwiJzIgaG91cnMnIl0sIlZhcmllbnROdW1iZXIiOjF9";
+		final String expected = "{\"entryexitlevel\":[\"DEC\",1.5],\"qr2\":[\"DEC\",1],\"qr1\":[\"DEC\",1.0E-5],\"enterexitwindow\":[\"STR\",\"'2 hours'\"],\"VarientNumber\":1}";
+
+		final String actual = DiscoUtils.decodeRaw(raw);
 		assertEquals(expected, actual);
 	}