1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.validate;
17
18 import org.junit.Test;
19
20 import static org.junit.Assert.fail;
21
22
23
24
25
26 public class UriValidatorTest {
27 private static final UriValidator validator = new UriValidator();
28
29 @Test
30 public void testValidateGoodCases() throws XDSMetaDataException {
31 validator.validate("http://localhost:8080");
32 validator.validate("filename.ext");
33 validator.validate("file:///c:/users/klaus/file.txt");
34 }
35
36 @Test
37 public void testValidateBadCases() throws XDSMetaDataException {
38 assertFails("");
39 assertFails("://localhost:8080");
40 }
41
42 private static void assertFails(String value) {
43 try {
44 validator.validate(value);
45 fail("Expected exception: " + XDSMetaDataException.class + " for " + value);
46 } catch (XDSMetaDataException e) {
47
48 }
49 }
50 }