public static byte[] decodeBase64Zipped( String string ) throws IOException {
    if ( string == null || string.isEmpty() ) {
      return new byte[0];
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // base 64 decode
    byte[] bytes64 = org.apache.commons.codec.binary.Base64.decodeBase64( string.getBytes(  ) );
    ByteArrayInputStream zip = new ByteArrayInputStream( bytes64 );

    try (
      GZIPInputStream unzip = new GZIPInputStream( zip, ZIP_BUFFER_SIZE );
      BufferedInputStream in = new BufferedInputStream( unzip, ZIP_BUFFER_SIZE );
    ) {
      byte[] buff = new byte[ ZIP_BUFFER_SIZE ];
      for ( int length = 0; ( length = in.read( buff ) ) > 0; ) {
        baos.write( buff, 0, length );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( "Unexpected error trying to decode object.", e );
    }

    return baos.toByteArray();
  }
@Test
  public void testDecodeBase64Zipped() throws Exception {
    TestClass testClass = new TestClass();
    testClass.setTestProp1( "testPropValue1" );
    testClass.setTestProp2( "testPropValue2" );

    String base64ZippedString = this.encode( testClass );

    TestClass reconstructedTestClass = (TestClass) this.decode( base64ZippedString );

    Assert.assertNotNull( reconstructedTestClass );
    Assert.assertEquals( reconstructedTestClass.getTestProp1(), testClass.getTestProp1() );
    Assert.assertEquals( reconstructedTestClass.getTestProp2(), testClass.getTestProp2() );
  }