-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
<exclude> | ||
<group>slow</group> | ||
<group>jpgraph</group> | ||
<group>pushserver</group> | ||
</exclude> | ||
</groups> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Meter tests | ||
* | ||
* @package Test | ||
* @author Andreas Götz <[email protected]> | ||
*/ | ||
|
||
namespace Tests; | ||
|
||
use Volkszaehler\Util; | ||
|
||
class PushServerTest extends Data | ||
{ | ||
// channel properties | ||
static $resolution = 100; | ||
|
||
/** | ||
* Create channel | ||
*/ | ||
static function setupBeforeClass() { | ||
parent::setupBeforeClass(); | ||
self::$uuid = self::createChannel('Counter', 'electric meter', self::$resolution); | ||
} | ||
|
||
/** | ||
* @group pushserver | ||
*/ | ||
function testPushMessage() { | ||
$this->assertTrue(Util\Configuration::read('push.enabled'), 'Push server disabled'); | ||
|
||
$exitCode = null; | ||
$port = Util\Configuration::read('push.server'); | ||
$curl = "curl %s -s -m 3 -X POST -d '{\"data\":[{\"uuid\":\"%s\",\"tuples\":[[1,1,1]]}]}' localhost:%d 2>&1"; | ||
|
||
// run and test for failure | ||
$cmd = sprintf($curl, '-f', self::$uuid, $port); | ||
passthru($cmd, $exitCode); | ||
|
||
// run to get output | ||
if ($exitCode !== 0) { | ||
$cmd = sprintf($curl, '-i', self::$uuid, $port); | ||
passthru($cmd); | ||
} | ||
|
||
$this->assertTrue($exitCode === 0, sprintf('Curl failed with exit code %d', $exitCode)); | ||
} | ||
} | ||
|
||
?> |