put some tests back
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 30 Mar 2007 11:18:39 +0000 (11:18 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 30 Mar 2007 11:18:39 +0000 (11:18 +0000)
25 files changed:
tests/cache/CMakeLists.txt [new file with mode: 0644]
tests/cache/CacheInitializer.cc [new file with mode: 0644]
tests/media/CMakeLists.txt [new file with mode: 0644]
tests/media/file_exists_test.cc [new file with mode: 0644]
tests/media/media1.cc [new file with mode: 0644]
tests/media/media2.cc [new file with mode: 0644]
tests/media/media3.cc [new file with mode: 0644]
tests/media/media4.cc [new file with mode: 0644]
tests/media/mymediaverifier.h [new file with mode: 0644]
tests/media/throw_if_not_exists.cc [new file with mode: 0644]
tests/zypp/Arch.cc [new file with mode: 0644]
tests/zypp/CMakeLists.txt [new file with mode: 0644]
tests/zypp/Capabilities.cc [new file with mode: 0644]
tests/zypp/CheckSum.cc [new file with mode: 0644]
tests/zypp/Digest.cc [new file with mode: 0644]
tests/zypp/Edition.cc [new file with mode: 0644]
tests/zypp/KeyRing.cc [new file with mode: 0644]
tests/zypp/Lazy.cc [new file with mode: 0644]
tests/zypp/PathInfo.cc [new file with mode: 0644]
tests/zypp/PtrTypes.cc [new file with mode: 0644]
tests/zypp/PublicKey.cc [new file with mode: 0644]
tests/zypp/RWPtr.cc [new file with mode: 0644]
tests/zypp/Signature.cc [new file with mode: 0644]
tests/zypp/TranslatedText.cc [new file with mode: 0644]
tests/zypp/Url.cc [new file with mode: 0644]

diff --git a/tests/cache/CMakeLists.txt b/tests/cache/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1061001
--- /dev/null
@@ -0,0 +1,10 @@
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
+
+SET(CacheInitializer_SRCS
+CacheInitializer.cc
+)
+
+ADD_EXECUTABLE(CacheInitializer ${CacheInitializer_SRCS})
+TARGET_LINK_LIBRARIES(CacheInitializer boost_unit_test_framework )
+TARGET_LINK_LIBRARIES(CacheInitializer zypp2 )
+TARGET_LINK_LIBRARIES(CacheInitializer zypp )
diff --git a/tests/cache/CacheInitializer.cc b/tests/cache/CacheInitializer.cc
new file mode 100644 (file)
index 0000000..bd47aa6
--- /dev/null
@@ -0,0 +1,49 @@
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/Arch.h"
+#include "zypp/TmpPath.h"
+#include "zypp2/cache/CacheInitializer.h"
+#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+using namespace boost::unit_test;
+using namespace boost::unit_test::log;
+using namespace boost::unit_test_framework;
+using namespace std;
+using namespace zypp;
+using namespace sqlite3x;
+
+// control output with BOOST_TEST_LOG_LEVEL="all"
+
+void cacheinit_test()
+{
+  //unit_test_log::instance().set_log_threshold_level(log_messages);
+  filesystem::TmpDir tmpdir;
+  cache::CacheInitializer initializer(tmpdir.path(), "test.db");
+  
+  sqlite3_connection con( (tmpdir.path() + "test.db").asString().c_str());
+  //con.executenonquery(SOURCES_TABLE_SCHEMA);
+  int count = con.executeint("select count(*) from sqlite_master where type='table';");
+  BOOST_CHECK( initializer.justInitialized() );
+  // 14 tables need to be created
+  BOOST_CHECK_EQUAL( count, 14);
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "CacheInit" );
+    test->add( BOOST_TEST_CASE( &cacheinit_test ), 0 /* expected zero error */ );
+    return test;
+}
diff --git a/tests/media/CMakeLists.txt b/tests/media/CMakeLists.txt
new file mode 100644 (file)
index 0000000..735e582
--- /dev/null
@@ -0,0 +1,182 @@
+INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR}  )
+
+
+########### next target ###############
+
+SET(media2_SRCS
+media2.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${media2_SRCS})
+
+KDE3_ADD_EXECUTABLE(media2 ${media2_SRCS})
+
+TARGET_LINK_LIBRARIES(media2  ${QT_AND_KDECORE_LIBS} )
+
+
+########### next target ###############
+
+SET(media3_SRCS
+media3.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${media3_SRCS})
+
+KDE3_ADD_EXECUTABLE(media3 ${media3_SRCS})
+
+TARGET_LINK_LIBRARIES(media3  ${QT_AND_KDECORE_LIBS} )
+
+
+########### next target ###############
+
+SET(media4_SRCS
+media4.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${media4_SRCS})
+
+KDE3_ADD_EXECUTABLE(media4 ${media4_SRCS})
+
+TARGET_LINK_LIBRARIES(media4  ${QT_AND_KDECORE_LIBS} )
+
+
+########### next target ###############
+
+SET(fileexists_SRCS
+file_exists_test.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${fileexists_SRCS})
+
+KDE3_ADD_EXECUTABLE(fileexists ${fileexists_SRCS})
+
+TARGET_LINK_LIBRARIES(fileexists  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+
+########### next target ###############
+
+SET(throw_if_not_exists_SRCS
+throw_if_not_exists.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${throw_if_not_exists_SRCS})
+
+KDE3_ADD_EXECUTABLE(throw_if_not_exists ${throw_if_not_exists_SRCS})
+
+TARGET_LINK_LIBRARIES(throw_if_not_exists  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+
+########### next target ###############
+
+SET(media1_SRCS
+media1.cc
+mymediaverifier.h
+)
+
+KDE3_AUTOMOC(${media1_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(media1 ${media1_SRCS})
+
+TARGET_LINK_LIBRARIES(media1  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(fileexists_SRCS
+dummy.cpp
+)
+
+KDE3_AUTOMOC(${fileexists_SRCS})
+
+FILE(WRITE dummy.cpp "//autogenerated file by cmake\n")
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(fileexists ${fileexists_SRCS})
+
+TARGET_LINK_LIBRARIES(fileexists  ${QT_AND_KDECORE_LIBS} )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(throw_if_not_exists_SRCS
+dummy.cpp
+)
+
+KDE3_AUTOMOC(${throw_if_not_exists_SRCS})
+
+FILE(WRITE dummy.cpp "//autogenerated file by cmake\n")
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(throw_if_not_exists ${throw_if_not_exists_SRCS})
+
+TARGET_LINK_LIBRARIES(throw_if_not_exists  ${QT_AND_KDECORE_LIBS} )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### install files ###############
+
+
+
+
+#original Makefile.am contents follow:
+
+### Process this file with automake to produce Makefile.in
+### ##################################################
+#
+## Do NOT list devel.* in subdirs. It's developers playgound and
+## must not prevent anything from building.
+#SUBDIRS =
+#
+### ##################################################
+#
+#
+#TESTS = media1 fileexists
+#
+#noinst_PROGRAMS = media2 media3 media4 fileexists throw_if_not_exists
+#
+#check_PROGRAMS = media1 fileexists throw_if_not_exists
+#
+#
+### ##################################################
+#
+#LDADD =       $(top_srcdir)/zypp/lib@PACKAGE@.la 
+#
+### ##################################################
+#
+#media1_SOURCES = media1.cc mymediaverifier.h
+#media1_LDADD = $(LDADD) -lboost_unit_test_framework
+#
+#fileexists_SOURCES = file_exists_test.cc mymediaverifier.h
+#fileexists_LDADD = $(LDADD) -lboost_unit_test_framework
+#
+#media2_SOURCES = media2.cc mymediaverifier.h
+#media2_LDADD = $(LDADD)
+#
+#media3_SOURCES = media3.cc mymediaverifier.h
+#media3_LDADD = $(LDADD)
+#
+#media4_SOURCES = media4.cc mymediaverifier.h
+#media4_LDADD = $(LDADD)
+#
+#throw_if_not_exists_SOURCES = throw_if_not_exists.cc mymediaverifier.h
+#throw_if_not_exists_LDADD = $(LDADD) -lboost_unit_test_framework
+#
+### ##################################################
+#
+#.PHONY:        always
+#
+#$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
+#
+##$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
+##     $(MAKE) -C $(top_srcdir)/zypp
+#
+### ##################################################
\ No newline at end of file
diff --git a/tests/media/file_exists_test.cc b/tests/media/file_exists_test.cc
new file mode 100644 (file)
index 0000000..b65bedd
--- /dev/null
@@ -0,0 +1,121 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <unistd.h>
+
+#include <boost/test/unit_test.hpp>
+
+#include "mymediaverifier.h"
+
+using namespace zypp;
+using namespace zypp::media;
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+void http_test()
+{
+  //MediaVerifierRef verifier( new MyMediaVerifier() );
+  MediaManager     mm;
+  media::MediaId   id;
+  
+  Url url("http://ftp.kernel.org/pub/");
+  
+//   iso_url = "iso:/";
+//   iso_url.setQueryParam("iso", "SUSE-10.1-Beta5/SUSE-Linux-10.1-beta5-i386-CD1.iso");
+//   iso_url.setQueryParam("url", src_url.asString());
+
+  id = mm.open( url, "");
+  //mm.addVerifier( id, verifier);
+  mm.attach(id);
+  BOOST_REQUIRE( mm.doesFileExist(id, Pathname("/README")) );
+  BOOST_REQUIRE( ! mm.doesFileExist(id, Pathname("/fakefile")) );
+  mm.release(id); 
+}
+
+void ftp_test()
+{
+  //MediaVerifierRef verifier( new MyMediaVerifier() );
+  MediaManager     mm;
+  media::MediaId   id;
+  
+  Url url("ftp://ftp.kernel.org/pub/");
+  
+//   iso_url = "iso:/";
+//   iso_url.setQueryParam("iso", "SUSE-10.1-Beta5/SUSE-Linux-10.1-beta5-i386-CD1.iso");
+//   iso_url.setQueryParam("url", src_url.asString());
+
+  id = mm.open( url, "");
+  //mm.addVerifier( id, verifier);
+  mm.attach(id);
+  BOOST_REQUIRE( mm.doesFileExist(id, Pathname("/README")) );
+  BOOST_REQUIRE( ! mm.doesFileExist(id, Pathname("/fakefile")) );
+  mm.release(id); 
+}
+
+void iso_test()
+{
+   if ( geteuid() != 0 )
+   {
+     BOOST_ERROR( "ISO test requires root permissions! (mount)");
+     return;
+   }
+  
+  MediaManager     mm;
+  media::MediaId   id;
+  
+  //Url url("nfs://dist.suse.de/dist/install/openSUSE-10.2-GM/");
+  Url url("dir:/mounts/dist/install/openSUSE-10.2-GM/");
+  
+  Url iso_url("iso:/");
+  iso_url.setQueryParam("iso", "openSUSE-10.2-RC5-PromoDVD-i386.iso");
+  iso_url.setQueryParam("url", url.asString());
+
+  id = mm.open( iso_url, "");
+  mm.attach(id);
+  BOOST_REQUIRE( mm.doesFileExist(id, Pathname("/README")) );
+  BOOST_REQUIRE( ! mm.doesFileExist(id, Pathname("/fakefile")) );
+  mm.release(id); 
+}
+
+void nfs_test()
+{
+   if ( geteuid() != 0 )
+   {
+     BOOST_ERROR( "NFS test requires root permissions! (mount)");
+     return;
+   }
+  
+  MediaManager     mm;
+  media::MediaId   id;
+  Url url("nfs://dist.suse.de/dist/install");
+  
+  id = mm.open( url, "");
+  mm.attach(id);
+  BOOST_REQUIRE( mm.doesFileExist(id, Pathname("/SLP/openSUSE-10.2-RM/i386/DVD1/README")) );
+  BOOST_REQUIRE( ! mm.doesFileExist(id, Pathname("/fakefile")) );
+  mm.release(id);
+  
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+  //tests would need root-privileges
+  test_suite* test= BOOST_TEST_SUITE( "MediaFileExistTest" );
+  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
+  test->add( BOOST_TEST_CASE( &http_test ), 0 /* expected zero error */ );
+  test->add( BOOST_TEST_CASE( &ftp_test ), 0 /* expected zero error */ );
+  //test->add( BOOST_TEST_CASE( &iso_test ), 0 /* expected zero error */ );
+  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
+  return test;
+}
+
+
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/media/media1.cc b/tests/media/media1.cc
new file mode 100644 (file)
index 0000000..867ecc2
--- /dev/null
@@ -0,0 +1,48 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+
+#include <boost/test/unit_test.hpp>
+
+#include "mymediaverifier.h"
+
+using namespace zypp;
+using namespace zypp::media;
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+void verifier_test()
+{
+  MediaVerifierRef verifier(
+      new MyMediaVerifier(/* "SUSE-Linux-CORE-i386 9" */)
+                           );
+  MediaManager     mm;
+  media::MediaId   id;
+
+  //id = mm.open(zypp::Url("cd:/"), "");
+  id = mm.open(zypp::Url("ftp://machcd2/CDs/SLES-10-ISSLE-Beta1a-ppc/CD1"), "");
+  mm.addVerifier( id, verifier);
+  mm.attach(id);
+  mm.provideFile(id, Pathname("/suse/setup/descr/EXTRA_PROV"));
+  mm.release(id);
+  mm.attach(id);
+  mm.provideFile(id, Pathname("/suse/setup/descr/EXTRA_PROV"));  
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+  test_suite* test= BOOST_TEST_SUITE( "MediaVerifierTest" );
+  test->add( BOOST_TEST_CASE( &verifier_test ), 0 /* expected zero error */ );
+  return test;
+}
+
+
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/media/media2.cc b/tests/media/media2.cc
new file mode 100644 (file)
index 0000000..aa8716a
--- /dev/null
@@ -0,0 +1,149 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <cstdlib>
+
+#include <signal.h>
+
+#include "mymediaverifier.h"
+
+using namespace zypp;
+using namespace zypp::media;
+
+
+bool       do_step = false;
+int        do_quit = 0;
+
+void quit(int)
+{
+    do_quit = 1;
+}
+
+void goon(int)
+{
+}
+
+#define ONE_STEP(MSG) \
+do { \
+  DBG << "======================================" << std::endl; \
+  DBG << "==>> " << MSG << std::endl; \
+  DBG << "======================================" << std::endl; \
+  if( do_step) { pause(); if( do_quit) exit(0); } \
+} while(0);
+
+int main(int argc, char *argv[])
+{
+  {
+      struct sigaction sa;
+      sigemptyset(&sa.sa_mask);
+      sa.sa_flags   = 0;
+      sa.sa_handler = goon;
+      sigaction(SIGINT,  &sa, NULL);
+      sa.sa_handler = quit;
+      sigaction(SIGTERM, &sa, NULL);
+
+      if( argc > 1 && std::string(argv[1]) == "-i")
+        do_step = true;
+  }
+
+  MediaVerifierRef verifier(
+    new MyMediaVerifier(/* "SUSE-Linux-CORE-i386 9" */)
+  );
+  MediaManager     mm;
+  media::MediaId   one;
+  media::MediaId   two;
+  zypp::Url        url;
+
+  url = "cd:/";
+
+  try
+  {
+    ONE_STEP("ONE: open " + url.asString());
+    one = mm.open(url);
+
+    ONE_STEP("TWO: open " + url.asString());
+    two = mm.open(url);
+
+
+    ONE_STEP("ONE: add verifier")
+    mm.addVerifier( one, verifier);
+
+    ONE_STEP("TWO: add verifier")
+    mm.addVerifier( two, verifier);
+
+
+    ONE_STEP("ONE: attach")
+    mm.attach(one);
+
+    ONE_STEP("ONE: provideFile(/INDEX.gz)")
+    mm.provideFile(one, Pathname("/INDEX.gz"));
+
+    ONE_STEP("TWO: attach")
+    mm.attach(two);
+
+
+    ONE_STEP("ONE: provideFile(/content)")
+    mm.provideFile(one, Pathname("/content"));
+
+    ONE_STEP("TWO: provideFile(/INDEX.gz)")
+    mm.provideFile(two, Pathname("/INDEX.gz"));
+
+
+    try
+    {
+      ONE_STEP("ONE: release()")
+      mm.release(one, true);
+    }
+    catch(const MediaException &e)
+    {
+      ZYPP_CAUGHT(e);
+      ERR << "ONE: HUH? Eject hasn't worked?!" << std::endl;
+    }
+
+    try {
+      ONE_STEP("ONE: provideFile(/content)")
+      mm.provideFile(one, Pathname("/content"));
+    }
+    catch(const MediaException &e)
+    {
+      ZYPP_CAUGHT(e);
+      DBG << "ONE: OK, EXPECTED IT (released)" << std::endl;
+    }
+
+    try {
+      ONE_STEP("TWO: provideFile(/ls-lR.gz)")
+      mm.provideFile(two, Pathname("/ls-lR.gz"));
+    }
+    catch(const MediaException &e)
+    {
+      ZYPP_CAUGHT(e);
+      DBG << "TWO: OK, EXPECTED IT (released)" << std::endl;
+    }
+
+    ONE_STEP("TWO: (RE)ATTACH IT")
+    mm.attach(two);
+
+    ONE_STEP("TWO: provideFile(/INDEX.gz)")
+    mm.provideFile(two, Pathname("/INDEX.gz"));
+
+    ONE_STEP("CLEANUP")
+  }
+  catch(const MediaException &e)
+  {
+    ZYPP_CAUGHT(e);
+  }
+  catch( ... )
+  {
+    // hmm...
+    ERR << "Catched *unknown* exception" << std::endl;
+  }
+
+  return 0;
+}
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/media/media3.cc b/tests/media/media3.cc
new file mode 100644 (file)
index 0000000..0679b1f
--- /dev/null
@@ -0,0 +1,155 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <cstdlib>
+
+#include <signal.h>
+
+#include "mymediaverifier.h"
+
+using namespace zypp;
+using namespace zypp::media;
+
+bool       do_step = false;
+int        do_quit = 0;
+
+void quit(int)
+{
+    do_quit = 1;
+}
+
+void goon(int)
+{
+}
+
+#define ONE_STEP(MSG) \
+do { \
+  DBG << "======================================" << std::endl; \
+  DBG << "==>> " << MSG << std::endl; \
+  DBG << "======================================" << std::endl; \
+  if( do_step) { pause(); if( do_quit) exit(0); } \
+} while(0);
+
+int main(int argc, char *argv[])
+{
+  bool eject_src = false;
+  bool close_src = false;
+  {
+      struct sigaction sa;
+      sigemptyset(&sa.sa_mask);
+      sa.sa_flags   = 0;
+      sa.sa_handler = goon;
+      sigaction(SIGINT,  &sa, NULL);
+      sa.sa_handler = quit;
+      sigaction(SIGTERM, &sa, NULL);
+
+      std::cerr << "ARGS=" << argc << std::endl;
+      for(int i=1; i < argc; i++)
+      {
+        if( std::string(argv[i]) == "-i")
+          do_step = true;
+        else
+        if( std::string(argv[i]) == "-e")
+          eject_src = true;
+        else
+        if( std::string(argv[i]) == "-c")
+          close_src = true;
+      }
+  }
+
+  MediaVerifierRef verifier(
+    new MyMediaVerifier(/* "SUSE-Linux-CORE-i386 9" */)
+  );
+  MediaManager     mm;
+  media::MediaId   src = 0;
+  media::MediaId   iso;
+  zypp::Url        src_url;
+  zypp::Url        iso_url;
+
+  src_url = "nfs://dist.suse.de/dist/install";
+
+  iso_url = "iso:/";
+  iso_url.setQueryParam("iso", "SUSE-10.1-Beta5/SUSE-Linux-10.1-beta5-i386-CD1.iso");
+  iso_url.setQueryParam("url", src_url.asString());
+
+/*
+  iso_url = "iso:/";
+  iso_url.setQueryParam("iso", "/space/tmp/iso/SUSE-Linux-10.1-beta7-i386-CD1.iso");
+*/
+
+  try
+  {
+    if( eject_src || close_src)
+    {
+      ONE_STEP("SRC: open " + src_url.asString());
+      src = mm.open(src_url);
+
+      ONE_STEP("SRC: attach")
+      mm.attach(src);
+    }
+
+    ONE_STEP("ISO: open " + iso_url.asString());
+    iso = mm.open(iso_url);
+
+    ONE_STEP("ISO: add verifier")
+    mm.addVerifier(iso, verifier);
+
+    ONE_STEP("ISO: attach")
+    mm.attach(iso);
+
+    ONE_STEP("provideFile(/INDEX.gz)")
+    mm.provideFile(iso, Pathname("/INDEX.gz"));
+
+    if( eject_src)
+    {
+      try
+      {
+        ONE_STEP("SRC: release(eject=true)")
+        mm.release(src, true);
+      }
+      catch(const MediaException &e)
+      {
+        ZYPP_CAUGHT(e);
+        ERR << "ONE: HUH? Eject hasn't worked?!" << std::endl;
+      }
+    }
+    else
+    if( close_src)
+    {
+      try
+      {
+        ONE_STEP("SRC: close()")
+        mm.close(src);
+      }
+      catch(const MediaException &e)
+      {
+        ZYPP_CAUGHT(e);
+        ERR << "SRC: HUH? Close hasn't worked?!" << std::endl;
+      }
+    }
+
+    ONE_STEP("ISO: RELEASE")
+    mm.release(iso);
+
+    ONE_STEP("CLEANUP")
+  }
+  catch(const MediaException &e)
+  {
+    ERR << "Catched media exception..." << std::endl;
+    ZYPP_CAUGHT(e);
+  }
+  catch( ... )
+  {
+    // hmm...
+    ERR << "Catched *unknown* exception" << std::endl;
+  }
+
+  return 0;
+}
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/media/media4.cc b/tests/media/media4.cc
new file mode 100644 (file)
index 0000000..e731b4d
--- /dev/null
@@ -0,0 +1,100 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+#include <zypp/PathInfo.h>
+#include <zypp/TmpPath.h>
+#include <zypp/ExternalProgram.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <cstdlib>
+
+#include <signal.h>
+#include <stdlib.h>
+
+using namespace zypp;
+using namespace zypp::media;
+
+bool       do_step = false;
+int        do_quit = 0;
+
+void quit(int)
+{
+    do_quit = 1;
+}
+
+void goon(int)
+{
+}
+
+#define ONE_STEP(MSG) \
+do { \
+  DBG << "======================================" << std::endl; \
+  DBG << "==>> " << MSG << std::endl; \
+  DBG << "======================================" << std::endl; \
+  if( do_step) { pause(); if( do_quit) exit(0); } \
+} while(0);
+
+int main(int argc, char *argv[])
+{
+  {
+      struct sigaction sa;
+      sigemptyset(&sa.sa_mask);
+      sa.sa_flags   = 0;
+      sa.sa_handler = goon;
+      sigaction(SIGINT,  &sa, NULL);
+      sa.sa_handler = quit;
+      sigaction(SIGTERM, &sa, NULL);
+
+      if( argc > 1 && std::string(argv[1]) == "-i")
+        do_step = true;
+  }
+
+  MediaManager     mm;
+  media::MediaId   id;
+  zypp::Url        url;
+  Pathname         dir("./suse/setup/descr");
+
+  url = "cd:/";
+
+  try
+  {
+    ONE_STEP("open " + url.asString());
+    id = mm.open(url);
+
+    ONE_STEP("attach")
+    mm.attach(id);
+
+    ONE_STEP("provideDirTree(" + dir.asString() + ")");
+    mm.provideDirTree(id, Pathname(dir));
+
+    ONE_STEP("Create a temporary dir");
+    zypp::filesystem::TmpDir temp;
+
+    ONE_STEP("Create a copy of " + dir.asString());
+    zypp::filesystem::copy_dir(mm.localPath(id, dir), temp.path());
+
+    std::string cmd("/bin/ls -lR ");
+                cmd += temp.path().asString();
+
+    ONE_STEP("Check the directory copy")
+    system( cmd.c_str());
+
+    ONE_STEP("CLEANUP")
+  }
+  catch(const MediaException &e)
+  {
+    ZYPP_CAUGHT(e);
+  }
+  catch( ... )
+  {
+    // hmm...
+    ERR << "Catched *unknown* exception" << std::endl;
+  }
+
+  return 0;
+}
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/media/mymediaverifier.h b/tests/media/mymediaverifier.h
new file mode 100644 (file)
index 0000000..5f48136
--- /dev/null
@@ -0,0 +1,65 @@
+
+#ifndef TEST_MYMEDIAVERIFIER
+#define TEST_MYMEDIAVERIFIER
+
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+using namespace zypp;
+using namespace zypp::media;
+
+/*
+** Very basic example verifier.
+**
+** This one does not know anything about the product, it
+** just checks if /media.1 (limited to 1st CD) exists...
+*/
+class MyMediaVerifier: public MediaVerifierBase
+{
+  private:
+  // std::string _productname;
+  public:
+    MyMediaVerifier(/* std::string &productname */)
+  : MediaVerifierBase()
+    //, _productname(productname)
+    {}
+
+    virtual
+        ~MyMediaVerifier()
+    {}
+
+    virtual bool
+        isDesiredMedia(const MediaAccessRef &ref)
+    {
+      DBG << "isDesiredMedia(): for media nr 1 " << std::endl;
+
+      if( !ref)
+        DBG << "isDesiredMedia(): invalid media handle" << std::endl;
+
+      std::list<std::string> lst;
+      Pathname               dir("/media.1");
+
+      DBG << "isDesiredMedia(): checking " << dir.asString() << std::endl;
+
+    // check the product e.g. via /media.1/products as well...
+      try
+      {
+        if( ref)
+          ref->dirInfo(lst, dir, false);
+      }
+      catch(const zypp::Exception &e)
+      {
+        ZYPP_CAUGHT(e);
+      }
+      DBG << "isDesiredMedia(): media "
+          << (lst.empty() ? "does not contain" : "contains")
+          << " the " << dir.asString() << " directory."
+          << std::endl;
+
+      return !lst.empty();
+    }
+};
+
+#endif
diff --git a/tests/media/throw_if_not_exists.cc b/tests/media/throw_if_not_exists.cc
new file mode 100644 (file)
index 0000000..55783c8
--- /dev/null
@@ -0,0 +1,50 @@
+#include <zypp/media/MediaManager.h>
+#include <zypp/base/String.h>
+#include <zypp/base/Logger.h>
+#include <zypp/Pathname.h>
+
+#include <string>
+#include <list>
+#include <iostream>
+#include <unistd.h>
+
+#include <boost/test/unit_test.hpp>
+
+#include "mymediaverifier.h"
+
+using namespace zypp;
+using namespace zypp::media;
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+void http_test()
+{
+  //MediaVerifierRef verifier( new MyMediaVerifier() );
+  MediaManager     mm;
+  media::MediaId   id;
+  
+  Url url("http://www.google.com");
+  
+  id = mm.open( url, "");
+  //mm.addVerifier( id, verifier);
+  mm.attach(id);
+  BOOST_CHECK_THROW( mm.provideFile(id, Pathname("/file-not-exists")), Exception );
+  mm.release(id); 
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+  test_suite* test= BOOST_TEST_SUITE( "throw_if_not_exists" );
+  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
+  test->add( BOOST_TEST_CASE( &http_test ), 0 /* expected zero error */ );
+  //test->add( BOOST_TEST_CASE( &ftp_test ), 0 /* expected zero error */ );
+  //test->add( BOOST_TEST_CASE( &iso_test ), 0 /* expected zero error */ );
+  //test->add( BOOST_TEST_CASE( &nfs_test ), 0 /* expected zero error */ );
+  return test;
+}
+
+
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/tests/zypp/Arch.cc b/tests/zypp/Arch.cc
new file mode 100644 (file)
index 0000000..075872a
--- /dev/null
@@ -0,0 +1,53 @@
+// Arch.cc
+//
+// tests for Arch
+//
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/Arch.h"
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+using namespace std;
+using namespace zypp;
+
+/******************************************************************
+**
+**
+**      FUNCTION NAME : main
+**      FUNCTION TYPE : int
+**
+**      DESCRIPTION :
+*/
+void arch_test()
+{
+  Arch _arch32( "i386" );
+
+  BOOST_CHECK_EQUAL( _arch32, Arch_i386 );
+  BOOST_CHECK_EQUAL( _arch32.asString(), string("i386"));
+  BOOST_REQUIRE( _arch32.compatibleWith (Arch_x86_64));
+  BOOST_CHECK_THROW( Arch(NULL), exception);
+  BOOST_CHECK_EQUAL( Arch(), Arch_noarch );
+  BOOST_REQUIRE( Arch("") != Arch_noarch );
+  BOOST_REQUIRE( Arch("").empty() );
+  BOOST_REQUIRE( ! Arch_noarch.empty() );
+  BOOST_REQUIRE( ! ( _arch32.compare(Arch_x86_64) >= 0) );
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "ArchTest" );
+    test->add( BOOST_TEST_CASE( &arch_test ), 0 /* expected zero error */ );
+    return test;
+}
diff --git a/tests/zypp/CMakeLists.txt b/tests/zypp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..38fa052
--- /dev/null
@@ -0,0 +1,326 @@
+INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR}  )
+
+
+########### next target ###############
+
+SET(Arch_SRCS
+Arch.cc
+)
+
+KDE3_AUTOMOC(${Arch_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Arch ${Arch_SRCS})
+
+TARGET_LINK_LIBRARIES(Arch  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Url_SRCS
+Url.cc
+)
+
+KDE3_AUTOMOC(${Url_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Url ${Url_SRCS})
+
+TARGET_LINK_LIBRARIES(Url  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(RWPtr_SRCS
+RWPtr.cc
+)
+
+KDE3_AUTOMOC(${RWPtr_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(RWPtr ${RWPtr_SRCS})
+
+TARGET_LINK_LIBRARIES(RWPtr  ${QT_AND_KDECORE_LIBS} )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Edition_SRCS
+Edition.cc
+)
+
+KDE3_AUTOMOC(${Edition_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Edition ${Edition_SRCS})
+
+TARGET_LINK_LIBRARIES(Edition  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Capabilities_SRCS
+Capabilities.cc
+)
+
+KDE3_AUTOMOC(${Capabilities_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Capabilities ${Capabilities_SRCS})
+
+TARGET_LINK_LIBRARIES(Capabilities  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(PtrTypes_SRCS
+PtrTypes.cc
+)
+
+KDE3_AUTOMOC(${PtrTypes_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(PtrTypes ${PtrTypes_SRCS})
+
+TARGET_LINK_LIBRARIES(PtrTypes  ${QT_AND_KDECORE_LIBS} )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(TranslatedText_SRCS
+TranslatedText.cc
+)
+
+KDE3_AUTOMOC(${TranslatedText_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(TranslatedText ${TranslatedText_SRCS})
+
+TARGET_LINK_LIBRARIES(TranslatedText  ${QT_AND_KDECORE_LIBS} )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(CheckSum_SRCS
+CheckSum.cc
+)
+
+KDE3_AUTOMOC(${CheckSum_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(CheckSum ${CheckSum_SRCS})
+
+TARGET_LINK_LIBRARIES(CheckSum  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(PublicKey_SRCS
+PublicKey.cc
+)
+
+KDE3_AUTOMOC(${PublicKey_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(PublicKey ${PublicKey_SRCS})
+
+TARGET_LINK_LIBRARIES(PublicKey  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(PathInfo_SRCS
+PathInfo.cc
+)
+
+KDE3_AUTOMOC(${PathInfo_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(PathInfo ${PathInfo_SRCS})
+
+TARGET_LINK_LIBRARIES(PathInfo  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Digest_SRCS
+Digest.cc
+)
+
+KDE3_AUTOMOC(${Digest_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Digest ${Digest_SRCS})
+
+TARGET_LINK_LIBRARIES(Digest  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Signature_SRCS
+Signature.cc
+)
+
+KDE3_AUTOMOC(${Signature_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Signature ${Signature_SRCS})
+
+TARGET_LINK_LIBRARIES(Signature  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(KeyRing_SRCS
+KeyRing.cc
+)
+
+KDE3_AUTOMOC(${KeyRing_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(KeyRing ${KeyRing_SRCS})
+
+TARGET_LINK_LIBRARIES(KeyRing  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### next target ###############
+
+SET(Lazy_SRCS
+Lazy.cc
+)
+
+KDE3_AUTOMOC(${Lazy_SRCS})
+
+IF(KDE3_BUILD_TESTS)
+
+KDE3_ADD_EXECUTABLE(Lazy ${Lazy_SRCS})
+
+TARGET_LINK_LIBRARIES(Lazy  ${QT_AND_KDECORE_LIBS} boost_unit_test_framework )
+
+ENDIF(KDE3_BUILD_TESTS)
+
+########### install files ###############
+
+
+
+
+#original Makefile.am contents follow:
+
+### Process this file with automake to produce Makefile.in
+### ##################################################
+#
+## Do NOT list devel.* in subdirs. It's developers playgound and
+## must not prevent anything from building.
+#SUBDIRS =
+#
+### ##################################################
+#
+#TESTS = Arch Url \
+#      RWPtr \
+#      Edition         \
+#      Capabilities    \
+#      PtrTypes \
+#      TranslatedText \
+#      CheckSum \
+#      PublicKey \
+#      PathInfo \
+#      Digest \
+#      Signature \
+#      KeyRing \
+#      Lazy
+#
+#check_PROGRAMS = Arch Url \
+#      RWPtr \
+#      Edition         \
+#      Capabilities    \
+#      PtrTypes \
+#      TranslatedText \
+#      CheckSum \
+#      PublicKey \
+#      PathInfo \
+#      Digest \
+#      Signature \
+#      KeyRing \
+#      Lazy
+#
+### ##################################################
+#
+#LDADD =       $(top_srcdir)/zypp/lib@PACKAGE@.la 
+#
+### ##################################################
+#
+#Arch_SOURCES = Arch.cc
+#Arch_LDADD = $(LDADD) -lboost_unit_test_framework
+#
+#TranslatedText_SOURCES  = TranslatedText.cc
+#
+#PublicKey_SOURCES = PublicKey.cc
+#PublicKey_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#CheckSum_SOURCES = CheckSum.cc
+#CheckSum_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#RWPtr_SOURCES = RWPtr.cc
+#
+#Edition_SOURCES = Edition.cc
+#Edition_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#Capabilities_SOURCES = Capabilities.cc
+#Capabilities_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#PtrTypes_SOURCES = PtrTypes.cc
+#
+#PathInfo_SOURCES = PathInfo.cc
+#PathInfo_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#Digest_SOURCES = Digest.cc
+#Digest_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#Signature_SOURCES = Signature.cc
+#Signature_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#Url_SOURCES = Url.cc
+#Url_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#KeyRing_SOURCES = KeyRing.cc
+#KeyRing_LDADD  = $(LDADD) -lboost_unit_test_framework
+#
+#Lazy_SOURCES = Lazy.cc
+#Lazy_LDADD  = $(LDADD) $(top_srcdir)/zypp2/lib@PACKAGE@2.la  -lboost_unit_test_framework
+#
+### ##################################################
+#
+#.PHONY:        always
+#
+#$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
+#
+##$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
+##     $(MAKE) -C $(top_srcdir)/zypp
+#
+### ##################################################
diff --git a/tests/zypp/Capabilities.cc b/tests/zypp/Capabilities.cc
new file mode 100644 (file)
index 0000000..c46d930
--- /dev/null
@@ -0,0 +1,68 @@
+// Capabilities.cc
+//
+// tests for Capabilities 
+//
+#include <string>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include "zypp/base/Logger.h"
+#include "zypp/CapFactory.h"
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+using namespace std;
+using namespace zypp;
+
+void capabilities_test()
+{
+//     Resolvable::Kind kind = ResTraits<zypp::Package>::kind;
+//     CapFactory factory;
+// 
+//     Edition edition ("1.0", "42");
+//     Capability cap = factory.parse ( kind, "foo", "=", "1.0-42");
+//     BOOST_CHECK_EQUAL( cap.asString(), "foo == 1.0-42" );
+//     BOOST_CHECK_EQUAL( cap.index(), "foo");
+//     BOOST_CHECK_EQUAL( cap.op(), Rel::EQ);
+//     BOOST_CHECK_EQUAL( cap.edition(), edition);
+// 
+//     Capability cap2 = factory.parse ( kind, "foo", Rel::EQ, edition);
+//     BOOST_CHECK_EQUAL( cap2.index(), cap.index());
+//     BOOST_CHECK_EQUAL( cap2.op(), cap.op());
+//     BOOST_CHECK_EQUAL( cap2.edition(), cap.edition());
+// 
+//     Capability cap3 = factory.parse ( kind, "foo = 1.0-42");
+//     BOOST_CHECK_EQUAL( cap3.index(), cap.index());
+//     BOOST_CHECK_EQUAL( cap3.op(), cap.op());
+//     BOOST_CHECK_EQUAL( cap3.edition(), cap.edition());
+//     
+//     Capability cap6 = factory.parse ( kind, "kdelibs* > 1.5");
+//     BOOST_CHECK_EQUAL( cap6.index(), "kdelibs*");
+//     BOOST_CHECK_EQUAL( cap6.op(), Rel::GT);
+//     BOOST_CHECK_EQUAL( cap6.edition(), Edition("1.5"));
+//     
+// 
+//     string bash = "/bin/bash";
+//     Capability cap4 = factory.parse ( kind, bash);
+//     BOOST_CHECK_EQUAL(cap4.index(), bash);
+//     BOOST_CHECK_EQUAL(cap4.op(), Rel::NONE);
+//     BOOST_CHECK_EQUAL(cap4.edition(), Edition::noedition);
+// 
+//     string hal = "hal(smp)";
+//     Capability cap5 = factory.parse ( kind, hal);
+//     BOOST_CHECK_EQUAL(cap5.index(), "hal()");
+//     BOOST_CHECK_EQUAL(cap5.op(), Rel::NONE);
+//     BOOST_CHECK_EQUAL(cap5.edition(), Edition::noedition);
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "CapabilitiesTest" );
+    test->add( BOOST_TEST_CASE( &capabilities_test ), 0 /* expected zero error */ );
+    return test;
+}
diff --git a/tests/zypp/CheckSum.cc b/tests/zypp/CheckSum.cc
new file mode 100644 (file)
index 0000000..69336b9
--- /dev/null
@@ -0,0 +1,44 @@
+
+#include <iostream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+// parameterized test
+// http://www.boost.org/libs/test/example/unit_test_example4.cpp
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
+using namespace std;
+using namespace zypp;
+
+
+// most frequently you implement test cases as a free functions
+void checksum_test()
+{
+  BOOST_CHECK_THROW( CheckSum( "sha1", "dsdsads" ), Exception ); // wrong size
+  BOOST_CHECK_THROW( CheckSum( "sha256", "dsdsads" ), Exception ); // wrong size
+  BOOST_CHECK_THROW( CheckSum( "md5", "dsdsads" ), Exception ); // wrong size
+  BOOST_CHECK_THROW( CheckSum( "md4", "dsdsads" ), Exception ); // wrong size
+  BOOST_CHECK_THROW( CheckSum( "md2", "dsdsads" ), Exception ); // wrong size
+
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "CheckSumTest" );
+    test->add( BOOST_TEST_CASE( &checksum_test ), 5 /* expected zero error */ , 0);
+    return test;
+}
+
diff --git a/tests/zypp/Digest.cc b/tests/zypp/Digest.cc
new file mode 100644 (file)
index 0000000..8e7ef63
--- /dev/null
@@ -0,0 +1,52 @@
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+// parameterized test
+// http://www.boost.org/libs/test/example/unit_test_example4.cpp
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/PathInfo.h"
+#include "zypp/Digest.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::filesystem;
+
+/**
+ * Test case for
+ * static std::string digest(const std::string& name, std::istream& is, size_t bufsize = 4096);
+ */
+void digest_test()
+{
+  string data("I will test the checksum of this");
+  stringstream str1(data);
+  stringstream str2(data);
+  stringstream str3(data);
+
+  BOOST_CHECK_EQUAL( Digest::digest( "sha1", str1 ), "142df4277c326f3549520478c188cab6e3b5d042" ); 
+  BOOST_CHECK_EQUAL( Digest::digest( "md5", str2 ), "f139a810b84d82d1f29fc53c5e59beae" ); 
+  // FIXME i think it should throw
+  BOOST_CHECK_EQUAL( Digest::digest( "lalala", str3) , "" ); 
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "DigestTest" );
+    test->add( BOOST_TEST_CASE( &digest_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/Edition.cc b/tests/zypp/Edition.cc
new file mode 100644 (file)
index 0000000..2ce32d4
--- /dev/null
@@ -0,0 +1,44 @@
+// Edition.cc
+//
+// tests for Edition
+//
+
+#include "zypp/base/Logger.h"
+#include "zypp/Edition.h"
+
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+
+void edition_test()
+{
+  BOOST_CHECK_THROW( Edition(string("A::foo--foo")), exception );
+  
+  Edition _ed1 ("1");
+  Edition _ed2 ("1.1");
+  Edition _ed3 ("1:1");
+  Edition _ed4 ("1:1-1");
+
+  BOOST_CHECK_EQUAL(_ed2.version(), "1.1");
+  BOOST_CHECK_EQUAL(_ed2.release(), "");
+  BOOST_CHECK_EQUAL(_ed2.epoch(), 0);
+  BOOST_CHECK_EQUAL(_ed4.epoch(), 1);
+
+  BOOST_CHECK_EQUAL(_ed1, Edition ("1", ""));
+  BOOST_CHECK_EQUAL(_ed2, Edition ("1.1", ""));
+  BOOST_CHECK_EQUAL(_ed3, Edition ("1", "", "1"));
+  BOOST_CHECK_EQUAL(_ed3, Edition ("1", "", 1));
+  BOOST_CHECK_EQUAL(_ed4, Edition ("1", "1", 1));
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "EditionTest" );
+    test->add( BOOST_TEST_CASE( &edition_test ), 0 /* expected zero error */ );
+    return test;
+}
\ No newline at end of file
diff --git a/tests/zypp/KeyRing.cc b/tests/zypp/KeyRing.cc
new file mode 100644 (file)
index 0000000..cc04801
--- /dev/null
@@ -0,0 +1,364 @@
+
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/KeyRing.h"
+#include "zypp/PublicKey.h"
+#include "zypp/TmpPath.h"
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using namespace boost::unit_test::log;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::filesystem;
+
+/*
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.4.2 (GNU/Linux)
+
+mQGiBDnu9IERBACT8Y35+2vv4MGVKiLEMOl9GdST6MCkYS3yEKeueNWc+z/0Kvff
+4JctBsgs47tjmiI9sl0eHjm3gTR8rItXMN6sJEUHWzDP+Y0PFPboMvKx0FXl/A0d
+M+HFrruCgBlWt6FA+okRySQiliuI5phwqkXefl9AhkwR8xocQSVCFxcwvwCglVcO
+QliHu8jwRQHxlRE0tkwQQI0D+wfQwKdvhDplxHJ5nf7U8c/yE/vdvpN6lF0tmFrK
+XBUX+K7u4ifrZlQvj/81M4INjtXreqDiJtr99Rs6xa0ScZqITuZC4CWxJa9GynBE
+D3+D2t1V/f8l0smsuYoFOF7Ib49IkTdbtwAThlZp8bEhELBeGaPdNCcmfZ66rKUd
+G5sRA/9ovnc1krSQF2+sqB9/o7w5/q2qiyzwOSTnkjtBUVKn4zLUOf6aeBAoV6NM
+CC3Kj9aZHfA+ND0ehPaVGJgjaVNFhPi4x0e7BULdvgOoAqajLfvkURHAeSsxXIoE
+myW/xC1sBbDkDUIBSx5oej73XCZgnj/inphRqGpsb+1nKFvF+rQoU3VTRSBQYWNr
+YWdlIFNpZ25pbmcgS2V5IDxidWlsZEBzdXNlLmRlPohiBBMRAgAiBQJA2AY+AhsD
+BQkObd+9BAsHAwIDFQIDAxYCAQIeAQIXgAAKCRCoTtronIAKypCfAJ9RuZ6ZSV7Q
+W4pTgTIxQ+ABPp0sIwCffG9bCNnrETPlgOn+dGEkAWegKL+IRgQQEQIABgUCOnBe
+UgAKCRCeQOMQAAqrpNzOAKCL512FZvv4VZx94TpbA9lxyoAejACeOO1HIbActAev
+k5MUBhNeLZa/qM2JARUDBRA6cGBvd7LmAD0l09kBATWnB/9An5vfiUUE1VQnt+T/
+EYklES3tXXaJJp9pHMa4fzFa8jPVtv5UBHGee3XoUNDVwM2OgSEISZxbzdXGnqIl
+cT08TzBUD9i579uifklLsnr35SJDZ6ram51/CWOnnaVhUzneOA9gTPSr+/fT3WeV
+nwJiQCQ30kNLWVXWATMnsnT486eAOlT6UNBPYQLpUprF5Yryk23pQUPAgJENDEqe
+U6iIO9Ot1ZPtB0lniw+/xCi13D360o1tZDYOp0hHHJN3D3EN8C1yPqZd5CvvznYv
+B6bWBIpWcRgdn2DUVMmpU661jwqGlRz1F84JG/xe4jGuzgpJt9IXSzyohEJB6XG5
++D0BuQINBDnu9JIQCACEkdBN6Mxf5WvqDWkcMRy6wnrd9DYJ8UUTmIT2iQf07tRU
+KJJ9v0JXfx2Z4d08IQSMNRaq4VgSe+PdYgIy0fbj23Via5/gO7fJEpD2hd2f+pMn
+OWvH2rOOIbeYfuhzAc6BQjAKtmgR0ERUTafTM9Wb6F13CNZZNZfDqnFDP6L12w3z
+3F7FFXkz07Rs3AIto1ZfYZd4sCSpMr/0S5nLrHbIvGLp271hhQBeRmmoGEKO2JRe
+lGgUJ2CUzOdtwDIKT0LbCpvaP8PVnYF5IFoYJIWRHqlEt5ucTXstZy7vYjL6vTP4
+l5xs+LIOkNmPhqmfsgLzVo0UaLt80hOwc4NvDCOLAAMGB/9g+9V3ORzw4LvO1pwR
+YJqfDKUq/EJ0rNMMD4N8RLpZRhKHKJUm9nNHLbksnlZwrbSTM5LpC/U6sheLP+l0
+bLVoq0lmsCcUSyh+mY6PxWirLIWCn/IAZAGnXb6Zd6TtIJlGG6pqUN8QxGJYQnon
+l0uTJKHJENbI9sWHQdcTtBMc34gorHFCo1Bcvpnc1LFLrWn7mfoGx6INQjf3HGQp
+MXAWuSBQhzkazY6vaWFpa8bBJ+gKbBuySWzNm3rFtT5HRKMWpO+M9bHp4d+puY0L
+1YwN1OMatcMMpcWnZpiWiR83oi32+xtWUY2U7Ae38mMag8zFbpeqPQUsDv9V7CAJ
+1dbriEwEGBECAAwFAkDYBnoFCQ5t3+gACgkQqE7a6JyACspnpgCfRbYwxT3iq+9l
+/PgNTUNTZOlof2oAn25y0eGi0371jap9kOV6uq71sUuO
+=pJli
+-----END PGP PUBLIC KEY BLOCK-----
+*/
+
+/**
+ * Array version of the above key
+ */
+char susekey[]=
+{
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x42,0x45,0x47,0x49,0x4e,0x20,0x50,0x47,
+        0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,0x4b,0x45,0x59,0x20,
+        0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x56,0x65,
+        0x72,0x73,0x69,0x6f,0x6e,0x3a,0x20,0x47,0x6e,0x75,0x50,0x47,0x20,
+        0x76,0x31,0x2e,0x34,0x2e,0x32,0x20,0x28,0x47,0x4e,0x55,0x2f,0x4c,
+        0x69,0x6e,0x75,0x78,0x29,0x0a,0x0a,0x6d,0x51,0x47,0x69,0x42,0x44,
+        0x6e,0x75,0x39,0x49,0x45,0x52,0x42,0x41,0x43,0x54,0x38,0x59,0x33,
+        0x35,0x2b,0x32,0x76,0x76,0x34,0x4d,0x47,0x56,0x4b,0x69,0x4c,0x45,
+        0x4d,0x4f,0x6c,0x39,0x47,0x64,0x53,0x54,0x36,0x4d,0x43,0x6b,0x59,
+        0x53,0x33,0x79,0x45,0x4b,0x65,0x75,0x65,0x4e,0x57,0x63,0x2b,0x7a,
+        0x2f,0x30,0x4b,0x76,0x66,0x66,0x0a,0x34,0x4a,0x63,0x74,0x42,0x73,
+        0x67,0x73,0x34,0x37,0x74,0x6a,0x6d,0x69,0x49,0x39,0x73,0x6c,0x30,
+        0x65,0x48,0x6a,0x6d,0x33,0x67,0x54,0x52,0x38,0x72,0x49,0x74,0x58,
+        0x4d,0x4e,0x36,0x73,0x4a,0x45,0x55,0x48,0x57,0x7a,0x44,0x50,0x2b,
+        0x59,0x30,0x50,0x46,0x50,0x62,0x6f,0x4d,0x76,0x4b,0x78,0x30,0x46,
+        0x58,0x6c,0x2f,0x41,0x30,0x64,0x0a,0x4d,0x2b,0x48,0x46,0x72,0x72,
+        0x75,0x43,0x67,0x42,0x6c,0x57,0x74,0x36,0x46,0x41,0x2b,0x6f,0x6b,
+        0x52,0x79,0x53,0x51,0x69,0x6c,0x69,0x75,0x49,0x35,0x70,0x68,0x77,
+        0x71,0x6b,0x58,0x65,0x66,0x6c,0x39,0x41,0x68,0x6b,0x77,0x52,0x38,
+        0x78,0x6f,0x63,0x51,0x53,0x56,0x43,0x46,0x78,0x63,0x77,0x76,0x77,
+        0x43,0x67,0x6c,0x56,0x63,0x4f,0x0a,0x51,0x6c,0x69,0x48,0x75,0x38,
+        0x6a,0x77,0x52,0x51,0x48,0x78,0x6c,0x52,0x45,0x30,0x74,0x6b,0x77,
+        0x51,0x51,0x49,0x30,0x44,0x2b,0x77,0x66,0x51,0x77,0x4b,0x64,0x76,
+        0x68,0x44,0x70,0x6c,0x78,0x48,0x4a,0x35,0x6e,0x66,0x37,0x55,0x38,
+        0x63,0x2f,0x79,0x45,0x2f,0x76,0x64,0x76,0x70,0x4e,0x36,0x6c,0x46,
+        0x30,0x74,0x6d,0x46,0x72,0x4b,0x0a,0x58,0x42,0x55,0x58,0x2b,0x4b,
+        0x37,0x75,0x34,0x69,0x66,0x72,0x5a,0x6c,0x51,0x76,0x6a,0x2f,0x38,
+        0x31,0x4d,0x34,0x49,0x4e,0x6a,0x74,0x58,0x72,0x65,0x71,0x44,0x69,
+        0x4a,0x74,0x72,0x39,0x39,0x52,0x73,0x36,0x78,0x61,0x30,0x53,0x63,
+        0x5a,0x71,0x49,0x54,0x75,0x5a,0x43,0x34,0x43,0x57,0x78,0x4a,0x61,
+        0x39,0x47,0x79,0x6e,0x42,0x45,0x0a,0x44,0x33,0x2b,0x44,0x32,0x74,
+        0x31,0x56,0x2f,0x66,0x38,0x6c,0x30,0x73,0x6d,0x73,0x75,0x59,0x6f,
+        0x46,0x4f,0x46,0x37,0x49,0x62,0x34,0x39,0x49,0x6b,0x54,0x64,0x62,
+        0x74,0x77,0x41,0x54,0x68,0x6c,0x5a,0x70,0x38,0x62,0x45,0x68,0x45,
+        0x4c,0x42,0x65,0x47,0x61,0x50,0x64,0x4e,0x43,0x63,0x6d,0x66,0x5a,
+        0x36,0x36,0x72,0x4b,0x55,0x64,0x0a,0x47,0x35,0x73,0x52,0x41,0x2f,
+        0x39,0x6f,0x76,0x6e,0x63,0x31,0x6b,0x72,0x53,0x51,0x46,0x32,0x2b,
+        0x73,0x71,0x42,0x39,0x2f,0x6f,0x37,0x77,0x35,0x2f,0x71,0x32,0x71,
+        0x69,0x79,0x7a,0x77,0x4f,0x53,0x54,0x6e,0x6b,0x6a,0x74,0x42,0x55,
+        0x56,0x4b,0x6e,0x34,0x7a,0x4c,0x55,0x4f,0x66,0x36,0x61,0x65,0x42,
+        0x41,0x6f,0x56,0x36,0x4e,0x4d,0x0a,0x43,0x43,0x33,0x4b,0x6a,0x39,
+        0x61,0x5a,0x48,0x66,0x41,0x2b,0x4e,0x44,0x30,0x65,0x68,0x50,0x61,
+        0x56,0x47,0x4a,0x67,0x6a,0x61,0x56,0x4e,0x46,0x68,0x50,0x69,0x34,
+        0x78,0x30,0x65,0x37,0x42,0x55,0x4c,0x64,0x76,0x67,0x4f,0x6f,0x41,
+        0x71,0x61,0x6a,0x4c,0x66,0x76,0x6b,0x55,0x52,0x48,0x41,0x65,0x53,
+        0x73,0x78,0x58,0x49,0x6f,0x45,0x0a,0x6d,0x79,0x57,0x2f,0x78,0x43,
+        0x31,0x73,0x42,0x62,0x44,0x6b,0x44,0x55,0x49,0x42,0x53,0x78,0x35,
+        0x6f,0x65,0x6a,0x37,0x33,0x58,0x43,0x5a,0x67,0x6e,0x6a,0x2f,0x69,
+        0x6e,0x70,0x68,0x52,0x71,0x47,0x70,0x73,0x62,0x2b,0x31,0x6e,0x4b,
+        0x46,0x76,0x46,0x2b,0x72,0x51,0x6f,0x55,0x33,0x56,0x54,0x52,0x53,
+        0x42,0x51,0x59,0x57,0x4e,0x72,0x0a,0x59,0x57,0x64,0x6c,0x49,0x46,
+        0x4e,0x70,0x5a,0x32,0x35,0x70,0x62,0x6d,0x63,0x67,0x53,0x32,0x56,
+        0x35,0x49,0x44,0x78,0x69,0x64,0x57,0x6c,0x73,0x5a,0x45,0x42,0x7a,
+        0x64,0x58,0x4e,0x6c,0x4c,0x6d,0x52,0x6c,0x50,0x6f,0x68,0x69,0x42,
+        0x42,0x4d,0x52,0x41,0x67,0x41,0x69,0x42,0x51,0x4a,0x41,0x32,0x41,
+        0x59,0x2b,0x41,0x68,0x73,0x44,0x0a,0x42,0x51,0x6b,0x4f,0x62,0x64,
+        0x2b,0x39,0x42,0x41,0x73,0x48,0x41,0x77,0x49,0x44,0x46,0x51,0x49,
+        0x44,0x41,0x78,0x59,0x43,0x41,0x51,0x49,0x65,0x41,0x51,0x49,0x58,
+        0x67,0x41,0x41,0x4b,0x43,0x52,0x43,0x6f,0x54,0x74,0x72,0x6f,0x6e,
+        0x49,0x41,0x4b,0x79,0x70,0x43,0x66,0x41,0x4a,0x39,0x52,0x75,0x5a,
+        0x36,0x5a,0x53,0x56,0x37,0x51,0x0a,0x57,0x34,0x70,0x54,0x67,0x54,
+        0x49,0x78,0x51,0x2b,0x41,0x42,0x50,0x70,0x30,0x73,0x49,0x77,0x43,
+        0x66,0x66,0x47,0x39,0x62,0x43,0x4e,0x6e,0x72,0x45,0x54,0x50,0x6c,
+        0x67,0x4f,0x6e,0x2b,0x64,0x47,0x45,0x6b,0x41,0x57,0x65,0x67,0x4b,
+        0x4c,0x2b,0x49,0x52,0x67,0x51,0x51,0x45,0x51,0x49,0x41,0x42,0x67,
+        0x55,0x43,0x4f,0x6e,0x42,0x65,0x0a,0x55,0x67,0x41,0x4b,0x43,0x52,
+        0x43,0x65,0x51,0x4f,0x4d,0x51,0x41,0x41,0x71,0x72,0x70,0x4e,0x7a,
+        0x4f,0x41,0x4b,0x43,0x4c,0x35,0x31,0x32,0x46,0x5a,0x76,0x76,0x34,
+        0x56,0x5a,0x78,0x39,0x34,0x54,0x70,0x62,0x41,0x39,0x6c,0x78,0x79,
+        0x6f,0x41,0x65,0x6a,0x41,0x43,0x65,0x4f,0x4f,0x31,0x48,0x49,0x62,
+        0x41,0x63,0x74,0x41,0x65,0x76,0x0a,0x6b,0x35,0x4d,0x55,0x42,0x68,
+        0x4e,0x65,0x4c,0x5a,0x61,0x2f,0x71,0x4d,0x32,0x4a,0x41,0x52,0x55,
+        0x44,0x42,0x52,0x41,0x36,0x63,0x47,0x42,0x76,0x64,0x37,0x4c,0x6d,
+        0x41,0x44,0x30,0x6c,0x30,0x39,0x6b,0x42,0x41,0x54,0x57,0x6e,0x42,
+        0x2f,0x39,0x41,0x6e,0x35,0x76,0x66,0x69,0x55,0x55,0x45,0x31,0x56,
+        0x51,0x6e,0x74,0x2b,0x54,0x2f,0x0a,0x45,0x59,0x6b,0x6c,0x45,0x53,
+        0x33,0x74,0x58,0x58,0x61,0x4a,0x4a,0x70,0x39,0x70,0x48,0x4d,0x61,
+        0x34,0x66,0x7a,0x46,0x61,0x38,0x6a,0x50,0x56,0x74,0x76,0x35,0x55,
+        0x42,0x48,0x47,0x65,0x65,0x33,0x58,0x6f,0x55,0x4e,0x44,0x56,0x77,
+        0x4d,0x32,0x4f,0x67,0x53,0x45,0x49,0x53,0x5a,0x78,0x62,0x7a,0x64,
+        0x58,0x47,0x6e,0x71,0x49,0x6c,0x0a,0x63,0x54,0x30,0x38,0x54,0x7a,
+        0x42,0x55,0x44,0x39,0x69,0x35,0x37,0x39,0x75,0x69,0x66,0x6b,0x6c,
+        0x4c,0x73,0x6e,0x72,0x33,0x35,0x53,0x4a,0x44,0x5a,0x36,0x72,0x61,
+        0x6d,0x35,0x31,0x2f,0x43,0x57,0x4f,0x6e,0x6e,0x61,0x56,0x68,0x55,
+        0x7a,0x6e,0x65,0x4f,0x41,0x39,0x67,0x54,0x50,0x53,0x72,0x2b,0x2f,
+        0x66,0x54,0x33,0x57,0x65,0x56,0x0a,0x6e,0x77,0x4a,0x69,0x51,0x43,
+        0x51,0x33,0x30,0x6b,0x4e,0x4c,0x57,0x56,0x58,0x57,0x41,0x54,0x4d,
+        0x6e,0x73,0x6e,0x54,0x34,0x38,0x36,0x65,0x41,0x4f,0x6c,0x54,0x36,
+        0x55,0x4e,0x42,0x50,0x59,0x51,0x4c,0x70,0x55,0x70,0x72,0x46,0x35,
+        0x59,0x72,0x79,0x6b,0x32,0x33,0x70,0x51,0x55,0x50,0x41,0x67,0x4a,
+        0x45,0x4e,0x44,0x45,0x71,0x65,0x0a,0x55,0x36,0x69,0x49,0x4f,0x39,
+        0x4f,0x74,0x31,0x5a,0x50,0x74,0x42,0x30,0x6c,0x6e,0x69,0x77,0x2b,
+        0x2f,0x78,0x43,0x69,0x31,0x33,0x44,0x33,0x36,0x30,0x6f,0x31,0x74,
+        0x5a,0x44,0x59,0x4f,0x70,0x30,0x68,0x48,0x48,0x4a,0x4e,0x33,0x44,
+        0x33,0x45,0x4e,0x38,0x43,0x31,0x79,0x50,0x71,0x5a,0x64,0x35,0x43,
+        0x76,0x76,0x7a,0x6e,0x59,0x76,0x0a,0x42,0x36,0x62,0x57,0x42,0x49,
+        0x70,0x57,0x63,0x52,0x67,0x64,0x6e,0x32,0x44,0x55,0x56,0x4d,0x6d,
+        0x70,0x55,0x36,0x36,0x31,0x6a,0x77,0x71,0x47,0x6c,0x52,0x7a,0x31,
+        0x46,0x38,0x34,0x4a,0x47,0x2f,0x78,0x65,0x34,0x6a,0x47,0x75,0x7a,
+        0x67,0x70,0x4a,0x74,0x39,0x49,0x58,0x53,0x7a,0x79,0x6f,0x68,0x45,
+        0x4a,0x42,0x36,0x58,0x47,0x35,0x0a,0x2b,0x44,0x30,0x42,0x75,0x51,
+        0x49,0x4e,0x42,0x44,0x6e,0x75,0x39,0x4a,0x49,0x51,0x43,0x41,0x43,
+        0x45,0x6b,0x64,0x42,0x4e,0x36,0x4d,0x78,0x66,0x35,0x57,0x76,0x71,
+        0x44,0x57,0x6b,0x63,0x4d,0x52,0x79,0x36,0x77,0x6e,0x72,0x64,0x39,
+        0x44,0x59,0x4a,0x38,0x55,0x55,0x54,0x6d,0x49,0x54,0x32,0x69,0x51,
+        0x66,0x30,0x37,0x74,0x52,0x55,0x0a,0x4b,0x4a,0x4a,0x39,0x76,0x30,
+        0x4a,0x58,0x66,0x78,0x32,0x5a,0x34,0x64,0x30,0x38,0x49,0x51,0x53,
+        0x4d,0x4e,0x52,0x61,0x71,0x34,0x56,0x67,0x53,0x65,0x2b,0x50,0x64,
+        0x59,0x67,0x49,0x79,0x30,0x66,0x62,0x6a,0x32,0x33,0x56,0x69,0x61,
+        0x35,0x2f,0x67,0x4f,0x37,0x66,0x4a,0x45,0x70,0x44,0x32,0x68,0x64,
+        0x32,0x66,0x2b,0x70,0x4d,0x6e,0x0a,0x4f,0x57,0x76,0x48,0x32,0x72,
+        0x4f,0x4f,0x49,0x62,0x65,0x59,0x66,0x75,0x68,0x7a,0x41,0x63,0x36,
+        0x42,0x51,0x6a,0x41,0x4b,0x74,0x6d,0x67,0x52,0x30,0x45,0x52,0x55,
+        0x54,0x61,0x66,0x54,0x4d,0x39,0x57,0x62,0x36,0x46,0x31,0x33,0x43,
+        0x4e,0x5a,0x5a,0x4e,0x5a,0x66,0x44,0x71,0x6e,0x46,0x44,0x50,0x36,
+        0x4c,0x31,0x32,0x77,0x33,0x7a,0x0a,0x33,0x46,0x37,0x46,0x46,0x58,
+        0x6b,0x7a,0x30,0x37,0x52,0x73,0x33,0x41,0x49,0x74,0x6f,0x31,0x5a,
+        0x66,0x59,0x5a,0x64,0x34,0x73,0x43,0x53,0x70,0x4d,0x72,0x2f,0x30,
+        0x53,0x35,0x6e,0x4c,0x72,0x48,0x62,0x49,0x76,0x47,0x4c,0x70,0x32,
+        0x37,0x31,0x68,0x68,0x51,0x42,0x65,0x52,0x6d,0x6d,0x6f,0x47,0x45,
+        0x4b,0x4f,0x32,0x4a,0x52,0x65,0x0a,0x6c,0x47,0x67,0x55,0x4a,0x32,
+        0x43,0x55,0x7a,0x4f,0x64,0x74,0x77,0x44,0x49,0x4b,0x54,0x30,0x4c,
+        0x62,0x43,0x70,0x76,0x61,0x50,0x38,0x50,0x56,0x6e,0x59,0x46,0x35,
+        0x49,0x46,0x6f,0x59,0x4a,0x49,0x57,0x52,0x48,0x71,0x6c,0x45,0x74,
+        0x35,0x75,0x63,0x54,0x58,0x73,0x74,0x5a,0x79,0x37,0x76,0x59,0x6a,
+        0x4c,0x36,0x76,0x54,0x50,0x34,0x0a,0x6c,0x35,0x78,0x73,0x2b,0x4c,
+        0x49,0x4f,0x6b,0x4e,0x6d,0x50,0x68,0x71,0x6d,0x66,0x73,0x67,0x4c,
+        0x7a,0x56,0x6f,0x30,0x55,0x61,0x4c,0x74,0x38,0x30,0x68,0x4f,0x77,
+        0x63,0x34,0x4e,0x76,0x44,0x43,0x4f,0x4c,0x41,0x41,0x4d,0x47,0x42,
+        0x2f,0x39,0x67,0x2b,0x39,0x56,0x33,0x4f,0x52,0x7a,0x77,0x34,0x4c,
+        0x76,0x4f,0x31,0x70,0x77,0x52,0x0a,0x59,0x4a,0x71,0x66,0x44,0x4b,
+        0x55,0x71,0x2f,0x45,0x4a,0x30,0x72,0x4e,0x4d,0x4d,0x44,0x34,0x4e,
+        0x38,0x52,0x4c,0x70,0x5a,0x52,0x68,0x4b,0x48,0x4b,0x4a,0x55,0x6d,
+        0x39,0x6e,0x4e,0x48,0x4c,0x62,0x6b,0x73,0x6e,0x6c,0x5a,0x77,0x72,
+        0x62,0x53,0x54,0x4d,0x35,0x4c,0x70,0x43,0x2f,0x55,0x36,0x73,0x68,
+        0x65,0x4c,0x50,0x2b,0x6c,0x30,0x0a,0x62,0x4c,0x56,0x6f,0x71,0x30,
+        0x6c,0x6d,0x73,0x43,0x63,0x55,0x53,0x79,0x68,0x2b,0x6d,0x59,0x36,
+        0x50,0x78,0x57,0x69,0x72,0x4c,0x49,0x57,0x43,0x6e,0x2f,0x49,0x41,
+        0x5a,0x41,0x47,0x6e,0x58,0x62,0x36,0x5a,0x64,0x36,0x54,0x74,0x49,
+        0x4a,0x6c,0x47,0x47,0x36,0x70,0x71,0x55,0x4e,0x38,0x51,0x78,0x47,
+        0x4a,0x59,0x51,0x6e,0x6f,0x6e,0x0a,0x6c,0x30,0x75,0x54,0x4a,0x4b,
+        0x48,0x4a,0x45,0x4e,0x62,0x49,0x39,0x73,0x57,0x48,0x51,0x64,0x63,
+        0x54,0x74,0x42,0x4d,0x63,0x33,0x34,0x67,0x6f,0x72,0x48,0x46,0x43,
+        0x6f,0x31,0x42,0x63,0x76,0x70,0x6e,0x63,0x31,0x4c,0x46,0x4c,0x72,
+        0x57,0x6e,0x37,0x6d,0x66,0x6f,0x47,0x78,0x36,0x49,0x4e,0x51,0x6a,
+        0x66,0x33,0x48,0x47,0x51,0x70,0x0a,0x4d,0x58,0x41,0x57,0x75,0x53,
+        0x42,0x51,0x68,0x7a,0x6b,0x61,0x7a,0x59,0x36,0x76,0x61,0x57,0x46,
+        0x70,0x61,0x38,0x62,0x42,0x4a,0x2b,0x67,0x4b,0x62,0x42,0x75,0x79,
+        0x53,0x57,0x7a,0x4e,0x6d,0x33,0x72,0x46,0x74,0x54,0x35,0x48,0x52,
+        0x4b,0x4d,0x57,0x70,0x4f,0x2b,0x4d,0x39,0x62,0x48,0x70,0x34,0x64,
+        0x2b,0x70,0x75,0x59,0x30,0x4c,0x0a,0x31,0x59,0x77,0x4e,0x31,0x4f,
+        0x4d,0x61,0x74,0x63,0x4d,0x4d,0x70,0x63,0x57,0x6e,0x5a,0x70,0x69,
+        0x57,0x69,0x52,0x38,0x33,0x6f,0x69,0x33,0x32,0x2b,0x78,0x74,0x57,
+        0x55,0x59,0x32,0x55,0x37,0x41,0x65,0x33,0x38,0x6d,0x4d,0x61,0x67,
+        0x38,0x7a,0x46,0x62,0x70,0x65,0x71,0x50,0x51,0x55,0x73,0x44,0x76,
+        0x39,0x56,0x37,0x43,0x41,0x4a,0x0a,0x31,0x64,0x62,0x72,0x69,0x45,
+        0x77,0x45,0x47,0x42,0x45,0x43,0x41,0x41,0x77,0x46,0x41,0x6b,0x44,
+        0x59,0x42,0x6e,0x6f,0x46,0x43,0x51,0x35,0x74,0x33,0x2b,0x67,0x41,
+        0x43,0x67,0x6b,0x51,0x71,0x45,0x37,0x61,0x36,0x4a,0x79,0x41,0x43,
+        0x73,0x70,0x6e,0x70,0x67,0x43,0x66,0x52,0x62,0x59,0x77,0x78,0x54,
+        0x33,0x69,0x71,0x2b,0x39,0x6c,0x0a,0x2f,0x50,0x67,0x4e,0x54,0x55,
+        0x4e,0x54,0x5a,0x4f,0x6c,0x6f,0x66,0x32,0x6f,0x41,0x6e,0x32,0x35,
+        0x79,0x30,0x65,0x47,0x69,0x30,0x33,0x37,0x31,0x6a,0x61,0x70,0x39,
+        0x6b,0x4f,0x56,0x36,0x75,0x71,0x37,0x31,0x73,0x55,0x75,0x4f,0x0a,
+        0x3d,0x70,0x4a,0x6c,0x69,0x0a,0x2d,0x2d,0x2d,0x2d,0x2d,0x45,0x4e,
+        0x44,0x20,0x50,0x47,0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,
+        0x4b,0x45,0x59,0x20,0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x0a,0x00,
+};
+
+size_t _susekey_size=2173;
+size_t *susekey_size=&_susekey_size;
+
+///////////////////////////////////////////////////////////////////
+// KeyRingReceive
+///////////////////////////////////////////////////////////////////
+struct KeyRingReceive : public zypp::callback::ReceiveReport<zypp::KeyRingReport>
+{
+  KeyRingReceive()
+  {}
+
+  virtual bool askUserToAcceptUnsignedFile( const std::string &file )
+  {
+    return true;
+  }
+  virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id )
+  {
+    return true;
+  }
+
+  virtual bool askUserToImportKey( const PublicKey &key )
+  {
+    DBG << "By default zypp-query-pool does not import keys for now." << std::endl;
+    return false;
+  }
+
+  virtual bool askUserToTrustKey(  const PublicKey &key  )
+  {
+    return true;
+  }
+  virtual bool askUserToAcceptVerificationFailed( const std::string &file,  const PublicKey &key  )
+  {
+    return true;
+  }
+};
+
+class KeyRingCallbacks
+{
+
+private:
+  KeyRingReceive _keyRingReport;
+
+public:
+  KeyRingCallbacks()
+  {
+    _keyRingReport.connect();
+  }
+
+  ~KeyRingCallbacks()
+  {
+    _keyRingReport.disconnect();
+  }
+
+};
+
+struct KeyRingSignalReceiver : callback::ReceiveReport<KeyRingSignals>
+{
+  KeyRingSignalReceiver(/*RpmDb &rpmdb*/)
+  : _trusted_key_added_called(false)
+  {
+    MIL << "KeyRing signals enabled" << endl;
+    connect();
+  }
+
+  ~KeyRingSignalReceiver()
+  {
+    disconnect();
+  }
+
+  virtual void trustedKeyAdded( const KeyRing &keyring, const PublicKey &key )
+  {
+    MIL << "TEST: trusted key added to zypp Keyring. Syncronizing keys with fake rpm keyring" << std::endl;
+    _trusted_key_added_called = true;
+    //std::cout << "trusted key added to zypp Keyring. Syncronizing keys with rpm keyring" << std::endl;
+    //_rpmdb.importZyppKeyRingTrustedKeys();
+    //_rpmdb.exportTrustedKeysInZyppKeyRing();
+  }
+
+  virtual void trustedKeyRemoved( const KeyRing &keyring, const PublicKey &key  )
+  {
+  }
+  
+  bool _trusted_key_added_called;
+  
+};
+
+void keyring_test()
+{
+  KeyRingCallbacks keyring_callbacks;
+  KeyRingSignalReceiver receiver;
+  // base sandbox for playing
+  TmpDir tmp_dir;
+  
+  KeyRing keyring( tmp_dir.path() );
+  
+  // create a public key from the array
+  TmpFile file;
+  ofstream str(file.path().asString().c_str(),ofstream::out);
+
+  if (!str.good())
+    ZYPP_THROW(Exception("cant open file"));
+
+  str << susekey;
+  str.flush();
+  str.close();
+  PublicKey key( file.path() );
+  
+  keyring.importKey( key, false );
+  BOOST_CHECK_EQUAL( keyring.publicKeys().size(), 1 );
+  BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 0 );
+  
+  keyring.importKey( key, true );
+  BOOST_CHECK_EQUAL( receiver._trusted_key_added_called, true );
+  BOOST_CHECK_EQUAL( keyring.trustedPublicKeys().size(), 1 );
+}
+
+test_suite*
+init_unit_test_suite( int argc, char* argv[] )
+{
+    //set_log_stream( std::cout );
+    test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" );
+    test->add( BOOST_TEST_CASE( &keyring_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/Lazy.cc b/tests/zypp/Lazy.cc
new file mode 100644 (file)
index 0000000..7134390
--- /dev/null
@@ -0,0 +1,228 @@
+
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp2/Lazy.h"
+#include "zypp/TmpPath.h"
+
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+
+char descfile[]=
+{
+        0x3d,0x56,0x65,0x72,0x3a,0x20,0x32,0x2e,0x30,0x0a,0x23,0x23,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x0a,0x3d,0x50,0x6b,0x67,0x3a,0x20,0x33,0x64,0x64,0x69,0x61,0x67,
+        0x20,0x30,0x2e,0x37,0x33,0x38,0x20,0x32,0x35,0x20,0x69,0x35,0x38,
+        0x36,0x0a,0x3d,0x53,0x75,0x6d,0x3a,0x20,0x41,0x20,0x54,0x6f,0x6f,
+        0x6c,0x20,0x74,0x6f,0x20,0x56,0x65,0x72,0x69,0x66,0x79,0x20,0x74,
+        0x68,0x65,0x20,0x33,0x44,0x20,0x43,0x6f,0x6e,0x66,0x69,0x67,0x75,
+        0x72,0x61,0x74,0x69,0x6f,0x6e,0x0a,0x2b,0x44,0x65,0x73,0x3a,0x0a,
+        0x3c,0x21,0x2d,0x2d,0x20,0x44,0x54,0x3a,0x52,0x69,0x63,0x68,0x20,
+        0x2d,0x2d,0x3e,0x0a,0x3c,0x70,0x3e,0x57,0x69,0x74,0x68,0x20,0x33,
+        0x44,0x64,0x69,0x61,0x67,0x20,0x79,0x6f,0x75,0x20,0x63,0x61,0x6e,
+        0x20,0x76,0x65,0x72,0x69,0x66,0x79,0x20,0x74,0x68,0x65,0x20,0x33,
+        0x44,0x20,0x63,0x6f,0x6e,0x66,0x69,0x67,0x75,0x72,0x61,0x74,0x69,
+        0x6f,0x6e,0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x0a,0x2d,0x44,0x65,0x73,
+        0x3a,0x0a,0x23,0x23,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x3d,0x50,0x6b,0x67,0x3a,0x20,0x33,
+        0x64,0x64,0x69,0x61,0x67,0x2d,0x64,0x65,0x62,0x75,0x67,0x69,0x6e,
+        0x66,0x6f,0x20,0x30,0x2e,0x37,0x33,0x38,0x20,0x32,0x35,0x20,0x69,
+        0x35,0x38,0x36,0x0a,0x3d,0x53,0x75,0x6d,0x3a,0x20,0x41,0x20,0x54,
+        0x6f,0x6f,0x6c,0x20,0x74,0x6f,0x20,0x56,0x65,0x72,0x69,0x66,0x79,
+        0x20,0x74,0x68,0x65,0x20,0x33,0x44,0x20,0x43,0x6f,0x6e,0x66,0x69,
+        0x67,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x0a,0x2b,0x44,0x65,0x73,
+        0x3a,0x0a,0x3c,0x21,0x2d,0x2d,0x20,0x44,0x54,0x3a,0x52,0x69,0x63,
+        0x68,0x20,0x2d,0x2d,0x3e,0x0a,0x3c,0x70,0x3e,0x57,0x69,0x74,0x68,
+        0x20,0x33,0x44,0x64,0x69,0x61,0x67,0x20,0x79,0x6f,0x75,0x20,0x63,
+        0x61,0x6e,0x20,0x76,0x65,0x72,0x69,0x66,0x79,0x20,0x74,0x68,0x65,
+        0x20,0x33,0x44,0x20,0x63,0x6f,0x6e,0x66,0x69,0x67,0x75,0x72,0x61,
+        0x74,0x69,0x6f,0x6e,0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x0a,0x2d,0x44,
+        0x65,0x73,0x3a,0x0a,0x23,0x23,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x3d,0x50,0x6b,0x67,0x3a,
+        0x20,0x33,0x64,0x74,0x6f,0x33,0x64,0x20,0x33,0x2e,0x35,0x20,0x35,
+        0x31,0x20,0x69,0x35,0x38,0x36,0x0a,0x3d,0x53,0x75,0x6d,0x3a,0x20,
+        0x43,0x6f,0x6e,0x76,0x65,0x72,0x74,0x65,0x72,0x20,0x66,0x6f,0x72,
+        0x20,0x53,0x65,0x76,0x65,0x72,0x61,0x6c,0x20,0x33,0x2d,0x44,0x69,
+        0x6d,0x65,0x6e,0x73,0x69,0x6f,0x6e,0x61,0x6c,0x20,0x4f,0x62,0x6a,
+        0x65,0x63,0x74,0x20,0x46,0x69,0x6c,0x65,0x20,0x46,0x6f,0x72,0x6d,
+        0x61,0x74,0x73,0x0a,0x2b,0x44,0x65,0x73,0x3a,0x0a,0x3c,0x21,0x2d,
+        0x2d,0x20,0x44,0x54,0x3a,0x52,0x69,0x63,0x68,0x20,0x2d,0x2d,0x3e,
+        0x0a,0x3c,0x70,0x3e,0x33,0x64,0x74,0x6f,0x33,0x64,0x20,0x69,0x73,
+        0x20,0x61,0x20,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x2d,0x6c,0x69,
+        0x6e,0x65,0x20,0x74,0x6f,0x6f,0x6c,0x20,0x61,0x62,0x6c,0x65,0x20,
+        0x74,0x6f,0x20,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x20,0x6f,0x62,
+        0x6a,0x65,0x63,0x74,0x73,0x20,0x69,0x6e,0x20,0x33,0x44,0x20,0x53,
+        0x74,0x75,0x64,0x69,0x6f,0x2c,0x20,0x49,0x6d,0x61,0x67,0x69,0x6e,
+        0x65,0x0a,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x4c,0x69,0x67,
+        0x68,0x74,0x57,0x61,0x76,0x65,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,
+        0x2c,0x20,0x41,0x75,0x74,0x6f,0x43,0x61,0x64,0x20,0x4f,0x62,0x6a,
+        0x65,0x63,0x74,0x2c,0x20,0x50,0x6f,0x76,0x72,0x61,0x79,0x20,0x42,
+        0x69,0x6e,0x61,0x72,0x79,0x2c,0x20,0x61,0x6e,0x64,0x20,0x57,0x61,
+        0x76,0x65,0x46,0x72,0x6f,0x6e,0x74,0x20,0x66,0x6f,0x72,0x6d,0x61,
+        0x74,0x73,0x20,0x74,0x6f,0x0a,0x4d,0x6f,0x72,0x61,0x79,0x2f,0x50,
+        0x6f,0x76,0x72,0x61,0x79,0x2c,0x20,0x4d,0x6f,0x72,0x61,0x79,0x2f,
+        0x50,0x6f,0x6c,0x79,0x72,0x61,0x79,0x2c,0x20,0x33,0x44,0x53,0x74,
+        0x75,0x64,0x69,0x6f,0x2c,0x20,0x48,0x69,0x67,0x68,0x4c,0x69,0x67,
+        0x68,0x74,0x2c,0x20,0x52,0x65,0x61,0x6c,0x33,0x44,0x20,0x4d,0x61,
+        0x63,0x72,0x6f,0x2c,0x20,0x33,0x44,0x20,0x53,0x74,0x75,0x64,0x69,
+        0x6f,0x20,0x42,0x69,0x6e,0x61,0x72,0x79,0x2c,0x0a,0x4d,0x6f,0x72,
+        0x61,0x79,0x2f,0x50,0x6f,0x76,0x72,0x61,0x79,0x20,0x28,0x57,0x69,
+        0x72,0x65,0x29,0x2c,0x20,0x4d,0x6f,0x72,0x61,0x79,0x2f,0x50,0x6f,
+        0x76,0x72,0x61,0x79,0x20,0x28,0x42,0x6c,0x6f,0x62,0x20,0x57,0x69,
+        0x72,0x65,0x29,0x2c,0x20,0x49,0x6d,0x61,0x67,0x69,0x6e,0x65,0x20,
+        0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x52,0x65,0x6e,0x64,0x65,
+        0x72,0x57,0x61,0x72,0x65,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,
+        0x0a,0x56,0x52,0x4d,0x4c,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,
+        0x20,0x44,0x58,0x46,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,
+        0x4c,0x69,0x67,0x68,0x74,0x77,0x61,0x76,0x65,0x20,0x4f,0x62,0x6a,
+        0x65,0x63,0x74,0x2c,0x20,0x44,0x69,0x72,0x65,0x63,0x74,0x20,0x58,
+        0x20,0x28,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x29,0x2c,
+        0x20,0x52,0x65,0x61,0x6c,0x33,0x44,0x20,0x4f,0x62,0x6a,0x65,0x63,
+        0x74,0x2c,0x0a,0x4f,0x70,0x65,0x6e,0x47,0x4c,0x20,0x43,0x20,0x73,
+        0x6f,0x75,0x72,0x63,0x65,0x2c,0x20,0x6f,0x72,0x20,0x57,0x61,0x76,
+        0x65,0x46,0x72,0x6f,0x6e,0x74,0x20,0x66,0x6f,0x72,0x6d,0x61,0x74,
+        0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x0a,0x2d,0x44,0x65,0x73,0x3a,0x0a,
+        0x23,0x23,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x0a,0x3d,0x50,0x6b,0x67,0x3a,0x20,0x33,0x64,0x74,
+        0x6f,0x33,0x64,0x2d,0x64,0x65,0x62,0x75,0x67,0x69,0x6e,0x66,0x6f,
+        0x20,0x33,0x2e,0x35,0x20,0x35,0x31,0x20,0x69,0x35,0x38,0x36,0x0a,
+        0x3d,0x53,0x75,0x6d,0x3a,0x20,0x43,0x6f,0x6e,0x76,0x65,0x72,0x74,
+        0x65,0x72,0x20,0x66,0x6f,0x72,0x20,0x53,0x65,0x76,0x65,0x72,0x61,
+        0x6c,0x20,0x33,0x2d,0x44,0x69,0x6d,0x65,0x6e,0x73,0x69,0x6f,0x6e,
+        0x61,0x6c,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x20,0x46,0x69,0x6c,
+        0x65,0x20,0x46,0x6f,0x72,0x6d,0x61,0x74,0x73,0x0a,0x2b,0x44,0x65,
+        0x73,0x3a,0x0a,0x3c,0x21,0x2d,0x2d,0x20,0x44,0x54,0x3a,0x52,0x69,
+        0x63,0x68,0x20,0x2d,0x2d,0x3e,0x0a,0x3c,0x70,0x3e,0x33,0x64,0x74,
+        0x6f,0x33,0x64,0x20,0x69,0x73,0x20,0x61,0x20,0x63,0x6f,0x6d,0x6d,
+        0x61,0x6e,0x64,0x2d,0x6c,0x69,0x6e,0x65,0x20,0x74,0x6f,0x6f,0x6c,
+        0x20,0x61,0x62,0x6c,0x65,0x20,0x74,0x6f,0x20,0x63,0x6f,0x6e,0x76,
+        0x65,0x72,0x74,0x20,0x6f,0x62,0x6a,0x65,0x63,0x74,0x73,0x20,0x69,
+        0x6e,0x20,0x33,0x44,0x20,0x53,0x74,0x75,0x64,0x69,0x6f,0x2c,0x20,
+        0x49,0x6d,0x61,0x67,0x69,0x6e,0x65,0x0a,0x4f,0x62,0x6a,0x65,0x63,
+        0x74,0x2c,0x20,0x4c,0x69,0x67,0x68,0x74,0x57,0x61,0x76,0x65,0x20,
+        0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x41,0x75,0x74,0x6f,0x43,
+        0x61,0x64,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x50,0x6f,
+        0x76,0x72,0x61,0x79,0x20,0x42,0x69,0x6e,0x61,0x72,0x79,0x2c,0x20,
+        0x61,0x6e,0x64,0x20,0x57,0x61,0x76,0x65,0x46,0x72,0x6f,0x6e,0x74,
+        0x20,0x66,0x6f,0x72,0x6d,0x61,0x74,0x73,0x20,0x74,0x6f,0x0a,0x4d,
+        0x6f,0x72,0x61,0x79,0x2f,0x50,0x6f,0x76,0x72,0x61,0x79,0x2c,0x20,
+        0x4d,0x6f,0x72,0x61,0x79,0x2f,0x50,0x6f,0x6c,0x79,0x72,0x61,0x79,
+        0x2c,0x20,0x33,0x44,0x53,0x74,0x75,0x64,0x69,0x6f,0x2c,0x20,0x48,
+        0x69,0x67,0x68,0x4c,0x69,0x67,0x68,0x74,0x2c,0x20,0x52,0x65,0x61,
+        0x6c,0x33,0x44,0x20,0x4d,0x61,0x63,0x72,0x6f,0x2c,0x20,0x33,0x44,
+        0x20,0x53,0x74,0x75,0x64,0x69,0x6f,0x20,0x42,0x69,0x6e,0x61,0x72,
+        0x79,0x2c,0x0a,0x4d,0x6f,0x72,0x61,0x79,0x2f,0x50,0x6f,0x76,0x72,
+        0x61,0x79,0x20,0x28,0x57,0x69,0x72,0x65,0x29,0x2c,0x20,0x4d,0x6f,
+        0x72,0x61,0x79,0x2f,0x50,0x6f,0x76,0x72,0x61,0x79,0x20,0x28,0x42,
+        0x6c,0x6f,0x62,0x20,0x57,0x69,0x72,0x65,0x29,0x2c,0x20,0x49,0x6d,
+        0x61,0x67,0x69,0x6e,0x65,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,
+        0x20,0x52,0x65,0x6e,0x64,0x65,0x72,0x57,0x61,0x72,0x65,0x20,0x4f,
+        0x62,0x6a,0x65,0x63,0x74,0x2c,0x0a,0x56,0x52,0x4d,0x4c,0x20,0x4f,
+        0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x44,0x58,0x46,0x20,0x4f,0x62,
+        0x6a,0x65,0x63,0x74,0x2c,0x20,0x4c,0x69,0x67,0x68,0x74,0x77,0x61,
+        0x76,0x65,0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x20,0x44,0x69,
+        0x72,0x65,0x63,0x74,0x20,0x58,0x20,0x28,0x4d,0x69,0x63,0x72,0x6f,
+        0x73,0x6f,0x66,0x74,0x29,0x2c,0x20,0x52,0x65,0x61,0x6c,0x33,0x44,
+        0x20,0x4f,0x62,0x6a,0x65,0x63,0x74,0x2c,0x0a,0x4f,0x70,0x65,0x6e,
+        0x47,0x4c,0x20,0x43,0x20,0x73,0x6f,0x75,0x72,0x63,0x65,0x2c,0x20,
+        0x6f,0x72,0x20,0x57,0x61,0x76,0x65,0x46,0x72,0x6f,0x6e,0x74,0x20,
+        0x66,0x6f,0x72,0x6d,0x61,0x74,0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x0a,
+        0x2d,0x44,0x65,0x73,0x3a,0x0a,0x23,0x23,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x3d,0x50,0x6b,
+        0x67,0x3a,0x20,0x39,0x31,0x35,0x72,0x65,0x73,0x6f,0x6c,0x75,0x74,
+        0x69,0x6f,0x6e,0x20,0x30,0x2e,0x35,0x2e,0x32,0x20,0x31,0x34,0x20,
+        0x69,0x35,0x38,0x36,0x0a,0x3d,0x53,0x75,0x6d,0x3a,0x20,0x54,0x68,
+        0x69,0x73,0x20,0x73,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x20,0x63,
+        0x68,0x61,0x6e,0x67,0x65,0x73,0x20,0x74,0x68,0x65,0x20,0x72,0x65,
+        0x73,0x6f,0x6c,0x75,0x74,0x69,0x6f,0x6e,0x20,0x6f,0x66,0x20,0x61,
+        0x6e,0x20,0x61,0x76,0x61,0x69,0x6c,0x61,0x62,0x6c,0x65,0x20,0x76,
+        0x62,0x69,0x6f,0x73,0x20,0x6d,0x6f,0x64,0x65,0x2e,0x0a,0x2b,0x44,
+        0x65,0x73,0x3a,0x0a,0x3c,0x21,0x2d,0x2d,0x20,0x44,0x54,0x3a,0x52,
+        0x69,0x63,0x68,0x20,0x2d,0x2d,0x3e,0x0a,0x3c,0x70,0x3e,0x54,0x68,
+        0x69,0x73,0x20,0x73,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x20,0x63,
+        0x68,0x61,0x6e,0x67,0x65,0x73,0x20,0x74,0x68,0x65,0x20,0x72,0x65,
+        0x73,0x6f,0x6c,0x75,0x74,0x69,0x6f,0x6e,0x20,0x6f,0x66,0x20,0x61,
+        0x6e,0x20,0x61,0x76,0x61,0x69,0x6c,0x61,0x62,0x6c,0x65,0x20,0x76,
+        0x62,0x69,0x6f,0x73,0x20,0x6d,0x6f,0x64,0x65,0x2e,0x0a,0x3c,0x2f,
+        0x70,0x3e,0x3c,0x70,0x3e,0x0a,0x49,0x74,0x20,0x70,0x61,0x74,0x63,
+        0x68,0x65,0x73,0x20,0x6f,0x6e,0x6c,0x79,0x20,0x74,0x68,0x65,0x20,
+        0x52,0x41,0x4d,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x6f,
+        0x66,0x20,0x74,0x68,0x65,0x20,0x76,0x69,0x64,0x65,0x6f,0x20,0x62,
+        0x69,0x6f,0x73,0x20,0x73,0x6f,0x20,0x74,0x68,0x65,0x20,0x6e,0x65,
+        0x77,0x20,0x72,0x65,0x73,0x6f,0x6c,0x75,0x74,0x69,0x6f,0x6e,0x0a,
+        0x69,0x73,0x20,0x6c,0x6f,0x6f,0x73,0x65,0x20,0x65,0x61,0x63,0x68,
+        0x20,0x74,0x69,0x6d,0x65,0x20,0x79,0x6f,0x75,0x20,0x72,0x65,0x62,
+        0x6f,0x6f,0x74,0x2e,0x20,0x49,0x66,0x20,0x79,0x6f,0x75,0x20,0x77,
+        0x61,0x6e,0x74,0x20,0x74,0x6f,0x20,0x73,0x65,0x74,0x20,0x74,0x68,
+        0x65,0x20,0x72,0x65,0x73,0x6f,0x6c,0x75,0x74,0x69,0x6f,0x6e,0x20,
+        0x65,0x61,0x63,0x68,0x0a,0x74,0x69,0x6d,0x65,0x20,0x79,0x6f,0x75,
+        0x20,0x72,0x65,0x62,0x6f,0x6f,0x74,0x20,0x61,0x6e,0x64,0x20,0x62,
+        0x65,0x66,0x6f,0x72,0x65,0x20,0x74,0x6f,0x20,0x6c,0x61,0x75,0x6e,
+        0x63,0x68,0x20,0x58,0x2c,0x20,0x75,0x73,0x65,0x20,0x79,0x6f,0x75,
+        0x72,0x20,0x72,0x63,0x2e,0x6c,0x6f,0x63,0x61,0x6c,0x2c,0x20,0x6c,
+        0x6f,0x63,0x61,0x6c,0x2e,0x73,0x74,0x61,0x72,0x74,0x20,0x2e,0x2e,
+        0x2e,0x0a,0x66,0x69,0x6c,0x65,0x20,0x6f,0x66,0x20,0x79,0x6f,0x75,
+        0x72,0x20,0x4c,0x69,0x6e,0x75,0x78,0x20,0x76,0x65,0x72,0x73,0x69,
+        0x6f,0x6e,0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x3c,0x70,0x3e,0x0a,0x39,
+        0x31,0x35,0x72,0x65,0x73,0x6f,0x6c,0x75,0x74,0x69,0x6f,0x6e,0x20,
+        0x73,0x75,0x70,0x70,0x6f,0x72,0x74,0x73,0x20,0x74,0x68,0x65,0x20,
+        0x38,0x34,0x35,0x47,0x2c,0x20,0x38,0x35,0x35,0x47,0x4d,0x2c,0x20,
+        0x38,0x36,0x35,0x47,0x2c,0x20,0x39,0x31,0x35,0x47,0x2c,0x20,0x39,
+        0x31,0x35,0x47,0x4d,0x2c,0x20,0x39,0x34,0x35,0x47,0x2c,0x20,0x61,
+        0x6e,0x64,0x20,0x39,0x34,0x35,0x47,0x4d,0x20,0x63,0x68,0x69,0x70,
+        0x73,0x65,0x74,0x73,0x2e,0x0a,0x3c,0x2f,0x70,0x3e,0x0a,0x2d,0x44,
+        0x65,0x73,0x3a,0x0a,0x00,
+};
+
+size_t _descfile_size=2240;
+size_t *descfile_size=&_descfile_size;
+
+void lazzy_test()
+{
+  // prepare a file
+  filesystem::TmpFile file;
+  ofstream str(file.path().asString().c_str(),ofstream::out);
+
+  if (!str.good())
+    ZYPP_THROW(Exception("cant open file"));
+
+  str << descfile;
+  str.flush();
+  str.close();
+  zypp::Lazy<std::string> lazzy_text(lazyTextFromFile( file.path(), 1415, 16));
+  
+  BOOST_CHECK_EQUAL( lazzy_text.value(), "3D Studio Binary" );
+  
+  zypp::Lazy<std::string> nofile_text(lazyTextFromFile( Pathname("notexists"), 0, 10));
+  BOOST_CHECK_THROW( nofile_text.value(), Exception );
+}
+
+test_suite*
+init_unit_test_suite( int argc, char* argv[] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "LazyTextTest" );
+    test->add( BOOST_TEST_CASE( &lazzy_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/PathInfo.cc b/tests/zypp/PathInfo.cc
new file mode 100644 (file)
index 0000000..aec22fd
--- /dev/null
@@ -0,0 +1,62 @@
+
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+// parameterized test
+// http://www.boost.org/libs/test/example/unit_test_example4.cpp
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/PathInfo.h"
+#include "zypp/TmpPath.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::filesystem;
+
+/**
+ * Test case for
+ * bool is_checksum( const Pathname & file, const CheckSum &checksum );
+ * std::string checksum( const Pathname & file, const std::string &algorithm );
+ */
+void pathinfo_checksum_test()
+{
+  const char *buffer = "I will test the checksum of this";
+  TmpFile file;
+  ofstream str(file.path().asString().c_str(),ofstream::out);
+
+  if (!str.good())
+    ZYPP_THROW(Exception("cant open file"));
+
+  str << buffer;
+  str.flush();
+  str.close();
+
+  CheckSum file_sha1("sha1", "142df4277c326f3549520478c188cab6e3b5d042");
+  CheckSum file_md5("md5", "f139a810b84d82d1f29fc53c5e59beae");
+
+  BOOST_CHECK_EQUAL( checksum( file.path(), "sha1"), "142df4277c326f3549520478c188cab6e3b5d042" );
+  BOOST_CHECK_EQUAL( checksum( file.path(), "md5"), "f139a810b84d82d1f29fc53c5e59beae" );
+
+  BOOST_REQUIRE( is_checksum( file.path(), file_sha1 ) );
+  BOOST_REQUIRE( is_checksum( file.path(), file_md5 ) );
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "PathInfoTest" );
+    test->add( BOOST_TEST_CASE( &pathinfo_checksum_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/PtrTypes.cc b/tests/zypp/PtrTypes.cc
new file mode 100644 (file)
index 0000000..25d5e94
--- /dev/null
@@ -0,0 +1,125 @@
+#include <iostream>
+
+#include "zypp/base/Logger.h"
+#include <zypp/base/PtrTypes.h>
+#include <zypp/base/ReferenceCounted.h>
+#include <zypp/base/ProvideNumericId.h>
+
+using std::endl;
+using namespace zypp;
+using namespace zypp::base;
+
+#define TRACE_TAG DBG << this->numericId() << " " << __PRETTY_FUNCTION__ << endl
+
+/** Logs Ctor, CopyCtor, Assign and Dtor. */
+template<class _Trace>
+  struct Trace : public ProvideNumericId<_Trace,unsigned>
+  {
+    Trace()                            { TRACE_TAG; }
+    Trace( const Trace & )             { TRACE_TAG; }
+    ~Trace()                           { TRACE_TAG; }
+    Trace & operator=( const Trace & ) { TRACE_TAG; return *this; }
+  };
+
+/** Data class for shared_ptr */
+struct NonIntrusive : private Trace<NonIntrusive>
+{
+  Trace<NonIntrusive>::numericId;
+};
+
+/** Data class for intrusive_ptr */
+struct Intrusive : public ReferenceCounted,
+                   private Trace<Intrusive>
+{
+  Trace<Intrusive>::numericId;
+};
+
+namespace zypp
+{
+  template<>
+    inline NonIntrusive * rwcowClone<NonIntrusive>( const NonIntrusive * rhs )
+    { return new NonIntrusive( *rhs ); }
+
+  template<>
+    inline Intrusive * rwcowClone<Intrusive>( const Intrusive * rhs )
+    { return new Intrusive( *rhs ); }
+
+}
+/******************************************************************
+**
+*/
+#define T_NULL       assert( !ptr )
+#define T_NOT_NULL   assert( ptr )
+#define T_UNIQUE     assert( ptr.unique() ); assert( ptr.use_count() < 2 )
+#define T_NOT_UNIQUE assert( !ptr.unique() ); assert( ptr.use_count() >= 2 )
+
+template<class _RW>
+  void test()
+  {
+    MIL << __PRETTY_FUNCTION__ << std::endl;
+    // typedefs that should be provided:
+    typedef typename _RW::_Ptr               _Ptr;
+    typedef typename _RW::_constPtr          _constPtr;
+    typedef typename _Ptr::element_type      _Ptr_element_type;
+    typedef typename _constPtr::element_type _constPtr_element_type;
+    // initial NULL
+    _RW ptr;
+    T_NULL;
+    T_UNIQUE;
+    // assign
+    ptr = _RW( new _Ptr_element_type );
+    T_NOT_NULL;
+    T_UNIQUE;
+    {
+      // share
+      _RW ptr2( ptr );
+      T_NOT_NULL;
+      T_NOT_UNIQUE;
+      // unshare
+      ptr2.reset();
+      T_NOT_NULL;
+      T_UNIQUE;
+    }
+    // assign
+    ptr.reset( 0 );
+    T_NULL;
+    T_UNIQUE;
+  }
+
+template<class _RW>
+  void cowt()
+  {
+    test<_RW>();
+    MIL << __PRETTY_FUNCTION__ << std::endl;
+    typedef typename _RW::_Ptr::element_type _Ptr_element_type;
+    // create
+    _RW ptr( new _Ptr_element_type );
+    unsigned long ptrid = ptr->numericId();
+    // share
+    _RW ptr2( ptr );
+    // clone aon access
+    unsigned long ptrid2 = ptr2->numericId();
+    assert( ptrid != ptrid2 );
+  }
+
+/******************************************************************
+**
+**      FUNCTION NAME : main
+**      FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+  MIL << "===[START]=====" << endl;
+  test<RW_pointer<NonIntrusive,          rw_pointer::Shared<NonIntrusive> > >();
+  test<RW_pointer<const NonIntrusive,    rw_pointer::Shared<NonIntrusive> > >();
+  test<RW_pointer<Intrusive,             rw_pointer::Intrusive<Intrusive> > >();
+  test<RW_pointer<const Intrusive,       rw_pointer::Intrusive<Intrusive> > >();
+
+  cowt<RWCOW_pointer<NonIntrusive,       rw_pointer::Shared<NonIntrusive> > >();
+  cowt<RWCOW_pointer<const NonIntrusive, rw_pointer::Shared<NonIntrusive> > >();
+  cowt<RWCOW_pointer<Intrusive,          rw_pointer::Intrusive<Intrusive> > >();
+  cowt<RWCOW_pointer<const Intrusive,    rw_pointer::Intrusive<Intrusive> > >();
+
+  MIL << "===[DONE]=====" << endl;
+  return 0;
+}
diff --git a/tests/zypp/PublicKey.cc b/tests/zypp/PublicKey.cc
new file mode 100644 (file)
index 0000000..ac0b6b2
--- /dev/null
@@ -0,0 +1,271 @@
+
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/PublicKey.h"
+#include "zypp/TmpPath.h"
+
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+
+/*
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.4.2 (GNU/Linux)
+
+mQGiBDnu9IERBACT8Y35+2vv4MGVKiLEMOl9GdST6MCkYS3yEKeueNWc+z/0Kvff
+4JctBsgs47tjmiI9sl0eHjm3gTR8rItXMN6sJEUHWzDP+Y0PFPboMvKx0FXl/A0d
+M+HFrruCgBlWt6FA+okRySQiliuI5phwqkXefl9AhkwR8xocQSVCFxcwvwCglVcO
+QliHu8jwRQHxlRE0tkwQQI0D+wfQwKdvhDplxHJ5nf7U8c/yE/vdvpN6lF0tmFrK
+XBUX+K7u4ifrZlQvj/81M4INjtXreqDiJtr99Rs6xa0ScZqITuZC4CWxJa9GynBE
+D3+D2t1V/f8l0smsuYoFOF7Ib49IkTdbtwAThlZp8bEhELBeGaPdNCcmfZ66rKUd
+G5sRA/9ovnc1krSQF2+sqB9/o7w5/q2qiyzwOSTnkjtBUVKn4zLUOf6aeBAoV6NM
+CC3Kj9aZHfA+ND0ehPaVGJgjaVNFhPi4x0e7BULdvgOoAqajLfvkURHAeSsxXIoE
+myW/xC1sBbDkDUIBSx5oej73XCZgnj/inphRqGpsb+1nKFvF+rQoU3VTRSBQYWNr
+YWdlIFNpZ25pbmcgS2V5IDxidWlsZEBzdXNlLmRlPohiBBMRAgAiBQJA2AY+AhsD
+BQkObd+9BAsHAwIDFQIDAxYCAQIeAQIXgAAKCRCoTtronIAKypCfAJ9RuZ6ZSV7Q
+W4pTgTIxQ+ABPp0sIwCffG9bCNnrETPlgOn+dGEkAWegKL+IRgQQEQIABgUCOnBe
+UgAKCRCeQOMQAAqrpNzOAKCL512FZvv4VZx94TpbA9lxyoAejACeOO1HIbActAev
+k5MUBhNeLZa/qM2JARUDBRA6cGBvd7LmAD0l09kBATWnB/9An5vfiUUE1VQnt+T/
+EYklES3tXXaJJp9pHMa4fzFa8jPVtv5UBHGee3XoUNDVwM2OgSEISZxbzdXGnqIl
+cT08TzBUD9i579uifklLsnr35SJDZ6ram51/CWOnnaVhUzneOA9gTPSr+/fT3WeV
+nwJiQCQ30kNLWVXWATMnsnT486eAOlT6UNBPYQLpUprF5Yryk23pQUPAgJENDEqe
+U6iIO9Ot1ZPtB0lniw+/xCi13D360o1tZDYOp0hHHJN3D3EN8C1yPqZd5CvvznYv
+B6bWBIpWcRgdn2DUVMmpU661jwqGlRz1F84JG/xe4jGuzgpJt9IXSzyohEJB6XG5
++D0BuQINBDnu9JIQCACEkdBN6Mxf5WvqDWkcMRy6wnrd9DYJ8UUTmIT2iQf07tRU
+KJJ9v0JXfx2Z4d08IQSMNRaq4VgSe+PdYgIy0fbj23Via5/gO7fJEpD2hd2f+pMn
+OWvH2rOOIbeYfuhzAc6BQjAKtmgR0ERUTafTM9Wb6F13CNZZNZfDqnFDP6L12w3z
+3F7FFXkz07Rs3AIto1ZfYZd4sCSpMr/0S5nLrHbIvGLp271hhQBeRmmoGEKO2JRe
+lGgUJ2CUzOdtwDIKT0LbCpvaP8PVnYF5IFoYJIWRHqlEt5ucTXstZy7vYjL6vTP4
+l5xs+LIOkNmPhqmfsgLzVo0UaLt80hOwc4NvDCOLAAMGB/9g+9V3ORzw4LvO1pwR
+YJqfDKUq/EJ0rNMMD4N8RLpZRhKHKJUm9nNHLbksnlZwrbSTM5LpC/U6sheLP+l0
+bLVoq0lmsCcUSyh+mY6PxWirLIWCn/IAZAGnXb6Zd6TtIJlGG6pqUN8QxGJYQnon
+l0uTJKHJENbI9sWHQdcTtBMc34gorHFCo1Bcvpnc1LFLrWn7mfoGx6INQjf3HGQp
+MXAWuSBQhzkazY6vaWFpa8bBJ+gKbBuySWzNm3rFtT5HRKMWpO+M9bHp4d+puY0L
+1YwN1OMatcMMpcWnZpiWiR83oi32+xtWUY2U7Ae38mMag8zFbpeqPQUsDv9V7CAJ
+1dbriEwEGBECAAwFAkDYBnoFCQ5t3+gACgkQqE7a6JyACspnpgCfRbYwxT3iq+9l
+/PgNTUNTZOlof2oAn25y0eGi0371jap9kOV6uq71sUuO
+=pJli
+-----END PGP PUBLIC KEY BLOCK-----
+*/
+
+/**
+ * Array version of the above key
+ */
+char susekey[]=
+{
+        0x2d,0x2d,0x2d,0x2d,0x2d,0x42,0x45,0x47,0x49,0x4e,0x20,0x50,0x47,
+        0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,0x4b,0x45,0x59,0x20,
+        0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d,0x2d,0x0a,0x56,0x65,
+        0x72,0x73,0x69,0x6f,0x6e,0x3a,0x20,0x47,0x6e,0x75,0x50,0x47,0x20,
+        0x76,0x31,0x2e,0x34,0x2e,0x32,0x20,0x28,0x47,0x4e,0x55,0x2f,0x4c,
+        0x69,0x6e,0x75,0x78,0x29,0x0a,0x0a,0x6d,0x51,0x47,0x69,0x42,0x44,
+        0x6e,0x75,0x39,0x49,0x45,0x52,0x42,0x41,0x43,0x54,0x38,0x59,0x33,
+        0x35,0x2b,0x32,0x76,0x76,0x34,0x4d,0x47,0x56,0x4b,0x69,0x4c,0x45,
+        0x4d,0x4f,0x6c,0x39,0x47,0x64,0x53,0x54,0x36,0x4d,0x43,0x6b,0x59,
+        0x53,0x33,0x79,0x45,0x4b,0x65,0x75,0x65,0x4e,0x57,0x63,0x2b,0x7a,
+        0x2f,0x30,0x4b,0x76,0x66,0x66,0x0a,0x34,0x4a,0x63,0x74,0x42,0x73,
+        0x67,0x73,0x34,0x37,0x74,0x6a,0x6d,0x69,0x49,0x39,0x73,0x6c,0x30,
+        0x65,0x48,0x6a,0x6d,0x33,0x67,0x54,0x52,0x38,0x72,0x49,0x74,0x58,
+        0x4d,0x4e,0x36,0x73,0x4a,0x45,0x55,0x48,0x57,0x7a,0x44,0x50,0x2b,
+        0x59,0x30,0x50,0x46,0x50,0x62,0x6f,0x4d,0x76,0x4b,0x78,0x30,0x46,
+        0x58,0x6c,0x2f,0x41,0x30,0x64,0x0a,0x4d,0x2b,0x48,0x46,0x72,0x72,
+        0x75,0x43,0x67,0x42,0x6c,0x57,0x74,0x36,0x46,0x41,0x2b,0x6f,0x6b,
+        0x52,0x79,0x53,0x51,0x69,0x6c,0x69,0x75,0x49,0x35,0x70,0x68,0x77,
+        0x71,0x6b,0x58,0x65,0x66,0x6c,0x39,0x41,0x68,0x6b,0x77,0x52,0x38,
+        0x78,0x6f,0x63,0x51,0x53,0x56,0x43,0x46,0x78,0x63,0x77,0x76,0x77,
+        0x43,0x67,0x6c,0x56,0x63,0x4f,0x0a,0x51,0x6c,0x69,0x48,0x75,0x38,
+        0x6a,0x77,0x52,0x51,0x48,0x78,0x6c,0x52,0x45,0x30,0x74,0x6b,0x77,
+        0x51,0x51,0x49,0x30,0x44,0x2b,0x77,0x66,0x51,0x77,0x4b,0x64,0x76,
+        0x68,0x44,0x70,0x6c,0x78,0x48,0x4a,0x35,0x6e,0x66,0x37,0x55,0x38,
+        0x63,0x2f,0x79,0x45,0x2f,0x76,0x64,0x76,0x70,0x4e,0x36,0x6c,0x46,
+        0x30,0x74,0x6d,0x46,0x72,0x4b,0x0a,0x58,0x42,0x55,0x58,0x2b,0x4b,
+        0x37,0x75,0x34,0x69,0x66,0x72,0x5a,0x6c,0x51,0x76,0x6a,0x2f,0x38,
+        0x31,0x4d,0x34,0x49,0x4e,0x6a,0x74,0x58,0x72,0x65,0x71,0x44,0x69,
+        0x4a,0x74,0x72,0x39,0x39,0x52,0x73,0x36,0x78,0x61,0x30,0x53,0x63,
+        0x5a,0x71,0x49,0x54,0x75,0x5a,0x43,0x34,0x43,0x57,0x78,0x4a,0x61,
+        0x39,0x47,0x79,0x6e,0x42,0x45,0x0a,0x44,0x33,0x2b,0x44,0x32,0x74,
+        0x31,0x56,0x2f,0x66,0x38,0x6c,0x30,0x73,0x6d,0x73,0x75,0x59,0x6f,
+        0x46,0x4f,0x46,0x37,0x49,0x62,0x34,0x39,0x49,0x6b,0x54,0x64,0x62,
+        0x74,0x77,0x41,0x54,0x68,0x6c,0x5a,0x70,0x38,0x62,0x45,0x68,0x45,
+        0x4c,0x42,0x65,0x47,0x61,0x50,0x64,0x4e,0x43,0x63,0x6d,0x66,0x5a,
+        0x36,0x36,0x72,0x4b,0x55,0x64,0x0a,0x47,0x35,0x73,0x52,0x41,0x2f,
+        0x39,0x6f,0x76,0x6e,0x63,0x31,0x6b,0x72,0x53,0x51,0x46,0x32,0x2b,
+        0x73,0x71,0x42,0x39,0x2f,0x6f,0x37,0x77,0x35,0x2f,0x71,0x32,0x71,
+        0x69,0x79,0x7a,0x77,0x4f,0x53,0x54,0x6e,0x6b,0x6a,0x74,0x42,0x55,
+        0x56,0x4b,0x6e,0x34,0x7a,0x4c,0x55,0x4f,0x66,0x36,0x61,0x65,0x42,
+        0x41,0x6f,0x56,0x36,0x4e,0x4d,0x0a,0x43,0x43,0x33,0x4b,0x6a,0x39,
+        0x61,0x5a,0x48,0x66,0x41,0x2b,0x4e,0x44,0x30,0x65,0x68,0x50,0x61,
+        0x56,0x47,0x4a,0x67,0x6a,0x61,0x56,0x4e,0x46,0x68,0x50,0x69,0x34,
+        0x78,0x30,0x65,0x37,0x42,0x55,0x4c,0x64,0x76,0x67,0x4f,0x6f,0x41,
+        0x71,0x61,0x6a,0x4c,0x66,0x76,0x6b,0x55,0x52,0x48,0x41,0x65,0x53,
+        0x73,0x78,0x58,0x49,0x6f,0x45,0x0a,0x6d,0x79,0x57,0x2f,0x78,0x43,
+        0x31,0x73,0x42,0x62,0x44,0x6b,0x44,0x55,0x49,0x42,0x53,0x78,0x35,
+        0x6f,0x65,0x6a,0x37,0x33,0x58,0x43,0x5a,0x67,0x6e,0x6a,0x2f,0x69,
+        0x6e,0x70,0x68,0x52,0x71,0x47,0x70,0x73,0x62,0x2b,0x31,0x6e,0x4b,
+        0x46,0x76,0x46,0x2b,0x72,0x51,0x6f,0x55,0x33,0x56,0x54,0x52,0x53,
+        0x42,0x51,0x59,0x57,0x4e,0x72,0x0a,0x59,0x57,0x64,0x6c,0x49,0x46,
+        0x4e,0x70,0x5a,0x32,0x35,0x70,0x62,0x6d,0x63,0x67,0x53,0x32,0x56,
+        0x35,0x49,0x44,0x78,0x69,0x64,0x57,0x6c,0x73,0x5a,0x45,0x42,0x7a,
+        0x64,0x58,0x4e,0x6c,0x4c,0x6d,0x52,0x6c,0x50,0x6f,0x68,0x69,0x42,
+        0x42,0x4d,0x52,0x41,0x67,0x41,0x69,0x42,0x51,0x4a,0x41,0x32,0x41,
+        0x59,0x2b,0x41,0x68,0x73,0x44,0x0a,0x42,0x51,0x6b,0x4f,0x62,0x64,
+        0x2b,0x39,0x42,0x41,0x73,0x48,0x41,0x77,0x49,0x44,0x46,0x51,0x49,
+        0x44,0x41,0x78,0x59,0x43,0x41,0x51,0x49,0x65,0x41,0x51,0x49,0x58,
+        0x67,0x41,0x41,0x4b,0x43,0x52,0x43,0x6f,0x54,0x74,0x72,0x6f,0x6e,
+        0x49,0x41,0x4b,0x79,0x70,0x43,0x66,0x41,0x4a,0x39,0x52,0x75,0x5a,
+        0x36,0x5a,0x53,0x56,0x37,0x51,0x0a,0x57,0x34,0x70,0x54,0x67,0x54,
+        0x49,0x78,0x51,0x2b,0x41,0x42,0x50,0x70,0x30,0x73,0x49,0x77,0x43,
+        0x66,0x66,0x47,0x39,0x62,0x43,0x4e,0x6e,0x72,0x45,0x54,0x50,0x6c,
+        0x67,0x4f,0x6e,0x2b,0x64,0x47,0x45,0x6b,0x41,0x57,0x65,0x67,0x4b,
+        0x4c,0x2b,0x49,0x52,0x67,0x51,0x51,0x45,0x51,0x49,0x41,0x42,0x67,
+        0x55,0x43,0x4f,0x6e,0x42,0x65,0x0a,0x55,0x67,0x41,0x4b,0x43,0x52,
+        0x43,0x65,0x51,0x4f,0x4d,0x51,0x41,0x41,0x71,0x72,0x70,0x4e,0x7a,
+        0x4f,0x41,0x4b,0x43,0x4c,0x35,0x31,0x32,0x46,0x5a,0x76,0x76,0x34,
+        0x56,0x5a,0x78,0x39,0x34,0x54,0x70,0x62,0x41,0x39,0x6c,0x78,0x79,
+        0x6f,0x41,0x65,0x6a,0x41,0x43,0x65,0x4f,0x4f,0x31,0x48,0x49,0x62,
+        0x41,0x63,0x74,0x41,0x65,0x76,0x0a,0x6b,0x35,0x4d,0x55,0x42,0x68,
+        0x4e,0x65,0x4c,0x5a,0x61,0x2f,0x71,0x4d,0x32,0x4a,0x41,0x52,0x55,
+        0x44,0x42,0x52,0x41,0x36,0x63,0x47,0x42,0x76,0x64,0x37,0x4c,0x6d,
+        0x41,0x44,0x30,0x6c,0x30,0x39,0x6b,0x42,0x41,0x54,0x57,0x6e,0x42,
+        0x2f,0x39,0x41,0x6e,0x35,0x76,0x66,0x69,0x55,0x55,0x45,0x31,0x56,
+        0x51,0x6e,0x74,0x2b,0x54,0x2f,0x0a,0x45,0x59,0x6b,0x6c,0x45,0x53,
+        0x33,0x74,0x58,0x58,0x61,0x4a,0x4a,0x70,0x39,0x70,0x48,0x4d,0x61,
+        0x34,0x66,0x7a,0x46,0x61,0x38,0x6a,0x50,0x56,0x74,0x76,0x35,0x55,
+        0x42,0x48,0x47,0x65,0x65,0x33,0x58,0x6f,0x55,0x4e,0x44,0x56,0x77,
+        0x4d,0x32,0x4f,0x67,0x53,0x45,0x49,0x53,0x5a,0x78,0x62,0x7a,0x64,
+        0x58,0x47,0x6e,0x71,0x49,0x6c,0x0a,0x63,0x54,0x30,0x38,0x54,0x7a,
+        0x42,0x55,0x44,0x39,0x69,0x35,0x37,0x39,0x75,0x69,0x66,0x6b,0x6c,
+        0x4c,0x73,0x6e,0x72,0x33,0x35,0x53,0x4a,0x44,0x5a,0x36,0x72,0x61,
+        0x6d,0x35,0x31,0x2f,0x43,0x57,0x4f,0x6e,0x6e,0x61,0x56,0x68,0x55,
+        0x7a,0x6e,0x65,0x4f,0x41,0x39,0x67,0x54,0x50,0x53,0x72,0x2b,0x2f,
+        0x66,0x54,0x33,0x57,0x65,0x56,0x0a,0x6e,0x77,0x4a,0x69,0x51,0x43,
+        0x51,0x33,0x30,0x6b,0x4e,0x4c,0x57,0x56,0x58,0x57,0x41,0x54,0x4d,
+        0x6e,0x73,0x6e,0x54,0x34,0x38,0x36,0x65,0x41,0x4f,0x6c,0x54,0x36,
+        0x55,0x4e,0x42,0x50,0x59,0x51,0x4c,0x70,0x55,0x70,0x72,0x46,0x35,
+        0x59,0x72,0x79,0x6b,0x32,0x33,0x70,0x51,0x55,0x50,0x41,0x67,0x4a,
+        0x45,0x4e,0x44,0x45,0x71,0x65,0x0a,0x55,0x36,0x69,0x49,0x4f,0x39,
+        0x4f,0x74,0x31,0x5a,0x50,0x74,0x42,0x30,0x6c,0x6e,0x69,0x77,0x2b,
+        0x2f,0x78,0x43,0x69,0x31,0x33,0x44,0x33,0x36,0x30,0x6f,0x31,0x74,
+        0x5a,0x44,0x59,0x4f,0x70,0x30,0x68,0x48,0x48,0x4a,0x4e,0x33,0x44,
+        0x33,0x45,0x4e,0x38,0x43,0x31,0x79,0x50,0x71,0x5a,0x64,0x35,0x43,
+        0x76,0x76,0x7a,0x6e,0x59,0x76,0x0a,0x42,0x36,0x62,0x57,0x42,0x49,
+        0x70,0x57,0x63,0x52,0x67,0x64,0x6e,0x32,0x44,0x55,0x56,0x4d,0x6d,
+        0x70,0x55,0x36,0x36,0x31,0x6a,0x77,0x71,0x47,0x6c,0x52,0x7a,0x31,
+        0x46,0x38,0x34,0x4a,0x47,0x2f,0x78,0x65,0x34,0x6a,0x47,0x75,0x7a,
+        0x67,0x70,0x4a,0x74,0x39,0x49,0x58,0x53,0x7a,0x79,0x6f,0x68,0x45,
+        0x4a,0x42,0x36,0x58,0x47,0x35,0x0a,0x2b,0x44,0x30,0x42,0x75,0x51,
+        0x49,0x4e,0x42,0x44,0x6e,0x75,0x39,0x4a,0x49,0x51,0x43,0x41,0x43,
+        0x45,0x6b,0x64,0x42,0x4e,0x36,0x4d,0x78,0x66,0x35,0x57,0x76,0x71,
+        0x44,0x57,0x6b,0x63,0x4d,0x52,0x79,0x36,0x77,0x6e,0x72,0x64,0x39,
+        0x44,0x59,0x4a,0x38,0x55,0x55,0x54,0x6d,0x49,0x54,0x32,0x69,0x51,
+        0x66,0x30,0x37,0x74,0x52,0x55,0x0a,0x4b,0x4a,0x4a,0x39,0x76,0x30,
+        0x4a,0x58,0x66,0x78,0x32,0x5a,0x34,0x64,0x30,0x38,0x49,0x51,0x53,
+        0x4d,0x4e,0x52,0x61,0x71,0x34,0x56,0x67,0x53,0x65,0x2b,0x50,0x64,
+        0x59,0x67,0x49,0x79,0x30,0x66,0x62,0x6a,0x32,0x33,0x56,0x69,0x61,
+        0x35,0x2f,0x67,0x4f,0x37,0x66,0x4a,0x45,0x70,0x44,0x32,0x68,0x64,
+        0x32,0x66,0x2b,0x70,0x4d,0x6e,0x0a,0x4f,0x57,0x76,0x48,0x32,0x72,
+        0x4f,0x4f,0x49,0x62,0x65,0x59,0x66,0x75,0x68,0x7a,0x41,0x63,0x36,
+        0x42,0x51,0x6a,0x41,0x4b,0x74,0x6d,0x67,0x52,0x30,0x45,0x52,0x55,
+        0x54,0x61,0x66,0x54,0x4d,0x39,0x57,0x62,0x36,0x46,0x31,0x33,0x43,
+        0x4e,0x5a,0x5a,0x4e,0x5a,0x66,0x44,0x71,0x6e,0x46,0x44,0x50,0x36,
+        0x4c,0x31,0x32,0x77,0x33,0x7a,0x0a,0x33,0x46,0x37,0x46,0x46,0x58,
+        0x6b,0x7a,0x30,0x37,0x52,0x73,0x33,0x41,0x49,0x74,0x6f,0x31,0x5a,
+        0x66,0x59,0x5a,0x64,0x34,0x73,0x43,0x53,0x70,0x4d,0x72,0x2f,0x30,
+        0x53,0x35,0x6e,0x4c,0x72,0x48,0x62,0x49,0x76,0x47,0x4c,0x70,0x32,
+        0x37,0x31,0x68,0x68,0x51,0x42,0x65,0x52,0x6d,0x6d,0x6f,0x47,0x45,
+        0x4b,0x4f,0x32,0x4a,0x52,0x65,0x0a,0x6c,0x47,0x67,0x55,0x4a,0x32,
+        0x43,0x55,0x7a,0x4f,0x64,0x74,0x77,0x44,0x49,0x4b,0x54,0x30,0x4c,
+        0x62,0x43,0x70,0x76,0x61,0x50,0x38,0x50,0x56,0x6e,0x59,0x46,0x35,
+        0x49,0x46,0x6f,0x59,0x4a,0x49,0x57,0x52,0x48,0x71,0x6c,0x45,0x74,
+        0x35,0x75,0x63,0x54,0x58,0x73,0x74,0x5a,0x79,0x37,0x76,0x59,0x6a,
+        0x4c,0x36,0x76,0x54,0x50,0x34,0x0a,0x6c,0x35,0x78,0x73,0x2b,0x4c,
+        0x49,0x4f,0x6b,0x4e,0x6d,0x50,0x68,0x71,0x6d,0x66,0x73,0x67,0x4c,
+        0x7a,0x56,0x6f,0x30,0x55,0x61,0x4c,0x74,0x38,0x30,0x68,0x4f,0x77,
+        0x63,0x34,0x4e,0x76,0x44,0x43,0x4f,0x4c,0x41,0x41,0x4d,0x47,0x42,
+        0x2f,0x39,0x67,0x2b,0x39,0x56,0x33,0x4f,0x52,0x7a,0x77,0x34,0x4c,
+        0x76,0x4f,0x31,0x70,0x77,0x52,0x0a,0x59,0x4a,0x71,0x66,0x44,0x4b,
+        0x55,0x71,0x2f,0x45,0x4a,0x30,0x72,0x4e,0x4d,0x4d,0x44,0x34,0x4e,
+        0x38,0x52,0x4c,0x70,0x5a,0x52,0x68,0x4b,0x48,0x4b,0x4a,0x55,0x6d,
+        0x39,0x6e,0x4e,0x48,0x4c,0x62,0x6b,0x73,0x6e,0x6c,0x5a,0x77,0x72,
+        0x62,0x53,0x54,0x4d,0x35,0x4c,0x70,0x43,0x2f,0x55,0x36,0x73,0x68,
+        0x65,0x4c,0x50,0x2b,0x6c,0x30,0x0a,0x62,0x4c,0x56,0x6f,0x71,0x30,
+        0x6c,0x6d,0x73,0x43,0x63,0x55,0x53,0x79,0x68,0x2b,0x6d,0x59,0x36,
+        0x50,0x78,0x57,0x69,0x72,0x4c,0x49,0x57,0x43,0x6e,0x2f,0x49,0x41,
+        0x5a,0x41,0x47,0x6e,0x58,0x62,0x36,0x5a,0x64,0x36,0x54,0x74,0x49,
+        0x4a,0x6c,0x47,0x47,0x36,0x70,0x71,0x55,0x4e,0x38,0x51,0x78,0x47,
+        0x4a,0x59,0x51,0x6e,0x6f,0x6e,0x0a,0x6c,0x30,0x75,0x54,0x4a,0x4b,
+        0x48,0x4a,0x45,0x4e,0x62,0x49,0x39,0x73,0x57,0x48,0x51,0x64,0x63,
+        0x54,0x74,0x42,0x4d,0x63,0x33,0x34,0x67,0x6f,0x72,0x48,0x46,0x43,
+        0x6f,0x31,0x42,0x63,0x76,0x70,0x6e,0x63,0x31,0x4c,0x46,0x4c,0x72,
+        0x57,0x6e,0x37,0x6d,0x66,0x6f,0x47,0x78,0x36,0x49,0x4e,0x51,0x6a,
+        0x66,0x33,0x48,0x47,0x51,0x70,0x0a,0x4d,0x58,0x41,0x57,0x75,0x53,
+        0x42,0x51,0x68,0x7a,0x6b,0x61,0x7a,0x59,0x36,0x76,0x61,0x57,0x46,
+        0x70,0x61,0x38,0x62,0x42,0x4a,0x2b,0x67,0x4b,0x62,0x42,0x75,0x79,
+        0x53,0x57,0x7a,0x4e,0x6d,0x33,0x72,0x46,0x74,0x54,0x35,0x48,0x52,
+        0x4b,0x4d,0x57,0x70,0x4f,0x2b,0x4d,0x39,0x62,0x48,0x70,0x34,0x64,
+        0x2b,0x70,0x75,0x59,0x30,0x4c,0x0a,0x31,0x59,0x77,0x4e,0x31,0x4f,
+        0x4d,0x61,0x74,0x63,0x4d,0x4d,0x70,0x63,0x57,0x6e,0x5a,0x70,0x69,
+        0x57,0x69,0x52,0x38,0x33,0x6f,0x69,0x33,0x32,0x2b,0x78,0x74,0x57,
+        0x55,0x59,0x32,0x55,0x37,0x41,0x65,0x33,0x38,0x6d,0x4d,0x61,0x67,
+        0x38,0x7a,0x46,0x62,0x70,0x65,0x71,0x50,0x51,0x55,0x73,0x44,0x76,
+        0x39,0x56,0x37,0x43,0x41,0x4a,0x0a,0x31,0x64,0x62,0x72,0x69,0x45,
+        0x77,0x45,0x47,0x42,0x45,0x43,0x41,0x41,0x77,0x46,0x41,0x6b,0x44,
+        0x59,0x42,0x6e,0x6f,0x46,0x43,0x51,0x35,0x74,0x33,0x2b,0x67,0x41,
+        0x43,0x67,0x6b,0x51,0x71,0x45,0x37,0x61,0x36,0x4a,0x79,0x41,0x43,
+        0x73,0x70,0x6e,0x70,0x67,0x43,0x66,0x52,0x62,0x59,0x77,0x78,0x54,
+        0x33,0x69,0x71,0x2b,0x39,0x6c,0x0a,0x2f,0x50,0x67,0x4e,0x54,0x55,
+        0x4e,0x54,0x5a,0x4f,0x6c,0x6f,0x66,0x32,0x6f,0x41,0x6e,0x32,0x35,
+        0x79,0x30,0x65,0x47,0x69,0x30,0x33,0x37,0x31,0x6a,0x61,0x70,0x39,
+        0x6b,0x4f,0x56,0x36,0x75,0x71,0x37,0x31,0x73,0x55,0x75,0x4f,0x0a,
+        0x3d,0x70,0x4a,0x6c,0x69,0x0a,0x2d,0x2d,0x2d,0x2d,0x2d,0x45,0x4e,
+        0x44,0x20,0x50,0x47,0x50,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,
+        0x4b,0x45,0x59,0x20,0x42,0x4c,0x4f,0x43,0x4b,0x2d,0x2d,0x2d,0x2d,
+        0x2d,0x0a,0x00,
+};
+
+size_t _susekey_size=2173;
+size_t *susekey_size=&_susekey_size;
+
+void publickey_test()
+{
+  BOOST_CHECK_THROW( zypp::PublicKey("nonexistant"), Exception );
+  
+  filesystem::TmpFile file;
+  ofstream str(file.path().asString().c_str(),ofstream::out);
+
+  if (!str.good())
+    ZYPP_THROW(Exception("cant open file"));
+
+  str << susekey;
+  str.flush();
+  str.close();
+  zypp::PublicKey k2(file.path());
+  
+  BOOST_CHECK_EQUAL( k2.id(), "A84EDAE89C800ACA" );
+  BOOST_CHECK_EQUAL( k2.name(), "SuSE Package Signing Key <build@suse.de>" );
+  BOOST_CHECK_EQUAL( k2.fingerprint(), "79C179B2E1C820C1890F9994A84EDAE89C800ACA" );
+  BOOST_REQUIRE( k2.path() != Pathname() );
+  BOOST_REQUIRE( k2 == k2 );
+  // test for a empty key
+  zypp::PublicKey empty_key;
+  BOOST_REQUIRE( ! empty_key.isValid() );
+}
+
+test_suite*
+init_unit_test_suite( int argc, char* argv[] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" );
+    test->add( BOOST_TEST_CASE( &publickey_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/RWPtr.cc b/tests/zypp/RWPtr.cc
new file mode 100644 (file)
index 0000000..6e1ddc6
--- /dev/null
@@ -0,0 +1,82 @@
+#include <zypp/base/PtrTypes.h>
+#include <string>
+#include <iostream>
+
+struct Foo
+{
+  int _foo;
+
+  Foo(int foo=0): _foo(foo)
+  {
+    std::cerr << "created Foo(" << _foo << ")" << std::endl;
+  }
+  ~Foo()
+  {
+    std::cerr << "destroy Foo(" << _foo << ")" << std::endl;
+  }
+};
+
+#define REF_TEST(ref,msg,exp,res) \
+do { \
+  bool unique = exp; \
+  std::cerr << msg << std::endl; \
+  if( ref) { \
+    std::cerr << "ref contains object" << std::endl; \
+  } else { \
+    std::cerr << "ref contains no object" << std::endl; \
+  } \
+  std::cerr << "ref counter is " << ref.use_count() << std::endl; \
+  if( ref.unique()) { \
+    std::cerr << "ref is unique" << std::endl; \
+    if( unique) { \
+      std::cerr << "EXPECTED" << std::endl; \
+    } else { \
+      std::cerr << "NOT EXPECTED" << std::endl; \
+      res = 1; \
+    } \
+  } else { \
+    std::cerr << "ref is shared" << std::endl; \
+    if( !unique) { \
+      std::cerr << "EXPECTED" << std::endl; \
+    } else { \
+      std::cerr << "NOT EXPECTED" << std::endl; \
+      res = 1;  \
+    } \
+  } \
+  std::cerr << std::endl; \
+} while(0);
+
+int main(int argc, char *argv[])
+{
+  (void)argv;
+
+  bool skip_reset = argc > 1;
+  int  result = 0;
+
+  typedef zypp::RW_pointer<Foo> FooRef;
+
+  FooRef ref;
+  REF_TEST(ref,"=== REF(nil)", true, result);
+
+  ref.reset(new Foo(42));
+  REF_TEST(ref,"=== REF(object)", true, result);
+
+  {
+    FooRef ref2(ref);
+    REF_TEST(ref,"=== REF2(REF)", false, result);
+  }
+
+  REF_TEST(ref,"=== REF(object), REF2 out of scope now", true, result);
+
+  if( !skip_reset)
+  {
+    ref.reset();
+    REF_TEST(ref,"=== REF(nil), reset()", true, result);
+  }
+
+  std::cerr << "RESULT: "
+            << (result == 0 ? "PASSED" : "FAILED")
+            << std::endl;
+  return result;
+}
+
diff --git a/tests/zypp/Signature.cc b/tests/zypp/Signature.cc
new file mode 100644 (file)
index 0000000..8bc7518
--- /dev/null
@@ -0,0 +1,30 @@
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/Signature.h"
+
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+
+
+void signature_test()
+{  
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "SignaureTest" );
+    test->add( BOOST_TEST_CASE( &signature_test ), 0 /* expected zero error */ );
+    return test;
+}
+
diff --git a/tests/zypp/TranslatedText.cc b/tests/zypp/TranslatedText.cc
new file mode 100644 (file)
index 0000000..2cced62
--- /dev/null
@@ -0,0 +1,69 @@
+// Arch.cc
+//
+// tests for Arch
+//
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
+using namespace std;
+using namespace zypp;
+
+int main( int argc, char * argv[] )
+{
+  ZYpp::Ptr god;
+  
+  try { 
+    god = getZYpp();
+  }
+  catch( const Exception &e )
+  {
+    return 99;
+  }
+  
+  TranslatedText testTT;
+  MIL << "Locale: en" << std::endl;
+  god->setTextLocale(Locale("en"));
+  testTT.setText("default");
+  if ( testTT.text() != "default" )
+    return 2;
+  
+  testTT.setText("default english", Locale("en"));
+  if ( testTT.text() != "default english" )
+    return 3;
+  
+  MIL << "Locale: es_ES" << std::endl;
+  god->setTextLocale(Locale("es_ES"));
+  
+  if ( testTT.text() != "default english" )
+  {
+    ERR << testTT.text() << std::endl;
+    return 4;
+  }
+    
+  testTT.setText("hola esto es neutro", Locale("es"));
+  testTT.setText("this is neutral", Locale("en"));
+  
+  if ( testTT.text() != "hola esto es neutro" )
+    return 5;
+    
+  testTT.setText("hola Spain", Locale("es_ES"));
+  if ( testTT.text() != "hola Spain" )
+    return 6;
+  
+  MIL << "Locale: null" << std::endl;
+  god->setTextLocale(Locale());
+  if ( testTT.text() != "default" )
+  {
+    ERR << testTT.text() << std::endl;
+    return 7;
+  }
+  
+  return 0;
+}
diff --git a/tests/zypp/Url.cc b/tests/zypp/Url.cc
new file mode 100644 (file)
index 0000000..0e5535d
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+** Check if the url by scheme repository works, e.g.
+** if there are some initialization order problems
+** (ViewOption) causing asString to format its string
+** differently than configured.
+*/
+
+#include "zypp/base/Exception.h"
+#include "zypp/Url.h"
+#include <stdexcept>
+#include <iostream>
+#include <cassert>
+
+// Boost.Test
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+using boost::test_tools::close_at_tolerance;
+
+using namespace zypp;
+
+void test_url1(void)
+{
+    std::string str, one, two;
+    zypp::Url   url;
+
+
+    // asString & asCompleteString should not print "mailto://"
+    str = "mailto:feedback@example.com?subject=hello";
+    url = str;
+    BOOST_CHECK_EQUAL( str, url.asString() );
+    BOOST_CHECK_EQUAL( str, url.asCompleteString() );
+
+    // asString & asCompleteString should add empty authority
+    // "dvd://...", except we request to avoid it.
+    str = "dvd:/srv/ftp";
+    one = "dvd:///srv/ftp";
+    two = "dvd:///srv/ftp";
+    url = str;
+
+    BOOST_CHECK_EQUAL( one, url.asString() );
+    BOOST_CHECK_EQUAL( two, url.asCompleteString() );
+    BOOST_CHECK_EQUAL( str, url.asString(zypp::url::ViewOptions() -
+                                 zypp::url::ViewOption::EMPTY_AUTHORITY));
+
+    // asString shouldn't print the password, asCompleteString should
+    // further, the "//" at the begin of the path should become "/%2F"
+    str = "ftp://user:pass@localhost//srv/ftp";
+    one = "ftp://user@localhost/%2Fsrv/ftp";
+    two = "ftp://user:pass@localhost/%2Fsrv/ftp";
+    url = str;
+
+    BOOST_CHECK_EQUAL( one, url.asString() );
+    BOOST_CHECK_EQUAL( two, url.asCompleteString() );
+
+    // asString shouldn't print the password, asCompleteString should.
+    // further, the "//" at the begin of the path should be keept.
+    str = "http://user:pass@localhost//srv/ftp";
+    one = "http://user@localhost//srv/ftp";
+    two = str;
+    url = str;
+
+    BOOST_CHECK_EQUAL( one, url.asString() );
+    BOOST_CHECK_EQUAL( two, url.asCompleteString() );
+
+    str = "file:./srv/ftp";
+    BOOST_CHECK_EQUAL( zypp::Url(str).asString(), str );
+
+    str = "ftp://foo//srv/ftp";
+    BOOST_CHECK_EQUAL( zypp::Url(str).asString(), "ftp://foo/%2Fsrv/ftp" );
+
+    str = "FTP://user@local%68ost/%2f/srv/ftp";
+    BOOST_CHECK_EQUAL( zypp::Url(str).asString(), "ftp://user@localhost/%2f/srv/ftp" );
+
+    str = "http://[::1]/foo/bar";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString() );
+
+    str = "http://:@just-localhost.example.net:8080/";
+    BOOST_CHECK_EQUAL( zypp::Url(str).asString(), "http://just-localhost.example.net:8080/" );
+
+    str = "mailto:feedback@example.com?subject=hello";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString() );
+
+    str = "nfs://nfs-server/foo/bar/trala";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString() );
+
+    str = "ldap://example.net/dc=example,dc=net?cn,sn?sub?(cn=*)#x";
+    BOOST_CHECK_THROW( zypp::Url(str).asString(), url::UrlNotAllowedException );
+  
+    str = "ldap://example.net/dc=example,dc=net?cn,sn?sub?(cn=*)";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString() );
+
+    // parseable but invalid, since no host avaliable
+    str = "ldap:///dc=foo,dc=bar";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString());
+    BOOST_CHECK( !zypp::Url(str).isValid());
+
+    // throws:  host is mandatory
+    str = "ftp:///foo/bar";
+    BOOST_CHECK_THROW(zypp::Url(str).asString(), url::UrlNotAllowedException );
+
+    // throws:  host is mandatory
+    str = "http:///%2f/srv/ftp";
+    BOOST_CHECK_THROW(zypp::Url(str).asString(), url::UrlNotAllowedException );
+
+    // OK, host allowed in file-url
+    str = "file://localhost/some/path";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString());
+
+    // throws:  host not allowed
+    str = "cd://localhost/some/path";
+    BOOST_CHECK_THROW(zypp::Url(str).asString(), url::UrlNotAllowedException );
+
+    // throws: no path (email)
+    str = "mailto:";
+    BOOST_CHECK_THROW(zypp::Url(str).asString(), url::UrlNotAllowedException );
+
+    // throws:  no path
+    str = "cd:";
+    BOOST_CHECK_THROW(zypp::Url(str).asString(), url::UrlNotAllowedException );
+
+    // OK, valid (no host, path is there)
+    str = "cd:///some/path";
+    BOOST_CHECK_EQUAL( str, zypp::Url(str).asString());
+    BOOST_CHECK( zypp::Url(str).isValid());
+}
+
+void test_url2(void)
+{
+  zypp::Url url("http://user:pass@localhost:/path/to;version=1.1?arg=val#frag");
+
+  BOOST_CHECK_EQUAL( url.asString(),
+  "http://user@localhost/path/to?arg=val#frag" );
+
+  BOOST_CHECK_EQUAL( url.asString(zypp::url::ViewOptions() +
+                     zypp::url::ViewOptions::WITH_PASSWORD),
+  "http://user:pass@localhost/path/to?arg=val#frag");
+
+  BOOST_CHECK_EQUAL( url.asString(zypp::url::ViewOptions() +
+                     zypp::url::ViewOptions::WITH_PATH_PARAMS),
+  "http://user@localhost/path/to;version=1.1?arg=val#frag");
+
+  BOOST_CHECK_EQUAL( url.asCompleteString(),
+  "http://user:pass@localhost/path/to;version=1.1?arg=val#frag");
+}
+
+void test_url3()
+{
+  zypp::Url   url("http://localhost/path/to#frag");
+  std::string key;
+  std::string val;
+
+  // will be encoded as "hoho=ha%20ha"
+  key = "hoho";
+  val = "ha ha";
+  url.setQueryParam(key, val);
+  BOOST_CHECK_EQUAL( url.asString(),
+  "http://localhost/path/to?hoho=ha%20ha#frag");
+
+  // will be encoded as "foo%3Dbar%26key=foo%26bar%3Dvalue"
+  key = "foo=bar&key";
+  val = "foo&bar=value";
+  url.setQueryParam(key, val);
+  BOOST_CHECK_EQUAL( url.asString(),
+  "http://localhost/path/to?foo%3Dbar%26key=foo%26bar%3Dvalue&hoho=ha%20ha#frag");
+
+  // will be encoded as "foo%25bar=is%25de%25ad"
+  key = "foo%bar";
+  val = "is%de%ad";
+  url.setQueryParam(key, val);
+  BOOST_CHECK_EQUAL( url.asString(),
+  "http://localhost/path/to?foo%25bar=is%25de%25ad&foo%3Dbar%26key=foo%26bar%3Dvalue&hoho=ha%20ha#frag");
+
+  // get encoded query parameters and compare with results:
+  zypp::url::ParamVec params( url.getQueryStringVec());
+  const char * const  result[] = {
+    "foo%25bar=is%25de%25ad",
+    "foo%3Dbar%26key=foo%26bar%3Dvalue",
+    "hoho=ha%20ha"
+  };
+  BOOST_CHECK( params.size() == (sizeof(result)/sizeof(result[0])));
+  for( size_t i=0; i<params.size(); i++)
+  {
+      BOOST_CHECK_EQUAL( params[i], result[i]);
+  }
+}
+
+void test_url4()
+{
+  try
+  {
+    zypp::Url url("ldap://example.net/dc=example,dc=net?cn,sn?sub?(cn=*)");
+
+    // fetch query params as vector
+    zypp::url::ParamVec pvec( url.getQueryStringVec());
+    BOOST_CHECK( pvec.size() == 3);
+    BOOST_CHECK_EQUAL( pvec[0], "cn,sn");
+    BOOST_CHECK_EQUAL( pvec[1], "sub");
+    BOOST_CHECK_EQUAL( pvec[2], "(cn=*)");
+
+    // fetch the query params map
+    // with its special ldap names/keys
+    zypp::url::ParamMap pmap( url.getQueryStringMap());
+    zypp::url::ParamMap::const_iterator m;
+    for(m=pmap.begin(); m!=pmap.end(); ++m)
+    {
+      if("attrs"  == m->first)
+      {
+        BOOST_CHECK_EQUAL( m->second, "cn,sn");
+      }
+      else
+      if("filter" == m->first)
+      {
+        BOOST_CHECK_EQUAL( m->second, "(cn=*)");
+      }
+      else
+      if("scope"  == m->first)
+      {
+        BOOST_CHECK_EQUAL( m->second, "sub");
+      }
+      else
+      {
+        BOOST_FAIL("Unexpected LDAP query parameter name in the map!");
+      }
+    }
+
+    url.setQueryParam("attrs", "cn,sn,uid");
+    url.setQueryParam("filter", "(|(sn=foo)(cn=bar))");
+
+    BOOST_CHECK_EQUAL(url.getQueryParam("attrs"),  "cn,sn,uid");
+    BOOST_CHECK_EQUAL(url.getQueryParam("filter"), "(|(sn=foo)(cn=bar))");
+
+  }
+  catch(const zypp::url::UrlException &e)
+  {
+    ZYPP_CAUGHT(e);
+  }
+}
+
+test_suite*
+init_unit_test_suite( int, char* [] )
+{
+    test_suite* test= BOOST_TEST_SUITE( "Url" );
+    test->add( BOOST_TEST_CASE( &test_url1 ), 0 /* expected zero error */ );
+    test->add( BOOST_TEST_CASE( &test_url2 ), 0 );
+    test->add( BOOST_TEST_CASE( &test_url3 ), 0 );
+    test->add( BOOST_TEST_CASE( &test_url4 ), 0 );
+    return test;
+}
+
+
+// vim: set ts=2 sts=2 sw=2 ai et: