You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2012/06/01 14:08:53 UTC

svn commit: r1345095 - in /incubator/etch/trunk/binding-cpp/runtime: include/common/ include/serialization/ src/main/ src/main/serialization/ src/test/ src/test/serialization/

Author: fitzner
Date: Fri Jun  1 12:08:53 2012
New Revision: 1345095

URL: http://svn.apache.org/viewvc?rev=1345095&view=rev
Log:
ETCH-184 EtchListSerializer Implementation

EtchListSerializer implementation

Change-Id: I592d93cb1a30cc977db6da13c176f60b34ffaae1

Added:
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchListSerializer.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
Modified:
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchList.h
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
    incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchType.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchType.cpp
    incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchList.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchList.h?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchList.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchList.h Fri Jun  1 12:08:53 2012
@@ -19,9 +19,11 @@
 #ifndef __ETCHLIST_H__
 #define __ETCHLIST_H__
 
+#include "capu/container/List.h"
 #include "common/EtchObject.h"
+#include "common/EtchObjectType.h"
+#include "common/EtchError.h"
 #include "common/EtchComparator.h"
-#include "capu/container/List.h"
 
 template <class T, class C = EtchComparator<T> >
 class EtchList : public EtchObject {

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h Fri Jun  1 12:08:53 2012
@@ -23,9 +23,9 @@
 
 #include "EtchConfig.h"
 #include "common/EtchObject.h"
+#include "capu/util/SmartPointer.h"
 
 enum EtchObjectTypeIds {
-
   EOTID_INT32 = 0,
   EOTID_BOOL,
   EOTID_BYTE,
@@ -72,9 +72,9 @@ enum EtchObjectTypeIds {
 
 class EtchObjectType : public EtchObject {
 public:
-   /**
-    * TypeIds for native types
-    */
+  /**
+   * TypeIds for native types
+   */
   static const EtchObjectType NATIVE_INT8;
   static const EtchObjectType NATIVE_INT16;
   static const EtchObjectType NATIVE_INT32;
@@ -135,7 +135,7 @@ private:
   struct __Wrapper__ {
 
     static const EtchObjectType * getType() {
-      return &T::TYPE;
+      return T::TYPE();
     }
   };
 
@@ -147,119 +147,127 @@ private:
     }
   };
 
-};
-
- template <>
- struct EtchObjectType::__Wrapper__<capu::int32_t> {
+  template <class T>
+  struct __Wrapper__<capu::SmartPointer<T> > {
 
     static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT32;
+      return T::TYPE();
     }
   };
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int16_t> {
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT16;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int32_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int8_t> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT32;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT8;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int16_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int64_t> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT16;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT64;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int8_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::float_t> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT8;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_FLOAT;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int64_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::double_t> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT64;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_DOUBLE;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::float_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::bool_t> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_FLOAT;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_BOOL;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::double_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int32_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_DOUBLE;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT32;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::bool_t> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int16_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_BOOL;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT16;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int32_t*> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int8_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT32;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT8;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int16_t*> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::int64_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT16;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_INT64;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int8_t*> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::float_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT8;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_FLOAT;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::int64_t*> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::double_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_INT64;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_DOUBLE;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::float_t*> {
 
-  template <>
-  struct EtchObjectType::__Wrapper__<capu::bool_t*> {
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_FLOAT;
+  }
+};
 
-    static const EtchObjectType * getType() {
-      return &EtchObjectType::NATIVE_BOOL;
-    }
-  };
+template <>
+struct EtchObjectType::__Wrapper__<capu::double_t*> {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_DOUBLE;
+  }
+};
+
+template <>
+struct EtchObjectType::__Wrapper__<capu::bool_t*> {
+
+  static const EtchObjectType * getType() {
+    return &EtchObjectType::NATIVE_BOOL;
+  }
+};
 
 #endif /* ETCHOBJECTTYPE_H */
 

Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchListSerializer.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchListSerializer.h?rev=1345095&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchListSerializer.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchListSerializer.h Fri Jun  1 12:08:53 2012
@@ -0,0 +1,69 @@
+/* $Id$
+ *
+ * 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 __ETCHLISTSERIALIZER_H__
+#define __ETCHLISTSERIALIZER_H__
+
+#include "common/EtchList.h"
+#include "common/EtchNativeArray.h"
+#include "serialization/EtchImportExportHelper.h"
+#include "serialization/EtchStructValue.h"
+#include "serialization/EtchField.h"
+#include "serialization/EtchType.h"
+#include "serialization/EtchClass2TypeMap.h"
+#include "serialization/EtchValidatorObject.h"
+
+class EtchListSerializer : public EtchImportExportHelper {
+public:
+
+  /**
+   * Constructor
+   */
+  EtchListSerializer(EtchType* type, EtchField* field);
+
+  /**
+   * Destructor
+   */
+  virtual ~EtchListSerializer();
+
+  /**
+   * @see EtchImportExportHelper
+   */
+  virtual status_t exportValue(EtchValueFactory* vf, capu::SmartPointer<EtchObject> value, EtchStructValue *&result);
+
+  /**
+   * @see EtchImportExportHelper
+   */
+  virtual status_t importValue(EtchStructValue* value, capu::SmartPointer<EtchObject> &result);
+
+  /**
+   * Defines custom fields in the value factory so that the importer can find them.
+   * @param type
+   * @param collection
+   */
+  static status_t Init(EtchType* type, EtchClass2TypeMap* class2type);
+
+private:
+
+  EtchType* mType;
+  EtchField mField;
+  const static EtchString FIELD_NAME;
+};
+
+#endif /* ETCHLISTSERIALIZER_H */
+

Modified: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchType.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchType.h?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchType.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchType.h Fri Jun  1 12:08:53 2012
@@ -101,7 +101,7 @@ public:
    *         ETCH_EINVAL if value is null
    *         ETCH_ERANGE if there is no existing pair with specified key
    */
-  status_t getField(EtchString &name, EtchField *field);
+  status_t getField(const EtchString &name, EtchField *field);
 
   /**
    * @return the time in milliseconds to wait for this response message.

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt Fri Jun  1 12:08:53 2012
@@ -83,6 +83,7 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchStructValue.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchTypeMap.h
     ${PROJECT_SOURCE_DIR}/include/serialization/EtchClass2TypeMap.h
+    ${PROJECT_SOURCE_DIR}/include/serialization/EtchListSerializer.h
     ${PROJECT_SOURCE_DIR}/include/util/EtchUtil.h
     )
 
@@ -126,6 +127,7 @@ SET(MAIN_SOURCES
     serialization/EtchStructValue.cpp
     serialization/EtchTypeMap.cpp
     serialization/EtchClass2TypeMap.cpp
+    serialization/EtchListSerializer.cpp
     util/EtchUtil.cpp
     )
 
@@ -142,7 +144,7 @@ ELSEIF(WIN32)
 ENDIF()
 
 IF (UNIX)
-  set_target_properties (etch-cpp PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
+  set_target_properties (etch-cpp PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
 ENDIF (UNIX)
 
 set_target_properties (etch-cpp PROPERTIES OUTPUT_NAME "etch")

Added: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp?rev=1345095&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp Fri Jun  1 12:08:53 2012
@@ -0,0 +1,109 @@
+/* $Id$
+ *
+ * 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.
+ */
+
+#include "serialization/EtchListSerializer.h"
+
+const EtchString EtchListSerializer::FIELD_NAME("values");
+
+// TODO: check signature regarding by value copy
+
+EtchListSerializer::EtchListSerializer(EtchType* type, EtchField* field)
+: mField(*field), mType(type) {
+}
+
+EtchListSerializer::~EtchListSerializer() {
+}
+
+status_t EtchListSerializer::exportValue(EtchValueFactory* vf, capu::SmartPointer<EtchObject> value, EtchStructValue *&result) {
+  if ((vf == NULL) || (value.get() == NULL))
+    return ETCH_EINVAL;
+
+  if (!value->getObjectType()->equals(EtchList<capu::SmartPointer<EtchObject> >::TYPE()))
+    return ETCH_EINVAL;
+
+  capu::SmartPointer<EtchList<capu::SmartPointer<EtchObject> > > list = capu::smartpointer_cast<EtchList<capu::SmartPointer<EtchObject> > >(value);
+
+  EtchList<capu::SmartPointer<EtchObject> >::Iterator it = list->begin();
+  capu::SmartPointer<EtchNativeArray<capu::SmartPointer<EtchObject> > > values = new EtchNativeArray<capu::SmartPointer<EtchObject> > (list->size(), 1);
+  capu::int32_t i = 0;
+  capu::SmartPointer<EtchObject> tmp = NULL;
+  while (it.hasNext()) {
+    it.next(&tmp);
+    values->set(Pos(i), tmp);
+    i++;
+  }
+  result = new EtchStructValue(mType, vf);
+  if (result->put(mField, values) != ETCH_OK)
+    return ETCH_ERROR;
+  return ETCH_OK;
+}
+
+status_t EtchListSerializer::importValue(EtchStructValue* value, capu::SmartPointer<EtchObject> &result) {
+  if (value == NULL) {
+    return ETCH_EINVAL;
+  }
+  if (!value->isType(mType)) {
+    return ETCH_EINVAL;
+  }
+
+  capu::SmartPointer<EtchObject> tmp = NULL;
+  if (value->get(mField, &tmp) != ETCH_OK)
+    return ETCH_ERROR;
+
+  capu::SmartPointer<EtchNativeArray<capu::SmartPointer<EtchObject> > > values = capu::smartpointer_cast<EtchNativeArray<capu::SmartPointer<EtchObject> > >(tmp);
+
+  EtchList<capu::SmartPointer<EtchObject> > *list = new EtchList<capu::SmartPointer<EtchObject> >();
+  // TODO improve this
+  for (capu::int32_t i = 0; i < values->getLength(); i++) {
+    capu::SmartPointer<EtchObject> item = NULL;
+    values->get(i, &item);
+    status_t res = list->add(item);
+    if (res != ETCH_OK)
+      return res;
+  }
+  result = (EtchObject*) list;
+  return ETCH_OK;
+}
+
+status_t EtchListSerializer::Init(EtchType* type, EtchClass2TypeMap * class2type) {
+  status_t result;
+
+  EtchField field;
+  result = type->getField(FIELD_NAME, &field);
+  if (result != ETCH_OK) {
+    return result;
+  }
+
+  class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+  type->setComponentType(EtchList<capu::SmartPointer<EtchObject> >::TYPE());
+  //set the import export helper
+  // TODO memory EtchField
+  type->setImportExportHelper(new EtchListSerializer(type, &field));
+  capu::SmartPointer<EtchValidator> validator;
+  result = EtchValidatorObject::Get(1, validator);
+  if (result != ETCH_OK) {
+    return result;
+  }
+  result = type->putValidator(field, validator);
+  if (result != ETCH_OK) {
+    return result;
+  }
+  type->lock();
+
+  return ETCH_OK;
+}

Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchType.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchType.cpp?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchType.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchType.cpp Fri Jun  1 12:08:53 2012
@@ -59,7 +59,7 @@ status_t EtchType::getField(capu::uint32
   return mFieldMap.get(id, field);
 }
 
-status_t EtchType::getField(EtchString &name, EtchField *field) {
+status_t EtchType::getField(const EtchString &name, EtchField *field) {
   return mFieldMap.get(name, field);
 }
 

Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt?rev=1345095&r1=1345094&r2=1345095&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt Fri Jun  1 12:08:53 2012
@@ -64,6 +64,7 @@ add_executable (etch-cpp-test
     serialization/EtchStructValueTest.cpp
     serialization/EtchTypeMapTest.cpp
     serialization/EtchClass2TypeMapTest.cpp
+    serialization/EtchListSerializerTest.cpp
     util/EtchUtilTest.cpp
     ${GTEST}/src/gtest-all.cc
     ${GMOCK}/src/gmock-all.cc
@@ -87,7 +88,7 @@ IF (WIN32 AND BUILD_CHECK_MEMORY)
 ENDIF (WIN32 AND BUILD_CHECK_MEMORY)
 
 IF (UNIX)
-  set_target_properties (etch-cpp-test PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32 -pthread")
+  set_target_properties (etch-cpp-test PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32 -pthread")
 ENDIF (UNIX)
 
 add_dependencies (etch-cpp Capu)

Added: incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp?rev=1345095&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchListSerializerTest.cpp Fri Jun  1 12:08:53 2012
@@ -0,0 +1,180 @@
+/* $Id$
+ *
+ * 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.
+ */
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "serialization/EtchValueFactory.h"
+#include "serialization/EtchListSerializer.h"
+#include "common/EtchNativeArray.h"
+
+class MockValueFactory1 : public virtual EtchValueFactory {
+public:
+
+  ~MockValueFactory1() {
+
+  }
+  MOCK_METHOD2(getType, status_t(capu::uint32_t id, EtchType*& result));
+
+  MOCK_METHOD2(getType, status_t(EtchString& name, EtchType*& result));
+
+  MOCK_METHOD1(addType, status_t(EtchType* type));
+
+  MOCK_METHOD0(lockDynamicTypes, status_t());
+
+  MOCK_METHOD0(unlockDynamicTypes, status_t());
+
+  MOCK_METHOD2(getMessageId, status_t(EtchMessage* msg, capu::int64_t &result));
+
+  MOCK_METHOD2(setMessageId, status_t(EtchMessage* msg, capu::int64_t msgid));
+
+  MOCK_METHOD0(get_mf__messageId, EtchField());
+
+  MOCK_METHOD2(getInReplyTo, status_t(EtchMessage* msg, capu::int64_t &result));
+
+  MOCK_METHOD2(setInReplyTo, status_t(EtchMessage* msg, capu::int64_t msgid));
+
+  MOCK_METHOD0(get_mf__inReplyTo, EtchField());
+
+
+  MOCK_METHOD2(importCustomValue, status_t(EtchStructValue* value, capu::SmartPointer<EtchObject> &result));
+
+  MOCK_METHOD2(exportCustomValue, status_t(capu::SmartPointer<EtchObject> value, EtchStructValue *&result));
+
+  MOCK_METHOD0(get_mt__exception, EtchType*());
+
+  MOCK_METHOD2(getCustomStructType, status_t(capu::int32_t c, EtchType *& type));
+
+  EtchLevel getLevel() {
+    return LEVEL_FULL;
+  }
+
+  MOCK_METHOD1(setLevel, EtchLevel(EtchLevel level));
+
+};
+
+TEST(EtchListSerializerTest, initTest) {
+  EtchClass2TypeMap* c2type = new EtchClass2TypeMap();
+  EtchString typeName("type1");
+  EtchType* type = new EtchType(10, typeName);
+  EtchType* result;
+  EXPECT_TRUE(EtchListSerializer::Init(type, c2type) == ETCH_OK);
+  c2type->get(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), &result);
+
+  //check the added type to class to type matching
+  EXPECT_TRUE(type == result);
+  //check the initialized component type
+  EXPECT_TRUE(type->getComponentType() == EtchList<capu::SmartPointer<EtchObject> >::TYPE());
+
+  //to check the initialized validator
+  capu::SmartPointer<EtchValidator> validator;
+  EtchField field;
+  typeName = "values";
+  type->getField(typeName, &field);
+  type->getValidator(field, validator);
+
+  capu::SmartPointer<EtchValidator> val;
+  EtchValidatorObject::Get(1, val);
+  EXPECT_TRUE(validator == val);
+  delete type;
+  delete c2type;
+}
+
+TEST(EtchListSerializerTest, exportTest) {
+  EtchClass2TypeMap* c2type = new EtchClass2TypeMap();
+  EtchString typeName("type1");
+  EtchValueFactory* factory = new MockValueFactory1();
+  EtchType* type = new EtchType(10, typeName);
+  capu::SmartPointer<EtchObject> object = new EtchList<capu::SmartPointer<EtchObject> > ();
+  capu::SmartPointer<EtchObject> object2 = new EtchInt32();
+  capu::SmartPointer<EtchObject> object3;
+  EtchStructValue* result;
+  //initialize the serializer
+  EXPECT_TRUE(EtchListSerializer::Init(type, c2type) == ETCH_OK);
+  EtchImportExportHelper* test = type->getImportExportHelper();
+  //check with invalid values
+  EXPECT_TRUE(test->exportValue(NULL, NULL, result) == ETCH_EINVAL);
+  EXPECT_TRUE(test->exportValue(NULL, object, result) == ETCH_EINVAL);
+  EXPECT_TRUE(test->exportValue(factory, NULL, result) == ETCH_EINVAL);
+  EXPECT_TRUE(test->exportValue(factory, object2, result) == ETCH_EINVAL);
+
+  EtchList<capu::SmartPointer<EtchObject> >* list = (EtchList<capu::SmartPointer<EtchObject> > *) object.get();
+
+  list->add(new EtchInt32(90));
+  //export values
+  EXPECT_TRUE(test->exportValue(factory, object, result) == ETCH_OK);
+
+  //check it has been correctly serialized or not
+  EtchString str("values");
+  EtchField field;
+
+  //get the fields
+  EXPECT_TRUE(type->getField(str, &field) == ETCH_OK);
+  //use the field to get the serialized value
+  EXPECT_TRUE(result->get(field, &object3) == ETCH_OK);
+  capu::SmartPointer<EtchNativeArray<capu::SmartPointer<EtchObject> > > na = capu::smartpointer_cast<EtchNativeArray<capu::SmartPointer<EtchObject> > >(object3);
+  //check the assigned type
+  EXPECT_TRUE(type->getComponentType() == EtchList<capu::SmartPointer<EtchObject> >::TYPE());
+  //get the serialized value
+  capu::SmartPointer<EtchObject> object4;
+  na->get(0, &object4);
+  EtchInt32 *serialized = (EtchInt32 *) object4.get();
+  //check the serialized value
+  EXPECT_TRUE(serialized->get() == 90);
+
+  delete c2type;
+  delete factory;
+  delete type;
+  delete result;
+}
+
+TEST(EtchListSerializerTest, importTest) {
+  EtchClass2TypeMap* c2type = new EtchClass2TypeMap();
+  EtchString typeName("type1");
+  EtchValueFactory* factory = new MockValueFactory1();
+  EtchType* type = new EtchType(10, typeName);
+  capu::SmartPointer<EtchObject> object = new EtchList<capu::SmartPointer<EtchObject> > ();
+  capu::SmartPointer<EtchObject> object2 = NULL;
+  EtchStructValue* structValue;
+  //initialize the serializer
+  EXPECT_TRUE(EtchListSerializer::Init(type, c2type) == ETCH_OK);
+  //get the serializer
+  EtchImportExportHelper* test = type->getImportExportHelper();
+  //check with invalid values
+  EtchList<capu::SmartPointer<EtchObject> >* list = (EtchList<capu::SmartPointer<EtchObject> > *) object.get();
+
+  list->add(new EtchInt32(90));
+  //export values
+  EXPECT_TRUE(test->exportValue(factory, object, structValue) == ETCH_OK);
+
+  //UPPER PART IS USED FOR GENERATING EXAMPLE INPUT VALUE FOR IMPORT VALUE
+  capu::SmartPointer<EtchObject> result;
+  //IMPORT TEST
+  EXPECT_TRUE(test->importValue(NULL, result) == ETCH_EINVAL);
+  EXPECT_TRUE(test->importValue(structValue, result) == ETCH_OK);
+
+  capu::SmartPointer<EtchList<capu::SmartPointer<EtchObject> > > importedlist = capu::smartpointer_cast<EtchList<capu::SmartPointer<EtchObject> > > (result);
+
+  //get the imported value
+  importedlist->get(0, &object2);
+  //check the imported value
+  EXPECT_TRUE(((EtchInt32*) object2.get())->get() == 90);
+  delete c2type;
+  delete factory;
+  delete type;
+  delete structValue;
+}