Exemplo n.º 1
0
    void setUp() {
        Transfer::ListOfServices *services;

        mNameService = new Transfer::CachedServiceLookup();
        services = new Transfer::ListOfServices;
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("testoftheemergencybroadcastsystem","blah","",""),
                                Transfer::ServiceParams())); // check that other URIs will be tried
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http","localhost","","nonexistantdirectory"),
                                Transfer::ServiceParams()));
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http","graphics.stanford.edu","","~danielrh/dns/names/global"),
                                Transfer::ServiceParams()));
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http","localhost","","nonexistantdirectory1"),
                                Transfer::ServiceParams()));
        mNameService->addToCache(URIContext("meerkat","","",""), Transfer::ListOfServicesPtr(services));

        mDownloadService = new Transfer::CachedServiceLookup();
        services = new Transfer::ListOfServices;
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("testoftheemergencybroadcastsystem2","blah","",""),
                                Transfer::ServiceParams())); // check that other URIs will be tried
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http", "localhost","","nonexistantdirectory2"),
                                Transfer::ServiceParams()));
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http","graphics.stanford.edu","","~danielrh/uploadsystem/files/global"),
                                Transfer::ServiceParams()));
        services->push_back(Transfer::ListOfServices::value_type(
                                URIContext("http", "localhost","","nonexistantdirectory3"),
                                Transfer::ServiceParams()));
        mDownloadService->addToCache(URIContext("mhash","","",""), Transfer::ListOfServicesPtr(services));

        mNameLookupReg = new Transfer::ProtocolRegistry<Transfer::NameLookupHandler>;
        std::tr1::shared_ptr<Transfer::HTTPDownloadHandler> httpHandler(new Transfer::HTTPDownloadHandler);
        mNameLookupReg->setHandler("http", httpHandler);
        mNameLookupMgr = new Transfer::ServiceManager<Transfer::NameLookupHandler>(mNameService,mNameLookupReg);
        mNameLookups = new Transfer::NameLookupManager(mNameLookupMgr);
        mCachedNameLookups = new Transfer::CachedNameLookupManager(mNameLookupMgr);

        mDownloadReg = new Transfer::ProtocolRegistry<Transfer::DownloadHandler>;
        mDownloadReg->setHandler("http", httpHandler);
        mDownloadMgr = new Transfer::ServiceManager<Transfer::DownloadHandler>(mDownloadService,mDownloadReg);
        mTransferLayer = new Transfer::NetworkCacheLayer(NULL, mDownloadMgr);

        finishedTest = 0;
    }
Exemplo n.º 2
0
	virtual void setUp() {
		finishedTest = 0;
		mCacheLayers.clear();
		mProtoReg = new Transfer::ProtocolRegistry<Transfer::DownloadHandler>();
		std::tr1::shared_ptr<Transfer::HTTPDownloadHandler> httpHandler(new Transfer::HTTPDownloadHandler);
		mProtoReg->setHandler("http", httpHandler);
		mNullService = new Transfer::NullServiceLookup();
		mServiceManager = new Transfer::ServiceManager<Transfer::DownloadHandler>(mNullService,mProtoReg);
	}
Exemplo n.º 3
0
	void setUp() {
		Transfer::ListOfServices *services;
		Transfer::ServiceParams params;
		Transfer::ProtocolRegistry<Transfer::DownloadHandler> *mDownloadReg;
		Transfer::ProtocolRegistry<Transfer::NameLookupHandler> *mDownNameReg;
		Transfer::ProtocolRegistry<Transfer::UploadHandler> *mUploadReg;
		Transfer::ProtocolRegistry<Transfer::NameUploadHandler> *mUpNameReg;
		Transfer::ServiceLookup *mDownNameService;
		Transfer::ServiceLookup *mDownloadService;
		Transfer::ServiceLookup *mUploadService;
		Transfer::ServiceLookup *mUpNameService;

		std::tr1::shared_ptr<Transfer::HTTPDownloadHandler> httpDownHandler(new Transfer::HTTPDownloadHandler);
		std::tr1::shared_ptr<Transfer::HTTPFormUploadHandler> httpUpHandler(new Transfer::HTTPFormUploadHandler);
		std::tr1::shared_ptr<Transfer::FileProtocolHandler> fileHandler(new Transfer::FileProtocolHandler);
		std::tr1::shared_ptr<Transfer::FileNameHandler> fileNameHandler(new Transfer::FileNameHandler(fileHandler));

		mDestroyEventManager = false;
		mWorkQueue = new Task::ThreadSafeWorkQueue;
		mEventSystem = new Task::GenEventManager(mWorkQueue);
		mEventProcessThread = new Thread(std::tr1::bind(
			&UploadTest::sleep_processEventQueue, this));

		mDownNameService = new Transfer::CachedServiceLookup;
		services = new Transfer::ListOfServices;
		services->push_back(Transfer::ListOfServices::value_type(
				URIContext(SERVER "/dns.txt"),
				Transfer::ServiceParams()));
		mDownNameService->addToCache(URIContext("meerkat:"), Transfer::ListOfServicesPtr(services));
		mDownNameReg = new Transfer::ProtocolRegistry<Transfer::NameLookupHandler>;
		mDownNameServMgr = new Transfer::ServiceManager<Transfer::NameLookupHandler>(mDownNameService,mDownNameReg);
		mDownNameReg->setHandler("http", httpDownHandler);
		mDownNameReg->setHandler("file", fileNameHandler);

		mDownloadService = new Transfer::CachedServiceLookup;
		services = new Transfer::ListOfServices;
		services->push_back(Transfer::ListOfServices::value_type(
				URIContext(SERVER "/"),
				Transfer::ServiceParams()));
		mDownloadService->addToCache(URIContext("mhash:"), Transfer::ListOfServicesPtr(services));
		mDownloadReg = new Transfer::ProtocolRegistry<Transfer::DownloadHandler>;
		mDownloadServMgr = new Transfer::ServiceManager<Transfer::DownloadHandler>(mDownloadService,mDownloadReg);
		mDownloadReg->setHandler("http", httpDownHandler);
		mDownloadReg->setHandler("file", fileHandler);

		//params.set("field:user", "");
		//params.set("field:password", "authentication0");
		//params.set("value:author", "test");
		params.set("value:password", "test");
		//params.set("value:authentication0", "test");

		mUploadService = new Transfer::CachedServiceLookup;
		params.set("field:file", "uploadFile0");
		params.unset("field:filename");
		params.set("value:uploadNeed", "1");
		services = new Transfer::ListOfServices;
		services->push_back(Transfer::ListOfServices::value_type(
				URIContext(SERVER "/"),
				params));
		mUploadService->addToCache(URIContext("mhash:"), Transfer::ListOfServicesPtr(services));
		mUploadReg = new Transfer::ProtocolRegistry<Transfer::UploadHandler>;
		mUploadServMgr = new Transfer::ServiceManager<Transfer::UploadHandler>(mUploadService,mUploadReg);
		mUploadReg->setHandler("http", httpUpHandler);
		mUploadReg->setHandler("file", fileHandler);

		mUpNameService = new Transfer::CachedServiceLookup;
		params.set("field:file", "MHashFile0");
		params.set("field:filename", "highlevel0");
		params.unset("value:uploadNeed");
		services = new Transfer::ListOfServices;
		services->push_back(Transfer::ListOfServices::value_type(
				URIContext(SERVER "/dns.txt"),
				params));
		mUpNameService->addToCache(URIContext("meerkat:"), Transfer::ListOfServicesPtr(services));
		mUpNameReg = new Transfer::ProtocolRegistry<Transfer::NameUploadHandler>;
		mUpNameServMgr = new Transfer::ServiceManager<Transfer::NameUploadHandler>(mUpNameService,mUpNameReg);
		mUpNameReg->setHandler("http", httpUpHandler);
		mUpNameReg->setHandler("file", fileNameHandler);

		mNetworkCache = new Transfer::NetworkCacheLayer(NULL, mDownloadServMgr);
		mNameLookup = new Transfer::NameLookupManager(mDownNameServMgr, mDownloadServMgr);
		mTransferManager = new Transfer::EventTransferManager(mNetworkCache, mNameLookup, mEventSystem, mDownloadServMgr, mUpNameServMgr, mUploadServMgr);

		mEventSystem->subscribe(Transfer::DownloadEventId, &printTransfer, Task::EARLY);

		finishedTest = 0;
	}