use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class BaseURLSourceImplTest method hostname_from_environment_variable.
@Test
public void hostname_from_environment_variable() {
expect(request.getServerPort()).andReturn(80).once();
expect(request.isSecure()).andReturn(false);
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "$HOSTNAME", 0, 0);
assertEquals(baseURLSource.getBaseURL(false), "http://" + System.getenv("HOSTNAME"));
verify();
}
use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class BaseURLSourceImplTest method secure_url_using_default_port.
@Test
public void secure_url_using_default_port() {
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 443);
assertEquals(baseURLSource.getBaseURL(true), "https://localhost");
verify();
}
use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class BaseURLSourceImplTest method insecure_url_using_default_port.
@Test
public void insecure_url_using_default_port() {
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 443);
assertEquals(baseURLSource.getBaseURL(false), "http://localhost");
verify();
}
use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class ClientPersistentFieldStorageImplTest method null_value_is_a_remove.
@Test
public void null_value_is_a_remove() {
Request request = mockRequest(null);
Link link = mockLink();
String pageName = "Foo";
String componentId = "bar.baz";
String fieldName = "woops";
replay();
ClientPersistentFieldStorage storage = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
storage.postChange(pageName, componentId, fieldName, 99);
storage.postChange(pageName, componentId, fieldName, null);
storage.updateLink(link);
assertTrue(storage.gatherFieldChanges(pageName).isEmpty());
verify();
}
use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class ClientPersistentFieldStorageImplTest method store_and_restore_a_change.
@SuppressWarnings("unchecked")
@Test
public void store_and_restore_a_change() {
Request request = mockRequest(null);
Link link = mockLink();
String pageName = "Foo";
String componentId = "bar.baz";
String fieldName = "biff";
Object value = 99;
final Holder<String> holder = captureLinkModification(link);
replay();
ClientPersistentFieldStorage storage1 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
storage1.postChange(pageName, componentId, fieldName, value);
List<PersistentFieldChange> changes1 = newList(storage1.gatherFieldChanges(pageName));
storage1.updateLink(link);
verify();
assertEquals(changes1.size(), 1);
PersistentFieldChange change1 = changes1.get(0);
assertEquals(change1.getComponentId(), componentId);
assertEquals(change1.getFieldName(), fieldName);
assertEquals(change1.getValue(), value);
// Now more training ...
train_getParameter(request, ClientPersistentFieldStorageImpl.PARAMETER_NAME, holder.get());
replay();
ClientPersistentFieldStorage storage2 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
List<PersistentFieldChange> changes2 = newList(storage2.gatherFieldChanges(pageName));
verify();
assertEquals(changes2.size(), 1);
PersistentFieldChange change2 = changes2.get(0);
assertEquals(change2.getComponentId(), componentId);
assertEquals(change2.getFieldName(), fieldName);
assertEquals(change2.getValue(), value);
assertNotSame(change1, change2);
}
Aggregations