Author: rezan
Date: Wed Jul 23 01:15:20 2014
New Revision: 1612735
URL: http://svn.apache.org/r1612735
Log:
index unit test
Modified:
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientUnitTest.java
Modified:
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientUnitTest.java
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientUnitTest.java?rev=1612735&r1=1612734&r2=1612735&view=diff
==============================================================================
---
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientUnitTest.java
(original)
+++
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientUnitTest.java
Wed Jul 23 01:15:20 2014
@@ -26,7 +26,7 @@ import org.apache.devicemap.loader.Loade
import org.junit.BeforeClass;
public class DeviceMapClientUnitTest {
-
+
private static DeviceMapClient client;
@BeforeClass
@@ -34,13 +34,27 @@ public class DeviceMapClientUnitTest {
client = new DeviceMapClient();
client.initDeviceData(LoaderOption.JAR);
}
-
+
+ @Test
+ public void DeviceMapClientUninitializedTest() throws Exception {
+ DeviceMapClient uninit = new DeviceMapClient();
+
+ try {
+ Map<String, String> m = uninit.classify("");
+ Assert.fail("Uninitialized device index exception expected");
+ } catch (RuntimeException re) {
+ //pass
+ } catch (Exception ex) {
+ Assert.fail("Uninitialized device index exception expected, got: "
+ ex.toString());
+ }
+ }
+
@Test
public void DeviceMapClientUnknownTest() throws Exception {
Map<String, String> m = client.classify("");
Assert.assertEquals("test ua not unknown", Constants.UNKNOWN_ID,
m.get("id"));
-
+
m = client.classify(null);
Assert.assertEquals("test ua not unknown", Constants.UNKNOWN_ID,
m.get("id"));
@@ -53,30 +67,30 @@ public class DeviceMapClientUnitTest {
Map<String, String> m = client.classify(test);
Assert.assertEquals("test ua not htc aria", "HTC Aria", m.get("id"));
-
+
try {
m.put("mutate", "true");
Assert.fail("UnsupportedOperationException expected when changing
result map");
- } catch(UnsupportedOperationException uoe) {
+ } catch (UnsupportedOperationException uoe) {
//pass
- } catch(Exception ex) {
- Assert.fail("UnsupportedOperationException expected when changing
result map, got: "+ex.toString());
+ } catch (Exception ex) {
+ Assert.fail("UnsupportedOperationException expected when changing
result map, got: " + ex.toString());
}
}
-
+
@Test
public void DeviceMapClientMutateUnknownTest() throws Exception {
Map<String, String> m = client.classify("unknown");
Assert.assertEquals("test ua not unknown", Constants.UNKNOWN_ID,
m.get("id"));
-
+
try {
m.put("mutate", "true");
Assert.fail("UnsupportedOperationException expected when changing
result map");
- } catch(UnsupportedOperationException uoe) {
+ } catch (UnsupportedOperationException uoe) {
//pass
- } catch(Exception ex) {
- Assert.fail("UnsupportedOperationException expected when changing
result map, got: "+ex.toString());
+ } catch (Exception ex) {
+ Assert.fail("UnsupportedOperationException expected when changing
result map, got: " + ex.toString());
}
}
}