@@ -90,5 +90,32 @@ public void copyToNonExistingContainer() throws Exception {
9090 } catch (NotFoundException ignored ) {
9191 }
9292 }
93+
94+ @ Test
95+ public void copyDirWithLastAddedTarEnryEmptyDir () throws Exception {
96+ // create a temp dir
97+ Path localDir = Files .createTempDirectory ("" );
98+ localDir .toFile ().deleteOnExit ();
99+ // create sub-dir with name b
100+ Path emptyDir = Files .createTempDirectory (localDir .resolve ("b" ), "" );
101+ emptyDir .toFile ().deleteOnExit ();
102+ // creaet sub-dir with name a
103+ Path dirWithFile = Files .createTempDirectory (localDir .resolve ("a" ), "" );
104+ dirWithFile .toFile ().deleteOnExit ();
105+ // create file in sub-dir b, name or conter are irrelevant
106+ Path file = Files .createTempFile (dirWithFile .resolve ("file" ), "" , "" );
107+ file .toFile ().deleteOnExit ();
108+
109+ // create a test container
110+ CreateContainerResponse container = dockerClient .createContainerCmd ("progrium/busybox:latest" )
111+ .withCmd ("/bin/sh" , "-c" , "while true; do sleep 9999; done" )
112+ .exec ();
113+ // start the container
114+ dockerClient .startContainerCmd (container .getId ()).exec ();
115+ // copy data from local dir to container
116+ dockerClient .copyArchiveToContainerCmd (container .getId ())
117+ .withHostResource (localDir .toString ())
118+ .exec ();
119+ }
93120
94121}
0 commit comments