public function testAuthorize()
 {
     $subject = new MetaAgentAdapter();
     $pipe_name = 'pipe';
     $token = 'token';
     $role = BStompRoleType::PUBLISHER;
     // 测试1 从还未被初始化的对象调用接口
     $this->assertFalse($subject->authorize($pipe_name, $token, $role));
     // 测试2 meta name为空
     $this->assertTrue(TestUtilities::set_private_var($subject, '_inited', true));
     $this->assertFalse($subject->authorize(null, $token, $role));
     // mock connection 行为
     // 定义connection行为
     $this->stub_conn->expects($this->any())->method('is_connected')->will($this->returnValue(true));
     $this->stub_conn->expects($this->any())->method('create_connection')->will($this->returnValue(true));
     $this->stub_conn->expects($this->any())->method('send')->will($this->returnValue(true));
     $this->stub_conn->expects($this->any())->method('close');
     $ack_pkgs = $this->_gen_authorize_ack();
     $this->stub_conn->expects($this->any())->method('receive')->will($this->onConsecutiveCalls(null, $ack_pkgs['bad'], $ack_pkgs['failed'], $ack_pkgs['passed']));
     $this->assertTrue(TestUtilities::set_private_var($subject, '_connection', $this->stub_conn));
     // 测试2.2 request null
     $subject->meta_name = 'meta';
     $this->assertFalse($subject->authorize($pipe_name, $token, $role));
     // 测试2.3 ack wrong pakcage
     $this->assertFalse($subject->authorize($pipe_name, $token, $role));
     // 测试2.4 认证不通过
     $auth_ret = $subject->authorize($pipe_name, $token, $role);
     $this->assertTrue(false != $auth_ret);
     $this->assertFalse($auth_ret['authorized']);
     // 测试2.5 认证通过
     $auth_ret = $subject->authorize($pipe_name, $token, $role);
     $this->assertTrue(false != $auth_ret);
     $this->assertTrue($auth_ret['authorized']);
     $this->assertTrue(TestUtilities::set_private_var($subject, '_inited', false));
 }