You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by re...@apache.org on 2014/07/05 01:03:59 UTC
svn commit: r1607954 [1/2] - in
/incubator/devicemap/trunk/devicemap/java/classifier/src/test: java/
java/org/ java/org/apache/ java/org/apache/devicemap/ resources/
Author: rezan
Date: Fri Jul 4 23:03:58 2014
New Revision: 1607954
URL: http://svn.apache.org/r1607954
Log:
java tests
Added:
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java (with props)
incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java (with props)
incubator/devicemap/trunk/devicemap/java/classifier/src/test/resources/
incubator/devicemap/trunk/devicemap/java/classifier/src/test/resources/uas.data
Added: incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java?rev=1607954&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java (added)
+++ incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java Fri Jul 4 23:03:58 2014
@@ -0,0 +1,41 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.devicemap;
+
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DeviceMapClientSimpleTest {
+
+ @Test
+ public void DeviceMapClientTest() throws Exception {
+ DeviceMapClient client=new DeviceMapClient();
+ client.loadFromResource("-j","");
+
+ String test="Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile Safari/524.15.0";
+
+ Map<String,String> m=client.classify(test);
+
+ Assert.assertEquals("test ua not htc aria", "HTC Aria", m.get("id"));
+ }
+}
Propchange: incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientSimpleTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java?rev=1607954&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java (added)
+++ incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java Fri Jul 4 23:03:58 2014
@@ -0,0 +1,83 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.devicemap;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class DeviceMapClientTest {
+
+ private static DeviceMapClient client;
+
+ @BeforeClass
+ public static void setupDeviceMapClient() throws Exception {
+ client=new DeviceMapClient();
+ client.loadFromResource("-j","");
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() throws Exception {
+ Collection params=new ArrayList<Object[]>();
+
+ BufferedReader reader=new BufferedReader(new InputStreamReader(DeviceMapClientTest.class.getResourceAsStream("/uas.data")));
+ String line;
+
+ while((line=reader.readLine())!=null) {
+ params.add(line.split("\\|\\|"));
+ }
+
+ reader.close();
+
+ return params;
+ }
+
+ private final String testString;
+ private final String resultId;
+
+ public DeviceMapClientTest(String testString, String resultId) {
+ this.testString=testString;
+ this.resultId=resultId;
+ }
+
+ @Test
+ public void DeviceMapClientTest() throws Exception {
+ Map<String,String> m=client.classify(testString);
+
+ String id="unknown";
+
+ if(m!=null) {
+ id=m.get("id");
+ }
+
+ Assert.assertEquals("classification failed for '"+testString+"'", resultId, id);
+ }
+}
Propchange: incubator/devicemap/trunk/devicemap/java/classifier/src/test/java/org/apache/devicemap/DeviceMapClientTest.java
------------------------------------------------------------------------------
svn:executable = *