NIFI-10138 Updated Atlas tests to use Jackson 2

- Replaced Jackson 1 dependencies with Jackson 2
- Removed commons-beanutils override that is no longer necessary with new Hadoop version

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #6136.
This commit is contained in:
exceptionfactory 2022-06-17 14:08:28 -05:00 committed by Pierre Villard
parent 4aee4546b9
commit eef4ea1fc6
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
3 changed files with 8 additions and 44 deletions

View File

@ -56,21 +56,6 @@
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-kerberos-credentials-service-api</artifactId>
</dependency>
<!-- Explicitly force beanutils 1.9.4 in order to avoid vulnerabilities in earlier versions.
Can remove this once atlas client which depends on hadoop-common uses a more recent version. -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v2</artifactId>
@ -90,28 +75,9 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<!-- jersey-json has dependency to newer javax.xml.stream:stax-api:jar -->
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.13</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- test -->

View File

@ -16,6 +16,8 @@
*/
package org.apache.nifi.atlas.emulator;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
@ -26,8 +28,6 @@ import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1;
import org.apache.nifi.atlas.AtlasUtils;
import org.apache.nifi.atlas.NiFiTypes;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
@ -243,10 +243,8 @@ public class AtlasAPIV2ServerEmulator {
private static <T> T readInputJSON(HttpServletRequest req, Class<? extends T> clazz) throws IOException {
return new ObjectMapper()
.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.reader()
.withType(clazz)
.readValue(req.getInputStream());
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.readValue(req.getInputStream(), clazz);
}
private static final AtlasTypesDef atlasTypesDef = new AtlasTypesDef();

View File

@ -43,7 +43,7 @@ import org.apache.nifi.state.MockStateManager;
import org.apache.nifi.util.MockComponentLog;
import org.apache.nifi.util.MockConfigurationContext;
import org.apache.nifi.util.MockPropertyValue;
import org.codehaus.jackson.map.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -522,7 +522,7 @@ public class ITReportLineageToAtlas {
private Lineage getLineage() throws Exception {
final URL url = new URL("http://localhost:21000/api/atlas/v2/debug/lineage/");
try (InputStream in = url.openStream()) {
Lineage lineage = new ObjectMapper().reader().withType(Lineage.class).readValue(in);
Lineage lineage = new ObjectMapper().readValue(in, Lineage.class);
return lineage;
}
}