Skip to content

Commit c469a12

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-parse-path
2 parents b481613 + 31b6f3a commit c469a12

File tree

4 files changed

+36
-46
lines changed

4 files changed

+36
-46
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
128128
<maven.site.plugin.version>3.21.0</maven.site.plugin.version>
129129
<maven.source.plugin.version>3.3.1</maven.source.plugin.version>
130-
<maven.surefire.plugin.version>3.5.2</maven.surefire.plugin.version>
130+
<maven.surefire.plugin.version>3.5.3</maven.surefire.plugin.version>
131131
<versions-maven-plugin.version>2.18.0</versions-maven-plugin.version>
132132
<!-- Maven build plugins for quality checks -->
133133
<error.prone.core.version>2.37.0</error.prone.core.version>

src/test/java/com/github/packageurl/PackageURLBuilderTest.java

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void packageURLBuilder(
7272
builder.withSubpath(subpath);
7373
}
7474
if (invalid) {
75-
assertThrows(MalformedPackageURLException.class, builder::build);
75+
assertThrows(MalformedPackageURLException.class, builder::build, "Build should fail due to " + description);
7676
} else {
7777
assertEquals(parameters.getType(), builder.getType(), "type");
7878
assertEquals(parameters.getNamespace(), builder.getNamespace(), "namespace");
@@ -109,68 +109,58 @@ void packageURLBuilderException1Null() throws MalformedPackageURLException {
109109
void packageURLBuilderException2() {
110110
assertThrowsExactly(
111111
MalformedPackageURLException.class,
112-
() -> {
113-
PackageURLBuilder.aPackageURL()
114-
.withType("type")
115-
.withNamespace("invalid//namespace")
116-
.withName("name")
117-
.build();
118-
},
112+
() -> PackageURLBuilder.aPackageURL()
113+
.withType("type")
114+
.withNamespace("invalid//namespace")
115+
.withName("name")
116+
.build(),
119117
"Build should fail due to invalid namespace");
120118
}
121119

122120
@Test
123121
void packageURLBuilderException3() {
124122
assertThrowsExactly(
125123
MalformedPackageURLException.class,
126-
() -> {
127-
PackageURLBuilder.aPackageURL()
128-
.withType("typ^e")
129-
.withSubpath("invalid/name%2Fspace")
130-
.withName("name")
131-
.build();
132-
},
124+
() -> PackageURLBuilder.aPackageURL()
125+
.withType("typ^e")
126+
.withSubpath("invalid/name%2Fspace")
127+
.withName("name")
128+
.build(),
133129
"Build should fail due to invalid subpath");
134130
}
135131

136132
@Test
137133
void packageURLBuilderException4() {
138134
assertThrowsExactly(
139135
MalformedPackageURLException.class,
140-
() -> {
141-
PackageURLBuilder.aPackageURL()
142-
.withType("0_type")
143-
.withName("name")
144-
.build();
145-
},
136+
() -> PackageURLBuilder.aPackageURL()
137+
.withType("0_type")
138+
.withName("name")
139+
.build(),
146140
"Build should fail due to invalid type");
147141
}
148142

149143
@Test
150144
void packageURLBuilderException5() {
151145
assertThrowsExactly(
152146
MalformedPackageURLException.class,
153-
() -> {
154-
PackageURLBuilder.aPackageURL()
155-
.withType("ype")
156-
.withName("name")
157-
.withQualifier("0_key", "value")
158-
.build();
159-
},
147+
() -> PackageURLBuilder.aPackageURL()
148+
.withType("ype")
149+
.withName("name")
150+
.withQualifier("0_key", "value")
151+
.build(),
160152
"Build should fail due to invalid qualifier key");
161153
}
162154

163155
@Test
164156
void packageURLBuilderException6() {
165157
assertThrowsExactly(
166158
MalformedPackageURLException.class,
167-
() -> {
168-
PackageURLBuilder.aPackageURL()
169-
.withType("ype")
170-
.withName("name")
171-
.withQualifier("", "value")
172-
.build();
173-
},
159+
() -> PackageURLBuilder.aPackageURL()
160+
.withType("ype")
161+
.withName("name")
162+
.withQualifier("", "value")
163+
.build(),
174164
"Build should fail due to invalid qualifier key");
175165
}
176166

src/test/java/com/github/packageurl/PackageURLTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import java.io.IOException;
3232
import java.util.Locale;
33-
import java.util.Map;
3433
import java.util.stream.Stream;
3534
import org.jspecify.annotations.Nullable;
3635
import org.junit.jupiter.api.AfterAll;
@@ -64,8 +63,7 @@ static void resetLocale() {
6463

6564
@Test
6665
void validPercentEncoding() throws MalformedPackageURLException {
67-
PackageURL purl =
68-
new PackageURL("maven", "com.google.summit", "summit-ast", "2.2.0\n", (Map<String, String>) null, null);
66+
PackageURL purl = new PackageURL("maven", "com.google.summit", "summit-ast", "2.2.0\n", null, null);
6967
assertEquals("pkg:maven/com.google.summit/[email protected]%0A", purl.toString());
7068
PackageURL purl2 =
7169
new PackageURL("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5");
@@ -75,7 +73,7 @@ void validPercentEncoding() throws MalformedPackageURLException {
7573
}
7674

7775
@Test
78-
void invalidPercentEncoding() throws MalformedPackageURLException {
76+
void invalidPercentEncoding() {
7977
assertThrowsExactly(
8078
MalformedPackageURLException.class,
8179
() -> new PackageURL("pkg:maven/com.google.summit/[email protected]%"));
@@ -100,7 +98,10 @@ void constructorParsing(
10098
boolean invalid)
10199
throws Exception {
102100
if (invalid) {
103-
assertThrows(getExpectedException(purlString), () -> new PackageURL(purlString));
101+
assertThrows(
102+
getExpectedException(purlString),
103+
() -> new PackageURL(purlString),
104+
"Build should fail due to " + description);
104105
} else {
105106
PackageURL purl = new PackageURL(purlString);
106107
assertPurlEquals(parameters, purl);
@@ -132,7 +133,8 @@ void constructorParameters(
132133
parameters.getName(),
133134
parameters.getVersion(),
134135
parameters.getQualifiers(),
135-
parameters.getSubpath()));
136+
parameters.getSubpath()),
137+
"Build should fail due to " + description);
136138
} else {
137139
PackageURL purl = new PackageURL(
138140
parameters.getType(),

src/test/java/com/github/packageurl/internal/StringUtilTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
import static org.junit.jupiter.api.Assertions.assertEquals;
2525
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
2626

27-
import com.github.packageurl.MalformedPackageURLException;
2827
import com.github.packageurl.ValidationException;
2928
import org.junit.jupiter.api.Test;
3029

31-
public class StringUtilTest {
32-
30+
class StringUtilTest {
3331
@Test
34-
void invalidPercentEncoding() throws MalformedPackageURLException {
32+
void invalidPercentEncoding() {
3533
Throwable t1 = assertThrowsExactly(ValidationException.class, () -> StringUtil.percentDecode("a%0"));
3634
assertEquals("Incomplete percent encoding at offset 1 with value '%0'", t1.getMessage());
3735
Throwable t2 = assertThrowsExactly(ValidationException.class, () -> StringUtil.percentDecode("aaaa%%0A"));

0 commit comments

Comments
 (0)