From d88ef3d5fb3d444dc2c5e833025bcaeb757e0b71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 31 Mar 2011 01:34:25 +0000 Subject: [PATCH] Generation of test units and keys continued: - Database folder for crunher projects added - Introduced two methods to MessageHelper - Introduced an iterator for test unit producers to generate keys - TODOs.txt updated --- .gitattributes | 3 + application/hub/config.php | 6 + .../helper/messages/class_MessageHelper.php | 14 +++ .../work_units/class_UnitHelper.php | 4 +- .../mcrypt/class_HubMcryptCruncher.php | 2 +- .../class_CryptoRandomUnitMessageHelper.php | 13 +++ .../cruncher/class_CruncherTestUnitHelper.php | 2 +- .../hub/main/iterator/producer/.htaccess | 1 + .../class_TestUnitKeyProducerIterator.php | 107 ++++++++++++++++++ .../class_CruncherTestUnitProducer.php | 6 +- db/cruncher_projects/.htaccess | 1 + docs/TODOs.txt | 8 +- 12 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 application/hub/main/iterator/producer/.htaccess create mode 100644 application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php create mode 100644 db/cruncher_projects/.htaccess diff --git a/.gitattributes b/.gitattributes index 463b9931a..0cc3d8ac5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -316,6 +316,8 @@ application/hub/main/iterator/pool/shutdown/class_Shutdown -text application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php -text svneol=unset#text/plain application/hub/main/iterator/pool/tasks/.htaccess -text svneol=unset#text/plain application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php -text svneol=unset#text/plain +application/hub/main/iterator/producer/.htaccess svneol=native#text/plain +application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php svneol=native#text/plain application/hub/main/listener/.htaccess -text svneol=unset#text/plain application/hub/main/listener/class_ -text svneol=unset#text/plain application/hub/main/listener/class_BaseListener.php -text svneol=unset#text/plain @@ -510,6 +512,7 @@ application/hub/templates/xml/self_connect/.htaccess -text svneol=unset#text/pla application/hub/templates/xml/self_connect/self_connect.xml -text svneol=unset#text/plain /clear-cache.sh -text db/.htaccess -text svneol=unset#text/plain +db/cruncher_projects/.htaccess svneol=native#text/plain db/cruncher_units/.htaccess svneol=native#text/plain db/news/.htaccess -text svneol=unset#text/plain db/node_data/.htaccess -text svneol=unset#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 50351b2a3..471744745 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -447,6 +447,12 @@ $cfg->setConfigEntry('query_iterator_class', 'DefaultIterator'); // CFG: HUB-PING-ITERATOR-CLASS $cfg->setConfigEntry('hub_ping_iterator_class', 'HubPingIterator'); +// CFG: TEST-UNIT-PRODUCER-KEY-ITERATOR-CLASS +$cfg->setConfigEntry('test_unit_producer_key_iterator_class', 'TestUnitKeyProducerIterator'); + +// CFG: WORK-UNIT-PRODUCER-KEY-ITERATOR-CLASS +$cfg->setConfigEntry('work_unit_producer_key_iterator_class', 'WorkUnitKeyProducerIterator'); + // CFG: LOCAL-QUERY-LIST-CLASS $cfg->setConfigEntry('local_query_list_class', 'LocalQueryList'); diff --git a/application/hub/interfaces/helper/messages/class_MessageHelper.php b/application/hub/interfaces/helper/messages/class_MessageHelper.php index 81057a706..2f2364b4c 100644 --- a/application/hub/interfaces/helper/messages/class_MessageHelper.php +++ b/application/hub/interfaces/helper/messages/class_MessageHelper.php @@ -22,6 +22,20 @@ * along with this program. If not, see . */ interface MessageHelper extends Helper { + /** + * Generates an encrypted random message + * + * @return $encryptedMessage The encrypted random message + */ + function generateRandomMessage (); + + /** + * "Getter" for an iterator for keys + * + * @param $encryptedMessage The encrypted message + * @return $iteratorInstance An instance of a Iterator class + */ + function getKeyIterator (); } // [EOF] diff --git a/application/hub/interfaces/work_units/class_UnitHelper.php b/application/hub/interfaces/work_units/class_UnitHelper.php index cada8ebc6..bed72540b 100644 --- a/application/hub/interfaces/work_units/class_UnitHelper.php +++ b/application/hub/interfaces/work_units/class_UnitHelper.php @@ -25,9 +25,9 @@ interface UnitHelper extends FrameworkInterface { /** * Generates a work/test/foo unit instance * - * @return $unitInstance A work unit instance + * @return $unitInstance A work/test/foo unit instance */ - function generateUnit (); + function generateNextUnitInstance (); } // [EOF] diff --git a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php b/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php index 442268e7c..ca4567b71 100644 --- a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php +++ b/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php @@ -72,7 +72,7 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis // We don't need an iterator here because we just need to generate some test units for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) { // Get a test unit from it - $unitInstance = $generatorInstance->generateUnit(); + $unitInstance = $generatorInstance->generateNextUnitInstance(); // ... and finally queue it to the in-buffer queue $this->queueUnitInstanceToInBuffer($unitInstance); diff --git a/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php b/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php index 9ec203cb7..9c11a0722 100644 --- a/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php +++ b/application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php @@ -64,6 +64,19 @@ class CryptoRandomUnitMessageHelper extends BaseMessageHelper implements Message // Return it return $encryptedMessage; } + + /** + * "Getter" for an iterator for keys + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getKeyIterator () { + // Create the iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('test_unit_producer_key_iterator_class'); + + // And return it + return $iteratorInstance; + } } // [EOF] diff --git a/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php b/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php index 38cf1c67b..8bb3926ca 100644 --- a/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php +++ b/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php @@ -63,7 +63,7 @@ class CruncherTestUnitHelper extends BaseWorkUnitHelper implements UnitHelper { * @return $unitInstance A work unit instance * @todo 0% done */ - public function generateUnit () { + public function generateNextUnitInstance () { $this->partialStub('Please implement this method.'); } } diff --git a/application/hub/main/iterator/producer/.htaccess b/application/hub/main/iterator/producer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/producer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php b/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php new file mode 100644 index 000000000..1e52bf435 --- /dev/null +++ b/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function createTestUnitKeyProducerIterator () { + // Get new instance + $iteratorInstance = new TestUnitKeyProducerIterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php index 545babfee..deb010694 100644 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -110,11 +110,15 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, /* * Now we need to create an iterator, just as for the work units, * to create new keys from the encrypted message. The iterator will - * not iterate over an object or collection. It will instead + * not iterate over an object nor a collection. It will instead * encapsulate "key production" into a class and not in a simple * for() loop. These keys then needs to be bundled into test units * and stored to database for later re-usage. */ + + // First get an iterator, again the helper will do that for us + $iteratorInstance = $this->getHelperInstance()->getKeyIterator(); + die(__METHOD__."\n"); } } } diff --git a/db/cruncher_projects/.htaccess b/db/cruncher_projects/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/db/cruncher_projects/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/docs/TODOs.txt b/docs/TODOs.txt index 7096d7682..189ba59a6 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -97,10 +97,10 @@ ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo Try to rewrite user/guest login classes and mark this exception as deprecated ./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo Rename this class to NoFoundEntryException ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo Find a better name for this interface -./inc/classes/main/class_BaseFrameworkSystem.php:1178: * @todo Write a logging mechanism for productive mode -./inc/classes/main/class_BaseFrameworkSystem.php:1192: // @TODO Finish this part! +./inc/classes/main/class_BaseFrameworkSystem.php:1196: * @todo Write a logging mechanism for productive mode +./inc/classes/main/class_BaseFrameworkSystem.php:1210: // @TODO Finish this part! ./inc/classes/main/class_BaseFrameworkSystem.php:169: // @todo Try to clean these constants up -./inc/classes/main/class_BaseFrameworkSystem.php:355: * @todo SearchableResult and UpdateableResult shall have a super interface to use here +./inc/classes/main/class_BaseFrameworkSystem.php:367: * @todo SearchableResult and UpdateableResult shall have a super interface to use here ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64: * @todo Add some stuff here: Some personal data, app/game related data ./inc/classes/main/commands/web/class_WebProblemCommand.php:58: * @todo 0% done ./inc/classes/main/commands/web/class_WebStatusCommand.php:58: * @todo 0% done @@ -118,7 +118,7 @@ ./inc/classes/main/controller/web/class_WebProblemController.php:40: * @todo Add some filters to this controller ./inc/classes/main/controller/web/class_WebRegisterController.php:40: * @todo Add some filters to this controller ./inc/classes/main/controller/web/class_WebStatusController.php:10: * @todo This controller shall still provide some headlines for sidebars -./inc/classes/main/criteria/search/class_SearchCriteria.php:114: * @todo Find a nice casting here. (int) allows until and including 32766. +./inc/classes/main/criteria/search/class_SearchCriteria.php:126: * @todo Find a nice casting here. (int) allows until and including 32766. ./inc/classes/main/criteria/search/class_SearchCriteria.php:94: * @todo Find a nice casting here. (int) allows until and including 32766. ./inc/classes/main/database/databases/class_LocalFileDatabase.php:360: * @todo Do some checks on the database directory and files here ./inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php:426: * @todo Find something useful with this! -- 2.39.5