|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.boot.jta.bitronix;
|
18 | 18 |
|
19 | 19 | import java.sql.Connection;
|
| 20 | +import java.sql.SQLFeatureNotSupportedException; |
| 21 | +import java.util.logging.Logger; |
20 | 22 |
|
21 | 23 | import javax.sql.XAConnection;
|
22 | 24 | import javax.sql.XADataSource;
|
@@ -60,6 +62,28 @@ void doesNotSetUniqueNameIfNotNull() throws Exception {
|
60 | 62 | assertThat(this.bean.getUniqueName()).isEqualTo("un");
|
61 | 63 | }
|
62 | 64 |
|
| 65 | + @Test |
| 66 | + void shouldReturnGlobalLoggerWhenDataSourceIsAbsent() throws SQLFeatureNotSupportedException { |
| 67 | + assertThat(this.bean.getParentLogger()).isSameAs(Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)); |
| 68 | + } |
| 69 | + |
| 70 | + @Test |
| 71 | + void shouldReturnGlobalLoggerWhenDataSourceThrowsException() throws SQLFeatureNotSupportedException { |
| 72 | + XADataSource dataSource = mock(XADataSource.class); |
| 73 | + given(dataSource.getParentLogger()).willThrow(new SQLFeatureNotSupportedException()); |
| 74 | + this.bean.setDataSource(dataSource); |
| 75 | + assertThat(this.bean.getParentLogger()).isSameAs(Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)); |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + void shouldReturnParentLoggerFromDataSource() throws SQLFeatureNotSupportedException { |
| 80 | + Logger logger = Logger.getLogger("test"); |
| 81 | + XADataSource dataSource = mock(XADataSource.class); |
| 82 | + given(dataSource.getParentLogger()).willReturn(logger); |
| 83 | + this.bean.setDataSource(dataSource); |
| 84 | + assertThat(this.bean.getParentLogger()).isSameAs(logger); |
| 85 | + } |
| 86 | + |
63 | 87 | @Test
|
64 | 88 | void setDataSource() throws Exception {
|
65 | 89 | XADataSource dataSource = mock(XADataSource.class);
|
|
0 commit comments