HHH-9844 : org.hibernate.cache.spi.access.AccessType enum names are not valid values for hibernate.cache.default_cache_concurrency_strategy
This commit is contained in:
parent
ee97148743
commit
53a8b18ca8
|
@ -302,7 +302,7 @@
|
|||
</para>
|
||||
</example>
|
||||
</section>
|
||||
<section id="caching-strategies-list">
|
||||
<section id="caching-strategies-list" revision="1">
|
||||
<title>Caching strategies</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
|
@ -315,7 +315,7 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>nonstrict read-write</term>
|
||||
<term>nonstrict-read-write</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Some applications only rarely need to modify data. This is the case if two transactions are unlikely to
|
||||
|
@ -358,7 +358,7 @@
|
|||
</varlistentry>
|
||||
</variablelist>
|
||||
</section>
|
||||
<section id="caching-provider-table">
|
||||
<section id="caching-provider-table" revision="1">
|
||||
<title>Second-level cache providers for Hibernate</title>
|
||||
<informaltable>
|
||||
<tgroup cols="5">
|
||||
|
@ -376,7 +376,7 @@
|
|||
<entry>
|
||||
<itemizedlist>
|
||||
<listitem><para>read-only</para></listitem>
|
||||
<listitem><para>nonstrict read-write</para></listitem>
|
||||
<listitem><para>nonstrict-read-write</para></listitem>
|
||||
<listitem><para>read-write</para></listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
|
@ -387,7 +387,7 @@
|
|||
<entry>
|
||||
<itemizedlist>
|
||||
<listitem><para>read-only</para></listitem>
|
||||
<listitem><para>nonstrict read-write</para></listitem>
|
||||
<listitem><para>nonstrict-read-write</para></listitem>
|
||||
<listitem><para>read-write</para></listitem>
|
||||
<listitem><para>transactional</para></listitem>
|
||||
</itemizedlist>
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.cache.spi.access;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The types of access strategies available.
|
||||
*
|
||||
|
@ -71,6 +73,12 @@ public enum AccessType {
|
|||
return accessType;
|
||||
}
|
||||
}
|
||||
throw new UnknownAccessTypeException( externalName );
|
||||
// Check to see if making upper-case matches an enum name.
|
||||
try {
|
||||
return AccessType.valueOf( externalName.toUpperCase( Locale.ROOT) );
|
||||
}
|
||||
catch ( IllegalArgumentException e ) {
|
||||
throw new UnknownAccessTypeException( externalName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
75
hibernate-core/src/test/java/org/hibernate/cache/spi/CacheAccessTypeTest.java
vendored
Normal file
75
hibernate-core/src/test/java/org/hibernate/cache/spi/CacheAccessTypeTest.java
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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.cache.spi;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cache.spi.access.UnknownAccessTypeException;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CacheAccessTypeTest {
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9844")
|
||||
public void testExplicitExternalNames() {
|
||||
assertSame( AccessType.READ_ONLY, AccessType.fromExternalName( "read-only" ) );
|
||||
assertSame( AccessType.READ_WRITE, AccessType.fromExternalName( "read-write" ) );
|
||||
assertSame( AccessType.NONSTRICT_READ_WRITE, AccessType.fromExternalName( "nonstrict-read-write" ) );
|
||||
assertSame( AccessType.TRANSACTIONAL, AccessType.fromExternalName( "transactional" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9844")
|
||||
public void testEnumNames() {
|
||||
assertSame( AccessType.READ_ONLY, AccessType.fromExternalName( "READ_ONLY" ) );
|
||||
assertSame( AccessType.READ_WRITE, AccessType.fromExternalName( "READ_WRITE" ) );
|
||||
assertSame( AccessType.NONSTRICT_READ_WRITE, AccessType.fromExternalName( "NONSTRICT_READ_WRITE" ) );
|
||||
assertSame( AccessType.TRANSACTIONAL, AccessType.fromExternalName( "TRANSACTIONAL" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9844")
|
||||
public void testLowerCaseEnumNames() {
|
||||
assertSame( AccessType.READ_ONLY, AccessType.fromExternalName( "read_only" ) );
|
||||
assertSame( AccessType.READ_WRITE, AccessType.fromExternalName( "read_write" ) );
|
||||
assertSame( AccessType.NONSTRICT_READ_WRITE, AccessType.fromExternalName( "nonstrict_read_write" ) );
|
||||
assertSame( AccessType.TRANSACTIONAL, AccessType.fromExternalName( "transactional" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9844")
|
||||
public void testUpperCaseWithHyphens() {
|
||||
try {
|
||||
AccessType.fromExternalName( "READ-ONLY" );
|
||||
fail( "should have failed because upper-case using hyphans is not supported." );
|
||||
}
|
||||
catch (UnknownAccessTypeException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
AccessType.fromExternalName( "READ-WRITE" );
|
||||
fail( "should have failed because upper-case using hyphans is not supported." );
|
||||
}
|
||||
catch (UnknownAccessTypeException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
AccessType.fromExternalName( "NONSTRICT-READ-WRITE" );
|
||||
fail( "should have failed because upper-case using hyphans is not supported." );
|
||||
}
|
||||
catch (UnknownAccessTypeException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue