File: z_10_component.t

package info (click to toggle)
libanyevent-xmpp-perl 0.55-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 784 kB
  • ctags: 553
  • sloc: perl: 8,004; makefile: 13
file content (43 lines) | stat: -rw-r--r-- 761 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!perl

use strict;
use Test::More;
use AnyEvent;
use AnyEvent::XMPP::Component;

my ($host, $dom, $port, $pass) = split /:/, $ENV{NET_XMPP2_TEST_COMPONENT};
if ($host eq '') {
   plan skip_all => 'NET_XMPP2_TEST_COMPONENT environment variable not set';
   exit;
}

plan tests => 1;

my $cv = AnyEvent->condvar;
my $com =
   AnyEvent::XMPP::Component->new (
      domain => $dom,
      host   => $host,
      port   => $port,
      secret => $pass,
   );

my $connected = 0;
$com->reg_cb (
   session_ready => sub {
      my ($com) = @_;
      $connected = 1;
      $cv->send;
   },
   disconnect => sub {
      my ($com) = @_;
      $connected = -1;
      $cv->send;
   }
);

$com->connect;

$cv->recv;

is ($connected, 1, 'component connected successfully');