ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [2/2] ignite git commit: IGNITE-3337 Review.
Date Wed, 29 Jun 2016 11:07:44 GMT
IGNITE-3337 Review.


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

Branch: refs/heads/master
Commit: 40d863246dab99c34d215a47eb6598e285e1a7f7
Parents: c60fcaf
Author: Andrey Novikov <anovikov@apache.org>
Authored: Wed Jun 29 18:06:34 2016 +0700
Committer: Andrey Novikov <anovikov@apache.org>
Committed: Wed Jun 29 18:06:34 2016 +0700

----------------------------------------------------------------------
 .../integration/ClientAbstractSelfTest.java     |   4 +-
 .../JettyRestProcessorAbstractSelfTest.java     | 144 +++++--------------
 .../cache/GridCacheCommandHandlerSelfTest.java  |  30 ----
 3 files changed, 37 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/40d86324/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
index 36b0c0f..535e0bd 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
@@ -502,8 +502,8 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
 
         GridClientCompute compute = client.compute();
 
-        Assert.assertEquals(new Integer(17), compute.execute(taskName, taskArg));
-        Assert.assertEquals(new Integer(17), compute.executeAsync(taskName, taskArg).get());
+        assertEquals(17, compute.execute(taskName, taskArg));
+        assertEquals(17, compute.executeAsync(taskName, taskArg).get());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/40d86324/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 18b6a51..0dd12ac 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
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.rest;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -28,10 +30,14 @@ import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.DateFormat;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
@@ -148,8 +154,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     }
 
     /**
-     * @return Port to use for rest. Needs to be changed over time
-     *      because Jetty has some delay before port unbind.
+     * @return Port to use for rest. Needs to be changed over time because Jetty has some
delay before port unbind.
      */
     protected abstract int restPort();
 
@@ -333,7 +338,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     /**
      * @throws Exception If failed.
      */
-    public void testNullMapKeyAndValue()  throws Exception {
+    public void testNullMapKeyAndValue() throws Exception {
         Map<String, String> map1 = new HashMap<>();
         map1.put(null, null);
         map1.put("key", "value");
@@ -366,7 +371,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     /**
      * @throws Exception If failed.
      */
-    public void testSimpleObject()  throws Exception {
+    public void testSimpleObject() throws Exception {
         SimplePerson p = new SimplePerson(1, "Test", java.sql.Date.valueOf("1977-01-26"),
1000.55, 39, "CIO", 25);
 
         jcache().put("simplePersonKey", p);
@@ -998,18 +1003,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      * @param metas Metadata for Ignite caches.
      * @throws Exception If failed.
      */
-    private void testMetadata(Collection<GridCacheSqlMetadata> metas) throws Exception
{
-        Map<String, String> params = F.asMap("cmd", GridRestCommand.CACHE_METADATA.key());
-
-        String cacheNameArg = F.first(metas).cacheName();
-
-        if (cacheNameArg != null)
-            params.put("cacheName", cacheNameArg);
-
-        String ret = content(params);
-
-        info("Cache metadata result: " + ret);
-
+    private void testMetadata(Collection<GridCacheSqlMetadata> metas, String ret) throws
Exception {
         JsonNode arr = jsonResponse(ret);
 
         assertTrue(arr.isArray());
@@ -1094,10 +1088,19 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         assertNotNull("Should have configured public cache!", cache);
 
-        Collection<GridCacheSqlMetadata> meta = cache.context().queries().sqlMetadata();
+        Collection<GridCacheSqlMetadata> metas = cache.context().queries().sqlMetadata();
+
+        String ret = content(F.asMap("cmd", GridRestCommand.CACHE_METADATA.key()));
+
+        info("Cache metadata: " + ret);
 
-        testMetadata(meta);
-        testMetadataForVoidCacheName(meta);
+        testMetadata(metas, ret);
+
+        ret = content(F.asMap("cmd", GridRestCommand.CACHE_METADATA.key(), "cacheName", "person"));
+
+        info("Cache metadata with cacheName parameter: " + ret);
+
+        testMetadata(metas, ret);
     }
 
     /**
@@ -1113,95 +1116,17 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         Collection<GridCacheSqlMetadata> metas = c.context().queries().sqlMetadata();
 
-        testMetadata(metas);
-        testMetadataForVoidCacheName(metas);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMetadataForVoidCacheName(Collection<GridCacheSqlMetadata> metas)
throws Exception {
+        String ret = content(F.asMap("cmd", GridRestCommand.CACHE_METADATA.key()));
 
-        Map<String, String> params = F.asMap("cmd", GridRestCommand.CACHE_METADATA.key());
+        info("Cache metadata: " + ret);
 
-        String ret = content(params);
+        testMetadata(metas, ret);
 
-        info("Cache metadata result: " + ret);
+        ret = content(F.asMap("cmd", GridRestCommand.CACHE_METADATA.key(), "cacheName", "person"));
 
-        JsonNode arr = jsonResponse(ret);
+        info("Cache metadata with cacheName parameter: " + ret);
 
-        assertTrue(arr.isArray());
-        assertEquals(metas.size(), arr.size());
-
-        for (JsonNode item : arr) {
-            JsonNode cacheNameNode = item.get("cacheName");
-            final String cacheName = cacheNameNode != null ? cacheNameNode.asText() : null;
-
-            GridCacheSqlMetadata meta = F.find(metas, null, new P1<GridCacheSqlMetadata>()
{
-                @Override public boolean apply(GridCacheSqlMetadata meta) {
-                    return F.eq(meta.cacheName(), cacheName);
-                }
-            });
-
-            assertNotNull("REST return metadata for unexpected cache: " + cacheName, meta);
-
-            JsonNode types = item.get("types");
-
-            assertNotNull(types);
-            assertFalse(types.isNull());
-
-            assertEqualsCollections(meta.types(), JSON_MAPPER.treeToValue(types, Collection.class));
-
-            JsonNode keyClasses = item.get("keyClasses");
-
-            assertNotNull(keyClasses);
-            assertFalse(keyClasses.isNull());
-
-            assertTrue(meta.keyClasses().equals(JSON_MAPPER.treeToValue(keyClasses, Map.class)));
-
-            JsonNode valClasses = item.get("valClasses");
-
-            assertNotNull(valClasses);
-            assertFalse(valClasses.isNull());
-
-            assertTrue(meta.valClasses().equals(JSON_MAPPER.treeToValue(valClasses, Map.class)));
-
-            JsonNode fields = item.get("fields");
-
-            assertNotNull(fields);
-            assertFalse(fields.isNull());
-            assertTrue(meta.fields().equals(JSON_MAPPER.treeToValue(fields, Map.class)));
-
-            JsonNode indexesByType = item.get("indexes");
-
-            assertNotNull(indexesByType);
-            assertFalse(indexesByType.isNull());
-            assertEquals(meta.indexes().size(), indexesByType.size());
-
-            for (Map.Entry<String, Collection<GridCacheSqlIndexMetadata>> metaIndexes
: meta.indexes().entrySet()) {
-                JsonNode indexes = indexesByType.get(metaIndexes.getKey());
-
-                assertNotNull(indexes);
-                assertFalse(indexes.isNull());
-                assertEquals(metaIndexes.getValue().size(), indexes.size());
-
-                for (final GridCacheSqlIndexMetadata metaIdx : metaIndexes.getValue()) {
-                    JsonNode idx = F.find(indexes, null, new P1<JsonNode>() {
-                        @Override public boolean apply(JsonNode idx) {
-                            return metaIdx.name().equals(idx.get("name").asText());
-                        }
-                    });
-
-                    assertNotNull(idx);
-
-                    assertEqualsCollections(metaIdx.fields(),
-                            JSON_MAPPER.treeToValue(idx.get("fields"), Collection.class));
-                    assertEqualsCollections(metaIdx.descendings(),
-                            JSON_MAPPER.treeToValue(idx.get("descendings"), Collection.class));
-                    assertEquals(metaIdx.unique(), idx.get("unique").asBoolean());
-                }
-            }
-        }
+        testMetadata(metas, ret);
     }
 
     /**
@@ -1980,6 +1905,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         public String getLastName() {
             return lastName;
         }
+
         /**
          * @return Salary.
          */
@@ -2094,7 +2020,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
          * @param vals Values.
          * @return This helper for chaining method calls.
          */
-        public VisorGatewayArgument argument(Class cls, Object ... vals) {
+        public VisorGatewayArgument argument(Class cls, Object... vals) {
             put("p" + idx++, cls.getName());
 
             for (Object val : vals)
@@ -2110,7 +2036,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
          * @param vals Values.
          * @return This helper for chaining method calls.
          */
-        public VisorGatewayArgument collection(Class cls, Object ... vals) {
+        public VisorGatewayArgument collection(Class cls, Object... vals) {
             put("p" + idx++, Collection.class.getName());
             put("p" + idx++, cls.getName());
             put("p" + idx++, concat(vals, ";"));
@@ -2168,7 +2094,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
          * @param vals Values.
          * @return This helper for chaining method calls.
          */
-        public VisorGatewayArgument set(Class cls, Object ... vals) {
+        public VisorGatewayArgument set(Class cls, Object... vals) {
             put("p" + idx++, Set.class.getName());
             put("p" + idx++, cls.getName());
             put("p" + idx++, concat(vals, ";"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/40d86324/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java
index 3c99dca..3d00626 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java
@@ -195,36 +195,6 @@ public class GridCacheCommandHandlerSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * @throws Exception If failed.
-     */
-    public void testHandleMetadataForAllCache() throws Exception {
-        GridCacheCommandHandler cmdHandler = new GridCacheCommandHandler(((IgniteKernal)grid()).context());
-        GridRestCacheRequest req = new GridRestCacheRequest();
-
-        req.command(GridRestCommand.GET_OR_CREATE_CACHE);
-        req.cacheName("partitioned_cache");
-
-        IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
-
-        req = new GridRestCacheRequest();
-        req.command(GridRestCommand.GET_OR_CREATE_CACHE);
-        req.cacheName("replicated_cache");
-
-        resp = cmdHandler.handleAsync(req);
-
-        req = new GridRestCacheRequest();
-        req.command(GridRestCommand.CACHE_METADATA);
-        req.cacheName(null);
-
-        resp = cmdHandler.handleAsync(req);
-
-        assertNull(resp.result().getError());
-        assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
-        assertEquals("[CacheSqlMetadata [cacheName=null], CacheSqlMetadata [cacheName=replicated_cache],
CacheSqlMetadata [cacheName=partitioned_cache]]",
-                resp.result().getResponse().toString());
-    }
-
-    /**
      * Test command handler.
      */
     private static class TestableCacheCommandHandler extends GridCacheCommandHandler {


Mime
View raw message