1 package utility;
2
3 import junit.framework.Assert;
4 import org.junit.Test;
5 import org.kuali.ole.docstore.OleException;
6 import org.kuali.ole.docstore.utility.ISBNUtil;
7 import org.kuali.ole.docstore.xstream.BaseTestCase;
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14
15
16
17
18
19
20
21 public class ISBNUtility_UT
22 extends BaseTestCase {
23
24 private static final Logger LOG = LoggerFactory.getLogger(ISBNUtility_UT.class);
25
26 @Test
27 public void testNormalization() throws OleException {
28 ISBNUtil isbnUtil = new ISBNUtil();
29 List<String> isbnList = new ArrayList<String>();
30 isbnList.add("0304935085847");
31 isbnList.add("0714839337 (v. 3)");
32 isbnList.add("0879514663 (set)");
33 isbnList.add("087951468X (v. 2) :");
34 isbnList.add("087951468X");
35 isbnList.add("8086098044 :");
36 isbnList.add("9781433113178 (hbk. : alk. paper)");
37 isbnList.add("1433113171 (hbk. : alk. paper)");
38 isbnList.add("978143311317X");
39 for (String isbn : isbnList) {
40 String normalizedIsbn = isbnUtil.normalizeISBN(isbn);
41
42 LOG.info(normalizedIsbn);
43 LOG.info(normalizedIsbn);
44 Assert.assertEquals(13, normalizedIsbn.length());
45 }
46
47
48 try {
49 isbnUtil.normalizeISBN("098789678956462137123");
50 } catch (Exception e) {
51 LOG.error("Invalid input " + e.getMessage());
52 }
53
54 }
55
56
57 }