ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-3345 WIP Added tests.
Date Sun, 18 Feb 2018 15:29:46 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3345 300a93a24 -> ac9699983


IGNITE-3345 WIP Added tests.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ac969998
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ac969998
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ac969998

Branch: refs/heads/ignite-3345
Commit: ac9699983794e545c23799fffb3ff29207e0d1e4
Parents: 300a93a
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Sun Feb 18 22:29:37 2018 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Sun Feb 18 22:29:37 2018 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 170 +++++++++++++++++--
 1 file changed, 154 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ac969998/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 9092d7b..50b64b9 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -2026,10 +2026,10 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     /**
      * @throws Exception If failed.
      */
-    public void testTypedPutGet() throws Exception {
+    public void testTypedPut() throws Exception {
         // Test boolean type.
         putTypedValue("boolean", "true", "false");
-        putTypedValue("java.lang.boolean", "false", "true");
+        putTypedValue("java.lang.Boolean", "false", "true");
 
         IgniteCache<Boolean, Boolean> cBool = jcache();
 
@@ -2038,7 +2038,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test byte type.
         putTypedValue("byte", "64", "100");
-        putTypedValue("java.lang.byte", "-25", "-127");
+        putTypedValue("java.lang.Byte", "-25", "-127");
 
         IgniteCache<Byte, Byte> cByte = jcache();
 
@@ -2047,7 +2047,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test short type.
         putTypedValue("short", "1024", "4096");
-        putTypedValue("java.lang.short", "-15000", "-16000");
+        putTypedValue("java.lang.Short", "-15000", "-16000");
 
         IgniteCache<Short, Short> cShort = jcache();
 
@@ -2056,8 +2056,8 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test integer type.
         putTypedValue("int", "65555", "128256");
-        putTypedValue("integer", "74555", "200000");
-        putTypedValue("java.lang.integer", "-200", "-100000");
+        putTypedValue("Integer", "74555", "200000");
+        putTypedValue("java.lang.Integer", "-200", "-100000");
 
         IgniteCache<Integer, Integer> cInt = jcache();
 
@@ -2067,7 +2067,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test long type.
         putTypedValue("long", "3000000", "400000");
-        putTypedValue("java.lang.long", "-3000000", "-400000");
+        putTypedValue("java.lang.Long", "-3000000", "-400000");
 
         IgniteCache<Long, Long> cLong = jcache();
 
@@ -2076,7 +2076,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test float type.
         putTypedValue("float", "1.5", "2.5");
-        putTypedValue("java.lang.float", "-7.5", "-8.5");
+        putTypedValue("java.lang.Float", "-7.5", "-8.5");
 
         IgniteCache<Float, Float> cFloat = jcache();
 
@@ -2085,7 +2085,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         // Test double type.
         putTypedValue("double", "5.5", "75.5");
-        putTypedValue("java.lang.double", "-155.5", "-255.5");
+        putTypedValue("java.lang.Double", "-155.5", "-255.5");
 
         IgniteCache<Double, Double> cDouble = jcache();
 
@@ -2093,8 +2093,8 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertEquals(cDouble.get(-155.5d), -255.5d);
 
         // Test date type.
-        putTypedValue("date", "2018-02-18", "2017-01-01");
-        putTypedValue("java.sql.date", "2018-01-01", "2017-02-02");
+        putTypedValue("Date", "2018-02-18", "2017-01-01");
+        putTypedValue("java.sql.Date", "2018-01-01", "2017-02-02");
 
         IgniteCache<Date, Date> cDate = jcache();
 
@@ -2102,8 +2102,8 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertEquals(cDate.get(Date.valueOf("2018-01-01")), Date.valueOf("2017-02-02"));
 
         // Test time type.
-        putTypedValue("time", "01:01:01", "02:02:02");
-        putTypedValue("java.sql.time", "03:03:03", "04:04:04");
+        putTypedValue("Time", "01:01:01", "02:02:02");
+        putTypedValue("java.sql.Time", "03:03:03", "04:04:04");
 
         IgniteCache<Time, Time> cTime = jcache();
 
@@ -2111,7 +2111,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertEquals(cTime.get(Time.valueOf("03:03:03")), Time.valueOf("04:04:04"));
 
         // Test timestamp type.
-        putTypedValue("timestamp", "2018-02-18%2001:01:01", "2017-01-01%2002:02:02");
+        putTypedValue("Timestamp", "2018-02-18%2001:01:01", "2017-01-01%2002:02:02");
         putTypedValue("java.sql.timestamp", "2018-01-01%2001:01:01", "2018-05-05%2005:05:05");
 
         IgniteCache<Timestamp, Timestamp> cTimestamp = jcache();
@@ -2122,10 +2122,10 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         // Test UUID type.
         UUID k1 = UUID.fromString("121f5ae8-148d-11e8-b642-0ed5f89f718b");
         UUID v1 = UUID.fromString("64c6c225-b31c-4000-b136-ef14562ac785");
+        putTypedValue("UUID", k1.toString(), v1.toString());
+
         UUID k2 = UUID.randomUUID();
         UUID v2 = UUID.randomUUID();
-
-        putTypedValue("UUID", k1.toString(), v1.toString());
         putTypedValue("java.util.UUID", k2.toString(), v2.toString());
 
         IgniteCache<UUID, UUID> cUUID = jcache();
@@ -2148,6 +2148,144 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertEquals(cIgniteUUID.get(ik2), iv2);
     }
 
+    private void getTypedValue(String type, String k, String v) throws Exception {
+        String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET,
+            "keyType", type,
+            "key", k
+        );
+
+        info("Command result: " + ret);
+
+        assertEquals(v, jsonResponse(ret).asText());
+    }
+
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTypedGet() throws Exception {
+        // Test boolean type.
+        IgniteCache<Boolean, String> cBool = jcache();
+
+        cBool.put(true, "test1");
+        cBool.put(false, "test2");
+
+        getTypedValue("boolean", "true", "test1");
+        getTypedValue("java.lang.Boolean", "false", "test2");
+
+        // Test byte type.
+        IgniteCache<Byte, String> cByte = jcache();
+
+        cByte.put((byte)77, "test3");
+        cByte.put((byte)-88, "test4");
+
+        getTypedValue("byte", "77", "test3");
+        getTypedValue("java.lang.Byte", "-88", "test4");
+
+//
+//        // Test short type.
+//        putTypedValue("short", "1024", "4096");
+//        putTypedValue("java.lang.Short", "-15000", "-16000");
+//
+//        IgniteCache<Short, Short> cShort = jcache();
+//
+//        assertEquals(cShort.get(Short.valueOf("1024")), Short.valueOf("4096"));
+//        assertEquals(cShort.get(Short.valueOf("-15000")), Short.valueOf("-16000"));
+//
+//        // Test integer type.
+//        putTypedValue("int", "65555", "128256");
+//        putTypedValue("Integer", "74555", "200000");
+//        putTypedValue("java.lang.Integer", "-200", "-100000");
+//
+//        IgniteCache<Integer, Integer> cInt = jcache();
+//
+//        assertEquals(cInt.get(65555), Integer.valueOf(128256));
+//        assertEquals(cInt.get(74555), Integer.valueOf(200000));
+//        assertEquals(cInt.get(-200), Integer.valueOf(-100000));
+//
+//        // Test long type.
+//        putTypedValue("long", "3000000", "400000");
+//        putTypedValue("java.lang.Long", "-3000000", "-400000");
+//
+//        IgniteCache<Long, Long> cLong = jcache();
+//
+//        assertEquals(cLong.get(3000000L), Long.valueOf(400000));
+//        assertEquals(cLong.get(-3000000L), Long.valueOf(-400000));
+//
+//        // Test float type.
+//        putTypedValue("float", "1.5", "2.5");
+//        putTypedValue("java.lang.Float", "-7.5", "-8.5");
+//
+//        IgniteCache<Float, Float> cFloat = jcache();
+//
+//        assertEquals(cFloat.get(1.5f), 2.5f);
+//        assertEquals(cFloat.get(-7.5f), -8.5f);
+//
+//        // Test double type.
+//        putTypedValue("double", "5.5", "75.5");
+//        putTypedValue("java.lang.Double", "-155.5", "-255.5");
+//
+//        IgniteCache<Double, Double> cDouble = jcache();
+//
+//        assertEquals(cDouble.get(5.5d), 75.5d);
+//        assertEquals(cDouble.get(-155.5d), -255.5d);
+//
+//        // Test date type.
+//        putTypedValue("Date", "2018-02-18", "2017-01-01");
+//        putTypedValue("java.sql.Date", "2018-01-01", "2017-02-02");
+//
+//        IgniteCache<Date, Date> cDate = jcache();
+//
+//        assertEquals(cDate.get(Date.valueOf("2018-02-18")), Date.valueOf("2017-01-01"));
+//        assertEquals(cDate.get(Date.valueOf("2018-01-01")), Date.valueOf("2017-02-02"));
+//
+//        // Test time type.
+//        putTypedValue("Time", "01:01:01", "02:02:02");
+//        putTypedValue("java.sql.Time", "03:03:03", "04:04:04");
+//
+//        IgniteCache<Time, Time> cTime = jcache();
+//
+//        assertEquals(cTime.get(Time.valueOf("01:01:01")), Time.valueOf("02:02:02"));
+//        assertEquals(cTime.get(Time.valueOf("03:03:03")), Time.valueOf("04:04:04"));
+//
+//        // Test timestamp type.
+//        putTypedValue("Timestamp", "2018-02-18%2001:01:01", "2017-01-01%2002:02:02");
+//        putTypedValue("java.sql.timestamp", "2018-01-01%2001:01:01", "2018-05-05%2005:05:05");
+//
+//        IgniteCache<Timestamp, Timestamp> cTimestamp = jcache();
+//
+//        assertEquals(cTimestamp.get(Timestamp.valueOf("2018-02-18 01:01:01")), Timestamp.valueOf("2017-01-01
02:02:02"));
+//        assertEquals(cTimestamp.get(Timestamp.valueOf("2018-01-01 01:01:01")), Timestamp.valueOf("2018-05-05
05:05:05"));
+//
+//        // Test UUID type.
+//        UUID k1 = UUID.fromString("121f5ae8-148d-11e8-b642-0ed5f89f718b");
+//        UUID v1 = UUID.fromString("64c6c225-b31c-4000-b136-ef14562ac785");
+//        putTypedValue("UUID", k1.toString(), v1.toString());
+//
+//        UUID k2 = UUID.randomUUID();
+//        UUID v2 = UUID.randomUUID();
+//        putTypedValue("java.util.UUID", k2.toString(), v2.toString());
+//
+//        IgniteCache<UUID, UUID> cUUID = jcache();
+//
+//        assertEquals(cUUID.get(k1), v1);
+//        assertEquals(cUUID.get(k2), v2);
+//
+//        // Test IgniteUuid type.
+//        IgniteUuid ik1 = IgniteUuid.randomUuid();
+//        IgniteUuid iv1 = IgniteUuid.randomUuid();
+//        IgniteUuid ik2 = IgniteUuid.randomUuid();
+//        IgniteUuid iv2 = IgniteUuid.randomUuid();
+//
+//        putTypedValue("IgniteUuid", ik1.toString(), iv1.toString());
+//        putTypedValue("org.apache.ignite.lang.IgniteUuid", ik2.toString(), iv2.toString());
+//
+//        IgniteCache<IgniteUuid, IgniteUuid> cIgniteUUID = jcache();
+//
+//        assertEquals(cIgniteUUID.get(ik1), iv1);
+//        assertEquals(cIgniteUUID.get(ik2), iv2);
+    }
+
     /**
      * @return Signature.
      * @throws Exception If failed.


Mime
View raw message