InMemoryUrlType implements UrlType { @Override public boolean matches(URL url) throws Exception { return url != null && url.getProtocol().equalsIgnoreCase("inmemory"); } InMemoryUrlType( ); @Override boolean matches(URL url); @Override Dir createDir(URL url);  }
@Test public void testMatches() throws Exception { URL inMemo1 = factory.createInMemoryResource("toto.txt"); assertThat(underTest.matches(inMemo1)).isTrue(); }
@SuppressWarnings("unchecked") @Test public void testRegex() { String pattern = "(/[a-zA-Z0-9\\-_\\.]+)+"; Object[][] data = array( array("/zerze/efrez/ferzr/zerrerre", true), array("/zerze/efrez/ferzr/zerrerre.txt", true), array("zerzerze/zerzer/rez4re/erzre5z.txd", false), array("/zerzer-zrzerze/zerzere_zerzer55ze", true), array("/zerzer-zrzerze/zerzere_zerze/", false), array("/zeorzeiorize", true) ); for (Object[] array : data) { String toTest = (String) array[0]; Boolean assertion = (Boolean) array[1]; assertThat(matches(pattern, toTest)).isEqualTo(assertion) .as("Check that " + toTest + " is " + assertion); } }