(file) Return to TestProtocolHandlerCache.cpp CVS log (file) (dir) Up to [OMI] / omi / tests / miapi

  1 krisbash 1.1 #include <ut/ut.h>
  2              #include <MI.h>
  3              #include <miapi/ProtocolHandlerCache.h>
  4              
  5              struct _TestProtocolHandler
  6              {
  7                  const char *protocolHandlerName;
  8                  const MI_Char *protocolHandlerName_w;
  9                  const char *protocolHandlerDll;
 10                  const char *protocolHandlerEntryPoint;
 11              };
 12              
 13              const struct _TestProtocolHandler g_test1Transport =
 14              {
 15                  "Test1",
 16                  PAL_T("Test1"),
 17              #if defined(_MSC_VER)
 18                  "test_miapi.dll",
 19              #else
 20                  "libtest_miapi."CONFIG_SHLIBEXT,
 21              #endif
 22 krisbash 1.1     "Test1_Application_Initialize"
 23              } ;
 24              
 25              const struct _TestProtocolHandler g_test2Transport =
 26              {
 27                  "Test2",
 28                  PAL_T("Test2"),
 29              #if defined(_MSC_VER)
 30                  "test_miapi.dll",
 31              #else
 32                  "libtest_miapi."CONFIG_SHLIBEXT,
 33              #endif
 34                  "Test2_Application_Initialize"
 35              } ;
 36              
 37              
 38              NitsTest(ProtocolHandlerCache_InitDeInit)
 39              {
 40                  ProtocolHandlerCache cache;
 41                  if (NitsCompare(ProtocolHandlerCache_Initialize(PAL_T("applicationID"), &cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_Initialize should succeed")))
 42                  {
 43 krisbash 1.1         NitsCompare(ProtocolHandlerCache_DeInitialize(&cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_DeInitialize should succeed"));
 44                  }
 45              }
 46              NitsEndTest
 47              
 48              NitsTest(ProtocolHandlerCache_GetHandler)
 49              {
 50                  ProtocolHandlerCache cache;
 51                  ProtocolHandlerCacheItem *cacheItem = NULL;
 52              
 53                  if (NitsCompare(ProtocolHandlerCache_Initialize(PAL_T("applicationID"), &cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_Initialize should succeed")))
 54                  {
 55                      if (NitsCompare(ProtocolHandlerCache_InsertProtocolEntries(&cache, g_test1Transport.protocolHandlerName, g_test1Transport.protocolHandlerDll, g_test1Transport.protocolHandlerEntryPoint, 1, 1, &cacheItem), MI_RESULT_OK, PAL_T("Registering test transport")) &&
 56                         (NitsCompare(ProtocolHandlerCache_GetProtocolHandler(&cache, PAL_T("Test1"), &cacheItem), MI_RESULT_OK, PAL_T("Successfully get protocol handler"))))
 57                      {
 58                          NitsAssert(cacheItem->application.ft != NULL, PAL_T("We should have a function table in the returned protocol handler application"));
 59                      }
 60              
 61                      NitsCompare(ProtocolHandlerCache_DeInitialize(&cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_DeInitialize should succeed"));
 62                  }
 63              }
 64 krisbash 1.1 NitsEndTest
 65              
 66              NitsTest(ProtocolHandlerCache_GetHandler_TwoTheSame)
 67              {
 68                  ProtocolHandlerCache cache;
 69                  ProtocolHandlerCacheItem *cacheItem1 = NULL;
 70                  ProtocolHandlerCacheItem *cacheItem2 = NULL;
 71                  if (NitsCompare(ProtocolHandlerCache_Initialize(NULL, &cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_Initialize should succeed")))
 72                  {
 73                      if (NitsCompare(ProtocolHandlerCache_InsertProtocolEntries(&cache, g_test1Transport.protocolHandlerName, g_test1Transport.protocolHandlerDll, g_test1Transport.protocolHandlerEntryPoint, 1, 1, &cacheItem1), MI_RESULT_OK, PAL_T("Registering test transport")) &&
 74                          NitsCompare(ProtocolHandlerCache_GetProtocolHandler(&cache, PAL_T("Test1"), &cacheItem1), MI_RESULT_OK, PAL_T("Successfully get protocol handler")) &&
 75                          NitsCompare(ProtocolHandlerCache_GetProtocolHandler(&cache, PAL_T("Test1"), &cacheItem2), MI_RESULT_OK, PAL_T("Second call successfully get protocol handler")))
 76                      {
 77                          NitsAssert(cacheItem1->application.ft != NULL, PAL_T("We should have a function table in the returned protocol handler application"));
 78                          NitsAssert(cacheItem2->application.ft != NULL, PAL_T("We should have a function table in the returned protocol handler application"));
 79                          NitsAssert(cacheItem1->application.ft == cacheItem2->application.ft, PAL_T("function tables should be the same"));
 80                      }
 81              
 82                      NitsCompare(ProtocolHandlerCache_DeInitialize(&cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_DeInitialize should succeed"));
 83                  }
 84              }
 85 krisbash 1.1 NitsEndTest
 86              
 87              NitsTest(ProtocolHandlerCache_GetHandler_TwoDifferent)
 88              {
 89                  ProtocolHandlerCache cache;
 90                  ProtocolHandlerCacheItem *cacheItem1 = NULL;
 91                  ProtocolHandlerCacheItem *cacheItem2 = NULL;
 92                  if (NitsCompare(ProtocolHandlerCache_Initialize(PAL_T("applicationID"), &cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_Initialize should succeed")))
 93                  {
 94                      if (NitsCompare(ProtocolHandlerCache_InsertProtocolEntries(&cache, g_test1Transport.protocolHandlerName, g_test1Transport.protocolHandlerDll, g_test1Transport.protocolHandlerEntryPoint, 1, 1, &cacheItem1), MI_RESULT_OK, PAL_T("Registering test transport")) &&
 95                          NitsCompare(ProtocolHandlerCache_InsertProtocolEntries(&cache, g_test2Transport.protocolHandlerName, g_test2Transport.protocolHandlerDll, g_test2Transport.protocolHandlerEntryPoint, 1, 1, &cacheItem1), MI_RESULT_OK, PAL_T("Registering test transport")) &&
 96                          NitsCompare(ProtocolHandlerCache_GetProtocolHandler(&cache, PAL_T("Test1"), &cacheItem1), MI_RESULT_OK, PAL_T("Successfully get protocol handler")) &&
 97                          NitsCompare(ProtocolHandlerCache_GetProtocolHandler(&cache, PAL_T("Test2"), &cacheItem2), MI_RESULT_OK, PAL_T("Second call successfully get protocol handler")))
 98                      {
 99                          NitsAssert(cacheItem1->application.ft != NULL, PAL_T("We should have a function table in the returned protocol handler application"));
100                          NitsAssert(cacheItem2->application.ft != NULL, PAL_T("We should have a function table in the returned protocol handler application"));
101                          NitsAssert(cacheItem1->application.ft != cacheItem2->application.ft, PAL_T("function tables should be different"));
102                      }
103              
104                      NitsCompare(ProtocolHandlerCache_DeInitialize(&cache), MI_RESULT_OK, PAL_T("ProtocolHandlerCache_DeInitialize should succeed"));
105                  }
106 krisbash 1.1 }
107              NitsEndTest

ViewCVS 0.9.2