Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1223 1341e9ee9 -> 767954276


IGNITE-1223 Fix tests.


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

Branch: refs/heads/ignite-1223
Commit: 767954276cc47350c432d70b7483bb59ec5edf92
Parents: 1341e9e
Author: sevdokimov <sevdoki...@gridgain.com>
Authored: Wed Aug 12 17:43:36 2015 +0300
Committer: sevdokimov <sevdoki...@gridgain.com>
Committed: Wed Aug 12 17:43:36 2015 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 114 ++++++-------------
 .../processors/rest/GridRestResponse.java       |   4 +
 .../internal/processors/rest/JsonIgnore.java    |  29 +++++
 .../internal/processors/rest/JsonName.java      |  32 ++++++
 .../message/GridClientTaskResultBean.java       |   2 +
 .../rest/handlers/query/CacheQueryResult.java   |   3 +
 .../http/jetty/GridJettyRestHandler.java        |   7 +-
 .../http/jetty/GsonExclusionStrategy.java       |  36 ++++++
 .../http/jetty/GsonFieldNamingStrategy.java     |  35 ++++++
 .../http/jetty/IgniteFieldNamingStrategy.java   |  66 -----------
 10 files changed, 180 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/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 07f3c7d..d883b31 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
@@ -122,11 +122,10 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String cachePattern(String res, boolean success) {
-        return 
"\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":\\\"" + res + "\\\"\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+        return "\\{\"affinityNodeId\":\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\"" 
+
+            ",\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"response\":\"" + res + "\"\\}";
     }
 
     /**
@@ -134,11 +133,9 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String errorPattern(String err) {
-        return "\\{" +
-            "\\\"error\\\":\\\"" + err + "\\\"\\," +
-            "\\\"response\\\":null\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + 1 + "\\}";
+        return "\\{\"successStatus\":" + 1 +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"error\":\"" + err + "\"\\}";
     }
 
     /**
@@ -147,10 +144,11 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String integerPattern(int res, boolean success) {
-        return "\\{\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+        return "\\{" + "\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"response\":" + res +
+            (success ? "" : "\"error\":\"\"")
+            + "\\}";
     }
 
     /**
@@ -158,25 +156,10 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @param success Success flag.
      * @return Regex pattern for JSON.
      */
-    private String cacheBulkPattern(String res, boolean success) {
-        return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
-    }
-
-    /**
-     * @param res Response.
-     * @param success Success flag.
-     * @return Regex pattern for JSON.
-     */
-    private String cacheBulkPattern(int res, boolean success) {
-        return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+    private String cacheBulkPattern(Object res, boolean success) {
+        return "\\{\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"response\":" + res + "\\}";
     }
 
     /**
@@ -185,24 +168,10 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String cachePattern(boolean res, boolean success) {
-        return 
"\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
-    }
-
-    /**
-     * @param res Response.
-     * @param success Success flag.
-     * @return Regex pattern for JSON.
-     */
-    private String cacheBulkPattern(boolean res, boolean success) {
-        return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+        return "\\{\"affinityNodeId\":\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\"" 
+
+            ",\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"response\":" + res + "\\}";
     }
 
     /**
@@ -211,11 +180,10 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String cacheMetricsPattern(String res, boolean success) {
-        return 
"\\{\\\"affinityNodeId\\\":\\\"(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})?\\\"\\," +
-            "\\\"error\\\":\\\"\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+        return "\\{\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            ",\"response\":" + res +
+            "(,\"affinityNodeId\":\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\")?" + 
"\\}";
     }
 
     /**
@@ -224,22 +192,10 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
      * @return Regex pattern for JSON.
      */
     private String pattern(String res, boolean success) {
-        return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
-            "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
-    }
-
-    /**
-     * @param res Response.
-     * @param success Success flag.
-     * @return Regex pattern for JSON.
-     */
-    private String stringPattern(String res, boolean success) {
-        return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
-            "\\\"response\\\":\\\"" + res + "\\\"\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
-            "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+        return "\\{\"successStatus\":" + (success ? 0 : 1) +
+            "(,\"sessionToken\":\"\")?" +
+            (success ? "" : ",\"error\":\".+\"") +
+            (res == null ? "" : ",\"response\":" + res) + "\\}";
     }
 
     /**
@@ -287,7 +243,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         info("Name command result: " + ret);
 
-        jsonEquals(ret, stringPattern(getTestGridName(0), true));
+        jsonEquals(ret, pattern('"' + getTestGridName(0) + '"', true));
     }
 
     /**
@@ -327,7 +283,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         jsonEquals(ret,
             // getKey[12] is used since the order is not determined.
-            
cacheBulkPattern("\\{\\\"getKey[12]\\\":\\\"getVal[12]\\\"\\,\\\"getKey[12]\\\":\\\"getVal[12]\\\"\\}",
+            
cacheBulkPattern("\\{\"getKey[12]\":\"getVal[12]\",\"getKey[12]\":\"getVal[12]\"\\}",
                 true));
     }
 
@@ -936,7 +892,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         info("Topology command result: " + ret);
 
-        jsonEquals(ret, pattern("null", true));
+        jsonEquals(ret, pattern(null, true));
     }
 
     /**
@@ -954,7 +910,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         info("Exe command result: " + ret);
 
-        jsonEquals(ret, pattern("null", false));
+        jsonEquals(ret, pattern(null, false));
 
         // Attempt to execute unknown task (UNKNOWN_TASK) will result in 
exception on server.
         ret = content(F.asMap("cmd", GridRestCommand.EXE.key(), "name", 
"UNKNOWN_TASK"));
@@ -964,7 +920,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         info("Exe command result: " + ret);
 
-        jsonEquals(ret, pattern("null", false));
+        jsonEquals(ret, pattern(null, false));
 
         grid(0).compute().localDeployTask(TestTask1.class, 
TestTask1.class.getClassLoader());
         grid(0).compute().localDeployTask(TestTask2.class, 
TestTask2.class.getClassLoader());
@@ -994,7 +950,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         info("Exe command result: " + ret);
 
-        jsonEquals(ret, pattern("null", false));
+        jsonEquals(ret, pattern(null, false));
     }
 
     /**
@@ -1006,7 +962,7 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());
 
-        jsonEquals(ret, stringPattern(".+", true));
+        jsonEquals(ret, pattern("\".+\"", true));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestResponse.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestResponse.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestResponse.java
index 83c987f..62e63cb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestResponse.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestResponse.java
@@ -47,16 +47,20 @@ public class GridRestResponse implements Externalizable {
     private int successStatus = STATUS_SUCCESS;
 
     /** Session token. */
+    @JsonIgnore
     private byte[] sesTokBytes;
 
     /** Session token string representation. */
+    @JsonName("sessionToken")
     private String sesTokStr;
 
     /** Error. */
+    @JsonName("error")
     private String err;
 
     /** Response object. */
     @GridToStringInclude
+    @JsonName("response")
     private Object obj;
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonIgnore.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonIgnore.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonIgnore.java
new file mode 100644
index 0000000..cbd8444
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonIgnore.java
@@ -0,0 +1,29 @@
+/*
+ * 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.ignite.internal.processors.rest;
+
+import java.lang.annotation.*;
+
+/**
+ * Specify name on JSON serialization.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface JsonIgnore {
+    // No-op.
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonName.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonName.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonName.java
new file mode 100644
index 0000000..50143c6
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/JsonName.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ignite.internal.processors.rest;
+
+import java.lang.annotation.*;
+
+/**
+ * Specify name on JSON serialization.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface JsonName {
+    /**
+     * @return Name.
+     */
+    public String value();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java
index 696ac03..ac677db 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.rest.client.message;
 
+import org.apache.ignite.internal.processors.rest.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.io.*;
@@ -35,6 +36,7 @@ public class GridClientTaskResultBean implements 
Externalizable {
     private boolean finished;
 
     /** Result. */
+    @JsonName("result")
     private Object res;
 
     /** Error if any occurs while execution. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/CacheQueryResult.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/CacheQueryResult.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/CacheQueryResult.java
index 544a094..fd0eb7e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/CacheQueryResult.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/CacheQueryResult.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.rest.handlers.query;
 
+import org.apache.ignite.internal.processors.rest.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.io.*;
@@ -30,12 +31,14 @@ public class CacheQueryResult implements Externalizable {
     private static final long serialVersionUID = 0L;
 
     /** Query ID. */
+    @JsonName("queryId")
     private long qryId;
 
     /** Result items. */
     private Collection<?> items;
 
     /** Fields metadata. */
+    @JsonName("fieldsMetadata")
     private Collection<?> fieldsMeta;
 
     /** Last flag. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 1c5f5ab..de48038 100644
--- 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -76,7 +76,10 @@ public class GridJettyRestHandler extends AbstractHandler {
         this.log = log;
         this.authChecker = authChecker;
 
-        gson = new GsonBuilder().setFieldNamingStrategy(new 
IgniteFieldNamingStrategy()).create();
+        gson = new GsonBuilder()
+            .setFieldNamingStrategy(new GsonFieldNamingStrategy())
+            .addSerializationExclusionStrategy(new GsonExclusionStrategy())
+            .create();
 
         // Init default page and favicon.
         try {
@@ -269,8 +272,6 @@ public class GridJettyRestHandler extends AbstractHandler {
                 throw (Error)e;
         }
 
-        Gson gson = new Gson();
-
         try {
             gson.toJson(cmdRes, res.getWriter());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonExclusionStrategy.java
----------------------------------------------------------------------
diff --git 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonExclusionStrategy.java
 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonExclusionStrategy.java
new file mode 100644
index 0000000..b4c5af3
--- /dev/null
+++ 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonExclusionStrategy.java
@@ -0,0 +1,36 @@
+/*
+ * 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.ignite.internal.processors.rest.protocols.http.jetty;
+
+import com.google.gson.*;
+import org.apache.ignite.internal.processors.rest.*;
+
+/**
+ *
+ */
+public class GsonExclusionStrategy implements ExclusionStrategy {
+    /** {@inheritDoc} */
+    @Override public boolean shouldSkipField(FieldAttributes f) {
+        return f.getAnnotation(JsonIgnore.class) != null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean shouldSkipClass(Class<?> clazz) {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonFieldNamingStrategy.java
----------------------------------------------------------------------
diff --git 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonFieldNamingStrategy.java
 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonFieldNamingStrategy.java
new file mode 100644
index 0000000..548ad45
--- /dev/null
+++ 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GsonFieldNamingStrategy.java
@@ -0,0 +1,35 @@
+/*
+ * 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.ignite.internal.processors.rest.protocols.http.jetty;
+
+import com.google.gson.*;
+import org.apache.ignite.internal.processors.rest.*;
+
+import java.lang.reflect.*;
+
+/**
+ * Ignite field name strategy.
+ */
+public class GsonFieldNamingStrategy implements FieldNamingStrategy {
+    /** {@inheritDoc} */
+    @Override public String translateName(Field f) {
+        JsonName ann = f.getAnnotation(JsonName.class);
+
+        return ann == null ? f.getName() : ann.value();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76795427/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/IgniteFieldNamingStrategy.java
----------------------------------------------------------------------
diff --git 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/IgniteFieldNamingStrategy.java
 
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/IgniteFieldNamingStrategy.java
deleted file mode 100644
index 5bb3df2..0000000
--- 
a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/IgniteFieldNamingStrategy.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.ignite.internal.processors.rest.protocols.http.jetty;
-
-import com.google.gson.*;
-import org.apache.ignite.internal.processors.rest.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-/**
- * Ignite field name strategy.
- */
-public class IgniteFieldNamingStrategy implements FieldNamingStrategy {
-    /** */
-    private static final Map<Field, String> FIELD_NAMES = new HashMap<>();
-
-    static {
-        addField(GridRestResponse.class, "obj", "response");
-        addField(GridRestResponse.class, "err", "error");
-        addField(GridRestResponse.class, "sesTokStr", "sessionToken");
-    }
-
-    /**
-     * @param cls Class.
-     * @param fldName Fld name.
-     * @param propName Property name.
-     */
-    private static void addField(Class<?> cls, String fldName, String 
propName) {
-        try {
-            Field field = cls.getDeclaredField(fldName);
-
-            // assert method exists.
-            cls.getDeclaredMethod("get" + 
Character.toUpperCase(propName.charAt(0)) + propName.substring(1));
-
-            String old = FIELD_NAMES.put(field, propName);
-
-            assert old == null;
-        }
-        catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public String translateName(Field f) {
-        String name = FIELD_NAMES.get(f);
-
-        return name == null ? f.getName() : name;
-    }
-}

Reply via email to