Package fitnesse.http

Source Code of fitnesse.http.MockRequestBuilderTest

package fitnesse.http;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

import fitnesse.http.MockRequestBuilder;
import org.junit.Test;

import fitnesse.http.Request;

public class MockRequestBuilderTest {
  @Test public void aCommandWithASlashShouldGenerateARequestResourceWithoutASlash() {
    assertThat(requestFrom("/myCommand").getResource(), is("myCommand"));
  }

  @Test public void aCommandWithoutASlashShouldGenerateARequestResourceWithoutASlash() {
    assertThat(requestFrom("myCommand").getResource(), is("myCommand"));
  }
   
  @Test public void aCommandShouldBeCorrectlyDeducedWhenCredentialsAreSpecified() {
    Request request = requestFrom("user:pass:/myCommand");
    assertThat(request.getResource(), is("myCommand"));
  }
 
  @Test public void requestAuthenticationShouldBeCorrectlySetWhenCredentialsAreSpecified() {
    Request request = requestFrom("user:pass:/myCommand");
    assertThat(request.getAuthorizationUsername(), is("user"));
    assertThat(request.getAuthorizationPassword(), is("pass"));
  }
 
  @Test(expected=IllegalArgumentException.class) public void aSpecificationShouldBeWellFormed() {
    requestFrom("abc:/myCommand");
  }
   
  protected Request requestFrom(String commandSpecification) {
    return new MockRequestBuilder(commandSpecification).build();
  }
}
TOP

Related Classes of fitnesse.http.MockRequestBuilderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.