Skip to content

Commit dfdb9c0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into GH-122
2 parents 43a3131 + 31b6f3a commit dfdb9c0

File tree

4 files changed

+36
-45
lines changed

4 files changed

+36
-45
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static void resetLocale() {
6767

6868
@Test
6969
void validPercentEncoding() throws MalformedPackageURLException {
70-
PackageURL purl =
71-
new PackageURL("maven", "com.google.summit", "summit-ast", "2.2.0\n", (Map<String, String>) null, null);
70+
PackageURL purl = new PackageURL("maven", "com.google.summit", "summit-ast", "2.2.0\n", null, null);
7271
assertEquals("pkg:maven/com.google.summit/[email protected]%0A", purl.toString());
7372
PackageURL purl2 =
7473
new PackageURL("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5");
@@ -78,7 +77,7 @@ void validPercentEncoding() throws MalformedPackageURLException {
7877
}
7978

8079
@Test
81-
void invalidPercentEncoding() throws MalformedPackageURLException {
80+
void invalidPercentEncoding() {
8281
assertThrowsExactly(
8382
MalformedPackageURLException.class,
8483
() -> new PackageURL("pkg:maven/com.google.summit/[email protected]%"));
@@ -103,7 +102,10 @@ void constructorParsing(
103102
boolean invalid)
104103
throws Exception {
105104
if (invalid) {
106-
assertThrows(getExpectedException(purlString), () -> new PackageURL(purlString));
105+
assertThrows(
106+
getExpectedException(purlString),
107+
() -> new PackageURL(purlString),
108+
"Build should fail due to " + description);
107109
} else {
108110
PackageURL purl = new PackageURL(purlString);
109111
assertPurlEquals(parameters, purl);
@@ -135,7 +137,8 @@ void constructorParameters(
135137
parameters.getName(),
136138
parameters.getVersion(),
137139
parameters.getQualifiers(),
138-
parameters.getSubpath()));
140+
parameters.getSubpath()),
141+
"Build should fail due to " + description);
139142
} else {
140143
PackageURL purl = new PackageURL(
141144
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)