Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleUploadInACoupleOfRounds() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleUploadInACoupleOfRounds()
        {
            ControlledProgressListener progressListener = new ControlledProgressListener();
            HttpCopier copier = new HttpCopier(new ControlledOutsideWorld(_fs), millis =>
            {
            }, (name, length) => progressListener);
            Path   source                     = CreateDump();
            long   sourceLength               = _fs.getFileSize(source.toFile());
            long   firstUploadLength          = sourceLength / 3;
            string authorizationTokenResponse = "abc";
            string signedURIPath              = "/signed";
            string uploadLocationPath         = "/upload";

            WireMock.stubFor(AuthenticationRequest(false).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse)));
            WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(SuccessfulInitiateUploadTargetResponse(signedURIPath)));
            WireMock.stubFor(InitiateUploadRequest(signedURIPath).willReturn(SuccessfulInitiateUploadResponse(uploadLocationPath)));
            WireMock.stubFor(ResumeUploadRequest(uploadLocationPath, 0, sourceLength).willReturn(aResponse().withStatus(HTTP_INTERNAL_ERROR)));
            WireMock.stubFor(GetResumablePositionRequest(sourceLength, uploadLocationPath).willReturn(UploadIncompleteGetResumablePositionResponse(firstUploadLength)));
            WireMock.stubFor(ResumeUploadRequest(uploadLocationPath, firstUploadLength, sourceLength).willReturn(SuccessfulResumeUploadResponse()));
            WireMock.stubFor(TriggerImportRequest(authorizationTokenResponse).willReturn(SuccessfulTriggerImportResponse()));
            WireMock.stubFor(FirstStatusPollingRequest(authorizationTokenResponse));
            WireMock.stubFor(SecondStatusPollingRequest(authorizationTokenResponse));

            // when
            AuthenticateAndCopy(copier, source, "user", "pass".ToCharArray());

            // then
            verify(putRequestedFor(urlEqualTo(uploadLocationPath)).withHeader("Content-Length", equalTo(Convert.ToString(sourceLength))).withoutHeader("Content-Range"));
            verify(putRequestedFor(urlEqualTo(uploadLocationPath)).withHeader("Content-Length", equalTo(Convert.ToString(sourceLength - firstUploadLength))).withHeader("Content-Range", equalTo(format("bytes %d-%d/%d", firstUploadLength, sourceLength - 1, sourceLength))));
            verify(putRequestedFor(urlEqualTo(uploadLocationPath)).withHeader("Content-Length", equalTo("0")).withHeader("Content-Range", equalTo("bytes */" + sourceLength)));
            assertTrue(progressListener.DoneCalled);
            // we need to add 3 to the progress listener because of the database phases
            assertEquals(sourceLength + 3, progressListener.Progress);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleSuccessfulHappyCaseRunThroughOfTheWholeProcess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleSuccessfulHappyCaseRunThroughOfTheWholeProcess()
        {
            // given
            ControlledProgressListener progressListener = new ControlledProgressListener();
            HttpCopier copier = new HttpCopier(new ControlledOutsideWorld(_fs), millis =>
            {
            }, (name, length) => progressListener);
            Path source       = CreateDump();
            long sourceLength = _fs.getFileSize(source.toFile());

            string authorizationTokenResponse = "abc";
            string signedURIPath      = "/signed";
            string uploadLocationPath = "/upload";

            WireMock.stubFor(AuthenticationRequest(false).willReturn(SuccessfulAuthorizationResponse(authorizationTokenResponse)));
            WireMock.stubFor(InitiateUploadTargetRequest(authorizationTokenResponse).willReturn(SuccessfulInitiateUploadTargetResponse(signedURIPath)));
            WireMock.stubFor(InitiateUploadRequest(signedURIPath).willReturn(SuccessfulInitiateUploadResponse(uploadLocationPath)));
            WireMock.stubFor(ResumeUploadRequest(uploadLocationPath, sourceLength).willReturn(SuccessfulResumeUploadResponse()));
            WireMock.stubFor(TriggerImportRequest(authorizationTokenResponse).willReturn(SuccessfulTriggerImportResponse()));
            WireMock.stubFor(FirstStatusPollingRequest(authorizationTokenResponse));
            WireMock.stubFor(SecondStatusPollingRequest(authorizationTokenResponse));

            // when
            AuthenticateAndCopy(copier, source, "user", "pass".ToCharArray());

            // then
            verify(postRequestedFor(urlEqualTo("/import/auth")));
            verify(postRequestedFor(urlEqualTo("/import")));
            verify(postRequestedFor(urlEqualTo(signedURIPath)));
            verify(putRequestedFor(urlEqualTo(uploadLocationPath)));
            verify(postRequestedFor(urlEqualTo("/import/upload-complete")));
            assertTrue(progressListener.DoneCalled);
            // we need to add 3 to the progress listener because of the database phases
            assertEquals(sourceLength + 3, progressListener.Progress);
        }