cvs: pecl /sam/tests sam_test1_wmq_p2p.php sam_test2_wpm_p2p.php sam_test3_wmq_pubsub.php sam_test4_wpm_pubsub.php

From: Date: Fri, 08 Dec 2006 17:02:32 +0000
Subject: cvs: pecl /sam/tests sam_test1_wmq_p2p.php sam_test2_wpm_p2p.php sam_test3_wmq_pubsub.php sam_test4_wpm_pubsub.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-6780@lists.php.net to get a copy of this message
dsr Fri Dec 8 17:02:32 2006 UTC Added files: /pecl/sam/tests sam_test3_wmq_pubsub.php sam_test4_wpm_pubsub.php Modified files: /pecl/sam/tests sam_test1_wmq_p2p.php sam_test2_wpm_p2p.php Log:

http://cvs.php.net/viewvc.cgi/pecl/sam/tests/sam_test1_wmq_p2p.php?r1=1.1&r2=1.2&diff_format=u Index: pecl/sam/tests/sam_test1_wmq_p2p.php diff -u pecl/sam/tests/sam_test1_wmq_p2p.php:1.1 pecl/sam/tests/sam_test1_wmq_p2p.php:1.2 --- pecl/sam/tests/sam_test1_wmq_p2p.php:1.1 Wed Nov 22 16:56:57 2006 +++ pecl/sam/tests/sam_test1_wmq_p2p.php Fri Dec 8 17:02:32 2006 @@ -257,23 +257,23 @@ echo '<font color="red"><b>FAILED</b></font>'." send(4) failed ($conn->errno) $conn->error"; } else { $ar = $conn->peekAll($queuename, array(SAM_CORRELID => '1111')); - if (!ar) { + if (!$ar) { echo '<font color="red"><b>FAILED</b></font>'." peekAll failed ($conn->errno) $conn->error"; } else { - if (sizeof($ar) != 4) { + $x = sizeof($ar); + if ($x != 4) { echo '<font color="red"><b>FAILED</b></font>'." peekAll failed. Array size=".sizeof($ar)." should be 4!"; - } else { - $fail = FALSE; - foreach($ar as $msg) { - if (!$conn->remove($queuename, array(SAM_MESSAGEID => $msg->header->SAM_MESSAGEID))) { - echo '<font color="red"><b>FAILED</b></font> remove failed '."($conn->errno) $conn->error"; - $fail = TRUE; - } - } - if (!$fail) { - echo '<font color="green"><b>OK</b></font>'; + } + foreach($ar as $msg) { + if (!$conn->remove($queuename, array(SAM_MESSAGEID => $msg->header->SAM_MESSAGEID))) { + echo '<font color="red"><b>FAILED</b></font> remove failed '."($conn->errno) $conn->error"; + } else { + $x -= 1; } } + if ($x == 0) { + echo '<font color="green"><b>OK</b></font>'; + } } } } http://cvs.php.net/viewvc.cgi/pecl/sam/tests/sam_test2_wpm_p2p.php?r1=1.1&r2=1.2&diff_format=u Index: pecl/sam/tests/sam_test2_wpm_p2p.php diff -u pecl/sam/tests/sam_test2_wpm_p2p.php:1.1 pecl/sam/tests/sam_test2_wpm_p2p.php:1.2 --- pecl/sam/tests/sam_test2_wpm_p2p.php:1.1 Wed Nov 22 16:56:57 2006 +++ pecl/sam/tests/sam_test2_wpm_p2p.php Fri Dec 8 17:02:32 2006 @@ -254,20 +254,20 @@ if (!ar) { echo '<font color="red"><b>FAILED</b></font>'." peekAll failed ($conn->errno) $conn->error"; } else { - if (sizeof($ar) != 4) { + $x = sizeof($ar); + if ($x != 4) { echo '<font color="red"><b>FAILED</b></font>'." peekAll failed. Array size=".sizeof($ar)." should be 4!"; - } else { - $fail = FALSE; - foreach($ar as $msg) { - if (!$conn->remove($queuename, array(SAM_MESSAGEID => $msg->header->SAM_MESSAGEID))) { - echo '<font color="red"><b>FAILED</b></font> remove failed '."($conn->errno) $conn->error"; - $fail = TRUE; - } - } - if (!$fail) { - echo '<font color="green"><b>OK</b></font>'; + } + foreach($ar as $msg) { + if (!$conn->remove($queuename, array(SAM_MESSAGEID => $msg->header->SAM_MESSAGEID))) { + echo '<font color="red"><b>FAILED</b></font> remove failed '."($conn->errno) $conn->error"; + } else { + $x -= 1; } } + if ($x == 0) { + echo '<font color="green"><b>OK</b></font>'; + } } } } http://cvs.php.net/viewvc.cgi/pecl/sam/tests/sam_test3_wmq_pubsub.php?view=markup&rev=1.1 Index: pecl/sam/tests/sam_test3_wmq_pubsub.php +++ pecl/sam/tests/sam_test3_wmq_pubsub.php <html> <head> <title>SAM - WMQ pub/sub Testcase</title> <?php if ( ! extension_loaded('sam') ) { dl('php_sam.dll'); } // uncomment the following line to get additional debug info //sam_debug_on(); // test set up data... // sam_debug_off(); $host = 'localhost'; $broker = 'bull'; $port = 1414; $queuename = 'topic://test/x/y'; $protocol = SAM_WMQ; //$protocol = SAM_WMQ_CLIENT; //$protocol = SAM_WMQ_BINDINGS; ?> </head> <body> <h1>SAM - WMQ pub/sub Testcase</h1> This testcase will exercise the SAM connect, subscribe, receive, unsubscribe and disconnect capabilities using the WMQ protocol to a WebSphere MQSeries Messaging server. <p> The tests will use the following set up:<br> Protocol: <b><?php echo $protocol ?></b><br> Host: <b><?php echo $host ?></b><br> Broker: <b><?php echo $broker ?></b><br> Port: <b><?php echo $port ?></b><br> Queue: <b><?php echo $queuename ?></b><br> <hr/> Attempting connection with insufficient parameters -<br> <?php $conn = new SAMConnection(); if (!$conn->connect()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font> $conn='.$conn; } ?> <p/> <hr/> Attempting connection with no option array -<br> <?php $conn = new SAMConnection(); if (!$conn->connect(SAM_WMQ)) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting connection to invalid host -<br> <?php if ($protocol == (SAM_WMQ_BINDINGS)) { echo '<font color="green"><b>Skipping test as not valid for this protocol and option combination.</b></font> '; } else { $conn = new SAMConnection(); if (!$conn->connect($protocol, array(SAM_HOST => 'non-existent_host', SAM_PORT => $port, SAM_BROKER => $broker))) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } } ?> <p/> <hr/> Checking unconnected connection shows as unconnected -<br> <?php if (!$conn->isConnected()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting disconnect with unconnected connection -<br> <?php if (!$conn->disconnect()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting connection to valid host -<br> <?php $conn1 = new SAMConnection(); if ($conn1->connect($protocol, array(SAM_HOST => $host, SAM_PORT => $port, SAM_BROKER => $broker))) { echo '<font color="green"><b>OK</b></font>'; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting a second connection to valid host -<br> <?php $conn = new SAMConnection(); if ($conn->connect($protocol, array(SAM_HOST => $host, SAM_PORT => $port, SAM_BROKER => $broker))) { echo '<font color="green"><b>OK</b></font>'; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting a receive with an invalid subscription id -<br> <?php if ($conn) { $msg = $conn->receive('invalid sub name', array(SAM_WAIT => 5000)); if (!$msg) { echo '<font color="green"><b>OK</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Should not have received a message!'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting subscribe -<br> <?php if ($conn) { $sub = $conn->subscribe($queuename); if ($sub) { echo '<font color="green"><b>OK</b></font> subscribe suceeded sub id='.$sub.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Subscribe failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting receive via subscription -<br> <?php if ($conn) { $msg = $conn->receive($sub, array(SAM_WAIT => 5000)); if (!$msg) { echo '<font color="green"><b>OK</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Should not have received a message!'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting send to topic -<br> <?php if ($conn1) { $msg = new SAMMessage('This is a test message on topic test/x/y'); $msg->header->SAM_TYPE = SAM_TEXT; $correlid = $conn1->send($queuename, $msg); if (!$correlid) { echo '<font color="red"><b>FAILED</b></font>'." ($conn->errno) $conn->error"; } else { echo '<font color="green"><b>OK</b></font> correlID='.$correlid; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting receive via subscription again -<br> <?php if ($conn) { $msg = $conn->receive($sub, array(SAM_WAIT => 10000)); if (!$msg) { echo '<font color="red"><b>FAILED</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="green"><b>OK</b></font> msg='.$msg->body.'<br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting unsubscribe -<br> <?php if ($conn) { if (!$conn->unsubscribe($sub)) { echo '<font color="red"><b>FAILED</b></font> unsubscribe failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="green"><b>OK</b></font><br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Check connection still shows as connected -<br> <?php if (!$conn->isConnected()) { echo '<font color="red"><b>FAILED</b></font>'; } else { echo '<font color="green"><b>OK</b></font> '; } ?> <p/> <hr/> Attempting disconnect with connected connection -<br> <?php if (!$conn->disconnect()) { echo '<font color="red"><b>FAILED</b></font>'; } else { echo '<font color="green"><b>OK</b></font> '; } ?> <p/> <hr/> </body> </html> http://cvs.php.net/viewvc.cgi/pecl/sam/tests/sam_test4_wpm_pubsub.php?view=markup&rev=1.1 Index: pecl/sam/tests/sam_test4_wpm_pubsub.php +++ pecl/sam/tests/sam_test4_wpm_pubsub.php <html> <head> <title>SAM - WPM pub/sub Testcase</title> <?php if ( ! extension_loaded('sam') ) { dl('php_sam.dll'); } // uncomment the following line to get additional debug info //sam_debug_on(); // test set up data... // //sam_debug_on(); $endpoints = 'localhost:7278:BootstrapBasicMessaging'; $bus = 'Bus1'; $target = 'InboundBasicMessaging'; $queuename = 'topic://test/x/y'; $home = 'RENSHAWDTPNode01.server1-Bus1'; ?> </head> <body> <h1>SAM - WPM pub/sub Testcase</h1> This testcase will exercise the SAM connect, subscribe, receive, unsubscribe and disconnect capabilities using the WPM protocol to a WebSphere Application Server Messaging system. <p> The tests will use the following set up:<br> Endpoints: <b><?php echo $endpoints ?></b><br> Target chain: <b><?php echo $target ?></b><br> Bus: <b><?php echo $bus ?></b><br> Queue: <b><?php echo $queuename ?></b><br> Pub/sub home: <b><?php echo $home ?></b><br> <hr/> Attempting connection with insufficient parameters -<br> <?php $conn = new SAMConnection(); if (!$conn->connect()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font> $conn='.$conn; } ?> <p/> <hr/> Attempting connection with no option array -<br> <?php $conn = new SAMConnection(); if (!$conn->connect(SAM_WPM)) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting connection to invalid host -<br> <?php $conn = new SAMConnection(); if (!$conn->connect(SAM_WPM, array(SAM_ENDPOINTS => 'non-existant-host:9999:BootstrapBasicMessaging', SAM_BUS => 'non-existant-bus', SAM_TARGETCHAIN => 'non-existant-target'))) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Checking unconnected connection shows as unconnected -<br> <?php if (!$conn->isConnected()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting disconnect with unconnected connection -<br> <?php if (!$conn->disconnect()) { echo '<font color="green"><b>OK</b></font> '; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting connection to valid host -<br> <?php $conn1 = new SAMConnection(); if ($conn1->connect(SAM_WPM, array(SAM_ENDPOINTS => $endpoints, SAM_BUS => $bus, SAM_TARGETCHAIN => $target, SAM_WPM_DUR_SUB_HOME => $home))) { echo '<font color="green"><b>OK</b></font>'; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting a second connection to valid host -<br> <?php $conn = new SAMConnection(); if ($conn->connect(SAM_WPM, array(SAM_ENDPOINTS => $endpoints, SAM_BUS => $bus, SAM_TARGETCHAIN => $target, SAM_WPM_DUR_SUB_HOME => $home))) { echo '<font color="green"><b>OK</b></font>'; } else { echo '<font color="red"><b>FAILED</b></font>'; } ?> <p/> <hr/> Attempting a receive with an invalid subscription id -<br> <?php if ($conn) { $msg = $conn->receive('invalid sub name', array(SAM_WAIT => 5000)); if (!$msg) { echo '<font color="green"><b>OK</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Should not have received a message!'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting subscribe -<br> <?php if ($conn) { $sub = $conn->subscribe($queuename); if ($sub) { echo '<font color="green"><b>OK</b></font> subscribe suceeded sub id='.$sub.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Subscribe failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting receive via subscription -<br> <?php if ($conn) { $msg = $conn->receive($sub, array(SAM_WAIT => 5000)); if (!$msg) { echo '<font color="green"><b>OK</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="red"><b>FAILED</b></font> Should not have received a message!'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting send to topic -<br> <?php if ($conn1) { $msg = new SAMMessage('This is a test message on topic test/x/y'); $msg->header->SAM_TYPE = SAM_TEXT; $correlid = $conn1->send($queuename, $msg); if (!$correlid) { echo '<font color="red"><b>FAILED</b></font>'." ($conn->errno) $conn->error"; } else { echo '<font color="green"><b>OK</b></font> correlID='.$correlid; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting receive via subscription again -<br> <?php if ($conn) { $msg = $conn->receive($sub, array(SAM_WAIT => 10000)); if (!$msg) { echo '<font color="red"><b>FAILED</b></font> receive failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="green"><b>OK</b></font> msg='.$msg->body.'<br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Attempting unsubscribe -<br> <?php if ($conn) { if (!$conn->unsubscribe($sub)) { echo '<font color="red"><b>FAILED</b></font> unsubscribe failed with errno='.$conn->errno.' '.$conn->error.'<br>'; } else { echo '<font color="green"><b>OK</b></font><br>'; } } else { echo '<font color="red"><b>FAILED</b></font> previous connection create test failed!'; } ?> <p/> <hr/> Check connection still shows as connected -<br> <?php if (!$conn->isConnected()) { echo '<font color="red"><b>FAILED</b></font>'; } else { echo '<font color="green"><b>OK</b></font> '; } ?> <p/> <hr/> Attempting disconnect with connected connection -<br> <?php if (!$conn->disconnect()) { echo '<font color="red"><b>FAILED</b></font>'; } else { echo '<font color="green"><b>OK</b></font> '; } ?> <p/> <hr/> </body> </html>
« previous php.pecl.cvs (#6780) next »