コード例 #1
0
 private void expectInvalidPattern(String pattern, String errorMessage) {
   try {
     Joda.forPattern(pattern);
     fail("Pattern " + pattern + " should have thrown an exception but did not");
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage(), containsString(errorMessage));
   }
 }
コード例 #2
0
 @Test()
 public void shouldRejectInvalidExtraType() {
   try {
     IntentBuilder.build("intent action", new Pair<>("CustomThing", new CustomThing()));
     Assert.fail("Exception not thrown");
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage(), containsString("Illegal parameter type"));
   }
 }
コード例 #3
0
 @Test
 public void testCreateInstanceWithoutHttpHandler() throws Exception {
   try {
     new RestfitClient.Builder().userAgent("RestfitTest/1.0").build();
     fail("never reached");
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage(), is("No httpStack specified"));
   }
 }
コード例 #4
0
 @Test
 public void testCreateInstanceWithoutUserAgent() throws Exception {
   try {
     new RestfitClient.Builder().httpStack(new DummyHttpStack()).build();
     fail("never reached");
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage(), is("No userAgent specified"));
   }
 }