diff --git a/hibernate-core/src/test/java/org/hibernate/type/AttributeConverterTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AttributeConverterTest.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/type/AttributeConverterTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/AttributeConverterTest.java index 4405018174..a1ab1ced22 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/AttributeConverterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AttributeConverterTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type; +package org.hibernate.test.type; import javax.persistence.AttributeConverter; import javax.persistence.Convert; @@ -37,6 +37,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.SimpleValue; +import org.hibernate.type.AbstractStandardBasicType; +import org.hibernate.type.BasicType; +import org.hibernate.type.Type; import org.hibernate.type.descriptor.java.StringTypeDescriptor; import org.junit.Test; @@ -49,7 +52,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; /** - * Tests the principle of adding "AttributeConverter" to the mix of {@link Type} resolution + * Tests the principle of adding "AttributeConverter" to the mix of {@link org.hibernate.type.Type} resolution * * @author Steve Ebersole */ diff --git a/hibernate-core/src/test/java/org/hibernate/type/BasicTypeRegistryTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/BasicTypeRegistryTest.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/type/BasicTypeRegistryTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/BasicTypeRegistryTest.java index a898e7a17d..ed9b7cc6b3 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/BasicTypeRegistryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/BasicTypeRegistryTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type; +package org.hibernate.test.type; import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -33,6 +33,15 @@ import org.junit.Test; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.testing.junit4.BaseUnitTestCase; + +import org.hibernate.type.AbstractSingleColumnStandardBasicType; +import org.hibernate.type.BasicType; +import org.hibernate.type.BasicTypeRegistry; +import org.hibernate.type.CompositeCustomType; +import org.hibernate.type.CustomType; +import org.hibernate.type.Type; +import org.hibernate.type.UUIDBinaryType; +import org.hibernate.type.UUIDCharType; import org.hibernate.type.descriptor.java.StringTypeDescriptor; import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor; import org.hibernate.usertype.CompositeUserType; diff --git a/hibernate-core/src/test/java/org/hibernate/type/TypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/TypeTest.java similarity index 90% rename from hibernate-core/src/test/java/org/hibernate/type/TypeTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/TypeTest.java index 541725b034..3f6a6de910 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/TypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/TypeTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type; +package org.hibernate.test.type; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -45,6 +45,39 @@ import org.hibernate.Session; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.collections.ArrayHelper; +import org.hibernate.type.AbstractSingleColumnStandardBasicType; +import org.hibernate.type.BigDecimalType; +import org.hibernate.type.BigIntegerType; +import org.hibernate.type.BinaryType; +import org.hibernate.type.BooleanType; +import org.hibernate.type.ByteType; +import org.hibernate.type.CalendarDateType; +import org.hibernate.type.CalendarType; +import org.hibernate.type.CharArrayType; +import org.hibernate.type.CharacterArrayType; +import org.hibernate.type.CharacterType; +import org.hibernate.type.ClassType; +import org.hibernate.type.CurrencyType; +import org.hibernate.type.DateType; +import org.hibernate.type.DoubleType; +import org.hibernate.type.FloatType; +import org.hibernate.type.ImageType; +import org.hibernate.type.IntegerType; +import org.hibernate.type.LocaleType; +import org.hibernate.type.LongType; +import org.hibernate.type.MaterializedBlobType; +import org.hibernate.type.MaterializedClobType; +import org.hibernate.type.NumericBooleanType; +import org.hibernate.type.SerializableType; +import org.hibernate.type.ShortType; +import org.hibernate.type.StringType; +import org.hibernate.type.TextType; +import org.hibernate.type.TimeType; +import org.hibernate.type.TimeZoneType; +import org.hibernate.type.TimestampType; +import org.hibernate.type.TrueFalseType; +import org.hibernate.type.YesNoType; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static org.junit.Assert.assertFalse; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/AbstractDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/AbstractDescriptorTest.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/AbstractDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/AbstractDescriptorTest.java index 312aeaaa14..ba8a2a1c40 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/AbstractDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/AbstractDescriptorTest.java @@ -21,11 +21,13 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; import java.io.Serializable; import java.sql.Blob; import java.sql.Clob; +import org.hibernate.type.descriptor.java.JavaTypeDescriptor; + import org.junit.Before; import org.junit.Test; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigDecimalDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigDecimalDescriptorTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigDecimalDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigDecimalDescriptorTest.java index c3924ffadd..0643102cdc 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigDecimalDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigDecimalDescriptorTest.java @@ -21,9 +21,11 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; import java.math.BigDecimal; +import org.hibernate.type.descriptor.java.BigDecimalTypeDescriptor; + /** * @author Steve Ebersole */ diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigIntegerDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigIntegerDescriptorTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigIntegerDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigIntegerDescriptorTest.java index fceb752037..76ec3e94bb 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BigIntegerDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BigIntegerDescriptorTest.java @@ -21,9 +21,11 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; import java.math.BigInteger; +import org.hibernate.type.descriptor.java.BigIntegerTypeDescriptor; + /** * @author Steve Ebersole */ diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BlobDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BlobDescriptorTest.java similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BlobDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BlobDescriptorTest.java index 8cdc89ab4e..b5f1cd2935 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BlobDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BlobDescriptorTest.java @@ -21,13 +21,16 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; import java.sql.Blob; import java.sql.SQLException; import org.junit.Test; import org.hibernate.engine.jdbc.BlobProxy; +import org.hibernate.type.descriptor.java.BlobTypeDescriptor; +import org.hibernate.type.descriptor.java.DataHelper; +import org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BooleanDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BooleanDescriptorTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BooleanDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BooleanDescriptorTest.java index 15cb04dd24..a045f548c6 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/BooleanDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/BooleanDescriptorTest.java @@ -21,9 +21,11 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; +import org.hibernate.type.descriptor.java.BooleanTypeDescriptor; + /** * @author Steve Ebersole */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/LocaleTypeDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/LocaleTypeDescriptorTest.java new file mode 100644 index 0000000000..8584106acc --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/LocaleTypeDescriptorTest.java @@ -0,0 +1,69 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2013, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.test.type.descriptor.java; + +import java.util.Locale; +import java.util.StringTokenizer; + +import org.hibernate.internal.util.StringHelper; +import org.hibernate.type.descriptor.java.LocaleTypeDescriptor; + +import org.junit.Test; + +import org.hibernate.testing.junit4.BaseUnitTestCase; + +import static org.junit.Assert.assertEquals; + +/** + * Tests of the {@link LocaleTypeDescriptor} class. + * + * @author Christian Beikov + * @author Steve Ebersole + */ +public class LocaleTypeDescriptorTest extends BaseUnitTestCase { + @Test + public void testConversionFromString() { + assertEquals( toLocale( "de", null, null ), LocaleTypeDescriptor.INSTANCE.fromString( "de" ) ); + assertEquals( toLocale( "de", "DE", null ), LocaleTypeDescriptor.INSTANCE.fromString( "de_DE" ) ); + assertEquals( toLocale( null, "DE", null ), LocaleTypeDescriptor.INSTANCE.fromString( "_DE" ) ); + assertEquals( toLocale( null, null, "ch" ), LocaleTypeDescriptor.INSTANCE.fromString( "__ch" ) ); + assertEquals( toLocale( null, "DE", "ch" ), LocaleTypeDescriptor.INSTANCE.fromString( "_DE_ch" ) ); + assertEquals( toLocale( "de", null, "ch" ), LocaleTypeDescriptor.INSTANCE.fromString( "de__ch" ) ); + assertEquals( toLocale( "de", "DE", "ch" ), LocaleTypeDescriptor.INSTANCE.fromString( "de_DE_ch" ) ); + } + + public Locale toLocale(String lang, String region, String variant) { + final Locale.Builder builder = new Locale.Builder(); + if ( StringHelper.isNotEmpty( lang ) ) { + builder.setLanguage( lang ); + } + if ( StringHelper.isNotEmpty( region ) ) { + builder.setRegion( region ); + } + if ( StringHelper.isNotEmpty( variant ) ) { + builder.setVariant( variant ); + } + return builder.build(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/StringDescriptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/StringDescriptorTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/java/StringDescriptorTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/StringDescriptorTest.java index 496358865c..df48304864 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/java/StringDescriptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/java/StringDescriptorTest.java @@ -21,9 +21,11 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.java; +package org.hibernate.test.type.descriptor.java; +import org.hibernate.type.descriptor.java.StringTypeDescriptor; + /** * @author Steve Ebersole */ diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/PreparedStatementProxy.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/PreparedStatementProxy.java similarity index 98% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/PreparedStatementProxy.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/PreparedStatementProxy.java index 521f1cd749..2429ed9c2f 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/PreparedStatementProxy.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/PreparedStatementProxy.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.sql; +package org.hibernate.test.type.descriptor.sql; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/ResultSetProxy.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/ResultSetProxy.java similarity index 98% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/ResultSetProxy.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/ResultSetProxy.java index 5406a25a75..a8932c1d39 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/ResultSetProxy.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/ResultSetProxy.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.sql; +package org.hibernate.test.type.descriptor.sql; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringClobImpl.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringClobImpl.java similarity index 98% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringClobImpl.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringClobImpl.java index e7e362c459..3a0246e492 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringClobImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringClobImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.sql; +package org.hibernate.test.type.descriptor.sql; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; diff --git a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringValueMappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringValueMappingTest.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringValueMappingTest.java rename to hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringValueMappingTest.java index 2803819df3..992cb643e1 100644 --- a/hibernate-core/src/test/java/org/hibernate/type/descriptor/sql/StringValueMappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/descriptor/sql/StringValueMappingTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.type.descriptor.sql; +package org.hibernate.test.type.descriptor.sql; import java.sql.Clob; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -36,6 +36,9 @@ 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.sql.ClobTypeDescriptor; +import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; +import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull;