model+test: Fixing tests and making sure all tests pass

Refs #1005 (http://redmine.named-data.net/)
diff --git a/test/ndnSIM-serialization.cc b/test/ndnSIM-serialization.cc
index 7217d26..4ed2bda 100644
--- a/test/ndnSIM-serialization.cc
+++ b/test/ndnSIM-serialization.cc
@@ -24,6 +24,7 @@
 #include "ndnSIM-serialization.h"
 
 #include <boost/lexical_cast.hpp>
+#include "ns3/ndnSIM/model/wire/ndnsim.h"
 
 using namespace std;
 
@@ -36,71 +37,70 @@
 void
 InterestSerializationTest::DoRun ()
 {
-  Interest source;
+  Ptr<Interest> source = Create<Interest> ();
   
-  source.SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2")));
-  NS_TEST_ASSERT_MSG_EQ (source.GetName (), boost::lexical_cast<Name> ("/test/test2"), "set/get name failed");
+  source->SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2")));
+  NS_TEST_ASSERT_MSG_EQ (source->GetName (), boost::lexical_cast<Name> ("/test/test2"), "set/get name failed");
   
-  source.SetScope (2);
-  NS_TEST_ASSERT_MSG_EQ (source.GetScope (), 2, "set/get scope failed");
+  source->SetScope (2);
+  NS_TEST_ASSERT_MSG_EQ (source->GetScope (), 2, "set/get scope failed");
 
-  source.SetInterestLifetime (Seconds (100));
-  NS_TEST_ASSERT_MSG_EQ (source.GetInterestLifetime (), Seconds (100), "set/get interest lifetime failed");
+  source->SetInterestLifetime (Seconds (100));
+  NS_TEST_ASSERT_MSG_EQ (source->GetInterestLifetime (), Seconds (100), "set/get interest lifetime failed");
 
-  source.SetNonce (200);
-  NS_TEST_ASSERT_MSG_EQ (source.GetNonce (), 200, "set/get nonce failed");
+  source->SetNonce (200);
+  NS_TEST_ASSERT_MSG_EQ (source->GetNonce (), 200, "set/get nonce failed");
 
-  source.SetNack (10);
-  NS_TEST_ASSERT_MSG_EQ (source.GetNack (), 10, "set/get NACK failed");
+  source->SetNack (10);
+  NS_TEST_ASSERT_MSG_EQ (source->GetNack (), 10, "set/get NACK failed");
 
-  // Packet packet (0);
-  // //serialization
-  // packet.AddHeader (source);
-	
-  // //deserialization
-  // Interest target;
-  // packet.RemoveHeader (target);
+  NS_TEST_ASSERT_MSG_EQ (source->GetWire (), 0, "Wire should be empty");
+  NS_TEST_ASSERT_MSG_NE (source->GetPayload (), 0, "Payload should not be empty");
+
+  Ptr<Packet> packet = wire::ndnSIM::Interest::ToWire (source);
+
+  NS_TEST_ASSERT_MSG_NE (source->GetWire (), 0, "Wire should not be empty now");
+
+  Ptr<Interest> target = wire::ndnSIM::Interest::FromWire (packet);
   
-  // NS_TEST_ASSERT_MSG_EQ (source.GetName ()            , target.GetName ()            , "source/target name failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetScope ()           , target.GetScope ()           , "source/target scope failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetInterestLifetime (), target.GetInterestLifetime (), "source/target interest lifetime failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetNonce ()           , target.GetNonce ()           , "source/target nonce failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetNack ()            , target.GetNack ()            , "source/target NACK failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetName ()            , target->GetName ()            , "source/target name failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetScope ()           , target->GetScope ()           , "source/target scope failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetInterestLifetime (), target->GetInterestLifetime (), "source/target interest lifetime failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetNonce ()           , target->GetNonce ()           , "source/target nonce failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetNack ()            , target->GetNack ()            , "source/target NACK failed");
 }
 
 void
 ContentObjectSerializationTest::DoRun ()
 {
-  ContentObject source;
+  Ptr<ContentObject> source = Create<ContentObject> (Create<Packet> (1024));
   
-  source.SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2/1")));
-  NS_TEST_ASSERT_MSG_EQ (source.GetName (), boost::lexical_cast<Name> ("/test/test2/1"), "set/get name failed");
+  source->SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2/1")));
+  NS_TEST_ASSERT_MSG_EQ (source->GetName (), boost::lexical_cast<Name> ("/test/test2/1"), "set/get name failed");
   
-  source.SetFreshness (Seconds (10));
-  NS_TEST_ASSERT_MSG_EQ (source.GetFreshness (), Seconds (10), "set/get freshness failed");
+  source->SetFreshness (Seconds (10));
+  NS_TEST_ASSERT_MSG_EQ (source->GetFreshness (), Seconds (10), "set/get freshness failed");
 
-  source.SetTimestamp (Seconds (100));
-  NS_TEST_ASSERT_MSG_EQ (source.GetTimestamp (), Seconds (100), "set/get timestamp failed");
+  source->SetTimestamp (Seconds (100));
+  NS_TEST_ASSERT_MSG_EQ (source->GetTimestamp (), Seconds (100), "set/get timestamp failed");
 
-  NS_TEST_ASSERT_MSG_EQ (source.GetSignature (), 0, "initialization of signature failed");
-  // int size = source.GetSerializedSize ();  
-  // source.SetSignature (10);
-  // NS_TEST_ASSERT_MSG_EQ (source.GetSignature (), 10, "set/get signature failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), 0, "initialization of signature failed");
 
-  // NS_TEST_ASSERT_MSG_EQ (source.GetSerializedSize (), static_cast<unsigned int> (size + 4), "Signature size should have increased by 4");
+  Ptr<Packet> packet = wire::ndnSIM::Data::ToWire (source);
+  int size = packet->GetSize ();
+
+  source->SetSignature (10);  
+  NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), 10, "set/get signature failed");
+
+  packet = wire::ndnSIM::Data::ToWire (source);
+  NS_TEST_ASSERT_MSG_EQ (packet->GetSize (), static_cast<unsigned int> (size + 4), "Signature size should have increased by 4");
+
+  Ptr<ContentObject> target = wire::ndnSIM::Data::FromWire (packet);
   
-  // Packet packet (0);
-  // //serialization
-  // packet.AddHeader (source);
-	
-  // //deserialization
-  // ContentObject target;
-  // packet.RemoveHeader (target);
-  
-  // NS_TEST_ASSERT_MSG_EQ (source.GetName ()     , target.GetName ()     , "source/target name failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetFreshness (), target.GetFreshness (), "source/target freshness failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetTimestamp (), target.GetTimestamp (), "source/target timestamp failed");
-  // NS_TEST_ASSERT_MSG_EQ (source.GetSignature (), target.GetSignature (), "source/target signature failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetName ()     , target->GetName ()     , "source/target name failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetFreshness (), target->GetFreshness (), "source/target freshness failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetTimestamp (), target->GetTimestamp (), "source/target timestamp failed");
+  NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), target->GetSignature (), "source/target signature failed");
 }
 
 }