@ -43,17 +43,17 @@ public class BasicAuthorizationInterceptorTests {
public ExpectedException thrown = ExpectedException . none ( ) ;
public ExpectedException thrown = ExpectedException . none ( ) ;
@Test
@Test
public void createWhenUsernameIsNull ShouldThrowException ( ) {
public void createWhenUsernameContainsColon ShouldThrowException ( ) {
this . thrown . expect ( IllegalArgumentException . class ) ;
this . thrown . expect ( IllegalArgumentException . class ) ;
this . thrown . expectMessage ( "Username must not be empty " ) ;
this . thrown . expectMessage ( "Username must not contain a colon " ) ;
new BasicAuthorizationInterceptor ( null , "password" ) ;
new BasicAuthorizationInterceptor ( "username:" , "password" ) ;
}
}
@Test
@Test
public void createWhenUsernameIsEmptyShouldThrowException ( ) throws Exception {
public void createWhenUsernameIsNullShouldUseEmptyUsername ( ) throws Exception {
this . thrown . expect ( IllegalArgumentException . class ) ;
BasicAuthorizationInterceptor interceptor = new BasicAuthorizationInterceptor (
this . thrown . expectMessage ( "Username must not be empty ") ;
null , "password " ) ;
new BasicAuthorizationInterceptor ( "" , "password" ) ;
assertEquals ( "" , new DirectFieldAccessor ( interceptor ) . getPropertyValue ( "username" ) ) ;
}
}
@Test
@Test