mirror of https://github.com/apache/jclouds.git
JCLOUDS-885: Add utility to gzip data
Useful for integration tests which expect gzip data.
This commit is contained in:
parent
2e7de9f850
commit
9342cad895
|
@ -16,9 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.utils;
|
package org.jclouds.utils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
|
|
||||||
|
@ -90,4 +92,12 @@ public class TestUtils {
|
||||||
closed = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] gzip(byte[] data) throws IOException {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length);
|
||||||
|
GZIPOutputStream gos = new GZIPOutputStream(baos);
|
||||||
|
gos.write(data, 0, data.length);
|
||||||
|
gos.finish();
|
||||||
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue