Update to NOTICE files & test (#5250)
Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/NOTICE.md b/NOTICE.md
index dbb6410..b325d93 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -47,7 +47,7 @@
* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag.
-Hibernate Validator CDI, 6.1.2.Final
+Hibernate Validator CDI, 6.2.4.Final
* License: Apache License, 2.0
* Project: https://beanvalidation.org/
* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
@@ -65,7 +65,7 @@
* License: Apache License, 2.0
* Copyright (C) 2009 The JSR-330 Expert Group
-Javassist Version 3.25.0-GA
+Javassist Version 3.29.0-GA
* License: Apache License, 2.0
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
@@ -95,7 +95,7 @@
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
* Copyright: Eric Rowell
-org.objectweb.asm Version 9.3
+org.objectweb.asm Version 9.4
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.
diff --git a/examples/NOTICE.md b/examples/NOTICE.md
index 4330b16..b47bbbb 100644
--- a/examples/NOTICE.md
+++ b/examples/NOTICE.md
@@ -43,6 +43,11 @@
* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag.
+Hibernate Validator CDI, 6.2.4.Final
+* License: Apache License, 2.0
+* Project: https://beanvalidation.org/
+* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
+
Bootstrap v3.3.7
* License: MIT license (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Project: http://getbootstrap.com
@@ -56,12 +61,12 @@
* License: Apache License, 2.0
* Copyright (C) 2009 The JSR-330 Expert Group
-Javassist Version 3.25.0-GA
+Javassist Version 3.29.0-GA
* License: Apache License, 2.0
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
-Jackson JAX-RS Providers Version 2.9.9
+Jackson JAX-RS Providers Version 2.14.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2011 FasterXML, LLC. All rights reserved unless otherwise indicated.
@@ -86,7 +91,7 @@
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
* Copyright: Eric Rowell
-org.objectweb.asm Version 7.2
+org.objectweb.asm Version 9.4
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.
diff --git a/ext/bean-validation/src/main/resources/META-INF/NOTICE.markdown b/ext/bean-validation/src/main/resources/META-INF/NOTICE.markdown
index 501db20..48e7d26 100644
--- a/ext/bean-validation/src/main/resources/META-INF/NOTICE.markdown
+++ b/ext/bean-validation/src/main/resources/META-INF/NOTICE.markdown
@@ -31,7 +31,7 @@
## Third-party Content
-Hibernate Validator CDI, 6.1.2.Final
+Hibernate Validator CDI, 6.2.4.Final
* License: Apache License, 2.0
* Project: https://beanvalidation.org/
* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
\ No newline at end of file
diff --git a/tests/pom.xml b/tests/pom.xml
index a140de6..d978c21 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -107,5 +107,14 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>JDK11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <modules>
+ <module>release-test</module>
+ </modules>
+ </profile>
</profiles>
</project>
diff --git a/tests/release-test/pom.xml b/tests/release-test/pom.xml
index 33eb1cf..998109b 100644
--- a/tests/release-test/pom.xml
+++ b/tests/release-test/pom.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,23 +20,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+<!-- <parent>-->
+<!-- <groupId>org.eclipse.ee4j</groupId>-->
+<!-- <artifactId>project</artifactId>-->
+<!-- <version>1.0.8</version>-->
+<!-- <relativePath>../../../pom.xml</relativePath>-->
+<!-- </parent>-->
+
<parent>
- <groupId>org.eclipse.ee4j</groupId>
+ <groupId>org.glassfish.jersey</groupId>
<artifactId>project</artifactId>
- <version>1.0.8</version>
- <relativePath>../../../pom.xml</relativePath>
+ <version>2.39-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.glassfish.jersey.tests</groupId>
<artifactId>release-test</artifactId>
- <version>2.37-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jersey-release-test</name>
<description>Jersey post-release validation tests</description>
<properties>
- <jersey.version>${jersey.version}</jersey.version> <!-- Must pass using -Djersey.version= -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.version>3.8.6</maven.version>
@@ -54,8 +59,7 @@
<reuseForks>false</reuseForks>
<enableAssertions>false</enableAssertions>
<includes>
- <include>**/DownloadBomPomDependencies.java</include>
- <include>**/*Test.class</include>
+ <include>**/NoticeFilesTest.class</include>
</includes>
</configuration>
</plugin>
@@ -117,6 +121,60 @@
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<version>${maven.resolver.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>ReleaseTests</id>
+ <activation>
+ <property>
+ <name>jersey.version</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M7</version>
+ <configuration>
+ <forkCount>1</forkCount>
+ <reuseForks>false</reuseForks>
+ <enableAssertions>false</enableAssertions>
+ <includes>
+ <include>**/DownloadBomPomDependencies.java</include>
+ <include>**/*Test.class</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish.jersey</groupId>
+ <artifactId>jersey-bom</artifactId>
+ <version>${jersey.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <properties>
+ <jersey.version>${jersey.version}</jersey.version> <!-- Must pass using -Djersey.version= -->
+ </properties>
+ </profile>
+ </profiles>
</project>
diff --git a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/ClassVersionChecker.java b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/ClassVersionChecker.java
index 43e5327..743d609 100644
--- a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/ClassVersionChecker.java
+++ b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/ClassVersionChecker.java
@@ -1,13 +1,17 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.test.artifacts;
diff --git a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyPair.java b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyPair.java
index dd31588..3256d48 100644
--- a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyPair.java
+++ b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyPair.java
@@ -1,13 +1,17 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.test.artifacts;
diff --git a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyResolver.java b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyResolver.java
index 5df3bc1..b1a7ee3 100644
--- a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyResolver.java
+++ b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/DependencyResolver.java
@@ -1,13 +1,17 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.test.artifacts;
diff --git a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/MavenUtil.java b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/MavenUtil.java
index 2c5b3a2..68d0a14 100644
--- a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/MavenUtil.java
+++ b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/MavenUtil.java
@@ -1,14 +1,19 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
+
package org.glassfish.jersey.test.artifacts;
import org.apache.maven.model.Dependency;
@@ -103,7 +108,7 @@
.filter(dep -> dep.getType().equals("jar"));
}
- private static Model getModelFromFile(String fileName) throws IOException, XmlPullParserException {
+ static Model getModelFromFile(String fileName) throws IOException, XmlPullParserException {
File pomFile = new File(fileName);
return getModelFromFile(pomFile);
}
diff --git a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/TestResult.java b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/TestResult.java
index 172c596..5c357fc 100644
--- a/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/TestResult.java
+++ b/tests/release-test/src/main/java/org/glassfish/jersey/test/artifacts/TestResult.java
@@ -1,14 +1,19 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
+
package org.glassfish.jersey.test.artifacts;
import java.io.IOException;
@@ -53,24 +58,24 @@
}
@Override
- public MessageBuilder append(CharSequence csq) throws IOException {
+ public MessageBuilder append(CharSequence csq) {
builder.append(csq);
return this;
}
- public MessageBuilder append(int i) throws IOException {
+ public MessageBuilder append(int i) {
builder.append(i);
return this;
}
@Override
- public MessageBuilder append(CharSequence csq, int start, int end) throws IOException {
+ public MessageBuilder append(CharSequence csq, int start, int end) {
builder.append(csq, start, end);
return this;
}
@Override
- public MessageBuilder append(char c) throws IOException {
+ public MessageBuilder append(char c) {
builder.append(c);
return this;
}
diff --git a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/DownloadBomPomDependencies.java b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/DownloadBomPomDependencies.java
index ef31d4e..01ba01e 100644
--- a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/DownloadBomPomDependencies.java
+++ b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/DownloadBomPomDependencies.java
@@ -1,14 +1,19 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
+
package org.glassfish.jersey.test.artifacts;
import org.eclipse.aether.DefaultRepositorySystemSession;
diff --git a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ManifestTest.java b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ManifestTest.java
index 8da0835..0c77d69 100644
--- a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ManifestTest.java
+++ b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ManifestTest.java
@@ -1,13 +1,17 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.test.artifacts;
@@ -28,7 +32,7 @@
private static final String BUNDLE_NAME_ATTRIBUTE = "Bundle-Name";
private static final String BUNDLE_VERSION_ATTRIBUTE = "Bundle-Version";
- private static final String [] EXCLUDED_JARS = {"test", "rx-client", "oauth", "weld2-se", "spring",
+ private static final String[] EXCLUDED_JARS = {"test", "rx-client", "oauth", "weld2-se", "spring",
"servlet-portability", /* obsolete */
"helidon-connector", /* Helidon does not contain OSGi headers */
"grizzly-connector", /* Limited maintenance */
diff --git a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/MultiReleaseTest.java b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/MultiReleaseTest.java
index deef29a..288932a 100644
--- a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/MultiReleaseTest.java
+++ b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/MultiReleaseTest.java
@@ -1,13 +1,17 @@
/*
- * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0,
- * or the Eclipse Distribution License v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
*
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.test.artifacts;
diff --git a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/NoticeFilesTest.java b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/NoticeFilesTest.java
new file mode 100644
index 0000000..d1a4d82
--- /dev/null
+++ b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/NoticeFilesTest.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.test.artifacts;
+
+import org.apache.maven.model.Model;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.glassfish.jersey.message.internal.ReaderWriter;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ws.rs.core.MediaType;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+
+public class NoticeFilesTest {
+
+ @Test
+ public void test() throws IOException, XmlPullParserException {
+ Model model = MavenUtil.getModelFromFile("../../pom.xml");
+ List<NoticeDependencyVersionPair> mainExpectedNoticeDeps = mainExpectedDependencies();
+
+ File mainNotice = new File("../../NOTICE.md");
+ List<NoticeDependencyVersionPair> mainNoticeDeps = parseNoticeFileVersions(mainNotice);
+ TestResult testResult = compareDependencies(mainExpectedNoticeDeps, mainNoticeDeps, model, mainNotice.getCanonicalPath());
+
+ // Nothing to check here, yet
+// File commonNotice = new File("../../core-common/src/main/resources/META-INF/NOTICE.markdown");
+// List<NoticeDependencyVersionPair> commonNoticeDeps = parseNoticeFileVersions(mainNotice);
+// testResult.append(compareDependencies(expectedNoticeDeps, commonNoticeDeps, model, commonNotice.getCanonicalPath()));
+
+ File serverNotice = new File("../../core-server/src/main/resources/META-INF/NOTICE.markdown");
+ List<NoticeDependencyVersionPair> serverNoticeDeps = parseNoticeFileVersions(serverNotice);
+ List<NoticeDependencyVersionPair> serverExpectedNoticeDeps = serverExpectedDependencies();
+ testResult.append(
+ compareDependencies(serverExpectedNoticeDeps, serverNoticeDeps, model, serverNotice.getCanonicalPath()));
+
+ File jacksonNotice = new File("../../media/json-jackson/src/main/resources/META-INF/NOTICE.markdown");
+ List<NoticeDependencyVersionPair> jacksonNoticeDeps = parseNoticeFileVersions(jacksonNotice);
+ List<NoticeDependencyVersionPair> jacksonExpectedNoticeDeps = jacksonExpectedDependencies();
+ testResult.append(
+ compareDependencies(jacksonExpectedNoticeDeps, jacksonNoticeDeps, model, jacksonNotice.getCanonicalPath()));
+
+ File bvNotice = new File("../../ext/bean-validation/src/main/resources/META-INF/NOTICE.markdown");
+ List<NoticeDependencyVersionPair> bvNoticeDeps = parseNoticeFileVersions(bvNotice);
+ List<NoticeDependencyVersionPair> bvExpectedNoticeDeps = bvExpectedDependencies();
+ testResult.append(
+ compareDependencies(bvExpectedNoticeDeps, bvNoticeDeps, model, bvNotice.getCanonicalPath()));
+
+ File examplesNotice = new File("../../examples/NOTICE.md");
+ List<NoticeDependencyVersionPair> examplesNoticeDeps = parseNoticeFileVersions(examplesNotice);
+ testResult.append(
+ compareDependencies(mainExpectedNoticeDeps, examplesNoticeDeps, model, examplesNotice.getCanonicalPath()));
+
+ Assert.assertTrue("Some error occurred, see previous messages", testResult.result());
+ }
+
+ private TestResult compareDependencies(List<NoticeDependencyVersionPair> expectedDeps,
+ List<NoticeDependencyVersionPair> actualDeps,
+ Model model, String noticeName) {
+ TestResult testResult = new TestResult();
+ NextExpected:
+ for (NoticeDependencyVersionPair expectedDep : expectedDeps) {
+ for (NoticeDependencyVersionPair actualDep : actualDeps) {
+ if (expectedDep.dependency.equals(actualDep.dependency)) {
+ String expectedVersion = findVersionInModel(expectedDep, model);
+ testResult.ok().append("Expected dependency ").append(expectedDep.dependency).println(" found");
+ if (expectedVersion.equals(actualDep.version)) {
+ testResult.ok().append("Dependency ").append(actualDep.dependency).append(" contains expected version ")
+ .append(expectedVersion).append(" in ").println(noticeName);
+ } else {
+ testResult.exception().append("Dependency ").append(actualDep.dependency).append(" differs version ")
+ .append(expectedVersion).append(" from ").append(noticeName).append(" version ")
+ .println(actualDep.version);
+ }
+ continue NextExpected;
+ }
+ }
+ testResult.exception().append("Expected dependency ").append(expectedDep.dependency).append(" not found in ")
+ .println(noticeName);
+ }
+ return testResult;
+ }
+
+ private static String findVersionInModel(NoticeDependencyVersionPair pair, Model model) {
+ if (pair.version.startsWith("${")) {
+ String version = pair.version.substring(2, pair.version.length() - 1);
+ return model.getProperties().getProperty(version);
+ } else {
+ return pair.version;
+ }
+ }
+
+ private void cat(File path) throws IOException {
+ StringTokenizer tokenizer = tokenizerFromNoticeFile(path);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.trim().length() > 1 && !token.trim().startsWith("*")) {
+ System.out.println(token);
+// String filteredToken = removeUnnecessary(token);
+// System.out.println(filteredToken);
+// Pattern versionizer = Pattern.compile("([.*])?([\\d])");
+// System.out.println(versionizer.matcher(filteredToken).replaceFirst("$1:$2"));
+ }
+ }
+ }
+
+ private List<NoticeDependencyVersionPair> parseNoticeFileVersions(File path) throws IOException {
+ List<NoticeDependencyVersionPair> list = new LinkedList<>();
+ StringTokenizer tokenizer = tokenizerFromNoticeFile(path);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.trim().length() > 1 && !token.trim().startsWith("*")) {
+ String filteredToken = removeUnnecessary(token);
+ Pattern versionizer = Pattern.compile("([.*])?([\\d])");
+ String[] args = versionizer.matcher(filteredToken).replaceFirst("$1:$2").split(":", 2);
+ NoticeDependencyVersionPair pair = args.length == 2
+ ? new NoticeDependencyVersionPair(args[0], args[1])
+ : new NoticeDependencyVersionPair(args[0], "");
+ list.add(pair);
+ }
+ }
+
+ return list;
+ }
+
+ private StringTokenizer tokenizerFromNoticeFile(File path) throws IOException {
+ StringTokenizer tokenizer = new StringTokenizer(getFile(path), "\n");
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.trim().startsWith("## Third-party Content")) {
+ break;
+ }
+ }
+ return tokenizer;
+ }
+
+ private String getFile(File path) throws IOException {
+ return ReaderWriter.readFromAsString(new FileInputStream(path), MediaType.TEXT_PLAIN_TYPE);
+ }
+
+ private String removeUnnecessary(String dependency) {
+ String filtered = dependency
+ .replace(" Version ", "").replace(" version ", "")
+ .replace(" API ", "")
+ .replace(" v", "")
+ .replace(", ", "").replace(",", "")
+ .replace(": ", "").replace(": ", "");
+ return filtered;
+ }
+
+ /**
+ * Return pair of Notice file dependency name & pom.xml version property name
+ */
+ private List<NoticeDependencyVersionPair> mainExpectedDependencies() {
+ final List<NoticeDependencyVersionPair> dependencyPairs = new LinkedList<>();
+ dependencyPairs.add(new NoticeDependencyVersionPair("org.objectweb.asm", "${asm.version}"));
+ dependencyPairs.add(new NoticeDependencyVersionPair("org.osgi.core", "${osgi.version}"));
+ dependencyPairs.add(new NoticeDependencyVersionPair("Jackson JAX-RS Providers", "${jackson.version}"));
+ dependencyPairs.add(new NoticeDependencyVersionPair("Javassist", "${javassist.version}"));
+ dependencyPairs.add(new NoticeDependencyVersionPair("Hibernate Validator CDI", "${validation.impl.version}"));
+ dependencyPairs.add(new NoticeDependencyVersionPair("Bean Validation", "${javax.validation.api.version}"));
+ return dependencyPairs;
+ }
+
+ private List<NoticeDependencyVersionPair> serverExpectedDependencies() {
+ final List<NoticeDependencyVersionPair> dependencyPairs = new LinkedList<>();
+ dependencyPairs.add(new NoticeDependencyVersionPair("org.objectweb.asm", "${asm.version}"));
+ return dependencyPairs;
+ }
+
+ private List<NoticeDependencyVersionPair> bvExpectedDependencies() {
+ final List<NoticeDependencyVersionPair> dependencyPairs = new LinkedList<>();
+ dependencyPairs.add(new NoticeDependencyVersionPair("Hibernate Validator CDI", "${validation.impl.version}"));
+ return dependencyPairs;
+ }
+
+ private List<NoticeDependencyVersionPair> jacksonExpectedDependencies() {
+ final List<NoticeDependencyVersionPair> dependencyPairs = new LinkedList<>();
+ dependencyPairs.add(new NoticeDependencyVersionPair("Jackson JAX-RS Providers", "${jackson.version}"));
+ return dependencyPairs;
+ }
+
+ private static class NoticeDependencyVersionPair {
+ private final String dependency;
+ private final String version;
+
+ private NoticeDependencyVersionPair(String dependency, String version) {
+ this.dependency = dependency.trim();
+ this.version = version.trim();
+ }
+ }
+}