Project

General

Profile

« Previous | Next » 

Revision 886ba3e2

Added by Andreas Müller about 5 years ago

ref #3767 ref #3572 some more tests for DOI parsing

View differences:

cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/DoiTest.java
74 74
		testInvalid(invalidDoi);
75 75
		invalidDoi = "10.1a02/12345";  //registrant code must include only number and dots (to separate sub codes)
76 76
		testInvalid(invalidDoi);
77
		invalidDoi = "10.1002:12345";  //column separator is only allowed (+required) in URNs
77
		invalidDoi = "10.1002:12345";  //colon separator is only allowed (+required) in URNs
78 78
		testInvalid(invalidDoi);
79 79
		invalidDoi = "10.1002/";  //doi must always have a suffix length > 0 (if this should changed in future, please do adapt equals and hashCode)
80 80
		testInvalid(invalidDoi);
......
94 94
		Assert.assertEquals("10.1002", doi.getPrefix());
95 95
		Assert.assertEquals("1234", doi.getSuffix());
96 96

  
97
		validDoi = "http://doi.org/urn:doi:10.123:456ABC%2Fzyz";
97
		validDoi = "http://doi.org/urn:doi:10.123:456ABC%2Fzyz";   //colon separator only in URNs (see above)
98 98
		doi = DOI.fromString(validDoi);
99 99
		Assert.assertEquals("10.123", doi.getPrefix());
100 100
		Assert.assertEquals("456ABC/zyz", doi.getSuffix());  //urn must be percentage encoded ( / -> %2F)
......
109 109
        Assert.assertEquals("10.123", doi.getPrefix());
110 110
        Assert.assertEquals("456ABC/zyz", doi.getSuffix());  //urn must be percentage encoded ( / -> %2F)
111 111

  
112
        validDoi = "doi.org/10.1002/1234";
113
        doi = DOI.fromString(validDoi);
114
        Assert.assertEquals("10.1002", doi.getPrefix());
115
        Assert.assertEquals("1234", doi.getSuffix());
116

  
117
        validDoi = "dx.doi.org/10.1002/1234";
118
        doi = DOI.fromString(validDoi);
119
        Assert.assertEquals("10.1002", doi.getPrefix());
120
        Assert.assertEquals("1234", doi.getSuffix());
121

  
112 122
	}
113 123

  
114 124
	@Test

Also available in: Unified diff