1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 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.
16
16
17
17
package org .springframework .aop .framework ;
18
18
19
+ import java .sql .SQLException ;
20
+ import java .sql .Savepoint ;
19
21
import java .util .ArrayList ;
22
+ import java .util .Date ;
20
23
import java .util .List ;
21
24
22
25
import javax .accessibility .Accessible ;
@@ -380,6 +383,40 @@ public void testInterceptorWithoutJoinpoint() {
380
383
assertThat (proxy .getName ()).isEqualTo ("tb" );
381
384
}
382
385
386
+ @ Test
387
+ public void testCharSequenceProxy () {
388
+ CharSequence target = "test" ;
389
+ ProxyFactory pf = new ProxyFactory (target );
390
+ ClassLoader cl = target .getClass ().getClassLoader ();
391
+ assertThat (((CharSequence ) pf .getProxy (cl )).toString ()).isEqualTo (target );
392
+ }
393
+
394
+ @ Test
395
+ public void testDateProxy () {
396
+ Date target = new Date ();
397
+ ProxyFactory pf = new ProxyFactory (target );
398
+ pf .setProxyTargetClass (true );
399
+ ClassLoader cl = target .getClass ().getClassLoader ();
400
+ assertThat (((Date ) pf .getProxy (cl )).getTime ()).isEqualTo (target .getTime ());
401
+ }
402
+
403
+ @ Test
404
+ public void testJdbcSavepointProxy () throws SQLException {
405
+ Savepoint target = new Savepoint () {
406
+ @ Override
407
+ public int getSavepointId () throws SQLException {
408
+ return 1 ;
409
+ }
410
+ @ Override
411
+ public String getSavepointName () throws SQLException {
412
+ return "sp" ;
413
+ }
414
+ };
415
+ ProxyFactory pf = new ProxyFactory (target );
416
+ ClassLoader cl = Savepoint .class .getClassLoader ();
417
+ assertThat (((Savepoint ) pf .getProxy (cl )).getSavepointName ()).isEqualTo ("sp" );
418
+ }
419
+
383
420
384
421
@ Order (2 )
385
422
public static class A implements Runnable {
@@ -391,7 +428,7 @@ public void run() {
391
428
392
429
393
430
@ Order (1 )
394
- public static class B implements Runnable {
431
+ public static class B implements Runnable {
395
432
396
433
@ Override
397
434
public void run () {
0 commit comments