Re-enabled additional tests
This commit is contained in:
parent
b2b8197388
commit
0c96fd75af
|
@ -4,7 +4,8 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.type.descriptor.sql;
|
||||
package org.hibernate.orm.test.type.descriptor.sql;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
@ -12,7 +13,7 @@ import java.sql.Clob;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
|
@ -39,7 +40,7 @@ public class PreparedStatementProxy<T> implements InvocationHandler {
|
|||
@SuppressWarnings({ "unchecked" })
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if ( value == null ) {
|
||||
Assert.assertEquals( "Expecting setNull call", "setNull", method.getName() );
|
||||
assertEquals( "setNull", method.getName(), "Expecting setNull call" );
|
||||
return null;
|
||||
}
|
||||
if ( method.getName().equals( methodName ) && args.length >= 1 ) {
|
||||
|
@ -50,14 +51,14 @@ public class PreparedStatementProxy<T> implements InvocationHandler {
|
|||
}
|
||||
|
||||
protected void checkValue(T arg) throws SQLException {
|
||||
Assert.assertEquals( value, arg );
|
||||
assertEquals( value, arg );
|
||||
}
|
||||
|
||||
protected final String extractString(Clob clob) throws SQLException {
|
||||
if ( StringClobImpl.class.isInstance( clob ) ) {
|
||||
return ( (StringClobImpl) clob ).getValue();
|
||||
}
|
||||
return clob.getSubString( 1, (int)clob.length() );
|
||||
return clob.getSubString( 1, (int) clob.length() );
|
||||
}
|
||||
|
||||
private final String methodName;
|
||||
|
@ -83,7 +84,7 @@ public class PreparedStatementProxy<T> implements InvocationHandler {
|
|||
new PreparedStatementProxy<Clob>( "setClob", value ) {
|
||||
@Override
|
||||
protected void checkValue(Clob arg) throws SQLException {
|
||||
Assert.assertEquals( extractString( getValue() ), extractString( arg ) );
|
||||
assertEquals( extractString( getValue() ), extractString( arg ) );
|
||||
}
|
||||
}
|
||||
);
|
|
@ -4,7 +4,8 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.type.descriptor.sql;
|
||||
package org.hibernate.orm.test.type.descriptor.sql;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
@ -53,13 +54,13 @@ public class ResultSetProxy<T> implements InvocationHandler {
|
|||
|
||||
public static ResultSet generateProxy(final String value) {
|
||||
return generateProxy(
|
||||
new ResultSetProxy<String>( "getString", value )
|
||||
new ResultSetProxy<>( "getString", value )
|
||||
);
|
||||
}
|
||||
|
||||
public static ResultSet generateProxy(final Clob value) {
|
||||
return generateProxy(
|
||||
new ResultSetProxy<Clob>( "getClob", value )
|
||||
new ResultSetProxy<>( "getClob", value )
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.type.descriptor.sql;
|
||||
package org.hibernate.orm.test.type.descriptor.sql;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
|
@ -4,7 +4,8 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.type.descriptor.sql;
|
||||
package org.hibernate.orm.test.type.descriptor.sql;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -13,39 +14,52 @@ import java.util.TimeZone;
|
|||
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.ClobTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class StringValueMappingTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class StringValueMappingTest {
|
||||
private final StringTypeDescriptor stringJavaDescriptor = new StringTypeDescriptor();
|
||||
|
||||
private final VarcharTypeDescriptor varcharSqlDescriptor = new VarcharTypeDescriptor();
|
||||
private final ClobTypeDescriptor clobSqlDescriptor = ClobTypeDescriptor.DEFAULT;
|
||||
|
||||
private final WrapperOptions wrapperOptions = new WrapperOptions() {
|
||||
@Override
|
||||
public SharedSessionContractImplementor getSession() {
|
||||
return getSession();
|
||||
}
|
||||
|
||||
public boolean useStreamForLobBinding() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferredSqlTypeCodeForBoolean() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public LobCreator getLobCreator() {
|
||||
return NonContextualLobCreator.INSTANCE;
|
||||
}
|
||||
|
||||
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
||||
public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor sqlTypeDescriptor) {
|
||||
return sqlTypeDescriptor;
|
||||
}
|
||||
|
||||
|
@ -55,7 +69,7 @@ public class StringValueMappingTest extends BaseUnitTestCase {
|
|||
}
|
||||
};
|
||||
|
||||
public static final String COLUMN_NAME = "n/a";
|
||||
public static final int COLUMN_POSITION = 0;
|
||||
public static final int BIND_POSITION = -1;
|
||||
|
||||
@Test
|
||||
|
@ -66,7 +80,7 @@ public class StringValueMappingTest extends BaseUnitTestCase {
|
|||
final String fixture = "string value";
|
||||
|
||||
ResultSet resultSet = ResultSetProxy.generateProxy( fixture );
|
||||
final String value = extractor.extract( resultSet, COLUMN_NAME, wrapperOptions );
|
||||
final String value = extractor.extract( resultSet, COLUMN_POSITION, wrapperOptions );
|
||||
assertEquals( fixture, value );
|
||||
|
||||
PreparedStatement ps = PreparedStatementProxy.generateProxy( fixture );
|
||||
|
@ -81,7 +95,7 @@ public class StringValueMappingTest extends BaseUnitTestCase {
|
|||
final String fixture = null;
|
||||
|
||||
ResultSet resultSet = ResultSetProxy.generateProxy( fixture );
|
||||
final String value = extractor.extract( resultSet, COLUMN_NAME, wrapperOptions );
|
||||
final String value = extractor.extract( resultSet, COLUMN_POSITION, wrapperOptions );
|
||||
assertEquals( fixture, value );
|
||||
|
||||
PreparedStatement ps = PreparedStatementProxy.generateProxy( fixture );
|
||||
|
@ -97,7 +111,7 @@ public class StringValueMappingTest extends BaseUnitTestCase {
|
|||
final Clob clob = new StringClobImpl( fixture );
|
||||
|
||||
ResultSet resultSet = ResultSetProxy.generateProxy( clob );
|
||||
final String value = extractor.extract( resultSet, COLUMN_NAME, wrapperOptions );
|
||||
final String value = extractor.extract( resultSet, COLUMN_POSITION, wrapperOptions );
|
||||
assertEquals( fixture, value );
|
||||
|
||||
PreparedStatement ps = PreparedStatementProxy.generateProxy( clob );
|
||||
|
@ -113,7 +127,7 @@ public class StringValueMappingTest extends BaseUnitTestCase {
|
|||
final Clob clob = null;
|
||||
|
||||
ResultSet resultSet = ResultSetProxy.generateProxy( clob );
|
||||
final String value = extractor.extract( resultSet, COLUMN_NAME, wrapperOptions );
|
||||
final String value = extractor.extract( resultSet, COLUMN_POSITION, wrapperOptions );
|
||||
assertNull( value );
|
||||
|
||||
PreparedStatement ps = PreparedStatementProxy.generateProxy( clob );
|
Loading…
Reference in New Issue