2 * This file is part of TouristP2PImpl
4 * Copyright (C) 2007,2008 NUST Institute of Information Technology
5 * Author: Faisal Khan <faisal.khan at [niit.edu.pk | cern.ch ]>
7 * TouristP2PImpl is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * TouristP2PImpl is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with TouristP2PImpl; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "TestCacheXfer.h"
22 #include "Tourist/Id.h"
23 #include "Tourist/TouristExceptions.h"
24 #include "Tourist/App/Application.h"
25 #include "CppUnit/TestCaller.h"
26 #include "CppUnit/TestSuite.h"
29 using Tourist::InvalidArgumentException
;
30 using Tourist::App::Application
;
33 using namespace Tourist::App
;
35 TestCacheXfer::TestCacheXfer(const std::string
& name
): CppUnit::TestCase(name
)
39 TestCacheXfer::~TestCacheXfer()
43 void TestCacheXfer::setUp()
47 void TestCacheXfer::tearDown()
51 void TestCacheXfer::testGetRemoteCache()
55 config_1
.setTCPEnable(true);
56 config_1
.setTCPPort(5000);
57 Application
app1(config_1
);
61 config_2
.setTCPEnable(true);
62 config_2
.setTCPPort(5010);
63 Application
app2(config_2
);
65 assert (app1
.init() == 0);
66 assert (app2
.init() == 0);
73 //connect to remote-node of application-1 with application-2
74 RemoteNode
*rn
= NULL
;
75 vector
<TransportInfo
> transportInfo
;
76 transportInfo
= app1
.getEnabledTransports();
78 assert (transportInfo
.size() != 0);
80 TransportInfo tInfo
= transportInfo
.at(0);
81 int status
= app2
.connectionTo(tInfo
.host
, tInfo
.port
, tInfo
.type
, &rn
, 10);
84 assert (rn
-> getHost() == tInfo
.host
);
85 assert (rn
-> getPort() == tInfo
.port
);
86 assert (rn
-> getProtocol() == tInfo
.type
);
87 assert (rn
-> getPipe() != NULL
);
89 //add the nodes to app1
90 RemoteNode rn1
, rn2
, rn3
;
91 app1
.addNewNode(&rn1
);
92 app1
.addNewNode(&rn2
);
93 app1
.addNewNode(&rn3
);
95 Tourist::NodeSet result
;
96 status
= app2
.getRemoteCache(rn
, PREFIX
, 0, 5, 10, result
);
98 assert(result
.treeSize
== 4);
107 CppUnit::Test
* TestCacheXfer::suite()
109 CppUnit::TestSuite
* pSuite
= new CppUnit::TestSuite("TestCacheXfer");
110 CppUnit_addTest(pSuite
, TestCacheXfer
, testGetRemoteCache
);