source: VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/test/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/ReferenceValidatorTest.java @ 5537

Last change on this file since 5537 was 5537, checked in by Twan Goosen, 10 years ago

Small help text tweak (resf #584) and small cleanup in test

File size: 2.6 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.virtualcollectionregistry.service.impl;
18
19import org.apache.wicket.validation.IValidatable;
20import org.apache.wicket.validation.Validatable;
21import org.junit.Test;
22import static org.junit.Assert.*;
23import org.junit.Before;
24
25/**
26 *
27 * @author twagoo
28 */
29public class ReferenceValidatorTest {
30
31    private ReferenceValidator instance;
32
33    @Before
34    public void setUp() {
35        instance = new ReferenceValidator();
36    }
37
38    /**
39     * Test of onValidate method, of class ReferenceValidator.
40     */
41    @Test
42    public void testOnValidateUrl() {
43        IValidatable<String> validatable = new Validatable<>("http://www.clarin.eu");
44        instance.validate(validatable);
45        assertTrue(validatable.isValid());
46    }
47
48    /**
49     * Test of onValidate method, of class ReferenceValidator.
50     */
51    @Test
52    public void testOnValidateHdl() {
53        IValidatable<String> validatable = new Validatable<>("hdl:1234/abcd-EF-5678");
54        instance.validate(validatable);
55        assertTrue(validatable.isValid());
56    }
57
58    /**
59     * Test of onValidate method, of class ReferenceValidator.
60     */
61    @Test
62    public void testOnValidateDoi() {
63        IValidatable<String> validatable = new Validatable<>("doi:10.1000/182");
64        instance.validate(validatable);
65        assertTrue(validatable.isValid());
66    }
67
68    /**
69     * Test of onValidate method, of class ReferenceValidator.
70     */
71    @Test
72    public void testOnValidateIllegal() {
73        IValidatable<String> validatable = new Validatable<>("not a legal URL or handle");
74        instance.validate(validatable);
75        assertFalse(validatable.isValid());
76    }
77
78    /**
79     * Test of onValidate method, of class ReferenceValidator.
80     */
81    @Test
82    public void testOnValidateIllegalHdl() {
83        IValidatable<String> validatable = new Validatable<>("hdl:12a4/abcd-EF-5678");
84        instance.validate(validatable);
85        assertFalse(validatable.isValid());
86    }
87
88}
Note: See TracBrowser for help on using the repository browser.