forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogContainerTestCallback.java
More file actions
42 lines (31 loc) · 976 Bytes
/
Copy pathLogContainerTestCallback.java
File metadata and controls
42 lines (31 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.github.dockerjava.utils;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.model.Frame;
import java.util.ArrayList;
import java.util.List;
/**
* @author Kanstantsin Shautsou
*/
public class LogContainerTestCallback extends ResultCallback.Adapter<Frame> {
protected final StringBuffer log = new StringBuffer();
List<Frame> collectedFrames = new ArrayList<>();
boolean collectFrames = false;
public LogContainerTestCallback() {
this(false);
}
public LogContainerTestCallback(boolean collectFrames) {
this.collectFrames = collectFrames;
}
@Override
public void onNext(Frame frame) {
if (collectFrames) collectedFrames.add(frame);
log.append(new String(frame.getPayload()));
}
@Override
public String toString() {
return log.toString();
}
public List<Frame> getCollectedFrames() {
return collectedFrames;
}
}