TestTPConnect.cxx
上传用户:xfwatch
上传日期:2020-12-14
资源大小:872k
文件大小:3k
- /*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
- #include "TestAssert.h"
- #include "BaseServerTest.h"
- #include "xatmi.h"
- #include "TestTPConnect.h"
- extern void testtpconnect_service(TPSVCINFO *svcinfo);
- void TestTPConnect::setUp() {
- userlogc((char*) "TestTPConnect::setUp");
- sendbuf = NULL;
- rcvbuf = NULL;
- // Setup server
- BaseServerTest::setUp();
- // Do local work
- cd = -1;
- cd2 = -1;
- int toCheck = tpadvertise((char*) "TestTPConnect", testtpconnect_service);
- BT_ASSERT(tperrno == 0);
- BT_ASSERT(toCheck != -1);
- sendlen = strlen("connect") + 1;
- BT_ASSERT((sendbuf
- = (char *) tpalloc((char*) "X_OCTET", NULL, sendlen)) != NULL);
- BT_ASSERT(
- (rcvbuf = (char *) tpalloc((char*) "X_OCTET", NULL, sendlen))
- != NULL);
- strcpy(sendbuf, "connect");
- BT_ASSERT(tperrno == 0);
- }
- void TestTPConnect::tearDown() {
- userlogc((char*) "TestTPConnect::tearDown");
- // Do local work
- if (cd != -1) {
- ::tpdiscon(cd);
- }
- if (cd2 != -1) {
- ::tpdiscon(cd2);
- }
- ::tpfree(sendbuf);
- ::tpfree(rcvbuf);
- int toCheck = tpunadvertise((char*) "TestTPConnect");
- BT_ASSERT(tperrno == 0);
- BT_ASSERT(toCheck != -1);
- // Clean up server
- BaseServerTest::tearDown();
- }
- void TestTPConnect::test_tpconnect() {
- userlogc((char*) "test_tpconnect");
- cd = ::tpconnect((char*) "TestTPConnect", sendbuf, sendlen, TPRECVONLY);
- BT_ASSERT(cd != -1);
- }
- void TestTPConnect::test_tpconnect_double_connect() {
- userlogc((char*) "test_tpconnect_double_connect");
- cd = ::tpconnect((char*) "TestTPConnect", sendbuf, sendlen, TPRECVONLY);
- cd2 = ::tpconnect((char*) "TestTPConnect", sendbuf, sendlen, TPRECVONLY);
- BT_ASSERT(cd != -1);
- BT_ASSERT(cd2 != -1);
- BT_ASSERT(cd != cd2);
- BT_ASSERT(tperrno == 0);
- BT_ASSERT(tperrno != TPEINVAL);
- BT_ASSERT(tperrno != TPENOENT);
- BT_ASSERT(tperrno != TPEITYPE);
- BT_ASSERT(tperrno != TPELIMIT);
- BT_ASSERT(tperrno != TPETRAN);
- BT_ASSERT(tperrno != TPETIME);
- BT_ASSERT(tperrno != TPEBLOCK);
- BT_ASSERT(tperrno != TPGOTSIG);
- BT_ASSERT(tperrno != TPEPROTO);
- BT_ASSERT(tperrno != TPESYSTEM);
- BT_ASSERT(tperrno != TPEOS);
- }
- void TestTPConnect::test_tpconnect_nodata() {
- userlogc((char*) "test_tpconnect_nodata");
- cd = ::tpconnect((char*) "TestTPConnect", NULL, 0, TPRECVONLY);
- BT_ASSERT(cd != -1);
- }
- void testtpconnect_service(TPSVCINFO *svcinfo) {
- userlogc((char*) "testtpconnect_service");
- tpreturn(TPSUCCESS, 0, NULL, 0, 0);
- }