30
30
import java .util .Date ;
31
31
import java .util .concurrent .TimeUnit ;
32
32
import org .junit .Before ;
33
+ import org .junit .Rule ;
33
34
import org .junit .Test ;
34
35
import org .junit .experimental .runners .Enclosed ;
36
+ import org .junit .rules .TemporaryFolder ;
35
37
import org .junit .runner .RunWith ;
36
38
import org .junit .runners .JUnit4 ;
37
39
40
42
public class JwtTokenFileCallCredentialsTest {
41
43
@ RunWith (JUnit4 .class )
42
44
public static class WithEmptyJwtTokenTest {
45
+ @ Rule
46
+ public TemporaryFolder tempFolder = new TemporaryFolder ();
47
+
43
48
private File jwtTokenFile ;
44
49
private JwtTokenFileCallCredentials unit ;
45
50
46
51
@ Before
47
52
public void setUp () throws Exception {
48
- this .jwtTokenFile = JwtTokenFileTestUtils . createEmptyJwtToken ( );
53
+ this .jwtTokenFile = tempFolder . newFile ( "empty_jwt.token" );
49
54
50
55
Constructor <JwtTokenFileCallCredentials > ctor =
51
56
JwtTokenFileCallCredentials .class .getDeclaredConstructor (String .class );
@@ -63,12 +68,16 @@ public void givenJwtTokenFileEmpty_WhenTokenRefreshed_ExpectException() {
63
68
64
69
@ RunWith (JUnit4 .class )
65
70
public static class WithInvalidJwtTokenTest {
71
+ @ Rule
72
+ public TemporaryFolder tempFolder = new TemporaryFolder ();
73
+
66
74
private File jwtTokenFile ;
67
75
private JwtTokenFileCallCredentials unit ;
68
76
69
77
@ Before
70
78
public void setUp () throws Exception {
71
- this .jwtTokenFile = JwtTokenFileTestUtils .createJwtTokenWithoutExpiration ();
79
+ this .jwtTokenFile = tempFolder .newFile ("invalid_jwt.token" );
80
+ JwtTokenFileTestUtils .writeJwtTokenContentWithoutExpiration (jwtTokenFile );
72
81
73
82
Constructor <JwtTokenFileCallCredentials > ctor =
74
83
JwtTokenFileCallCredentials .class .getDeclaredConstructor (String .class );
@@ -92,15 +101,19 @@ public void givenJwtTokenFileWithoutExpiration_WhenTokenRefreshed_ExpectExceptio
92
101
93
102
@ RunWith (JUnit4 .class )
94
103
public static class WithValidJwtTokenTest {
104
+ @ Rule
105
+ public TemporaryFolder tempFolder = new TemporaryFolder ();
106
+
95
107
private File jwtTokenFile ;
96
108
private JwtTokenFileCallCredentials unit ;
97
109
private Long givenExpTimeInSeconds ;
98
110
99
111
@ Before
100
112
public void setUp () throws Exception {
113
+ this .jwtTokenFile = tempFolder .newFile ("jwt.token" );
101
114
this .givenExpTimeInSeconds = Instant .now ().getEpochSecond () + TimeUnit .HOURS .toSeconds (1 );
102
-
103
- this . jwtTokenFile = JwtTokenFileTestUtils .createValidJwtToken ( givenExpTimeInSeconds );
115
+
116
+ JwtTokenFileTestUtils .writeValidJwtTokenContent ( jwtTokenFile , givenExpTimeInSeconds );
104
117
105
118
Constructor <JwtTokenFileCallCredentials > ctor =
106
119
JwtTokenFileCallCredentials .class .getDeclaredConstructor (String .class );
0 commit comments