本文整理汇总了Java中org.springframework.core.JdkVersion.JAVA_16属性的典型用法代码示例。如果您正苦于以下问题:Java JdkVersion.JAVA_16属性的具体用法?Java JdkVersion.JAVA_16怎么用?Java JdkVersion.JAVA_16使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.core.JdkVersion
的用法示例。
在下文中一共展示了JdkVersion.JAVA_16属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGetBundle
/**
* Obtain the resource bundle for the given basename and Locale.
* @param basename the basename to look for
* @param locale the Locale to look for
* @return the corresponding ResourceBundle
* @throws MissingResourceException if no matching bundle could be found
* @see java.util.ResourceBundle#getBundle(String, java.util.Locale, ClassLoader)
* @see #getBundleClassLoader()
*/
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
if ((this.defaultEncoding != null && !"ISO-8859-1".equals(this.defaultEncoding)) ||
!this.fallbackToSystemLocale || this.cacheMillis >= 0) {
// Custom Control required...
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
throw new IllegalStateException("Cannot use 'defaultEncoding', 'fallbackToSystemLocale' and " +
"'cacheSeconds' on the standard ResourceBundleMessageSource when running on Java 5. " +
"Consider using ReloadableResourceBundleMessageSource instead.");
}
return new ControlBasedResourceBundleFactory().getBundle(basename, locale);
}
else {
// Good old standard call...
return ResourceBundle.getBundle(basename, locale, getBundleClassLoader());
}
}
示例2: testResourceBundleMessageSourceWithInappropriateDefaultCharset
public void testResourceBundleMessageSourceWithInappropriateDefaultCharset() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
ms.setBasename("org/springframework/context/support/messages");
ms.setDefaultEncoding("argh");
ms.setFallbackToSystemLocale(false);
try {
ms.getMessage("code1", null, Locale.ENGLISH);
fail("Should have thrown NoSuchMessageException");
}
catch (NoSuchMessageException ex) {
// expected
}
}
示例3: testNotMXBean
public void testNotMXBean() throws Exception {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
FooNotX foo = new FooNotX();
assertFalse("MXBean annotation not detected correctly", JmxUtils.isMBean(foo.getClass()));
}
示例4: testAnnotatedMXBean
public void testAnnotatedMXBean() throws Exception {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
FooX foo = new FooX();
assertTrue("MXBean annotation not detected correctly", JmxUtils.isMBean(foo.getClass()));
}
示例5: SQLErrorCodeSQLExceptionTranslator
/**
* Constructor for use as a JavaBean.
* The SqlErrorCodes or DataSource property must be set.
*/
public SQLErrorCodeSQLExceptionTranslator() {
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_16) {
setFallbackTranslator(new SQLExceptionSubclassTranslator());
}
else {
setFallbackTranslator(new SQLStateSQLExceptionTranslator());
}
}
示例6: supports
public boolean supports(Type genericType) {
if (genericType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericType;
if (JAXBElement.class.equals(parameterizedType.getRawType()) &&
parameterizedType.getActualTypeArguments().length == 1) {
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
if (typeArgument instanceof Class) {
Class<?> classArgument = (Class<?>) typeArgument;
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_17 && classArgument.isArray()) {
return classArgument.getComponentType().equals(Byte.TYPE);
}
else {
return (isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
supportsInternal(classArgument, false));
}
}
else if (JdkVersion.getMajorJavaVersion() <= JdkVersion.JAVA_16 &&
typeArgument instanceof GenericArrayType) {
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784
GenericArrayType arrayType = (GenericArrayType) typeArgument;
return arrayType.getGenericComponentType().equals(Byte.TYPE);
}
}
}
else if (genericType instanceof Class) {
Class<?> clazz = (Class<?>) genericType;
return supportsInternal(clazz, this.checkForXmlRootElement);
}
return false;
}
示例7: testServiceLoaderFactoryBean
@Test
public void testServiceLoaderFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(ServiceLoaderFactoryBean.class);
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
ServiceLoader<?> serviceLoader = (ServiceLoader<?>) bf.getBean("service");
assertTrue(serviceLoader.iterator().next() instanceof DocumentBuilderFactory);
}
示例8: testServiceFactoryBean
@Test
public void testServiceFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(ServiceFactoryBean.class);
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
assertTrue(bf.getBean("service") instanceof DocumentBuilderFactory);
}
示例9: testServiceListFactoryBean
@Test
public void testServiceListFactoryBean() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16 ||
!ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()){
return;
}
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(ServiceListFactoryBean.class);
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
List<?> serviceList = (List<?>) bf.getBean("service");
assertTrue(serviceList.get(0) instanceof DocumentBuilderFactory);
}
示例10: shouldUseBackport
private boolean shouldUseBackport() {
return (StringUtils.hasText(this.poolSize) && this.poolSize.startsWith("0") &&
JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16);
}
示例11: testMessageAccessWithDefaultMessageSourceAndFallbackTurnedOff
public void testMessageAccessWithDefaultMessageSourceAndFallbackTurnedOff() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
doTestMessageAccess(false, false, false, false, false);
}
示例12: testMessageAccessWithDefaultMessageSourceAndFallbackTurnedOffAndFallbackToGerman
public void testMessageAccessWithDefaultMessageSourceAndFallbackTurnedOffAndFallbackToGerman() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
doTestMessageAccess(false, false, true, true, false);
}
示例13: tearDown
@Override
protected void tearDown() throws Exception {
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_16) {
ResourceBundle.clearCache();
}
}
示例14: testErrorCodeTranslation
public void testErrorCodeTranslation() {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
return;
}
SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES);
SQLException dataIntegrityViolationEx = SQLExceptionSubclassFactory.newSQLDataException("", "", 0);
DataIntegrityViolationException divex = (DataIntegrityViolationException) sext.translate("task", "SQL", dataIntegrityViolationEx);
assertEquals(dataIntegrityViolationEx, divex.getCause());
SQLException featureNotSupEx = SQLExceptionSubclassFactory.newSQLFeatureNotSupportedException("", "", 0);
InvalidDataAccessApiUsageException idaex = (InvalidDataAccessApiUsageException) sext.translate("task", "SQL", featureNotSupEx);
assertEquals(featureNotSupEx, idaex.getCause());
SQLException dataIntegrityViolationEx2 = SQLExceptionSubclassFactory.newSQLIntegrityConstraintViolationException("", "", 0);
DataIntegrityViolationException divex2 = (DataIntegrityViolationException) sext.translate("task", "SQL", dataIntegrityViolationEx2);
assertEquals(dataIntegrityViolationEx2, divex2.getCause());
SQLException permissionDeniedEx = SQLExceptionSubclassFactory.newSQLInvalidAuthorizationSpecException("", "", 0);
PermissionDeniedDataAccessException pdaex = (PermissionDeniedDataAccessException) sext.translate("task", "SQL", permissionDeniedEx);
assertEquals(permissionDeniedEx, pdaex.getCause());
SQLException dataAccessResourceEx = SQLExceptionSubclassFactory.newSQLNonTransientConnectionException("", "", 0);
DataAccessResourceFailureException darex = (DataAccessResourceFailureException) sext.translate("task", "SQL", dataAccessResourceEx);
assertEquals(dataAccessResourceEx, darex.getCause());
SQLException badSqlEx2 = SQLExceptionSubclassFactory.newSQLSyntaxErrorException("", "", 0);
BadSqlGrammarException bsgex2 = (BadSqlGrammarException) sext.translate("task", "SQL2", badSqlEx2);
assertEquals("SQL2", bsgex2.getSql());
assertEquals(badSqlEx2, bsgex2.getSQLException());
SQLException tranRollbackEx = SQLExceptionSubclassFactory.newSQLTransactionRollbackException("", "", 0);
ConcurrencyFailureException cfex = (ConcurrencyFailureException) sext.translate("task", "SQL", tranRollbackEx);
assertEquals(tranRollbackEx, cfex.getCause());
SQLException transientConnEx = SQLExceptionSubclassFactory.newSQLTransientConnectionException("", "", 0);
TransientDataAccessResourceException tdarex = (TransientDataAccessResourceException) sext.translate("task", "SQL", transientConnEx);
assertEquals(transientConnEx, tdarex.getCause());
SQLException transientConnEx2 = SQLExceptionSubclassFactory.newSQLTimeoutException("", "", 0);
QueryTimeoutException tdarex2 = (QueryTimeoutException) sext.translate("task", "SQL", transientConnEx2);
assertEquals(transientConnEx2, tdarex2.getCause());
SQLException recoverableEx = SQLExceptionSubclassFactory.newSQLRecoverableException("", "", 0);
RecoverableDataAccessException rdaex2 = (RecoverableDataAccessException) sext.translate("task", "SQL", recoverableEx);
assertEquals(recoverableEx, rdaex2.getCause());
// Test classic error code translation. We should move there next if the exception we pass in is not one
// of the new sub-classes.
SQLException sexEct = new SQLException("", "", 1);
BadSqlGrammarException bsgEct = (BadSqlGrammarException) sext.translate("task", "SQL-ECT", sexEct);
assertEquals("SQL-ECT", bsgEct.getSql());
assertEquals(sexEct, bsgEct.getSQLException());
// Test fallback. We assume that no database will ever return this error code,
// but 07xxx will be bad grammar picked up by the fallback SQLState translator
SQLException sexFbt = new SQLException("", "07xxx", 666666666);
BadSqlGrammarException bsgFbt = (BadSqlGrammarException) sext.translate("task", "SQL-FBT", sexFbt);
assertEquals("SQL-FBT", bsgFbt.getSql());
assertEquals(sexFbt, bsgFbt.getSQLException());
// and 08xxx will be data resource failure (non-transient) picked up by the fallback SQLState translator
SQLException sexFbt2 = new SQLException("", "08xxx", 666666666);
DataAccessResourceFailureException darfFbt = (DataAccessResourceFailureException) sext.translate("task", "SQL-FBT2", sexFbt2);
assertEquals(sexFbt2, darfFbt.getCause());
}