@Test
public void testUpdateHiveEnvContent() throws Exception {

  setupIoCContext();
  final Injector mockInjector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
    }
  });
  String testContent = " if [ \"$SERVICE\" = \"cli\" ]; then\n" +
          "   if [ -z \"$DEBUG\" ]; then\n" +
          "     export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit\"\n" +
          "   else\n" +
          "     export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit\"\n" +
          "   fi\n" +
          " fi\n" +
          "\n" +
          "export HADOOP_HEAPSIZE=\"{{hive_heapsize}}\"\n" +
          "export HADOOP_CLIENT_OPTS=\"-Xmx${HADOOP_HEAPSIZE}m $HADOOP_CLIENT_OPTS\"\n" +
          "\n" +
          "# Set HADOOP_HOME to point to a specific hadoop install directory\n" +
          "HADOOP_HOME=${HADOOP_HOME:-{{hadoop_home}}}\n";
  String expectedResult = " if [ \"$SERVICE\" = \"cli\" ]; then\n" +
          "   if [ -z \"$DEBUG\" ]; then\n" +
          "     export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit\"\n" +
          "   else\n" +
          "     export HADOOP_OPTS=\"$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit\"\n" +
          "   fi\n" +
          " fi\n" +
          "\n" +
          "\n" +
          "\n" +
          "# Set HADOOP_HOME to point to a specific hadoop install directory\n" +
          "HADOOP_HOME=${HADOOP_HOME:-{{hadoop_home}}}\n";
  assertEquals(expectedResult, mockInjector.getInstance(UpgradeCatalog212.class).updateHiveEnvContent(testContent));
}