Пример #1
0
 public void testLinkDetails() throws Exception {
   LinkDetails linkDetails = new LinkDetails();
   linkDetails.setAction("Load");
   ActionParam actionParam = new ActionParam();
   actionParam.setName("officeName");
   actionParam.setValue("officeName");
   linkDetails.setActionParam(new ActionParam[] {actionParam});
   StringBuilder stringBuilder = new StringBuilder();
   linkDetails.generateLink(stringBuilder, createOfficeView());
   assertContains("Load", stringBuilder.toString());
 }
  @Test
  public void doPostException() throws Exception {
    setupPost();
    expect(fixture.httpFetcher.fetch(request))
        .andThrow(
            new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE));
    fixture.replay();

    servlet.doPost(fixture.request, recorder);

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode());
    assertContains(ERROR_MESSAGE, recorder.getResponseAsString());
  }
Пример #3
0
  public void testParser() throws Exception {
    Table table =
        TableTagParser.getInstance()
            .parser(
                ClasspathResource.getURI(
                        "org/mifos/framework/util/resources/customTableTag/example.xml")
                    .toString());
    Assert.assertNotNull(table);
    HeaderDetails details = table.getHeaderDetails();
    Assert.assertEquals("drawtablerowbold", details.getHeaderStyle());
    StringBuilder builder = new StringBuilder();
    details.getHeaderInfo(builder);
    assertContains("drawtablerowbold", builder.toString());
    Row row = table.getRow();
    Assert.assertEquals("true", row.getBottomLineRequired());
    Assert.assertEquals("100", row.getTotWidth());
    Column[] columns = row.getColumn();
    for (int i = 0; i < columns.length; i++) {
      if (i == 0) {
        Assert.assertEquals("text", columns[i].getColumnType());
        Assert.assertEquals("Name", columns[i].getLabel());
        Assert.assertEquals("Name", columns[i].getValue());
        Assert.assertEquals("method", columns[i].getValueType());
        StringBuilder builder2 = new StringBuilder();
        Locale locale = new Locale("en", "GB");
        OfficeView officeView =
            new OfficeView(
                Short.valueOf("1"), "abcd", Short.valueOf("1"), "branch", Integer.valueOf("1"));

        ColumnDetails columnDetails = new ColumnDetails();
        columnDetails.setRowStyle("drawtablerowbold");
        columnDetails.setAlign("Down");
        columns[i].setColumnDetials(columnDetails);
        columns[i].generateTableColumn(builder2, officeView, locale, locale, locale);
        Assert.assertEquals(
            "<td class=\"drawtablerowbold\"   align=\"Down\" > </td>", builder2.toString());
      }
    }
  }