Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common-lib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
lib
common-lib
Commits
cf063506
Commit
cf063506
authored
2 months ago
by
Krzysztof Witukiewicz
Browse files
Options
Downloads
Patches
Plain Diff
OZG-7262 OZG-7680 Remove unneeded code
parent
133aa19b
No related branches found
No related tags found
1 merge request
!8
Ozg 7262 fix unfinished downloads
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java
+1
-69
1 addition, 69 deletions
...common/binaryfile/GrpcBinaryFileServerDownloaderTest.java
with
1 addition
and
69 deletions
ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java
+
1
−
69
View file @
cf063506
...
...
@@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.*;
import
static
org
.
mockito
.
ArgumentMatchers
.*;
import
static
org
.
mockito
.
Mockito
.*;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
...
...
@@ -40,7 +39,6 @@ import java.util.function.Consumer;
import
java.util.function.Function
;
import
java.util.stream.Stream
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Nested
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -486,7 +484,7 @@ class GrpcBinaryFileServerDownloaderTest {
@ParameterizedTest
@MethodSource
(
"provideArguments"
)
void
shouldReturnValue
(
boolean
requestFinished
,
boolean
ready
,
boolean
expected
)
{
ReflectionTestUtils
.
setField
(
downloader
,
"requestFinished"
,
new
AtomicBoolean
(
requestFinished
)
)
;
setRequestFinishedField
(
requestFinished
);
lenient
().
when
(
callObserver
.
isReady
()).
thenReturn
(
ready
);
var
canSendChunks
=
downloader
.
canSendChunks
();
...
...
@@ -635,72 +633,6 @@ class GrpcBinaryFileServerDownloaderTest {
return
(
TechnicalException
)
ReflectionTestUtils
.
getField
(
downloader
,
"downloadError"
,
AtomicReference
.
class
).
get
();
}
private
void
setDownloadFinishedField
(
boolean
downloadFinished
)
{
ReflectionTestUtils
.
setField
(
downloader
,
"downloadFinished"
,
new
AtomicBoolean
(
downloadFinished
));
}
private
boolean
getDownloadFinished
()
{
return
ReflectionTestUtils
.
getField
(
downloader
,
"downloadFinished"
,
AtomicBoolean
.
class
).
get
();
}
private
static
class
GrpcResponseDummy
{
}
@Nested
class
TestStreams
{
private
static
final
int
CHUNK_SIZE
=
255
*
1024
;
private
PipedInputStream
inputStream
;
private
PipedOutputStream
outputStream
;
@SneakyThrows
@BeforeEach
void
init
()
{
outputStream
=
new
PipedOutputStream
();
inputStream
=
new
PipedInputStream
(
CHUNK_SIZE
);
outputStream
.
connect
(
inputStream
);
}
@SneakyThrows
@Test
void
shouldReadIncompleteFile
()
{
var
fileBuffer
=
new
byte
[
CHUNK_SIZE
];
var
readBuffer
=
new
byte
[
CHUNK_SIZE
];
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
"/Users/kwitukiewicz/Documents/books/__Debt__The_First_5_000_Years.pdf"
))
{
fileInputStream
.
read
(
fileBuffer
,
0
,
255
);
outputStream
.
write
(
fileBuffer
,
0
,
1
);
var
read
=
inputStream
.
read
(
readBuffer
,
0
,
CHUNK_SIZE
);
assertThat
(
read
).
isEqualTo
(
1
);
}
}
@SneakyThrows
@Test
void
shouldReadAfterOutputStreamWasClosed
()
{
var
fileBuffer
=
new
byte
[
CHUNK_SIZE
];
var
readBuffer
=
new
byte
[
CHUNK_SIZE
*
2
];
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
"/Users/kwitukiewicz/Documents/books/__Debt__The_First_5_000_Years.pdf"
))
{
fileInputStream
.
read
(
fileBuffer
,
0
,
fileBuffer
.
length
);
outputStream
.
write
(
fileBuffer
);
outputStream
.
close
();
var
read
=
inputStream
.
read
(
readBuffer
);
assertThat
(
read
).
isEqualTo
(
CHUNK_SIZE
);
read
=
inputStream
.
read
(
readBuffer
);
assertThat
(
read
).
isEqualTo
(-
1
);
}
}
@SneakyThrows
@AfterEach
void
cleanup
()
{
outputStream
.
close
();
inputStream
.
close
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment