/**
  * 可以open和close索引库。索引库被关闭后不会在集群上产生开销(除了metadata的维护),不能进行
  * 读写操作。
  */
 public function testCloseAndOpenIndex()
 {
     $method = "POST";
     $url = "http://10.232.42.205:9200/test/_close";
     self::$ch = curl_init($url);
     curl_setopt(self::$ch, CURLOPT_URL, $url);
     curl_setopt(self::$ch, CURLOPT_PORT, 9200);
     curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt(self::$ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
     curl_setopt(self::$ch, CURLOPT_POSTFIELDS, "");
     $result = curl_exec(self::$ch);
     $expected = '{"ok":true,"acknowledged":true}';
     $this->assertEquals($expected, $result, $result);
     $url = "http://10.232.42.205:9200/test/_open";
     curl_setopt(self::$ch, CURLOPT_URL, $url);
     $result = curl_exec(self::$ch);
     $expected = '{"ok":true,"acknowledged":true}';
     $this->assertEquals($expected, $result, $result);
 }
Example #2
0
 * @package    Autoloader
 * @subpackage Test
 * @author     Markus Malkusch <*****@*****.**>
 * @copyright  2009 - 2010 Markus Malkusch
 * @license    http://php-autoloader.malkusch.de/en/license/ GPL 3
 * @version    SVN: $Id: TestIndex.php,v 1.3 2011/01/11 14:25:31 nicke Exp $
 * @link       http://php-autoloader.malkusch.de/en/
 */
/**
 * The Autoloader is used for class loading.
 */
require_once dirname(__FILE__) . "/../Autoloader.php";
/**
 * The tests need an one-time initialisation.
 */
TestIndex::classConstructor();
/**
 * AutoloaderIndex test cases
 *
 * @category   PHP
 * @package    Autoloader
 * @subpackage Test
 * @author     Markus Malkusch <*****@*****.**>
 * @license    http://php-autoloader.malkusch.de/en/license/ GPL 3
 * @version    Release: 1.11
 * @link       http://php-autoloader.malkusch.de/en/
 * @see        AutoloaderIndex
 * @see        AutoloaderIndex_CSV
 * @see        AutoloaderIndex_Dummy
 * @see        AutoloaderIndex_IniFile
 * @see        AutoloaderIndex_PDO
Example #3
0
 /**
  * Deletes all temporary files
  *
  * @return void
  */
 public function tearDown()
 {
     AutoloaderTestHelper::deleteDirectory('.');
     AutoloaderTestHelper::deleteDirectory(TestIndex::getIndexDirectory(), false);
 }
$t = new lime_test(20, new lime_output_color());
$index = new TestIndex();
$invalid = new TestIndex();
$t->diag('->get*(), ->set*()');
$t->is($index->getName(), 'TestIndex', '->getName() is initially the name of the class');
$index->setName('foobar');
$t->is($index->getName(), 'foobar', '->setName() changes the name');
$t->isa_ok($index->getServiceRegistry(), 'xfServiceRegistry', '->getServiceRegistry() returns a service registry');
$registry = new xfServiceRegistry();
$index->setServiceRegistry($registry);
$t->is($index->getServiceRegistry(), $registry, '->setServiceRegistry() changes the service registry');
$engine = new xfMockEngine();
$index->setEngine($engine);
$t->is($index->getEngine(), $engine, '->setEngine() changes the engine');
$t->ok(!$index->isSetup(), '->isSetup() is false initially');
$index = new TestIndex();
$registry = new xfServiceRegistry();
$registry->register(new xfService(new xfMockIdentifier()));
$engine = new xfMockEngine();
$index->setServiceRegistry($registry);
$index->setEngine($engine);
$t->diag('->insert(), ->remove()');
$index->insert('foo');
$t->ok($index->isSetup(), '->insert() automatically runs setup');
$t->is(count($engine->getDocuments()), 1, '->insert() adds a document');
$index->remove('foo');
$t->is(count($engine->getDocuments()), 0, '->remove() deletes a document');
try {
    $msg = '->insert() fails if an engine does not exist';
    $invalid->insert('foo');
    $t->fail($msg);