/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 *	   Zhenkai Zhu <zhenkai@cs.ucla.edu>
 */

#include "logging.h"
#include "object-manager.h"

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>

#include <boost/test/unit_test.hpp>
#include <unistd.h>
#include <boost/make_shared.hpp>
#include <iostream>
#include <iterator>

INIT_LOGGER ("Test.ObjectManager");

using namespace Ccnx;
using namespace std;
using namespace boost;
namespace fs = boost::filesystem;

BOOST_AUTO_TEST_SUITE(TestObjectManager)

BOOST_AUTO_TEST_CASE (ObjectManagerTest)
{
  INIT_LOGGERS ();

  fs::path tmpdir = fs::unique_path (fs::temp_directory_path () / "%%%%-%%%%-%%%%-%%%%");
  _LOG_DEBUG ("tmpdir: " << tmpdir);
  Name deviceName ("/device");

  CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
  ObjectManager manager (ccnx, tmpdir, "test-chronoshare");

  tuple<HashPtr,int> hash_semgents = manager.localFileToObjects (fs::path("test") / "test-object-manager.cc", deviceName);

  BOOST_CHECK_EQUAL (hash_semgents.get<1> (), 3);

  bool ok = manager.objectsToLocalFile (deviceName, *hash_semgents.get<0> (), tmpdir / "test.cc");
  BOOST_CHECK_EQUAL (ok, true);

  {
    fs::ifstream origFile (fs::path("test") / "test-object-manager.cc");
    fs::ifstream newFile (tmpdir / "test.cc");

    istream_iterator<char> eof,
      origFileI (origFile),
      newFileI (newFile);

    BOOST_CHECK_EQUAL_COLLECTIONS (origFileI, eof, newFileI, eof);
  }

  remove_all (tmpdir);
}


BOOST_AUTO_TEST_SUITE_END()
