1 |
williamc |
1.1 |
#
|
2 |
|
|
# ProjectSearcher test
|
3 |
|
|
#
|
4 |
|
|
|
5 |
|
|
package Configuration::test::test_ProjectSearcher;
|
6 |
|
|
use Configuration::ProjectSearcher;
|
7 |
|
|
use Configuration::test::DummyConfigArea;
|
8 |
|
|
use Configuration::test::DummyConfigItem;
|
9 |
|
|
require 5.001;
|
10 |
|
|
|
11 |
|
|
@ISA = ("Utilities::TestClass"); #methods both from the test class
|
12 |
|
|
|
13 |
|
|
sub init {
|
14 |
|
|
my $self=shift;
|
15 |
|
|
my $centraldb=ActiveDoc::ActiveConfig->
|
16 |
|
|
new($self->temparea()."/".$self->newfilename());
|
17 |
|
|
my $userdb=ActiveDoc::ActiveConfig->
|
18 |
|
|
new($self->temparea()."/".$self->newfilename());
|
19 |
|
|
$self->{config}=Configuration::ConfigureStore->new();
|
20 |
|
|
$self->{config}->db("central",$centraldb);
|
21 |
|
|
$self->{config}->db("user",$userdb);
|
22 |
|
|
$area1=Configuration::test::DummyConfigArea->new($self->temparea()."/".
|
23 |
|
|
$self->newfilename());
|
24 |
|
|
$area1->name("testarea1");
|
25 |
|
|
$area1->version("version1");
|
26 |
|
|
$area2=Configuration::test::DummyConfigArea->new($self->temparea()."/".
|
27 |
|
|
$self->newfilename());
|
28 |
|
|
$area2->name("testarea1");
|
29 |
|
|
$area2->version("version1");
|
30 |
|
|
use Configuration::test::ConfigItemTest;
|
31 |
|
|
$item1=Configuration::test::DummyConfigItem->new();
|
32 |
|
|
$item2=Configuration::test::DummyConfigItem->new();
|
33 |
|
|
$item1->name("test");
|
34 |
|
|
$item1->version("V1");
|
35 |
|
|
$item2->name("test");
|
36 |
|
|
$item2->version("V2");
|
37 |
|
|
$area1->storeconfigobject($item1);
|
38 |
|
|
$area2->storeconfigobject($item2);
|
39 |
|
|
|
40 |
|
|
# store the areas in our secondary database hierarchy
|
41 |
|
|
$centraldb->store($area1,"Area1","version1");
|
42 |
|
|
$userdb->store($area2,"Area1","version2");
|
43 |
|
|
|
44 |
|
|
# Cheat a liitle - use the ScramSearcher as an example Searcher object
|
45 |
|
|
$self->{Searcher}=Scram::ScramSearcher->new();
|
46 |
|
|
$self->{Searcher}->config($self->{config});
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
sub test {
|
50 |
|
|
my $self=shift;
|
51 |
|
|
$self->newtest("Set Up");
|
52 |
|
|
$self->newobject();
|
53 |
|
|
$self->newtest("Set Up Searcher");
|
54 |
|
|
$it=$self->testinterface("newiterator");
|
55 |
|
|
$it->iterator($self->{Searcher}->newiterator());
|
56 |
|
|
$it->project("Area1");
|
57 |
|
|
$it->keys("test");
|
58 |
|
|
$self->newtest("Start Iterator");
|
59 |
|
|
$self->_testiterator($it);
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
sub _testiterator {
|
63 |
|
|
my $self=shift;
|
64 |
|
|
my $it=shift;
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
my $teststring="test";
|
68 |
|
|
my (@objs,$ts);
|
69 |
|
|
my $num=0;
|
70 |
|
|
while ( ! $it->last() ) {
|
71 |
|
|
$num++;
|
72 |
|
|
@objs=$it->next();
|
73 |
|
|
if ( $#objs != 0 ) {
|
74 |
|
|
$self->testfail("Wrong number of objects returned ".($#objs+1))
|
75 |
|
|
}
|
76 |
|
|
elsif ( ($ts=$objs[0]->name()) ne $teststring ) {
|
77 |
|
|
$self->testfail("Wrong Object Data Returned got $ts, expecting $teststring");
|
78 |
|
|
}
|
79 |
|
|
else {
|
80 |
|
|
$self->testpass("Correct Object Data Returned");
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
$self->testfail("$num objects returned in total - expecting 2") , if ( $num != 2);
|
84 |
|
|
}
|