HHH-14371 Move tests specific to Javassist to the appropriate source set
Otherwise they won't be executed with the appropriate JVM args. Signed-off-by: Yoann Rodière <yoann@hibernate.org>
This commit is contained in:
parent
8e3bf43a18
commit
7f518cddb3
|
@ -9,7 +9,6 @@ package org.hibernate.test.bytecode;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.hibernate.bytecode.internal.javassist.BulkAccessor;
|
|
||||||
import org.hibernate.bytecode.spi.BytecodeProvider;
|
import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||||
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
import org.hibernate.bytecode.spi.ReflectionOptimizer;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
@ -21,15 +20,6 @@ import org.junit.Test;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class ReflectionOptimizerTest extends BaseUnitTestCase {
|
public class ReflectionOptimizerTest extends BaseUnitTestCase {
|
||||||
@Test
|
|
||||||
public void testBulkAccessorDirectly() {
|
|
||||||
BulkAccessor bulkAccessor = BulkAccessor.create(
|
|
||||||
Bean.class,
|
|
||||||
BeanReflectionHelper.getGetterNames(),
|
|
||||||
BeanReflectionHelper.getSetterNames(),
|
|
||||||
BeanReflectionHelper.getTypes()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReflectionOptimization() {
|
public void testReflectionOptimization() {
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* 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.bytecode.javassist;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class Bean {
|
||||||
|
private String someString;
|
||||||
|
private Long someLong;
|
||||||
|
private Integer someInteger;
|
||||||
|
private Date someDate;
|
||||||
|
private long somelong;
|
||||||
|
private int someint;
|
||||||
|
private Object someObject;
|
||||||
|
|
||||||
|
|
||||||
|
public String getSomeString() {
|
||||||
|
return someString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeString(String someString) {
|
||||||
|
this.someString = someString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSomeLong() {
|
||||||
|
return someLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeLong(Long someLong) {
|
||||||
|
this.someLong = someLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSomeInteger() {
|
||||||
|
return someInteger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeInteger(Integer someInteger) {
|
||||||
|
this.someInteger = someInteger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSomeDate() {
|
||||||
|
return someDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeDate(Date someDate) {
|
||||||
|
this.someDate = someDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSomelong() {
|
||||||
|
return somelong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomelong(long somelong) {
|
||||||
|
this.somelong = somelong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSomeint() {
|
||||||
|
return someint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeint(int someint) {
|
||||||
|
this.someint = someint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSomeObject() {
|
||||||
|
return someObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeObject(Object someObject) {
|
||||||
|
this.someObject = someObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void throwException() throws ParseException {
|
||||||
|
throw new ParseException( "you asked for it...", 0 );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* 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.bytecode.javassist;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.hibernate.property.access.internal.PropertyAccessStrategyBasicImpl;
|
||||||
|
import org.hibernate.property.access.spi.Getter;
|
||||||
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
|
import org.hibernate.property.access.spi.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class BeanReflectionHelper {
|
||||||
|
|
||||||
|
public static final Object[] TEST_VALUES = new Object[] {
|
||||||
|
"hello", new Long(1), new Integer(1), new Date(), new Long(1), new Integer(1), new Object()
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String[] getterNames = new String[7];
|
||||||
|
private static final String[] setterNames = new String[7];
|
||||||
|
private static final Class[] types = new Class[7];
|
||||||
|
|
||||||
|
static {
|
||||||
|
final PropertyAccessStrategyBasicImpl propertyAccessStrategy = new PropertyAccessStrategyBasicImpl();
|
||||||
|
|
||||||
|
PropertyAccess propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someString" );
|
||||||
|
Getter getter = propertyAccess.getGetter();
|
||||||
|
Setter setter = propertyAccess.getSetter();
|
||||||
|
getterNames[0] = getter.getMethodName();
|
||||||
|
types[0] = getter.getReturnType();
|
||||||
|
setterNames[0] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someLong" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[1] = getter.getMethodName();
|
||||||
|
types[1] = getter.getReturnType();
|
||||||
|
setterNames[1] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someInteger" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[2] = getter.getMethodName();
|
||||||
|
types[2] = getter.getReturnType();
|
||||||
|
setterNames[2] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someDate" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[3] = getter.getMethodName();
|
||||||
|
types[3] = getter.getReturnType();
|
||||||
|
setterNames[3] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "somelong" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[4] = getter.getMethodName();
|
||||||
|
types[4] = getter.getReturnType();
|
||||||
|
setterNames[4] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someint" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[5] = getter.getMethodName();
|
||||||
|
types[5] = getter.getReturnType();
|
||||||
|
setterNames[5] = setter.getMethodName();
|
||||||
|
|
||||||
|
propertyAccess = propertyAccessStrategy.buildPropertyAccess( Bean.class, "someObject" );
|
||||||
|
getter = propertyAccess.getGetter();
|
||||||
|
setter = propertyAccess.getSetter();
|
||||||
|
getterNames[6] = getter.getMethodName();
|
||||||
|
types[6] = getter.getReturnType();
|
||||||
|
setterNames[6] = setter.getMethodName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getGetterNames() {
|
||||||
|
return getterNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getSetterNames() {
|
||||||
|
return setterNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class[] getTypes() {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* 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.bytecode.javassist;
|
||||||
|
|
||||||
|
import org.hibernate.bytecode.internal.javassist.BulkAccessor;
|
||||||
|
|
||||||
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
// Extracted from org.hibernate.test.bytecode.ReflectionOptimizerTest.
|
||||||
|
// I (Yoann) don't know what this tests does, but it's definitely specific to javassist.
|
||||||
|
public class BulkAccessorTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBulkAccessorDirectly() {
|
||||||
|
BulkAccessor bulkAccessor = BulkAccessor.create(
|
||||||
|
Bean.class,
|
||||||
|
BeanReflectionHelper.getGetterNames(),
|
||||||
|
BeanReflectionHelper.getSetterNames(),
|
||||||
|
BeanReflectionHelper.getTypes()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue