Beispiel #1
0
 @Test
 public void testMe() throws Exception {
   MyTest proxy = ProxyFactory.create(MyTest.class, TestPortProvider.generateURL(""));
   try {
     proxy.postIt("hello");
   } catch (ClientResponseFailure e) {
     Assert.assertEquals(401, e.getResponse().getStatus());
   }
 }
  public void testLogout() throws Exception {
    api.logout(MockSubjectWorker.DEVICE_CODE);

    try {
      api.logout("wrong device code");
      Assert.fail();
    } catch (ClientResponseFailure e) {
      Assert.assertEquals(e.getMessage(), "Error status 400 Bad Request returned");
    }
  }
  public void testLogin() throws Exception {
    Assert.assertEquals(
        api.login(new Api.Login(LOGIN, MockUserWorker.PASSWORD)), MockSubjectWorker.DEVICE_CODE);

    try {
      api.login(new Api.Login("", "wrong pass"));
      Assert.fail();
    } catch (ClientResponseFailure e) {
      Assert.assertEquals(e.getMessage(), "Error status 403 Forbidden returned");
    }
  }
  @Override
  public void createControl(Composite parent) {

    // try to list cases first; if there's an error we need to display it
    List<Case> cases;
    try {
      cases = getOpenCases();
    } catch (ClientResponseFailure e) {
      setErrorMessage(e.getMessage());
      return;
    }

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());

    // build the table
    final Table caseTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    TableColumn caseCol = new TableColumn(caseTable, SWT.LEFT);
    caseCol.setText("Case");
    caseCol.setWidth(80);
    TableColumn descCol = new TableColumn(caseTable, SWT.LEFT);
    descCol.setText("Description");
    descCol.pack(); // needed?
    caseTable.setHeaderVisible(true);

    // capture case number when an event lands
    caseTable.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            String caseNumber = caseTable.getSelection()[0].getText();
            command.setCaseNumber(caseNumber);
          }
        });

    for (Case c : cases) {
      TableItem item = new TableItem(caseTable, SWT.NONE);
      item.setText(new String[] {c.getCaseNumber(), c.getSummary()});
    }

    setControl(composite);
  }