You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/03 19:15:59 UTC

[10/11] ignite git commit: IGNITE-1364: Squashed commit from initial branch.

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp b/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
new file mode 100644
index 0000000..6ccfd51
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/cache_query_test.cpp
@@ -0,0 +1,651 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <sstream>
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/utils.h"
+#include "ignite/cache/cache.h"
+#include "ignite/cache/query/query_cursor.h"
+#include "ignite/cache/query/query_sql.h"
+#include "ignite/cache/query/query_text.h"
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace boost::unit_test;
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::impl::utils;
+
+/**
+ * Person class for query tests.
+ */
+class IGNITE_IMPORT_EXPORT QueryPerson
+{
+public:
+    /**
+     * Constructor.
+     */
+    QueryPerson() : name(NULL), age(0)
+    {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param name Name.
+     * @param age Age.
+     */
+    QueryPerson(std::string name, int age) : name(CopyChars(name.c_str())), age(age)
+    {
+        // No-op.
+    }
+
+    /**
+     * Copy constructor.
+     *
+     * @param other Other instance.
+     */
+    QueryPerson(const QueryPerson& other)
+    {
+        name = CopyChars(other.name);
+        age = other.age;
+    }
+
+    /**
+     * Assignment operator.
+     *
+     * @param other Other instance.
+     * @return This instance.
+     */
+    QueryPerson& operator=(const QueryPerson& other)
+    {
+        if (&other != this)
+        {
+            QueryPerson tmp(other);
+
+            char* name0 = name;
+            int age0 = age;
+
+            name = tmp.name;
+            age = tmp.age;
+
+            tmp.name = name0;
+            tmp.age = age0;
+        }
+
+        return *this;
+    }
+
+    /**
+     * Destructor.
+     */
+    ~QueryPerson()
+    {
+        ReleaseChars(name);
+    }
+
+    /**
+     * Get name.
+     * 
+     * @return Name.
+     */
+    std::string GetName()
+    {
+        return name ? std::string(name) : std::string();
+    }
+
+    /**
+     * Get age.
+     * 
+     * @return Age.
+     */
+    int32_t GetAge()
+    {
+        return age;
+    }
+
+private:
+    /** Name. */
+    char* name;
+
+    /** Age. */
+    int age;
+};
+
+namespace ignite
+{
+    namespace portable
+    {
+        /**
+         * Portable type definition.
+         */
+        IGNITE_PORTABLE_TYPE_START(QueryPerson)
+            IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(QueryPerson)
+            IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(QueryPerson)
+            IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
+            IGNITE_PORTABLE_GET_HASH_CODE_ZERO(QueryPerson)
+            IGNITE_PORTABLE_IS_NULL_FALSE(QueryPerson)
+            IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(QueryPerson)
+
+            void Write(PortableWriter& writer, QueryPerson obj)
+            {
+                writer.WriteString("name", obj.GetName());
+                writer.WriteInt32("age", obj.GetAge());
+            }
+
+            QueryPerson Read(PortableReader& reader)
+            {
+                std::string name = reader.ReadString("name");
+                int age = reader.ReadInt32("age");
+            
+                return QueryPerson(name, age);
+            }
+
+        IGNITE_PORTABLE_TYPE_END
+    }
+}
+
+/** Node started during the test. */
+Ignite grid = Ignite();
+
+/** Cache accessor. */
+Cache<int, QueryPerson> GetCache()
+{
+    return grid.GetCache<int, QueryPerson>("cache");
+}
+
+/**
+ * Test setup fixture.
+ */
+struct CacheQueryTestSuiteFixture {
+    /**
+     * Constructor.
+     */
+    CacheQueryTestSuiteFixture()
+    {
+        IgniteConfiguration cfg;
+
+        IgniteJvmOption opts[5];
+
+        opts[0] = IgniteJvmOption("-Xdebug");
+        opts[1] = IgniteJvmOption("-Xnoagent");
+        opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+        opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+        opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+        cfg.jvmOptsLen = 5;
+        cfg.jvmOpts = opts;
+
+        cfg.jvmInitMem = 1024;
+        cfg.jvmMaxMem = 4096;
+
+        char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+        std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-query.xml");
+
+        cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+
+        IgniteError err;
+
+        Ignite grid0 = Ignition::Start(cfg, &err);
+
+        if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+            BOOST_ERROR(err.GetText());
+
+        grid = grid0;
+    }
+
+    /**
+     * Destructor.
+     */
+    ~CacheQueryTestSuiteFixture()
+    {
+        Ignition::Stop(grid.GetName(), true);
+    }
+};
+
+/**
+ * Ensure that HasNext() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckHasNextFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try
+    {
+        cur.HasNext();
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Ensure that GetNext() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckGetNextFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try
+    {
+        cur.GetNext();
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Ensure that GetAll() fails.
+ *
+ * @param cur Cursor.
+ */
+void CheckGetAllFail(QueryCursor<int, QueryPerson>& cur)
+{
+    try 
+    {
+        std::vector<CacheEntry<int, QueryPerson>> res;
+
+        cur.GetAll(res);
+
+        BOOST_FAIL("Must fail.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    }
+}
+
+/**
+ * Check empty result through iteration.
+ *
+ * @param cur Cursor.
+ */
+void CheckEmpty(QueryCursor<int, QueryPerson>& cur)
+{
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check empty result through GetAll().
+ *
+ * @param cur Cursor.
+ */
+void CheckEmptyGetAll(QueryCursor<int, QueryPerson>& cur)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    BOOST_REQUIRE(res.size() == 0);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+}
+
+/**
+ * Check single result through iteration.
+ *
+ * @param cur Cursor.
+ * @param key1 Key.
+ * @param name1 Name.
+ * @param age1 Age.
+ */
+void CheckSingle(QueryCursor<int, QueryPerson>& cur, int key, std::string name, int age)
+{
+    BOOST_REQUIRE(cur.HasNext());
+
+    CheckGetAllFail(cur);
+
+    CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(entry.GetKey() == key);
+    BOOST_REQUIRE(entry.GetValue().GetName().compare(name) == 0);
+    BOOST_REQUIRE(entry.GetValue().GetAge() == age);
+
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check single result through GetAll().
+ *
+ * @param cur Cursor.
+ * @param key1 Key.
+ * @param name1 Name.
+ * @param age1 Age.
+ */
+void CheckSingleGetAll(QueryCursor<int, QueryPerson>& cur, int key, std::string name, int age)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(res.size() == 1);
+
+    BOOST_REQUIRE(res[0].GetKey() == 1);    
+    BOOST_REQUIRE(res[0].GetValue().GetName().compare(name) == 0);
+    BOOST_REQUIRE(res[0].GetValue().GetAge() == age);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check multiple results through iteration.
+ *
+ * @param cur Cursor.
+ * @param key1 Key 1.
+ * @param name1 Name 1.
+ * @param age1 Age 1.
+ * @param key2 Key 2.
+ * @param name2 Name 2.
+ * @param age2 Age 2.
+ */
+void CheckMultiple(QueryCursor<int, QueryPerson>& cur, int key1, std::string name1, 
+    int age1, int key2, std::string name2, int age2)
+{
+    for (int i = 0; i < 2; i++)
+    {
+        BOOST_REQUIRE(cur.HasNext());
+
+        CheckGetAllFail(cur);
+
+        CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+        CheckGetAllFail(cur);
+
+        if (entry.GetKey() == key1)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name1) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age1);            
+        }
+        else if (entry.GetKey() == key2)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name2) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age2);            
+        }
+        else
+            BOOST_FAIL("Unexpected entry.");
+    }
+    
+    BOOST_REQUIRE(!cur.HasNext());
+
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+}
+
+/**
+ * Check multiple results through GetAll().
+ *
+ * @param cur Cursor.
+ * @param key1 Key 1.
+ * @param name1 Name 1.
+ * @param age1 Age 1.
+ * @param key2 Key 2.
+ * @param name2 Name 2.
+ * @param age2 Age 2.
+ */
+void CheckMultipleGetAll(QueryCursor<int, QueryPerson>& cur, int key1, std::string name1, int age1, 
+    int key2, std::string name2, int age2)
+{
+    std::vector<CacheEntry<int, QueryPerson>> res;
+
+    cur.GetAll(res);
+
+    CheckHasNextFail(cur);
+    CheckGetNextFail(cur);
+    CheckGetAllFail(cur);
+
+    BOOST_REQUIRE(res.size() == 2);
+
+    for (int i = 0; i < 2; i++)
+    {
+        CacheEntry<int, QueryPerson> entry = res[i];
+
+        if (entry.GetKey() == key1)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name1) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age1);            
+        }
+        else if (entry.GetKey() == key2)
+        {
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(name2) == 0);
+            BOOST_REQUIRE(entry.GetValue().GetAge() == age2);
+        }
+        else
+            BOOST_FAIL("Unexpected entry.");
+    }
+}
+
+BOOST_FIXTURE_TEST_SUITE(CacheQueryTestSuite, CacheQueryTestSuiteFixture)
+
+/**
+ * Test SQL query.
+ */
+BOOST_AUTO_TEST_CASE(TestSqlQuery)
+{    
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    SqlQuery qry("QueryPerson", "age < 20");
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+    cache.Put(2, QueryPerson("A2", 20));
+    
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+    
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test simple local query.
+    qry.SetLocal(true);
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query with arguments.
+    qry.SetSql("age < ? AND name = ?");
+    qry.AddArgument<int>(20);
+    qry.AddArgument<std::string>("A1");
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    qry = SqlQuery("QueryPerson", "age < 30");
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test text query.
+ */
+BOOST_AUTO_TEST_CASE(TestTextQuery)
+{
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    TextQuery qry("QueryPerson", "A1");
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+    cache.Put(2, QueryPerson("A2", 20));
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test simple local query.
+    qry.SetLocal(true);
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    qry = TextQuery("QueryPerson", "A*");
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test scan query.
+ */
+BOOST_AUTO_TEST_CASE(TestScanQuery)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with no results.
+    ScanQuery qry;
+
+    QueryCursor<int, QueryPerson> cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    cursor = cache.Query(qry);
+    CheckEmptyGetAll(cursor);
+
+    // Test simple query.
+    cache.Put(1, QueryPerson("A1", 10));
+
+    cursor = cache.Query(qry);
+    CheckSingle(cursor, 1, "A1", 10);
+
+    cursor = cache.Query(qry);
+    CheckSingleGetAll(cursor, 1, "A1", 10);
+
+    // Test query returning multiple entries.
+    cache.Put(2, QueryPerson("A2", 20));
+
+    cursor = cache.Query(qry);
+    CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
+
+    cursor = cache.Query(qry);
+    CheckMultipleGetAll(cursor, 1, "A1", 10, 2, "A2", 20);
+}
+
+/**
+ * Test scan query over partitions.
+ */
+BOOST_AUTO_TEST_CASE(TestScanQueryPartitioned)
+{
+    // Populate cache with data.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    int32_t partCnt = 256;   // Defined in configuration explicitly.   
+    int32_t entryCnt = 1000; // Should be greater than partCnt.
+    
+    for (int i = 0; i < entryCnt; i++) 
+    {
+        std::stringstream stream; 
+        
+        stream << "A" << i;
+            
+        cache.Put(i, QueryPerson(stream.str(), i * 10));
+    }
+
+    // Iterate over all partitions and collect data.
+    std::set<int> keys;
+
+    for (int i = 0; i < partCnt; i++)
+    {
+        ScanQuery qry(i);
+
+        QueryCursor<int, QueryPerson> cur = cache.Query(qry);
+
+        while (cur.HasNext())
+        {
+            CacheEntry<int, QueryPerson> entry = cur.GetNext();
+
+            int key = entry.GetKey();
+
+            keys.insert(key);
+
+            std::stringstream stream;
+            stream << "A" << key;
+            BOOST_REQUIRE(entry.GetValue().GetName().compare(stream.str()) == 0);
+
+            BOOST_REQUIRE(entry.GetValue().GetAge() == key * 10);
+        }
+    }
+
+    // Ensure that all keys were read.
+    BOOST_REQUIRE(keys.size() == entryCnt);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/cache_test.cpp b/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
new file mode 100644
index 0000000..b69caab
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/cache_test.cpp
@@ -0,0 +1,481 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/cache/cache_peek_mode.h"
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace boost::unit_test;
+
+/* Nodes started during the test. */
+Ignite grid0 = Ignite();
+Ignite grid1 = Ignite();
+
+/** Cache accessor. */
+cache::Cache<int, int> Cache()
+{
+    return grid0.GetCache<int, int>("partitioned");
+}
+
+struct Person
+{
+    std::string name;
+    int age;
+
+    Person() : name(""), age(0)
+    {
+        // No-op.
+    }
+
+    Person(std::string name, int age) : name(name), age(age)
+    {
+        // No-op.
+    }
+};
+
+namespace ignite
+{
+    namespace portable
+    {
+        IGNITE_PORTABLE_TYPE_START(Person)
+        IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(Person)
+        IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(Person)
+        IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
+        IGNITE_PORTABLE_GET_HASH_CODE_ZERO(Person)
+        IGNITE_PORTABLE_IS_NULL_FALSE(Person)
+        IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(Person)
+            
+        void Write(PortableWriter& writer, Person obj)
+        {
+            writer.WriteString("name", obj.name);
+            writer.WriteInt32("age", obj.age);            
+        }
+
+        Person Read(PortableReader& reader)
+        {
+            std::string name = reader.ReadString("name");
+            int age = reader.ReadInt32("age");
+            
+            return Person(name, age);
+        }
+
+        IGNITE_PORTABLE_TYPE_END
+    }
+}
+
+/*
+ * Test setup fixture.
+ */
+struct CacheTestSuiteFixture {
+    /*
+     * Constructor.
+     */
+    CacheTestSuiteFixture()
+    {
+        IgniteConfiguration cfg;
+
+        IgniteJvmOption opts[5];
+
+        opts[0] = IgniteJvmOption("-Xdebug");
+        opts[1] = IgniteJvmOption("-Xnoagent");
+        opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+        opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+        opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+        cfg.jvmOptsLen = 5;
+        cfg.jvmOpts = opts;
+
+        cfg.jvmInitMem = 1024;
+        cfg.jvmMaxMem = 4096;
+
+        char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+        std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
+
+        cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+        
+        for (int i = 0; i < 2; i++) 
+        {
+            std::stringstream stream;
+
+            stream << "grid-" << i;
+
+            IgniteError err;
+
+            Ignite grid = Ignition::Start(cfg, stream.str().c_str(), &err);
+                
+            if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+                BOOST_FAIL(err.GetText());
+
+            if (i == 0)
+                grid0 = grid;
+            else
+                grid1 = grid;
+        }
+    }
+
+    /*
+     * Destructor.
+     */
+    ~CacheTestSuiteFixture()
+    {
+        Ignition::Stop(grid0.GetName(), true);
+        Ignition::Stop(grid1.GetName(), true);
+
+        grid0 = Ignite();
+        grid1 = Ignite();
+    }
+};
+
+BOOST_FIXTURE_TEST_SUITE(CacheTestSuite, CacheTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestRemoveAllKeys)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    cache.Put(3, 3);
+
+    int size = cache.Size(cache::IGNITE_PEEK_MODE_PRIMARY);
+
+    BOOST_REQUIRE(3 == size);
+
+    cache.RemoveAll();
+
+    size = cache.Size(cache::IGNITE_PEEK_MODE_ALL);
+
+    BOOST_REQUIRE(0 == size);
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    cache.Put(3, 3);
+
+    int keys[] = { 1, 2, 4, 5 };
+
+    std::set<int> keySet(keys, keys + 4);
+
+    cache.RemoveAll(keySet);
+
+    size = cache.Size(cache::IGNITE_PEEK_MODE_PRIMARY);
+
+    BOOST_REQUIRE(1 == size);
+}
+
+BOOST_AUTO_TEST_CASE(TestPut)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(1 == cache.Get(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutAll)
+{
+    std::map<int, int> map;
+
+    for (int i = 0; i < 100; i++)
+        map[i] = i + 1;
+    
+    cache::Cache<int, int> cache = Cache();
+
+    cache.PutAll(map);
+
+    for (int i = 0; i < 100; i++)
+        BOOST_REQUIRE(i + 1 == cache.Get(i));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutIfAbsent)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(true == cache.PutIfAbsent(1, 3));
+    BOOST_REQUIRE(false == cache.PutIfAbsent(1, 3));
+}
+
+BOOST_AUTO_TEST_CASE(TestGet)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+
+    BOOST_REQUIRE(1 == cache.Get(1));
+    BOOST_REQUIRE(2 == cache.Get(2));
+    
+    BOOST_REQUIRE(0 == cache.Get(3));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAll)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    int keys[] = { 1, 2, 3, 4, 5 };
+    
+    std::set<int> keySet (keys, keys + 5);
+
+    for (int i = 0; i < keySet.size(); i++)
+        cache.Put(i + 1, i + 1);
+
+    std::map<int, int> map = cache.GetAll(keySet);
+
+    for (int i = 0; i < keySet.size(); i++)
+        BOOST_REQUIRE(i + 1 == map[i + 1]);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndPut)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndPut(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndPut(1, 1));
+    BOOST_REQUIRE(1 == cache.GetAndPut(1, 0));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndPutIfAbsent)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndPutIfAbsent(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndPutIfAbsent(1, 1));
+    BOOST_REQUIRE(3 == cache.GetAndPutIfAbsent(1, 1));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndRemove)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 3);
+
+    BOOST_REQUIRE(3 == cache.GetAndRemove(1));
+    BOOST_REQUIRE(0 == cache.GetAndRemove(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetAndReplace)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.GetAndReplace(1, 3));
+    BOOST_REQUIRE(0 == cache.GetAndReplace(1, 3));
+
+    cache.Put(1, 5);
+
+    BOOST_REQUIRE(5 == cache.GetAndReplace(1, 3));
+    BOOST_REQUIRE(3 == cache.GetAndReplace(1, 3));
+}
+
+BOOST_AUTO_TEST_CASE(TestContainsKey)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.ContainsKey(1));
+
+    BOOST_REQUIRE(true == cache.Remove(1));
+    
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestContainsKeys)
+{
+    cache::Cache<int, int> cache = Cache();
+    
+    int keys[] = { 1, 2 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    BOOST_REQUIRE(false == cache.ContainsKeys(keySet));
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+    
+    BOOST_REQUIRE(true == cache.ContainsKeys(keySet));
+
+    cache.Remove(1);
+
+    BOOST_REQUIRE(false == cache.ContainsKeys(keySet));
+}
+
+BOOST_AUTO_TEST_CASE(TestIsEmpty)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(true == cache.IsEmpty());
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(false == cache.IsEmpty());
+
+    cache.Remove(1);
+
+    BOOST_REQUIRE(true == cache.IsEmpty());
+}
+
+BOOST_AUTO_TEST_CASE(TestRemove)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(false == cache.Remove(1));
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.Remove(1));
+    BOOST_REQUIRE(false == cache.Remove(1));
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestClear)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 1);
+
+    BOOST_REQUIRE(true == cache.ContainsKey(1));
+
+    cache.Clear(1);
+
+    BOOST_REQUIRE(false == cache.ContainsKey(1));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalClear)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(0, 2);
+
+    BOOST_REQUIRE(2 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+
+    cache.LocalClear(0);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalClearAll)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(0, 3);
+    cache.Put(1, 3);
+
+    int keys[] = { 0, 1 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    BOOST_REQUIRE(3 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+    BOOST_REQUIRE(3 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_PRIMARY));
+
+    cache.LocalClearAll(keySet);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(0, cache::IGNITE_PEEK_MODE_PRIMARY));
+    BOOST_REQUIRE(0 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestSizes)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    BOOST_REQUIRE(0 == cache.Size());
+
+    cache.Put(1, 1);
+    cache.Put(2, 2);
+
+    BOOST_REQUIRE(2 <= cache.Size());
+
+    BOOST_REQUIRE(1 <= cache.LocalSize(cache::IGNITE_PEEK_MODE_PRIMARY));
+}
+
+BOOST_AUTO_TEST_CASE(TestLocalEvict)
+{
+    cache::Cache<int, int> cache = Cache();
+
+    cache.Put(1, 5);
+
+    BOOST_REQUIRE(5 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+
+    int keys[] = { 0, 1 };
+
+    std::set<int> keySet(keys, keys + 2);
+
+    cache.LocalEvict(keySet);
+
+    BOOST_REQUIRE(0 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+
+    BOOST_REQUIRE(5 == cache.Get(1));
+
+    BOOST_REQUIRE(5 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
+}
+
+BOOST_AUTO_TEST_CASE(TestPortable)
+{
+    cache::Cache<int, Person> cache = grid0.GetCache<int, Person>("partitioned");
+
+    Person person("John Johnson", 3);
+
+    cache.Put(1, person);
+
+    Person person0 = cache.Get(1);
+
+    BOOST_REQUIRE(person.age == person0.age);
+    BOOST_REQUIRE(person.name.compare(person0.name) == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestCreateCache)
+{
+    // Create new cache
+    cache::Cache<int, int> cache = grid0.CreateCache<int, int>("dynamic_cache");
+
+    cache.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache.Get(5));
+
+    // Attempt to create cache with existing name
+    IgniteError err;
+
+    grid0.CreateCache<int, int>("dynamic_cache", &err);
+
+    BOOST_REQUIRE(err.GetCode() != IgniteError::IGNITE_SUCCESS);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetOrCreateCache)
+{
+    // Get existing cache
+    cache::Cache<int, int> cache = grid0.GetOrCreateCache<int, int>("partitioned");
+
+    cache.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache.Get(5));
+
+    // Create new cache
+    cache::Cache<int, int> cache2 = grid0.GetOrCreateCache<int, int>("partitioned_new");
+
+    cache2.Put(5, 7);
+
+    BOOST_REQUIRE(7 == cache2.Get(5));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp b/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
new file mode 100644
index 0000000..2d89b7a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/concurrent_test.cpp
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/common/concurrent.h>
+
+using namespace ignite::common::concurrent;
+
+BOOST_AUTO_TEST_SUITE(ConcurrentTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestAtomic32)
+{
+    int32_t val = 1;
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32(&val, 1, 2));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(!Atomics::CompareAndSet32(&val, 3, 1));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32Val(&val, 2, 3) == 2);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet32Val(&val, 4, 2) == 3);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::IncrementAndGet32(&val) == 4);
+    BOOST_REQUIRE(val == 4);
+
+    BOOST_REQUIRE(Atomics::DecrementAndGet32(&val) == 3);
+    BOOST_REQUIRE(val == 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestAtomic64)
+{
+    int64_t val = 1;
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64(&val, 1, 2));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(!Atomics::CompareAndSet64(&val, 3, 1));
+    BOOST_REQUIRE(val == 2);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64Val(&val, 2, 3) == 2);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::CompareAndSet64Val(&val, 4, 2) == 3);
+    BOOST_REQUIRE(val == 3);
+
+    BOOST_REQUIRE(Atomics::IncrementAndGet64(&val) == 4);
+    BOOST_REQUIRE(val == 4);
+
+    BOOST_REQUIRE(Atomics::DecrementAndGet64(&val) == 3);
+    BOOST_REQUIRE(val == 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestThreadLocal)
+{
+    int32_t idx1 = ThreadLocal::NextIndex();
+    int32_t idx2 = ThreadLocal::NextIndex();
+    BOOST_REQUIRE(idx2 > idx1);
+
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 0);
+
+    ThreadLocal::Set(idx1, 1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 1);
+
+    ThreadLocal::Set(idx1, 2);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 2);
+
+    ThreadLocal::Remove(idx1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 0);
+    
+    ThreadLocal::Set(idx1, 1);
+    BOOST_REQUIRE(ThreadLocal::Get<int32_t>(idx1) == 1);
+
+    ThreadLocal::Remove(idx1);
+}
+
+BOOST_AUTO_TEST_CASE(TestThreadLocalInstance)
+{
+    ThreadLocalInstance<int32_t> val;
+
+    BOOST_REQUIRE(val.Get() == 0);
+
+    val.Set(1);
+    BOOST_REQUIRE(val.Get() == 1);
+
+    val.Set(2);
+    BOOST_REQUIRE(val.Get() == 2);
+
+    val.Remove();
+    BOOST_REQUIRE(val.Get() == 0);
+
+    val.Set(1);
+    BOOST_REQUIRE(val.Get() == 1);
+
+    val.Remove();
+}
+
+struct SharedPointerTarget
+{
+    bool deleted;
+
+    SharedPointerTarget() : deleted(false)
+    {
+        // No-op.
+    }
+};
+
+void DeleteSharedPointerTarget(SharedPointerTarget* ptr)
+{
+    ptr->deleted = true;
+}
+
+BOOST_AUTO_TEST_CASE(TestSharedPointer)
+{
+    // 1. Test the simples scenario.
+    SharedPointerTarget* target = new SharedPointerTarget();
+
+    SharedPointer<SharedPointerTarget>* ptr1 = 
+        new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    delete ptr1;
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 2. Test copy ctor.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+    SharedPointer<SharedPointerTarget>* ptr2 = new SharedPointer<SharedPointerTarget>(*ptr1);
+
+    delete ptr1;
+    BOOST_REQUIRE(!target->deleted);
+
+    delete ptr2;
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 3. Test assignment logic.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    SharedPointer<SharedPointerTarget> ptr3 = *ptr1;
+
+    delete ptr1;
+    BOOST_REQUIRE(!target->deleted);
+
+    ptr3 = SharedPointer<SharedPointerTarget>();
+    BOOST_REQUIRE(target->deleted);
+
+    target->deleted = false;
+
+    // 4. Test self-assignment.
+    ptr1 = new SharedPointer<SharedPointerTarget>(target, DeleteSharedPointerTarget);
+
+    *ptr1 = *ptr1;
+
+    delete ptr1;
+
+    BOOST_REQUIRE(target->deleted);
+
+    // 5. Tear-down.
+    delete target;    
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp b/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
new file mode 100644
index 0000000..bc4a654
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/handle_registry_test.cpp
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/handle_registry.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::impl;
+
+struct HandleRegistryTestProbe
+{
+    bool deleted;
+    
+    HandleRegistryTestProbe()
+    {
+        deleted = false;
+    }
+};
+
+class HandleRegistryTestEntry : public HandleRegistryEntry
+{
+public:
+    HandleRegistryTestEntry(HandleRegistryTestProbe* probe) : probe(probe)
+    {
+        // No-op.
+    }
+
+    virtual ~HandleRegistryTestEntry()
+    {
+        probe->deleted = true;
+    }
+
+private:
+    HandleRegistryTestProbe* probe;
+};
+
+BOOST_AUTO_TEST_SUITE(HandleRegistryTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestCritical)
+{
+    HandleRegistry reg(2, 1);
+
+    HandleRegistryTestProbe probe0;
+    HandleRegistryTestProbe probe1;
+    HandleRegistryTestProbe probe2;
+
+    HandleRegistryTestEntry* entry0 = new HandleRegistryTestEntry(&probe0);
+    HandleRegistryTestEntry* entry1 = new HandleRegistryTestEntry(&probe1);
+    HandleRegistryTestEntry* entry2 = new HandleRegistryTestEntry(&probe2);
+
+    int64_t hnd0 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry0));
+    int64_t hnd1 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry1));
+    int64_t hnd2 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry2));
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == entry0);
+    BOOST_REQUIRE(!probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Release(hnd0);
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Close();
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == NULL);
+    BOOST_REQUIRE(probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == NULL);
+    BOOST_REQUIRE(probe2.deleted);
+
+    HandleRegistry closedReg(2, 1);
+
+    closedReg.Close();
+
+    HandleRegistryTestProbe closedProbe;
+    HandleRegistryTestEntry* closedEntry = new HandleRegistryTestEntry(&closedProbe);
+
+    int64_t closedHnd = closedReg.AllocateCritical(SharedPointer<HandleRegistryEntry>(closedEntry));
+    BOOST_REQUIRE(closedHnd == -1);
+    BOOST_REQUIRE(closedProbe.deleted);
+}
+
+BOOST_AUTO_TEST_CASE(TestNonCritical)
+{
+    HandleRegistry reg(0, 2);
+
+    HandleRegistryTestProbe probe0;
+    HandleRegistryTestProbe probe1;
+    HandleRegistryTestProbe probe2;
+
+    HandleRegistryTestEntry* entry0 = new HandleRegistryTestEntry(&probe0);
+    HandleRegistryTestEntry* entry1 = new HandleRegistryTestEntry(&probe1);
+    HandleRegistryTestEntry* entry2 = new HandleRegistryTestEntry(&probe2);
+
+    int64_t hnd0 = reg.AllocateCritical(SharedPointer<HandleRegistryEntry>(entry0));
+    int64_t hnd1 = reg.Allocate(SharedPointer<HandleRegistryEntry>(entry1));
+    int64_t hnd2 = reg.Allocate(SharedPointer<HandleRegistryEntry>(entry2));
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == entry0);
+    BOOST_REQUIRE(!probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Release(hnd0);
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == entry1);
+    BOOST_REQUIRE(!probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == entry2);
+    BOOST_REQUIRE(!probe2.deleted);
+
+    reg.Close();
+
+    BOOST_REQUIRE(reg.Get(hnd0).Get() == NULL);
+    BOOST_REQUIRE(probe0.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd1).Get() == NULL);
+    BOOST_REQUIRE(probe1.deleted);
+
+    BOOST_REQUIRE(reg.Get(hnd2).Get() == NULL);
+    BOOST_REQUIRE(probe2.deleted);
+
+    HandleRegistry closedReg(0, 2);
+
+    closedReg.Close();
+
+    HandleRegistryTestProbe closedProbe;
+    HandleRegistryTestEntry* closedEntry = new HandleRegistryTestEntry(&closedProbe);
+
+    int64_t closedHnd = closedReg.Allocate(SharedPointer<HandleRegistryEntry>(closedEntry));
+    BOOST_REQUIRE(closedHnd == -1);
+    BOOST_REQUIRE(closedProbe.deleted);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp b/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
new file mode 100644
index 0000000..f55977a
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/ignition_test.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace boost::unit_test;
+
+BOOST_AUTO_TEST_SUITE(IgnitionTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestIgnition)
+{
+    IgniteConfiguration cfg;
+
+    IgniteJvmOption opts[5];
+
+    opts[0] = IgniteJvmOption("-Xdebug");
+    opts[1] = IgniteJvmOption("-Xnoagent");
+    opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
+    opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+    opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
+
+    cfg.jvmOptsLen = 5;
+    cfg.jvmOpts = opts;
+
+    cfg.jvmInitMem = 1024;
+    cfg.jvmMaxMem = 4096;
+
+    char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
+
+    std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
+
+    cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+
+    IgniteError err;
+
+    // Start two Ignite instances.
+    Ignite grid1 = Ignition::Start(cfg, "ignitionTest-1", &err);
+    
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+    
+    BOOST_REQUIRE(strcmp(grid1.GetName(), "ignitionTest-1") == 0);
+
+    Ignite grid2 = Ignition::Start(cfg, "ignitionTest-2", &err);
+
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+
+    BOOST_REQUIRE(strcmp(grid2.GetName(), "ignitionTest-2") == 0);
+
+    // Test get
+    Ignite grid0 = Ignition::Get("ignitionTest-1", &err);
+    
+    if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+        BOOST_ERROR(err.GetText());
+
+    BOOST_REQUIRE(strcmp(grid0.GetName(), grid1.GetName()) == 0);
+
+    // Stop one grid
+    Ignition::Stop(grid1.GetName(), true);
+    
+    Ignition::Get("ignitionTest-1", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);
+    
+    Ignition::Get("ignitionTest-2", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    // Stop all
+    Ignition::StopAll(true);
+    
+    Ignition::Get("ignitionTest-2", &err);
+    BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_GENERIC);    
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fc06e01/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
new file mode 100644
index 0000000..c3a98aa
--- /dev/null
+++ b/modules/platform/src/main/cpp/core-test/src/portable_reader_writer_raw_test.cpp
@@ -0,0 +1,1532 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+    #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/portable/portable.h"
+
+#include "ignite/portable_test_defs.h"
+#include "ignite/portable_test_utils.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::portable;
+using namespace ignite::portable;
+using namespace ignite_test::core::portable;
+
+template<typename T>
+void CheckRawPrimitive(T val)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    Write<T>(rawWriter, val);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    T readVal = Read<T>(rawReader);
+    
+    BOOST_REQUIRE(readVal == val);
+}
+
+template<typename T>
+void CheckRawPrimitiveArray(T dflt, T val1, T val2)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+    
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    // 1. Write NULL and see what happens.
+    WriteArray<T>(rawWriter, NULL, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+    
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == -1);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == -1);
+
+    T arr1[2];
+    arr1[0] = dflt;
+    arr1[1] = dflt;
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == -1);
+
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 2. Write empty array.
+    T arr2[2];
+    arr2[0] = val1;
+    arr2[1] = val2;
+
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 0);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 0);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 0);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 0);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    // 3. Partial array write.
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 1);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 1);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 1);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 1);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    in.Position(0);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 1);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == dflt);
+    arr1[0] = dflt;
+
+    // 4. Full array write.
+    out.Position(0);
+    in.Position(0);
+
+    WriteArray<T>(rawWriter, arr2, 2);
+
+    out.Synchronize();
+    in.Synchronize();
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 2);
+    BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 2);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 2);
+    BOOST_REQUIRE(arr1[0] == dflt);
+    BOOST_REQUIRE(arr1[1] == dflt);
+
+    BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 2);
+    BOOST_REQUIRE(arr1[0] == val1);
+    BOOST_REQUIRE(arr1[1] == val2);
+}
+
+void CheckRawWritesRestricted(PortableRawWriter& writer)
+{
+    try
+    {
+        writer.WriteInt8(1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        writer.WriteInt8Array(arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        Guid val(1, 1);
+
+        writer.WriteGuid(val);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        writer.WriteString("test");
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteArray<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteCollection<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try 
+    {
+        writer.WriteMap<int8_t, int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckRawReadsRestricted(PortableRawReader& reader)
+{
+    try
+    {
+        reader.ReadInt8();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        int8_t arr[1];
+
+        reader.ReadInt8Array(arr, 1);
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadGuid();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadString();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadArray<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadCollection<int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        reader.ReadMap<int8_t, int8_t>();
+
+        BOOST_FAIL("Not restricted.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+}
+
+void CheckRawCollectionEmpty(CollectionType* colType)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    colWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 0);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawCollection(CollectionType* colType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableCollectionWriter<PortableInner> colWriter = colType ?
+        rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
+
+    colWriter.Write(writeVal1);
+    colWriter.Write(writeVal2);
+    colWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    colWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        colWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        colWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    if (colType)
+        BOOST_REQUIRE(colReader.GetType() == *colType);
+    else
+        BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+    BOOST_REQUIRE(colReader.GetSize() == 3);
+    BOOST_REQUIRE(!colReader.IsNull());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(colReader.HasNext());
+    BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!colReader.HasNext());
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMapEmpty(MapType* mapType)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    mapWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        mapWriter.Write(1, PortableInner(1));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 0);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMap(MapType* mapType)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
+        rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
+
+    mapWriter.Write(1, writeVal1);
+    mapWriter.Write(2, writeVal2);
+    mapWriter.Write(3, writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    mapWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        mapWriter.Write(4, PortableInner(4));
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        mapWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    if (mapType)
+        BOOST_REQUIRE(mapReader.GetType() == *mapType);
+    else
+        BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+    BOOST_REQUIRE(mapReader.GetSize() == 3);
+    BOOST_REQUIRE(!mapReader.IsNull());
+
+    int8_t key;
+    PortableInner val;
+
+    BOOST_REQUIRE(mapReader.HasNext());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 1);
+    BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 2);
+    BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+    mapReader.GetNext(&key, &val);
+    BOOST_REQUIRE(key == 3);
+    BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!mapReader.HasNext());
+
+    try
+    {
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_SUITE(PortableReaderWriterRawTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+{
+    CheckRawPrimitive<int8_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+{
+    CheckRawPrimitive<bool>(true);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+{
+    CheckRawPrimitive<int16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+{
+    CheckRawPrimitive<uint16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+{
+    CheckRawPrimitive<int32_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+{
+    CheckRawPrimitive<int64_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+{
+    CheckRawPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+{
+    CheckRawPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+{
+    Guid val(1, 2);
+
+    CheckRawPrimitive<Guid>(val);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+{
+    CheckRawPrimitiveArray<int8_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+{
+    CheckRawPrimitiveArray<bool>(false, true, false);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+{
+    CheckRawPrimitiveArray<int16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+{
+    CheckRawPrimitiveArray<uint16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+{
+    CheckRawPrimitiveArray<int32_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+{
+    CheckRawPrimitiveArray<int64_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+{
+    CheckRawPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+{
+    CheckRawPrimitiveArray<double>(1.1, 2.2, 3.3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+{
+    Guid dflt(1, 2);
+    Guid val1(3, 4);
+    Guid val2(5, 6);
+
+    CheckRawPrimitiveArray<Guid>(dflt, val1, val2);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    Guid expVal;
+    Guid actualVal = rawReader.ReadGuid();
+
+    BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestString) {
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = writeVal1;
+
+    rawWriter.WriteString(writeVal1);
+    rawWriter.WriteString(writeVal1, 4);
+    rawWriter.WriteString(writeVal3);
+    rawWriter.WriteString(NULL);
+    rawWriter.WriteString(NULL, 4);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    char readVal1[9];
+    char readVal2[5];
+    
+    BOOST_REQUIRE(rawReader.ReadString(NULL, 0) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(NULL, 8) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 0) == 8);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 4) == 8);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    std::string readVal3 = rawReader.ReadString();
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+    BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArray)
+{
+    const char* writeVal1 = "testtest";
+    const char* writeVal2 = "test";
+    std::string writeVal3 = "test2";
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+    arrWriter.Write(writeVal1);
+    arrWriter.Write(writeVal1, 4);
+    arrWriter.Write(NULL); // NULL value.
+    arrWriter.Write(NULL, 100); // NULL value again.
+    arrWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val, 4);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        const char* val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        std::string val = "test";
+
+        arrWriter.Write(val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableStringArrayReader arrReader = rawReader.ReadStringArray();
+
+    CheckRawReadsRestricted(rawReader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 5);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    // 1. Read first value.
+    BOOST_REQUIRE(arrReader.HasNext());
+        
+    char readVal1[9];
+    
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+    std::string writeVal1Str = writeVal1;
+    std::string readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 2. Read second value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    char readVal2[5];
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+    std::string writeVal2Str = writeVal2;
+    std::string readVal2Str = readVal2;
+    BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+    // 3. Read NULL.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+    readVal1Str = readVal1;
+    BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+    // 4. Read NULL again, this time through another method.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readNullVal = arrReader.GetNext();
+
+    BOOST_REQUIRE(readNullVal.length() == 0);
+
+    // 5. Read third value.
+    BOOST_REQUIRE(arrReader.HasNext());
+
+    std::string readVal3 = arrReader.GetNext();
+    BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        char res[100];
+
+        arrReader.GetNext(res, 100);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+    PortableInner writeVal1(1);
+    PortableInner writeVal2(0);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteObject(writeVal1);
+    rawWriter.WriteObject(writeVal2);
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableInner readVal1 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+    PortableInner readVal2 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+    PortableInner readVal3 = rawReader.ReadObject<PortableInner>();
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestNestedObject)
+{
+    PortableOuter writeVal1(1, 2);
+    PortableOuter writeVal2(0, 0);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteObject(writeVal1);
+    rawWriter.WriteObject(writeVal2);
+    rawWriter.WriteNull();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableOuter readVal1 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+    BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+    PortableOuter readVal2 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+    BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+    PortableOuter readVal3 = rawReader.ReadObject<PortableOuter>();
+    BOOST_REQUIRE(0 == readVal3.GetValue());
+    BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    BOOST_REQUIRE(arrReader.GetSize() == -1);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayEmpty) 
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    BOOST_REQUIRE(arrReader.GetSize() == 0);
+    BOOST_REQUIRE(!arrReader.HasNext());
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArray)
+{
+    PortableInner writeVal1 = PortableInner(1);
+    PortableInner writeVal2 = PortableInner(0);
+    PortableInner writeVal3 = PortableInner(2);
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
+
+    arrWriter.Write(writeVal1); 
+    arrWriter.Write(writeVal2);
+    arrWriter.Write(writeVal3);
+
+    CheckRawWritesRestricted(rawWriter);
+
+    arrWriter.Close();
+
+    rawWriter.WriteInt8(1);
+
+    try
+    {
+        arrWriter.Write(1);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    try
+    {
+        arrWriter.Close();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
+
+    CheckRawReadsRestricted(rawReader);
+
+    BOOST_REQUIRE(arrReader.GetSize() == 3);
+    BOOST_REQUIRE(!arrReader.IsNull());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+    BOOST_REQUIRE(arrReader.HasNext());
+    BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+    BOOST_REQUIRE(!arrReader.HasNext());
+
+    try
+    {
+        arrReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
+
+    BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+    BOOST_REQUIRE(colReader.GetSize() == -1);
+    BOOST_REQUIRE(!colReader.HasNext());
+    BOOST_REQUIRE(colReader.IsNull()); 
+
+    try
+    {
+        colReader.GetNext();
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+{
+    CheckRawCollectionEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckRawCollectionEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollection)
+{
+    CheckRawCollection(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(testCollectionTyped)
+{
+    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+    CheckRawCollection(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapNull)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    PortableWriterImpl writer(&out, NULL);
+    PortableRawWriter rawWriter(&writer);
+
+    rawWriter.WriteNull();
+    rawWriter.WriteInt8(1);
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    PortableReaderImpl reader(&in);
+    PortableRawReader rawReader(&reader);
+
+    PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
+
+    BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+    BOOST_REQUIRE(mapReader.GetSize() == -1);
+    BOOST_REQUIRE(!mapReader.HasNext());
+    BOOST_REQUIRE(mapReader.IsNull());
+
+    try
+    {
+        int8_t key;
+        PortableInner val;
+
+        mapReader.GetNext(&key, &val);
+
+        BOOST_FAIL("Error expected.");
+    }
+    catch (IgniteError& err)
+    {
+        BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
+    }
+
+    BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmpty)
+{
+    CheckRawMapEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckRawMapEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMap)
+{
+    CheckRawMap(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapTyped)
+{
+    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+    CheckRawMap(&typ);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file