text: /************************************************************************************************************************
   Copyright (c) 2016, Imagination Technologies Limited and/or its affiliated group companies.
   All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
   following conditions are met:
       1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
          following disclaimer.
       2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
          following disclaimer in the documentation and/or other materials provided with the distribution.
       3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
          products derived from this software without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
   USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  ************************************************************************************************************************/
  
  #include <pthread.h>
  #include <gtest/gtest.h>
  #include "awa/static.h"
  #include "awa/server.h"
  #include "support/static_api_support.h"
  
  namespace Awa {
  
  class TestStaticClient : public TestClientBase {};
  
  TEST_F(TestStaticClient, AwaStaticClient_New_Free)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      ASSERT_TRUE(client != NULL);
  
      AwaStaticClient_Free(&client);
      ASSERT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_Init_NULL_Client)
  {
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_Init(NULL));
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_New_Init_Unconfigured_Client)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_StaticClientNotConfigured, AwaStaticClient_Init(client));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetBootstrapServerURI_valid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetBootstrapServerURI_invalid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetBootstrapServerURI(NULL, "coap://127.0.0.1:15683/"));
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetBootstrapServerURI(client, NULL));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetBootstrapServerURI_after_init)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      EXPECT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.2:15683/"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetBootstrapServerURI_while_running)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Process(client);
  
      EXPECT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.2:15683/"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetEndPointName_valid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetEndPointName_invalid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetEndPointName(NULL, "test"));
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetEndPointName(client, NULL));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetEndPointName_long_name)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_OutOfMemory, AwaStaticClient_SetEndPointName(client, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetEndPointName_after_init)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      EXPECT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetEndPointName(client, "imagination12"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetEndPointName_while_running)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Process(client);
  
      EXPECT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetEndPointName(client, "imagination12"));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetCoAPListenAddressPort_valid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "::", 5683));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetCoAPListenAddressPort_invalid_input)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetCoAPListenAddressPort(NULL, "test", 5683));
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetCoAPListenAddressPort(client, NULL, 5683));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetCoAPListenAddressPort_long_name)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_OutOfMemory, AwaStaticClient_SetCoAPListenAddressPort(client, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 5683));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  
  TEST_F(TestStaticClient, AwaStaticClient_SetCoAPListenAddressPort_after_init)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetCoAPListenAddressPort(client, "::", 5683));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetCoAPListenAddressPort_while_running)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Process(client);
  
      ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetCoAPListenAddressPort(client, "::", 5683));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetLogLevel_valid_input)
  {
      DebugLevel oldLogLevel = Lwm2m_GetLogLevel();
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetLogLevel(AwaLogLevel_None));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetLogLevel(AwaLogLevel_Debug));
      Lwm2m_SetLogLevel(oldLogLevel);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetLogLevel_invalid_input)
  {
      DebugLevel oldLogLevel = Lwm2m_GetLogLevel();
      EXPECT_EQ(AwaError_LogLevelInvalid, AwaStaticClient_SetLogLevel(static_cast<AwaLogLevel>(AwaLogLevel_None - 1)));
      EXPECT_EQ(AwaError_LogLevelInvalid, AwaStaticClient_SetLogLevel(static_cast<AwaLogLevel>(AwaLogLevel_Debug + 1)));
      Lwm2m_SetLogLevel(oldLogLevel);
  }
  
  
  TEST_F(TestStaticClient, AwaStaticClient_SetApplicationContext_invalid_inputs)
  {
      ASSERT_TRUE(NULL == AwaStaticClient_GetApplicationContext(NULL));
      ASSERT_EQ(AwaError_StaticClientInvalid, AwaStaticClient_SetApplicationContext(NULL, NULL));
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_SetApplicationContext_valid_inputs)
  {
      int dummycontext = 5;
      void * applicationContext = &dummycontext;
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_Success, AwaStaticClient_SetApplicationContext(client, applicationContext));
      ASSERT_EQ(applicationContext, AwaStaticClient_GetApplicationContext(client));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_Init_not_configured)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      ASSERT_EQ(AwaError_StaticClientNotConfigured, AwaStaticClient_Init(client));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_Init_valid_inputs)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      ASSERT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  //This test is for valgrind
  TEST_F(TestStaticClient, AwaStaticClient_Process)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Process(client);
      AwaStaticClient_Process(client);
      AwaStaticClient_Process(client);
      AwaStaticClient_Process(client);
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient, AwaStaticClient_Process_invalid_input)
  {
      EXPECT_EQ(-1, AwaStaticClient_Process(NULL));
  }
  
  TEST_F(TestStaticClient, AwaStaticClinet_SetFactoryBootstrapInformation_before_init)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      AwaFactoryBootstrapInfo bootstrapinfo = { 0 };
  
      sprintf(bootstrapinfo.SecurityInfo.ServerURI, "coap://127.0.0.1");
      bootstrapinfo.SecurityInfo.SecurityMode = AwaSecurityMode_NoSec;
      sprintf(bootstrapinfo.SecurityInfo.PublicKeyOrIdentity, "[PublicKey]");
      sprintf(bootstrapinfo.SecurityInfo.SecretKey, "[SecretKey]");
  
      bootstrapinfo.ServerInfo.Lifetime = 30;
      bootstrapinfo.ServerInfo.DefaultMinPeriod = 1;
      bootstrapinfo.ServerInfo.DefaultMaxPeriod = -1;
      bootstrapinfo.ServerInfo.DisableTimeout = 86400;
      bootstrapinfo.ServerInfo.Notification = false;
      sprintf(bootstrapinfo.ServerInfo.Binding, "U");
  
      ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetFactoryBootstrapInformation(client, &bootstrapinfo));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient,  AwaStaticClient_SetFactoryBootstrapInformation_while_running)
  {
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, "coap://127.0.0.1:15683/"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, "imagination1"));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      AwaStaticClient_Process(client);
  
      AwaFactoryBootstrapInfo bootstrapinfo = { 0 };
  
      sprintf(bootstrapinfo.SecurityInfo.ServerURI, "coap://127.0.0.1");
      bootstrapinfo.SecurityInfo.SecurityMode = AwaSecurityMode_NoSec;
      sprintf(bootstrapinfo.SecurityInfo.PublicKeyOrIdentity, "[PublicKey]");
      sprintf(bootstrapinfo.SecurityInfo.SecretKey, "[SecretKey]");
  
      bootstrapinfo.ServerInfo.Lifetime = 30;
      bootstrapinfo.ServerInfo.DefaultMinPeriod = 1;
      bootstrapinfo.ServerInfo.DefaultMaxPeriod = -1;
      bootstrapinfo.ServerInfo.DisableTimeout = 86400;
      bootstrapinfo.ServerInfo.Notification = false;
      sprintf(bootstrapinfo.ServerInfo.Binding, "U");
  
      ASSERT_EQ(AwaError_OperationInvalid, AwaStaticClient_SetFactoryBootstrapInformation(client, &bootstrapinfo));
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  }
  
  TEST_F(TestStaticClient,  AwaStaticClient_Bootstrap_Test)
  {
      std::string testDescription = std::string(CURRENT_TEST_CASE_NAME + std::string(".") + CURRENT_TEST_NAME);
  
      int bootstrapServerCoapPort = 23667;
      std::string bootstrapServerAddress = "127.0.0.1";
      std::string bootstrapURI = std::string("coap://") + bootstrapServerAddress + std::string(":") + std::to_string(bootstrapServerCoapPort);
      AwaBootstrapServerDaemon bootstrapServerDaemon;
      bootstrapServerDaemon.SetCoapPort(bootstrapServerCoapPort);
  
      std::string serverAddress = "127.0.0.1";
      int serverCoapPort = 44443;
      int serverIpcPort = 6301;
      AwaServerDaemon serverDaemon;
      serverDaemon.SetCoapPort(serverCoapPort);
      serverDaemon.SetIpcPort(serverIpcPort);
  
  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
      std::string bootstrapConfigFilename = tmpnam(NULL);
  #pragma GCC diagnostic pop
      BootstrapConfigFile bootstrapConfigFile (bootstrapConfigFilename, serverAddress, serverCoapPort);
      bootstrapServerDaemon.SetConfigFile(bootstrapConfigFile.GetFilename());
  
      // start the bootstrap and server daemons
      EXPECT_TRUE(bootstrapServerDaemon.Start(testDescription));
      EXPECT_TRUE(serverDaemon.Start(testDescription));
  
      std::string clientEndpointName = "BootstrapTestClient";
      AwaStaticClient * client = AwaStaticClient_New();
      EXPECT_TRUE(client != NULL);
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetBootstrapServerURI(client, bootstrapURI.c_str()));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetEndPointName(client, clientEndpointName.c_str()));
      EXPECT_EQ(AwaError_Success, AwaStaticClient_SetCoAPListenAddressPort(client, "0.0.0.0", 5683));
  
      EXPECT_EQ(AwaError_Success, AwaStaticClient_Init(client));
  
      // wait for the client to register with the server
      AwaServerSession * session = AwaServerSession_New();
      EXPECT_TRUE(NULL != session);
      EXPECT_EQ(AwaError_Success, AwaServerSession_SetIPCAsUDP(session, serverAddress.c_str(), serverIpcPort));
      EXPECT_EQ(AwaError_Success, AwaServerSession_Connect(session));
  
      AwaServerListClientsOperation * operation = AwaServerListClientsOperation_New(session);
      EXPECT_TRUE(NULL != operation);
  
      SingleStaticClientPollCondition condition(client, operation, clientEndpointName, 10);
      ASSERT_TRUE(condition.Wait());
  
      AwaServerListClientsOperation_Free(&operation);
      AwaServerSession_Free(&session);
  
      AwaStaticClient_Free(&client);
      EXPECT_TRUE(client == NULL);
  
      serverDaemon.Stop();
      bootstrapServerDaemon.Stop();
  }
  
  TEST_F(TestStaticClientWithServer,  AwaStaticClient_Factory_Bootstrap_Test)
  {
      AwaServerListClientsOperation * operation = AwaServerListClientsOperation_New(session_);
      EXPECT_TRUE(NULL != operation);
  
      SingleStaticClientPollCondition condition(client_, operation, global::clientEndpointName, 20);
      ASSERT_TRUE(condition.Wait());
  
      AwaServerListClientsOperation_Free(&operation);
  }
  
  } // namespace Awa
  