1919#include " driver_info.hpp"
2020#include " query_request.hpp"
2121#include " session.hpp"
22-
22+ # include " testing.hpp "
2323
2424#define APPLICATION_NAME " DataStax C/C++ Test Harness"
2525#define APPLICATION_VERSION " 1.0.0"
2626
27+ inline bool operator ==(const CassUuid& rhs, const CassUuid& lhs) {
28+ return rhs.clock_seq_and_node == lhs.clock_seq_and_node &&
29+ rhs.time_and_version == lhs.time_and_version ;
30+ }
31+
32+ inline bool operator !=(const CassUuid& rhs, const CassUuid& lhs) {
33+ return !(rhs == lhs);
34+ }
35+
2736class StartupRequestUnitTest : public Unit {
2837public:
2938 void TearDown () {
3039 ASSERT_TRUE (session_.close ()->wait_for (WAIT_FOR_TIME));
3140 Unit::TearDown ();
3241 }
3342
43+ cass::Session& session () { return session_; }
3444 const cass::String& client_id () const { return client_id_; }
3545 cass::Config& config () { return config_; }
3646 const mockssandra::RequestHandler* simple_with_client_options () {
@@ -129,3 +139,27 @@ TEST_F(StartupRequestUnitTest, Application) {
129139 ASSERT_EQ (cass::driver_name (), options[" DRIVER_NAME" ]);
130140 ASSERT_EQ (cass::driver_version (), options[" DRIVER_VERSION" ]);
131141}
142+
143+ TEST_F (StartupRequestUnitTest, SetClientId) {
144+ mockssandra::SimpleCluster cluster (simple_with_client_options ());
145+ ASSERT_EQ (cluster.start_all (), 0 );
146+
147+ CassUuid generated_client_id = session ().client_id ();
148+ CassUuid assigned_client_id;
149+ ASSERT_EQ (CASS_OK,
150+ cass_uuid_from_string (" 03398c99-c635-4fad-b30a-3b2c49f785c2" ,
151+ &assigned_client_id));
152+ config ().set_client_id (assigned_client_id);
153+
154+ connect ();
155+ CassUuid current_client_id = session ().client_id ();
156+ ASSERT_EQ (assigned_client_id, current_client_id);
157+ ASSERT_NE (generated_client_id, current_client_id);
158+ cass::Map<cass::String, cass::String> options = client_options ();
159+ ASSERT_EQ (4u , options.size ());
160+
161+ ASSERT_EQ (" 03398c99-c635-4fad-b30a-3b2c49f785c2" , options[" CLIENT_ID" ]);
162+ ASSERT_EQ (CASS_DEFAULT_CQL_VERSION, options[" CQL_VERSION" ]);
163+ ASSERT_EQ (cass::driver_name (), options[" DRIVER_NAME" ]);
164+ ASSERT_EQ (cass::driver_version (), options[" DRIVER_VERSION" ]);
165+ }
0 commit comments