1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.cdm.common;
|
5
|
|
6
|
import org.junit.Assert;
|
7
|
import org.junit.Before;
|
8
|
import org.junit.Test;
|
9
|
|
10
|
/**
|
11
|
* @author a.mueller
|
12
|
*
|
13
|
*/
|
14
|
public class GeneralParserTest {
|
15
|
|
16
|
/**
|
17
|
* @throws java.lang.Exception
|
18
|
*/
|
19
|
@Before
|
20
|
public void setUp() throws Exception {
|
21
|
}
|
22
|
|
23
|
@Test
|
24
|
public void test() {
|
25
|
String isbn1 = "ISBN 90-71236-61-7";
|
26
|
Assert.assertTrue("isbn1 should be an ISBN", GeneralParser.isIsbn(isbn1));
|
27
|
|
28
|
String isbn2 = "90-71236-61-7";
|
29
|
Assert.assertTrue("'ISBN' string should not be required", GeneralParser.isIsbn(isbn2));
|
30
|
|
31
|
String isbnToShort = "ISBN 90-7123-61-7";
|
32
|
Assert.assertFalse("ISBN must have 10 or 13 numbers, 9 numbered string should not be an ISBN", GeneralParser.isIsbn(isbnToShort));
|
33
|
|
34
|
String isbn3 = "ISBN 123-456-789-112-3";
|
35
|
Assert.assertTrue("isbn3 (with 13 numbers) should be an ISBN", GeneralParser.isIsbn(isbn3));
|
36
|
|
37
|
String isbn4 = "ISBN 123-456-789-112-3-";
|
38
|
Assert.assertFalse("- at the end of ISBN is not allowed", GeneralParser.isIsbn(isbn4));
|
39
|
|
40
|
String isbn5 = "ISBN 123-456-789-12-3";
|
41
|
Assert.assertFalse("12 numbers are not allowed, either 10 or 13", GeneralParser.isIsbn(isbn5));
|
42
|
|
43
|
String isbn6 = "ISBN 123-456-789-112-X";
|
44
|
Assert.assertTrue("X should be allowed as a final digit", GeneralParser.isIsbn(isbn6));
|
45
|
|
46
|
}
|
47
|
|
48
|
}
|