Skip to content

Commit 579be72

Browse files
committed
Allow x.y.z format in license list version
Closes #247 Signed-off-by: Gary O'Neall <[email protected]>
1 parent 6388208 commit 579be72

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/main/java/org/spdx/library/SpdxConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public class SpdxConstants {
373373

374374
// License list version Format
375375

376-
public static final Pattern LICENSE_LIST_VERSION_PATTERN = Pattern.compile("^[a-zA-Z0-9]+\\.[a-zA-Z0-9]+");
376+
public static final Pattern LICENSE_LIST_VERSION_PATTERN = Pattern.compile("^[a-zA-Z0-9]+\\.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?");
377377
// Standard value strings
378378
public static String NONE_VALUE = "NONE";
379379
public static String NOASSERTION_VALUE = "NOASSERTION";

src/main/java/org/spdx/library/model/SpdxCreatorInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
260260
if (SpdxConstants.LICENSE_LIST_VERSION_PATTERN.matcher(version).matches()) {
261261
return null;
262262
} else {
263-
return "License list version does not match the pattern M.N";
263+
return "License list version does not match the pattern M.N or M.N.P";
264264
}
265265
}
266266
}

src/test/java/org/spdx/library/model/SpdxCreatorInformationTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ public void testGetSetCreators() throws InvalidSPDXAnalysisException {
6969
assertEquals(0, ci.verify().size());
7070
}
7171

72+
public void testSemVerLicenseListVersion() throws InvalidSPDXAnalysisException {
73+
List<String> creators = new ArrayList<>(Arrays.asList(new String[] {"Person: me"}));
74+
DateFormat format = new SimpleDateFormat(SpdxConstants.SPDX_DATE_FORMAT);
75+
String date = format.format(new Date());
76+
SpdxCreatorInformation ci = gmo.createCreationInfo(creators, date);
77+
String licenseVersion = "1.1";
78+
ci.setLicenseListVersion(licenseVersion);
79+
assertEquals(0, ci.verify().size());
80+
licenseVersion = "1.1.2";
81+
ci.setLicenseListVersion(licenseVersion);
82+
assertEquals(0, ci.verify().size());
83+
}
84+
7285
public void testGetSetLicenseListVersion() throws InvalidSPDXAnalysisException {
7386
List<String> creators = new ArrayList<>(Arrays.asList(new String[] {"Person: me"}));
7487
DateFormat format = new SimpleDateFormat(SpdxConstants.SPDX_DATE_FORMAT);

src/test/java/org/spdx/library/model/license/ListedLicensesTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.spdx.library.model.license;
2-
import java.io.ByteArrayInputStream;
32
import java.io.IOException;
43
import java.io.InputStream;
54
import java.util.List;
65
import java.util.Optional;
76

8-
import org.apache.commons.lang3.StringUtils;
97
import org.spdx.library.InvalidSPDXAnalysisException;
108
import org.spdx.library.SpdxConstants;
119

@@ -54,14 +52,6 @@ protected void setUp() throws Exception {
5452
protected void tearDown() throws Exception {
5553
super.tearDown();
5654
}
57-
58-
public void testLicenseListVersionFormat() {
59-
String licenseListversion = ListedLicenses.getListedLicenses().getLicenseListVersion();
60-
61-
assertEquals("Expected one point in license list version. ", 1, StringUtils.countMatches(licenseListversion, "."));
62-
assertTrue("Number expected before the point in license list version (" + licenseListversion + ")", StringUtils.isNumeric(StringUtils.substringBefore(licenseListversion, ".")));
63-
assertTrue("Number expected after the point in license list version (" + licenseListversion + ")", StringUtils.isNumeric(StringUtils.substringAfter(licenseListversion, ".")));
64-
}
6555

6656
/**
6757
* Test method for {@link org.spdx.library.model.license.ListedLicenses#isSpdxListedLicenseId(java.lang.String)}.

0 commit comments

Comments
 (0)