3131
3232package com .google .auth .appengine ;
3333
34- import static org .junit .Assert .assertArrayEquals ;
35- import static org .junit .Assert .assertEquals ;
36- import static org .junit .Assert . assertFalse ;
37- import static org .junit .Assert .assertNotNull ;
38- import static org .junit .Assert .assertNotSame ;
39- import static org .junit .Assert .assertTrue ;
40- import static org .junit .Assert .fail ;
34+ import static org .junit .jupiter . api . Assertions .assertArrayEquals ;
35+ import static org .junit .jupiter . api . Assertions .assertEquals ;
36+ import static org .junit .jupiter . api . Assertions . assertNotEquals ;
37+ import static org .junit .jupiter . api . Assertions .assertNotNull ;
38+ import static org .junit .jupiter . api . Assertions .assertNotSame ;
39+ import static org .junit .jupiter . api . Assertions .assertTrue ;
40+ import static org .junit .jupiter . api . Assertions .fail ;
4141
4242import com .google .auth .Credentials ;
4343import com .google .auth .oauth2 .AccessToken ;
5151import java .util .Date ;
5252import java .util .List ;
5353import java .util .Map ;
54- import org .junit .Test ;
55- import org .junit .runner .RunWith ;
56- import org .junit .runners .JUnit4 ;
54+ import org .junit .jupiter .api .Test ;
5755
5856/** Unit tests for AppEngineCredentials */
59- @ RunWith (JUnit4 .class )
60- public class AppEngineCredentialsTest extends BaseSerializationTest {
57+ class AppEngineCredentialsTest extends BaseSerializationTest {
6158
62- private static Collection <String > SCOPES =
59+ private static final Collection <String > SCOPES =
6360 Collections .unmodifiableCollection (Arrays .asList ("scope1" , "scope2" ));
6461 private static final URI CALL_URI = URI .create ("http://googleapis.com/testapi/v1/foo" );
6562 private static final String EXPECTED_ACCOUNT = "serviceAccount" ;
6663
6764 @ Test
68- public void constructor_usesAppIdentityService () throws IOException {
65+ void constructor_usesAppIdentityService () throws IOException {
6966 String expectedAccessToken = "ExpectedAccessToken" ;
7067
7168 MockAppIdentityService appIdentity = new MockAppIdentityService ();
@@ -83,7 +80,7 @@ public void constructor_usesAppIdentityService() throws IOException {
8380 }
8481
8582 @ Test
86- public void refreshAccessToken_sameAs () throws IOException {
83+ void refreshAccessToken_sameAs () throws IOException {
8784 String expectedAccessToken = "ExpectedAccessToken" ;
8885
8986 MockAppIdentityService appIdentity = new MockAppIdentityService ();
@@ -100,7 +97,7 @@ public void refreshAccessToken_sameAs() throws IOException {
10097 }
10198
10299 @ Test
103- public void getAccount_sameAs () throws IOException {
100+ void getAccount_sameAs () {
104101 MockAppIdentityService appIdentity = new MockAppIdentityService ();
105102 appIdentity .setServiceAccountName (EXPECTED_ACCOUNT );
106103 AppEngineCredentials credentials =
@@ -112,7 +109,7 @@ public void getAccount_sameAs() throws IOException {
112109 }
113110
114111 @ Test
115- public void sign_sameAs () throws IOException {
112+ void sign_sameAs () {
116113 byte [] expectedSignature = {0xD , 0xE , 0xA , 0xD };
117114 MockAppIdentityService appIdentity = new MockAppIdentityService ();
118115 appIdentity .setSignature (expectedSignature );
@@ -125,7 +122,7 @@ public void sign_sameAs() throws IOException {
125122 }
126123
127124 @ Test
128- public void createScoped_clonesWithScopes () throws IOException {
125+ void createScoped_clonesWithScopes () throws IOException {
129126 String expectedAccessToken = "ExpectedAccessToken" ;
130127 Collection <String > emptyScopes = Collections .emptyList ();
131128
@@ -155,7 +152,7 @@ public void createScoped_clonesWithScopes() throws IOException {
155152 }
156153
157154 @ Test
158- public void equals_true () throws IOException {
155+ void equals_true () {
159156 Collection <String > emptyScopes = Collections .emptyList ();
160157 MockAppIdentityService appIdentity = new MockAppIdentityService ();
161158
@@ -169,13 +166,12 @@ public void equals_true() throws IOException {
169166 .setScopes (emptyScopes )
170167 .setAppIdentityService (appIdentity )
171168 .build ();
172- assertTrue (credentials .equals (credentials ));
173- assertTrue (credentials .equals (otherCredentials ));
174- assertTrue (otherCredentials .equals (credentials ));
169+ assertEquals (credentials , otherCredentials );
170+ assertEquals (otherCredentials , credentials );
175171 }
176172
177173 @ Test
178- public void equals_false_scopes () throws IOException {
174+ void equals_false_scopes () {
179175 Collection <String > emptyScopes = Collections .emptyList ();
180176 Collection <String > scopes = Collections .singleton ("SomeScope" );
181177 MockAppIdentityService appIdentity = new MockAppIdentityService ();
@@ -190,12 +186,12 @@ public void equals_false_scopes() throws IOException {
190186 .setScopes (scopes )
191187 .setAppIdentityService (appIdentity )
192188 .build ();
193- assertFalse (credentials . equals ( otherCredentials ) );
194- assertFalse (otherCredentials . equals ( credentials ) );
189+ assertNotEquals (credentials , otherCredentials );
190+ assertNotEquals (otherCredentials , credentials );
195191 }
196192
197193 @ Test
198- public void toString_containsFields () throws IOException {
194+ void toString_containsFields () {
199195 String expectedToString =
200196 String .format (
201197 "AppEngineCredentials{scopes=[%s], scopesRequired=%b, appIdentityServiceClassName=%s}" ,
@@ -213,7 +209,7 @@ public void toString_containsFields() throws IOException {
213209 }
214210
215211 @ Test
216- public void hashCode_equals () throws IOException {
212+ void hashCode_equals () {
217213 Collection <String > emptyScopes = Collections .emptyList ();
218214 MockAppIdentityService appIdentity = new MockAppIdentityService ();
219215 AppEngineCredentials credentials =
@@ -230,7 +226,7 @@ public void hashCode_equals() throws IOException {
230226 }
231227
232228 @ Test
233- public void serialize () throws IOException , ClassNotFoundException {
229+ void serialize () throws IOException , ClassNotFoundException {
234230 Collection <String > scopes = Collections .singleton ("SomeScope" );
235231 MockAppIdentityService appIdentity = new MockAppIdentityService ();
236232 AppEngineCredentials credentials =
@@ -249,7 +245,7 @@ private static void assertContainsBearerToken(Map<String, List<String>> metadata
249245 assertNotNull (token );
250246 String expectedValue = "Bearer " + token ;
251247 List <String > authorizations = metadata .get ("Authorization" );
252- assertNotNull ("Authorization headers not found" , authorizations );
253- assertTrue ("Bearer token not found" , authorizations . contains ( expectedValue ) );
248+ assertNotNull (authorizations , "Authorization headers not found" );
249+ assertTrue (authorizations . contains ( expectedValue ), "Bearer token not found" );
254250 }
255251}
0 commit comments