Date: Wednesday, November 9, 2005 @ 14:34:10
  Author: gilles
    Path: /cvsroot/carob/carob/test

   Added: TestOnValidConnection.cpp (1.1) TestOnValidConnection.hpp (1.1)

(new files)
Added superclass for tests on valid connection.
Classes that use an established connection and test over-socket data transferts 
shoud inherit 
from this class to avoid redefinition of connection/clean up function


---------------------------+
 TestOnValidConnection.cpp |   66 ++++++++++++++++++++++++++++++++++++++++++++
 TestOnValidConnection.hpp |   53 +++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)


Index: carob/test/TestOnValidConnection.cpp
diff -u /dev/null carob/test/TestOnValidConnection.cpp:1.1
--- /dev/null   Wed Nov  9 14:34:10 2005
+++ carob/test/TestOnValidConnection.cpp        Wed Nov  9 14:34:10 2005
@@ -0,0 +1,66 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s): 
+ */
+
+#include "Common.hpp"
+#include "ConnectionParameters.hpp"
+#include "ConnectionPool.hpp"
+#include "CarobException.hpp"
+#include "TestOnValidConnection.hpp"
+
+void TestOnValidConnection::setUp()
+{
+  wstring fctName(L"TestExecReadRequest::setUp");
+  ConnectionPool& connectionPool = ConnectionPool::getInstance();
+  ConnectionParameters connectionPrms(L"localhost",
+                                      25322,
+                                      L"myDB",
+                                      L"user",
+                                      L"",
+                                      DEBUG_LEVEL_DEBUG);  
+  try
+  {
+    connectionPtr = connectionPool.connectToController(connectionPrms);
+  }
+  catch (ConnectionException ce)
+  {
+    logError(fctName, L"ConnectionException "+ce.description());
+    connectionPtr = NULL;
+    CPPUNIT_ASSERT(false);
+  }
+  catch (AuthenticationException ae)
+  {
+    logError(fctName, L"AuthenticationException "+ae.description());
+    connectionPtr = NULL;
+    CPPUNIT_ASSERT(false);
+  }
+  catch (...)
+  {
+    logError(fctName, L"Unexpected excption. Aborting ");
+    connectionPtr = NULL;
+    CPPUNIT_ASSERT(false);
+  }
+}
+
+void TestOnValidConnection::tearDown()
+{
+  if (connectionPtr)
+    delete connectionPtr;
+}
Index: carob/test/TestOnValidConnection.hpp
diff -u /dev/null carob/test/TestOnValidConnection.hpp:1.1
--- /dev/null   Wed Nov  9 14:34:10 2005
+++ carob/test/TestOnValidConnection.hpp        Wed Nov  9 14:34:10 2005
@@ -0,0 +1,53 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s): 
+ */
+
+#ifndef TESTONVALIDCONNECTION_H_
+#define TESTONVALIDCONNECTION_H_
+
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/TestCase.h>
+#include <cppunit/TestSuite.h>
+#include <cppunit/TestCaller.h>
+
+
+/**
+ * Test super class for running tests on a valid connection to a local
+ * controller.
+ * Defines setUp() and tearDown() functions to connect to localhost:25322,
+ * db "myDB" user "user" pass "". Inherit from this class to launch tests and
+ * get rid of connection aspects. No testing is done here !
+ * A controller *MUST* run locally for test success !!!
+ */
+class TestOnValidConnection : CppUnit::TestFixture
+{
+public:
+
+  /** Creates the connection and connects to the running local controller. */
+  void setUp();
+  /** Destroys the connection if applicable */
+  void tearDown();
+
+protected:
+  Connection*       connectionPtr;
+};
+
+#endif /*TESTONVALIDCONNECTION_H_*/

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to