package com.zaxxer.hikari;

import java.sql.Connection;
import java.util.Properties;

import org.hibernate.service.UnknownUnwrapTypeException;
import org.junit.Assert;
import org.junit.Test;

import com.zaxxer.hikari.hibernate.HikariConnectionProvider;

public class TestHibernate
{
   @Test
   public void testConnectionProvider() throws Exception
   {
      HikariConnectionProvider provider = new HikariConnectionProvider();

      Properties props = new Properties();
      props.load(getClass().getResourceAsStream("/hibernate.properties"));

      provider.configure(props);
      Connection connection = provider.getConnection();
      provider.closeConnection(connection);

      Assert.assertNotNull(provider.unwrap(HikariConnectionProvider.class));
      Assert.assertFalse(provider.supportsAggressiveRelease());

      try {
         provider.unwrap(TestHibernate.class);
         Assert.fail("Expected exception");
      }
      catch (UnknownUnwrapTypeException e) {
      }

      provider.stop();
   }
}

package com.zaxxer.hikari;

import java.sql.Connection;
import java.util.Properties;

import org.junit.Assert;
import org.junit.Test;

import com.zaxxer.hikari.hibernate.HikariConnectionProvider;

public class TestHibernate
{
   @Test
   public void testConnectionProvider() throws Exception
   {
      HikariConnectionProvider provider = new HikariConnectionProvider();

      Properties props = new Properties();
      props.load(getClass().getResourceAsStream("/hibernate.properties"));

      provider.configure(props);
      Connection connection = provider.getConnection();
      provider.closeConnection(connection);

      Assert.assertNotNull(provider.unwrap(HikariConnectionProvider.class));
      Assert.assertFalse(provider.supportsAggressiveRelease());
      provider.stop();
   }
}

--- 
+++ 
@@ -3,6 +3,7 @@
 import java.sql.Connection;
 import java.util.Properties;
 
+import org.hibernate.service.UnknownUnwrapTypeException;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -24,6 +25,14 @@
 
       Assert.assertNotNull(provider.unwrap(HikariConnectionProvider.class));
       Assert.assertFalse(provider.supportsAggressiveRelease());
+
+      try {
+         provider.unwrap(TestHibernate.class);
+         Assert.fail("Expected exception");
+      }
+      catch (UnknownUnwrapTypeException e) {
+      }
+
       provider.stop();
    }
 }
Test unwrap exception for Hibernate
