Java Collections.assertTrue Examples

Java Collections.assertTrue - 19 examples found. These are the top rated real world Java examples of java.util.Collections.assertTrue extracted from open source projects. You can rate examples to help us improve the quality of examples.
  @Test
  public void supportsPosixlyCorrectBehavior() {
    OptionParser parser = new OptionParser("i:j::k");
    String[] arguments = {
      "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"
    };

    OptionSet options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertTrue(options.has("j"));
    assertTrue(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(singletonList("ixnay"), options.valuesOf("j"));
    assertEquals(asList("xyz", "foo", "blah", "bah"), options.nonOptionArguments());

    parser.posixlyCorrect(true);
    options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertFalse(options.has("j"));
    assertFalse(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(emptyList(), options.valuesOf("j"));
    assertEquals(
        asList("xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"), options.nonOptionArguments());
  }
  public void testConnectionFailure() throws Exception {
    // create mock objects that will simulate a connection failure
    GSSClient client = createMock(GSSClient.class);
    expect(client.getCentralRevision((QName) anyObject()))
        .andThrow(new IOException("Host unreachable"));
    replay(client);
    GSSClientFactory factory = createMock(GSSClientFactory.class);
    expect(factory.createClient(new URL("http://localhost:8081/geoserver/ows"), null, null))
        .andReturn(client);
    replay(factory);

    synch.clientFactory = factory;

    // perform synch
    Date start = new Date();
    synch.synchronizeOustandlingLayers();
    Date end = new Date();

    // check we stored the last failure marker
    SimpleFeature f =
        getSingleFeature(fsUnitTables, ff.equal(ff.property("table_id"), ff.literal(1), false));
    Date lastFailure = (Date) f.getAttribute("last_failure");
    assertNotNull(lastFailure);
    assertTrue(lastFailure.compareTo(start) >= 0 && lastFailure.compareTo(end) <= 0);

    // check we marked the unit as failed
    f = getSingleFeature(fsUnits, ff.equal(ff.property("unit_name"), ff.literal("unit1"), false));
    assertTrue((Boolean) f.getAttribute("errors"));
  }
 @Test
 public void resolvesToShortOptionsWithArgumentFollowingX() {
   OptionSet options = parser.parse("-foxbar");
   assertFalse(options.has("fox"));
   assertTrue(options.has("f"));
   assertTrue(options.has("o"));
   assertTrue(options.has("x"));
   assertEquals(singletonList("bar"), options.valuesOf("x"));
 }
 @Test
 public void shortOptionsInDifferentOrder() {
   OptionSet options = parser.parse("-fxo");
   assertFalse(options.has("fox"));
   assertTrue(options.has("f"));
   assertFalse(options.has("o"));
   assertTrue(options.has("x"));
   assertEquals(singletonList("o"), options.valuesOf("x"));
 }
 private static void delete(File directory) {
   for (File file : directory.listFiles()) {
     if (file.isDirectory()) {
       delete(file);
     } else {
       assertTrue(file.delete());
     }
   }
   assertTrue(directory.delete());
 }
 @Test
 public void shouldFindChangedFiles() throws IOException {
   Set<File> files = detector.findChangedFiles();
   assertTrue("Should have found changed files on first run", files.size() > 0);
   assertThat(
       "TestFakeProduct should be in changed list",
       files,
       hasItem(getFileForClass(TestFakeProduct.class)));
   assertTrue(
       "FakeProduct should be in changed list",
       files.contains(getFileForClass(FakeProduct.class)));
   assertTrue("Should have no changed files now", detector.findChangedFiles().isEmpty());
 }