Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BF211200CB5 for ; Wed, 24 May 2017 00:07:19 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BC3AF160BD3; Tue, 23 May 2017 22:07:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3D61E160BDA for ; Wed, 24 May 2017 00:07:17 +0200 (CEST) Received: (qmail 53913 invoked by uid 500); 23 May 2017 22:07:16 -0000 Mailing-List: contact commits-help@atlas.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.incubator.apache.org Delivered-To: mailing list commits@atlas.incubator.apache.org Received: (qmail 53843 invoked by uid 99); 23 May 2017 22:07:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2017 22:07:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id CAB95190D3F for ; Tue, 23 May 2017 22:07:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id SoNiOM8LIHAf for ; Tue, 23 May 2017 22:07:03 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 6C66260CCB for ; Tue, 23 May 2017 22:07:00 +0000 (UTC) Received: (qmail 52754 invoked by uid 99); 23 May 2017 22:06:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 May 2017 22:06:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 57A44E3AA7; Tue, 23 May 2017 22:06:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: apoorvnaik@apache.org To: commits@atlas.incubator.apache.org Date: Tue, 23 May 2017 22:07:07 -0000 Message-Id: In-Reply-To: <74cf728c4f474011b1f52cf5c20b1579@git.apache.org> References: <74cf728c4f474011b1f52cf5c20b1579@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/12] incubator-atlas git commit: ATLAS-1198: Spring Framework (v4 with Spring security) over Guice archived-at: Tue, 23 May 2017 22:07:19 -0000 http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java index c08fbc9..26dc6a8 100644 --- a/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java +++ b/repository/src/test/java/org/apache/atlas/repository/graph/ReverseReferenceUpdateTestBase.java @@ -21,10 +21,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import org.apache.atlas.CreateUpdateEntitiesResult; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.MetadataRepository; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.types.AttributeDefinition; @@ -40,7 +38,6 @@ import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.Arrays; @@ -52,9 +49,7 @@ import java.util.Map; * Verifies automatic update of reverse references * */ -@Guice(modules = TestOnlyModule.class) public abstract class ReverseReferenceUpdateTestBase { - @Inject MetadataRepository repositoryService; @@ -63,8 +58,6 @@ public abstract class ReverseReferenceUpdateTestBase { protected ClassType typeA; protected ClassType typeB; - abstract DeleteHandler getDeleteHandler(TypeSystem typeSystem); - abstract void assertTestOneToOneReference(Object actual, ITypedReferenceableInstance expectedValue, ITypedReferenceableInstance referencingInstance) throws Exception; abstract void assertTestOneToManyReference(Object refValue, ITypedReferenceableInstance referencingInstance) throws Exception; @@ -73,8 +66,6 @@ public abstract class ReverseReferenceUpdateTestBase { typeSystem = TypeSystem.getInstance(); typeSystem.reset(); - new GraphBackedSearchIndexer(new AtlasTypeRegistry()); - HierarchicalTypeDefinition aDef = TypesUtil.createClassTypeDef("A", ImmutableSet.of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), new AttributeDefinition("b", "B", Multiplicity.OPTIONAL, false, "a"), // 1-1 @@ -95,7 +86,6 @@ public abstract class ReverseReferenceUpdateTestBase { typeA = typeSystem.getDataType(ClassType.class, "A"); typeB = typeSystem.getDataType(ClassType.class, "B"); - repositoryService = new GraphBackedMetadataRepository(getDeleteHandler(typeSystem)); repositoryService = TestUtils.addTransactionWrapper(repositoryService); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java index b34db82..b835d22 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java @@ -18,8 +18,7 @@ package org.apache.atlas.repository.impexp; -import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.impexp.AtlasExportRequest; @@ -33,20 +32,21 @@ import org.apache.atlas.repository.store.graph.v1.AtlasEntityChangeNotifier; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1; +import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper; import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; +import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; -import org.powermock.reflect.Whitebox; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Guice; import org.testng.annotations.Test; import scala.actors.threadpool.Arrays; +import javax.inject.Inject; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; @@ -61,7 +61,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ExportServiceTest { private static final Logger LOG = LoggerFactory.getLogger(ExportServiceTest.class); @@ -71,6 +71,9 @@ public class ExportServiceTest { @Inject private AtlasTypeDefStore typeDefStore; + @Inject + private EntityGraphMapper graphMapper; + @Inject ExportService exportService; private DeleteHandlerV1 deleteHandler = mock(SoftDeleteHandlerV1.class);; private AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); @@ -78,7 +81,7 @@ public class ExportServiceTest { @BeforeClass public void setupSampleData() throws AtlasBaseException { - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier);; + entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper);; AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); @@ -94,11 +97,6 @@ public class ExportServiceTest { LOG.debug("==> setupSampleData: ", AtlasEntity.dumpObjects(hrDept.getEntities(), null).toString()); } - @BeforeTest - public void setupExportService () throws AtlasBaseException { - exportService = new ExportService(typeRegistry); - } - @AfterClass public void clear() { AtlasGraphProvider.cleanup(); @@ -257,33 +255,33 @@ public class ExportServiceTest { @Test public void verifyOverallStatus() throws Exception { - ExportService service = new ExportService(typeRegistry); - assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(service, +// ExportService service = new ExportService(typeRegistry); + assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, "getOverallOperationStatus")); - assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS, AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, AtlasExportResult.OperationStatus.SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.PARTIAL_SUCCESS, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.PARTIAL_SUCCESS)); - assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(service, + assertEquals(AtlasExportResult.OperationStatus.FAIL, Whitebox.invokeMethod(exportService, "getOverallOperationStatus", AtlasExportResult.OperationStatus.FAIL, AtlasExportResult.OperationStatus.FAIL, http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java index f9a0584..0aaaa70 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceReportingTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.impexp; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; @@ -26,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Guice; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ImportServiceReportingTest { private static final Logger LOG = LoggerFactory.getLogger(ImportServiceReportingTest.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java index 91966f8..08e9ee8 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.impexp; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.store.AtlasTypeDefStore; @@ -36,7 +36,7 @@ import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZip import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.loadModelFromJson; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runAndVerifyQuickStart_v1_Import; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class ImportServiceTest { private static final Logger LOG = LoggerFactory.getLogger(ImportServiceTest.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java index 31fba33..5f01136 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasEntityDefStoreV1Test.java @@ -22,7 +22,7 @@ import com.google.inject.Inject; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; -import org.apache.atlas.RepositoryMetadataModule; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; @@ -34,14 +34,10 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - /** * Tests for AtlasEntityStoreV1 */ -@Guice(modules = RepositoryMetadataModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasEntityDefStoreV1Test { @Inject http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java index 9b977db..9f7214c 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java @@ -18,7 +18,7 @@ package org.apache.atlas.repository.store.graph; import com.google.inject.Inject; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.SearchFilter; @@ -28,12 +28,10 @@ import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasTypesDef; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.store.AtlasTypeDefStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; -import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -44,7 +42,7 @@ import java.util.List; import static org.testng.Assert.*; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasTypeDefGraphStoreTest { private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreTest.class); @@ -52,11 +50,6 @@ public class AtlasTypeDefGraphStoreTest { private AtlasTypeDefStore typeDefStore; - @AfterClass - public void clear(){ - AtlasGraphProvider.cleanup(); - } - @Test(priority = 1) public void testGet() { try { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java index 9a11e08..9331e35 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java @@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasException; import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; @@ -39,7 +38,6 @@ import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.AtlasEdgeLabel; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasVertex; @@ -63,7 +61,6 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; -import org.testng.annotations.Guice; import org.testng.annotations.Test; import javax.inject.Inject; @@ -81,7 +78,6 @@ import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -@Guice(modules = TestOnlyModule.class) public abstract class AtlasDeleteHandlerV1Test { @Inject @@ -90,6 +86,7 @@ public abstract class AtlasDeleteHandlerV1Test { @Inject AtlasTypeDefStore typeDefStore; + @Inject AtlasEntityStore entityStore; @Inject @@ -101,13 +98,9 @@ public abstract class AtlasDeleteHandlerV1Test { private TypeSystem typeSystem = TypeSystem.getInstance(); - AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); - - @BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); - new GraphBackedSearchIndexer(typeRegistry); final AtlasTypesDef deptTypesDef = TestUtilsV2.defineDeptEmployeeTypes(); typeDefStore.createTypesDef(deptTypesDef); @@ -144,8 +137,6 @@ public abstract class AtlasDeleteHandlerV1Test { @BeforeTest public void init() throws Exception { - DeleteHandlerV1 deleteHandler = getDeleteHandler(typeRegistry); - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); RequestContextV1.clear(); } @@ -155,8 +146,6 @@ public abstract class AtlasDeleteHandlerV1Test { AtlasGraphProvider.cleanup(); } - abstract DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry); - @Test public void testDeleteAndCreate() throws Exception { init(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java index 1dd7276..44067b9 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java @@ -20,8 +20,8 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; +import org.apache.atlas.TestModules; import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.exception.AtlasBaseException; @@ -83,7 +83,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class AtlasEntityStoreV1Test { private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityStoreV1Test.class); @@ -106,6 +106,8 @@ public class AtlasEntityStoreV1Test { private AtlasEntityWithExtInfo tblEntity; AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); + @Inject + private EntityGraphMapper graphMapper; @BeforeClass @@ -137,7 +139,7 @@ public class AtlasEntityStoreV1Test { @BeforeTest public void init() throws Exception { - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); + entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier, graphMapper); RequestContextV1.clear(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java index 4403b12..407ebff 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/HardDeleteHandlerV1Test.java @@ -20,6 +20,7 @@ package org.apache.atlas.repository.store.graph.v1; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; @@ -28,11 +29,11 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasVertex; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedStruct; import org.testng.Assert; +import org.testng.annotations.Guice; import java.util.List; import java.util.Map; @@ -44,13 +45,9 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.fail; import static org.testng.AssertJUnit.assertNotNull; +@Guice(modules = TestModules.HardDeleteModule.class) public class HardDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test { - @Override - DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - return new HardDeleteHandlerV1(typeRegistry); - } - @Override protected void assertTableForTestDeleteReference(String tableId) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java index 6a23807..d54adeb 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateHardDeleteV1Test.java @@ -18,10 +18,11 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; +import org.apache.atlas.TestModules; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasObjectId; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; +import org.testng.annotations.Guice; import java.util.Map; @@ -31,15 +32,10 @@ import static org.testng.Assert.assertTrue; /** * Inverse reference update test with {@link HardDeleteHandlerV1} */ +@Guice(modules = TestModules.HardDeleteModule.class) public class InverseReferenceUpdateHardDeleteV1Test extends InverseReferenceUpdateV1Test { @Override - protected DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - - return new HardDeleteHandlerV1(typeRegistry); - } - - @Override protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { // Max should have been removed from the subordinates list, leaving only John. http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java index ae6731c..884ab54 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateSoftDeleteV1Test.java @@ -18,10 +18,11 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; +import org.apache.atlas.TestModules; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasObjectId; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; +import org.testng.annotations.Guice; import java.util.Map; @@ -32,15 +33,10 @@ import static org.testng.Assert.assertTrue; /** * Inverse reference update test with {@link SoftDeleteHandlerV1} */ +@Guice(modules = TestModules.SoftDeleteModule.class) public class InverseReferenceUpdateSoftDeleteV1Test extends InverseReferenceUpdateV1Test { @Override - protected DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry) { - - return new SoftDeleteHandlerV1(typeRegistry); - } - - @Override protected void verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(AtlasEntity jane) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java index c90f716..e2a8010 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/InverseReferenceUpdateV1Test.java @@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.apache.atlas.RequestContextV1; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.model.instance.AtlasEntity; @@ -31,7 +30,6 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.services.MetadataService; @@ -42,7 +40,6 @@ import org.apache.atlas.type.AtlasTypeUtil; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Guice; import org.testng.annotations.Test; import javax.inject.Inject; @@ -52,7 +49,6 @@ import java.util.List; import java.util.Map; import static org.apache.atlas.TestUtils.NAME; -import static org.mockito.Mockito.mock; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; @@ -61,35 +57,26 @@ import static org.testng.Assert.assertTrue; * Test automatic inverse reference updating in V1 (V2?) code path. * */ -@Guice(modules = TestOnlyModule.class) public abstract class InverseReferenceUpdateV1Test { - @Inject AtlasTypeRegistry typeRegistry; @Inject AtlasTypeDefStore typeDefStore; + @Inject AtlasEntityStore entityStore; @Inject MetadataService metadataService; - @Inject - DeleteHandlerV1 deleteHandler; - private AtlasEntitiesWithExtInfo deptEntity; - AtlasEntityChangeNotifier mockChangeNotifier = mock(AtlasEntityChangeNotifier.class); - protected Map nameIdMap = new HashMap<>(); - protected abstract DeleteHandlerV1 getDeleteHandler(AtlasTypeRegistry typeRegistry); - @BeforeClass public void setUp() throws Exception { metadataService = TestUtils.addSessionCleanupWrapper(metadataService); - new GraphBackedSearchIndexer(typeRegistry); AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() @@ -104,8 +91,6 @@ public abstract class InverseReferenceUpdateV1Test { } deptEntity = TestUtilsV2.createDeptEg2(); - DeleteHandlerV1 deleteHandler = getDeleteHandler(typeRegistry); - entityStore = new AtlasEntityStoreV1(deleteHandler, typeRegistry, mockChangeNotifier); init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java index 8935faf..3f1ed03 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1Test.java @@ -19,6 +19,7 @@ package org.apache.atlas.repository.store.graph.v1; import org.apache.atlas.AtlasClient; +import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntityHeader; @@ -27,13 +28,13 @@ import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.services.MetadataService; -import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedStruct; import org.apache.atlas.typesystem.persistence.Id; import org.testng.Assert; +import org.testng.annotations.Guice; import javax.inject.Inject; import java.util.List; @@ -44,17 +45,13 @@ import static org.apache.atlas.TestUtils.NAME; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +@Guice(modules = TestModules.SoftDeleteModule.class) public class SoftDeleteHandlerV1Test extends AtlasDeleteHandlerV1Test { @Inject MetadataService metadataService; @Override - DeleteHandlerV1 getDeleteHandler(final AtlasTypeRegistry typeRegistry) { - return new SoftDeleteHandlerV1(typeRegistry); - } - - @Override protected void assertDeletedColumn(final AtlasEntity.AtlasEntityWithExtInfo tableInstance) throws AtlasBaseException { final List columns = (List) tableInstance.getEntity().getAttribute(COLUMNS_ATTR_NAME); Assert.assertEquals(columns.size(), 3); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java index 65cd938..6e3dabb 100755 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java @@ -21,10 +21,9 @@ package org.apache.atlas.repository.typestore; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.RepositoryException; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasEdge; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; @@ -50,7 +49,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAt import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class GraphBackedTypeStoreTest { private static final String DESCRIPTION = "_description"; @@ -70,7 +69,7 @@ public class GraphBackedTypeStoreTest { @AfterClass public void tearDown() throws Exception { ts.reset(); - AtlasGraphProvider.cleanup(); +// AtlasGraphProvider.cleanup(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java deleted file mode 100644 index 6c5dcfc..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheConfigurationTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.atlas.repository.typestore; - -import com.google.inject.Inject; -import org.apache.atlas.typesystem.types.cache.TypeCache; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -/** - * Verify Guice can successfully instantiate and inject StoreBackTypeCache. - * StoreBackedTypeCacheTestModule Guice module uses Atlas configuration - * which has type cache implementation class set to {@link StoreBackedTypeCache}. - */ -@Guice(modules = StoreBackedTypeCacheTestOnlyModule.class) -public class StoreBackedTypeCacheConfigurationTest { - - @Inject - private TypeCache typeCache; - - @Test - public void testConfigureAsTypeCache() throws Exception { - // Verify Guice successfully instantiated and injected StoreBackTypeCache - Assert.assertTrue(typeCache instanceof StoreBackedTypeCache); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java index 1608bd7..2ea63ff 100644 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTest.java @@ -20,9 +20,8 @@ package org.apache.atlas.repository.typestore; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; -import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.typesystem.types.AttributeInfo; import org.apache.atlas.typesystem.types.ClassType; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; @@ -46,7 +45,7 @@ import java.util.Map; /** * Unit test for {@link StoreBackedTypeCache} */ -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class StoreBackedTypeCacheTest { @Inject @@ -87,7 +86,7 @@ public class StoreBackedTypeCacheTest { @AfterClass public void tearDown() throws Exception { ts.reset(); - AtlasGraphProvider.cleanup(); +// AtlasGraphProvider.cleanup(); } @BeforeMethod http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java b/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java deleted file mode 100644 index 7fb0155..0000000 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/StoreBackedTypeCacheTestOnlyModule.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.atlas.repository.typestore; - -import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasException; -import org.apache.atlas.TestOnlyModule; -import org.apache.atlas.util.AtlasRepositoryConfiguration; -import org.apache.commons.configuration.Configuration; - - -/** - * Guice module which sets TypeCache implementation class configuration property to {@link StoreBackedTypeCache}. - * - */ -public class StoreBackedTypeCacheTestOnlyModule extends TestOnlyModule { - - @Override - protected Configuration getConfiguration() { - try { - Configuration configuration = ApplicationProperties.get(); - configuration.setProperty(AtlasRepositoryConfiguration.TYPE_CACHE_IMPLEMENTATION_PROPERTY, - StoreBackedTypeCache.class.getName()); - return configuration; - } catch (AtlasException e) { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java index 7e2edd8..d8d8d91 100644 --- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java @@ -24,14 +24,15 @@ import com.google.inject.Inject; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; import org.apache.atlas.EntityAuditEvent; +import org.apache.atlas.TestModules; import org.apache.atlas.RequestContext; -import org.apache.atlas.TestOnlyModule; import org.apache.atlas.TestUtils; import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.listener.ChangedTypeDefs; import org.apache.atlas.listener.EntityChangeListener; import org.apache.atlas.listener.TypeDefChangeListener; +import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.query.QueryParams; import org.apache.atlas.repository.audit.EntityAuditRepository; import org.apache.atlas.repository.audit.HBaseBasedAuditRepository; @@ -85,7 +86,7 @@ import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeD import static org.apache.atlas.typesystem.types.utils.TypesUtil.createOptionalAttrDef; import static org.testng.Assert.*; -@Guice(modules = TestOnlyModule.class) +@Guice(modules = TestModules.TestOnlyModule.class) public class DefaultMetadataServiceTest { @Inject private MetadataService metadataService; @@ -150,7 +151,7 @@ public class DefaultMetadataServiceTest { AtlasGraphProvider.cleanup(); } } - private AtlasClient.EntityResult updateInstance(Referenceable entity) throws Exception { + private EntityResult updateInstance(Referenceable entity) throws Exception { RequestContext.createContext(); ParamChecker.notNull(entity, "Entity"); ParamChecker.notNull(entity.getId(), "Entity"); @@ -296,7 +297,7 @@ public class DefaultMetadataServiceTest { assertAuditEvents(id, EntityAuditEvent.EntityAuditAction.ENTITY_DELETE); } - private AtlasClient.EntityResult deleteEntities(String... guids) throws AtlasException { + private EntityResult deleteEntities(String... guids) throws AtlasException { RequestContext.createContext(); return metadataService.deleteEntities(Arrays.asList(guids)); } @@ -529,7 +530,7 @@ public class DefaultMetadataServiceTest { assertEquals(actualColumns, updatedColNameList); } - private AtlasClient.EntityResult updateEntityPartial(String guid, Referenceable entity) throws AtlasException { + private EntityResult updateEntityPartial(String guid, Referenceable entity) throws AtlasException { RequestContext.createContext(); return metadataService.updateEntityPartialByGuid(guid, entity).getEntityResult(); } @@ -547,7 +548,7 @@ public class DefaultMetadataServiceTest { put(COLUMNS_ATTR_NAME, columns); }}); - AtlasClient.EntityResult entityResult = updateEntityPartial(tableId._getId(), tableUpdated); + EntityResult entityResult = updateEntityPartial(tableId._getId(), tableUpdated); assertEquals(entityResult.getCreatedEntities().size(), 1); //col1 created assertEquals(entityResult.getUpdateEntities().size(), 1); //table updated assertEquals(entityResult.getUpdateEntities().get(0), tableId._getId()); @@ -1020,7 +1021,7 @@ public class DefaultMetadataServiceTest { //Delete one column String columnId = table1Columns.get(0).getId()._getId(); - AtlasClient.EntityResult entityResult = deleteEntities(columnId); + EntityResult entityResult = deleteEntities(columnId); //column is deleted and table is updated assertEquals(entityResult.getDeletedEntities().get(0), columnId); assertEquals(entityResult.getUpdateEntities().get(0), table1Entity.getId()._getId()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java index 217fc8d..5c37b9e 100644 --- a/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/service/StoreBackedTypeCacheMetadataServiceTest.java @@ -19,12 +19,11 @@ package org.apache.atlas.service; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; +import org.apache.atlas.TestModules; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.typestore.ITypeStore; import org.apache.atlas.repository.typestore.StoreBackedTypeCache; -import org.apache.atlas.repository.typestore.StoreBackedTypeCacheTestOnlyModule; import org.apache.atlas.services.MetadataService; import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.typesystem.json.TypesSerialization; @@ -44,14 +43,17 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Guice; import org.testng.annotations.Test; +import javax.inject.Inject; + /** * Verify MetadataService type operations trigger StoreBackedTypeCache to load non-cached types from the store. * StoreBackedTypeCacheTestModule Guice module sets Atlas configuration * to use {@link StoreBackedTypeCache} as the TypeCache implementation class. */ -@Guice(modules = StoreBackedTypeCacheTestOnlyModule.class) -public class StoreBackedTypeCacheMetadataServiceTest { +@Guice(modules = TestModules.StoreBackedTypeCacheTestModule.class) +public class StoreBackedTypeCacheMetadataServiceTest +{ @Inject private MetadataService metadataService; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java index d503ef7..d490083 100644 --- a/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/services/EntityDiscoveryServiceTest.java @@ -17,7 +17,7 @@ */ package org.apache.atlas.services; -import org.apache.atlas.TestOnlyModule; +import org.apache.atlas.TestModules.TestOnlyModule; import org.apache.atlas.discovery.EntityDiscoveryService; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasEntityDef; @@ -28,7 +28,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Guice; import org.testng.annotations.Test; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.testng.Assert.assertEquals; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala index 60464be..a948d16 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala @@ -41,7 +41,7 @@ class GremlinTest extends BaseGremlinTest { @BeforeClass def beforeAll() { TypeSystem.getInstance().reset() - var repo = new GraphBackedMetadataRepository(null) + var repo = new GraphBackedMetadataRepository(null, new AtlasGraphProvider().get()) TestUtils.setupGraphProvider(repo) //force graph to be initialized first AtlasGraphProvider.getGraphInstance() http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala index cc22865..880a0c6 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala @@ -43,7 +43,7 @@ class GremlinTest2 extends BaseGremlinTest { def beforeAll() { TypeSystem.getInstance().reset() QueryTestsUtils.setupTypes - var repo = new GraphBackedMetadataRepository(null); + var repo = new GraphBackedMetadataRepository(null, null); gp = new DefaultGraphPersistenceStrategy(repo) g = QueryTestsUtils.setupTestGraph(repo) } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala b/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala index 3a3c967..b01cbf8 100755 --- a/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/LineageQueryTest.scala @@ -43,7 +43,7 @@ class LineageQueryTest extends BaseGremlinTest { @BeforeClass def beforeAll() { TypeSystem.getInstance().reset() - var repo = new GraphBackedMetadataRepository(null); + var repo = new GraphBackedMetadataRepository(null, new AtlasGraphProvider().get()); TestUtils.setupGraphProvider(repo); //force graph to be initialized first AtlasGraphProvider.getGraphInstance(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/pom.xml ---------------------------------------------------------------------- diff --git a/server-api/pom.xml b/server-api/pom.xml index 278184f..7761a71 100644 --- a/server-api/pom.xml +++ b/server-api/pom.xml @@ -37,11 +37,6 @@ - com.google.inject - guice - - - org.apache.atlas atlas-typesystem @@ -60,58 +55,5 @@ org.apache.atlas atlas-client - - - org.aspectj - aspectjrt - - - - - - org.codehaus.mojo - aspectj-maven-plugin - - 1.7 - true - true - true - - **/*.java - **/*.aj - - - - - compile_with_aspectj - - compile - - - src/main/java - - - - test-compile_with_aspectj - - test-compile - - - - - - org.aspectj - aspectjrt - ${aspectj.runtime.version} - - - org.aspectj - aspectjtools - ${aspectj.runtime.version} - - - - - http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java ---------------------------------------------------------------------- diff --git a/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java b/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java deleted file mode 100644 index 3579dd2..0000000 --- a/server-api/src/main/java/org/apache/atlas/aspect/AtlasAspect.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.atlas.aspect; - -import org.apache.atlas.RequestContext; -import org.apache.atlas.metrics.Metrics; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.List; - -@Aspect -public class AtlasAspect { - - public static final Logger LOG = LoggerFactory.getLogger(AtlasAspect.class); - - @Around("@annotation(org.apache.atlas.aspect.Monitored) && execution(* *(..))") - public Object collectMetricsForMonitored(ProceedingJoinPoint joinPoint) throws Throwable { - Signature methodSign = joinPoint.getSignature(); - Metrics metrics = RequestContext.getMetrics(); - String metricName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName(); - long start = System.currentTimeMillis(); - - try { - Object response = joinPoint.proceed(); - return response; - } finally { - metrics.record(metricName, (System.currentTimeMillis() - start)); - } - } - - @Around("@annotation(org.apache.atlas.aspect.Loggable) && execution(* *(..))") - public Object logAroundLoggable(ProceedingJoinPoint joinPoint) throws Throwable { - Signature methodSign = joinPoint.getSignature(); - String methodName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName(); - - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("==> %s(%s)", methodName, Arrays.toString(joinPoint.getArgs()))); - } - Object response = joinPoint.proceed(); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("<== %s(%s): %s", methodName, Arrays.toString(joinPoint.getArgs()), - response instanceof List ? ((List)response).size() : response)); - } - return response; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/server-api/src/main/java/org/apache/atlas/services/MetadataService.java ---------------------------------------------------------------------- diff --git a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java index 31ef7b5..7fb3d3f 100644 --- a/server-api/src/main/java/org/apache/atlas/services/MetadataService.java +++ b/server-api/src/main/java/org/apache/atlas/services/MetadataService.java @@ -18,11 +18,11 @@ package org.apache.atlas.services; -import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasException; import org.apache.atlas.CreateUpdateEntitiesResult; import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.listener.EntityChangeListener; +import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedStruct; @@ -267,7 +267,7 @@ public interface MetadataService { * @return List of guids for deleted entities * @throws AtlasException */ - AtlasClient.EntityResult deleteEntities(List guids) throws AtlasException; + EntityResult deleteEntities(List guids) throws AtlasException; /** * Register a listener for entity change. @@ -292,8 +292,8 @@ public interface MetadataService { * @return List of guids for deleted entities (including their composite references) * @throws AtlasException */ - AtlasClient.EntityResult deleteEntityByUniqueAttribute(String typeName, String uniqueAttributeName, - String attrValue) throws AtlasException; + EntityResult deleteEntityByUniqueAttribute(String typeName, String uniqueAttributeName, + String attrValue) throws AtlasException; /** * Returns entity audit events for entity id in the decreasing order of timestamp http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java index c853ec6..262f784 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java @@ -20,7 +20,6 @@ package org.apache.atlas.typesystem.types; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - import org.apache.atlas.AtlasException; import org.apache.atlas.classification.InterfaceAudience; import org.apache.atlas.typesystem.TypesDef; @@ -31,6 +30,7 @@ import org.apache.atlas.typesystem.types.cache.TypeCache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.inject.Singleton; import java.lang.reflect.Constructor; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -41,8 +41,6 @@ import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; -import javax.inject.Singleton; - @Singleton @InterfaceAudience.Private @Deprecated http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java deleted file mode 100644 index 4e1cd36..0000000 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystemProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.atlas.typesystem.types; - -import com.google.inject.Provider; - -public class TypeSystemProvider implements Provider { - @Override - public TypeSystem get() { - return TypeSystem.getInstance(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java index ce750af..0d86474 100644 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/cache/DefaultTypeCache.java @@ -17,8 +17,8 @@ */ package org.apache.atlas.typesystem.types.cache; -import com.google.inject.Singleton; import org.apache.atlas.AtlasException; +import org.apache.atlas.annotation.ConditionalOnAtlasProperty; import org.apache.atlas.typesystem.types.ClassType; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; import org.apache.atlas.typesystem.types.EnumType; @@ -29,7 +29,9 @@ import org.apache.atlas.typesystem.types.TraitType; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import javax.inject.Singleton; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -41,8 +43,10 @@ import java.util.concurrent.ConcurrentHashMap; /** * Caches the types in-memory within the same process space. */ -@Singleton @SuppressWarnings("rawtypes") +@Singleton +@Component +@ConditionalOnAtlasProperty(property = "atlas.TypeCache.impl", isDefault = true) public class DefaultTypeCache implements TypeCache { private static final Logger LOG = LoggerFactory.getLogger(DefaultTypeCache.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/typesystem/src/main/resources/atlas-log4j.xml ---------------------------------------------------------------------- diff --git a/typesystem/src/main/resources/atlas-log4j.xml b/typesystem/src/main/resources/atlas-log4j.xml index 8312657..c30403e 100755 --- a/typesystem/src/main/resources/atlas-log4j.xml +++ b/typesystem/src/main/resources/atlas-log4j.xml @@ -75,6 +75,21 @@ + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/pom.xml ---------------------------------------------------------------------- diff --git a/webapp/pom.xml b/webapp/pom.xml index 045ccdb..4132912 100755 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -172,11 +172,6 @@ atlas-catalog - - org.apache.atlas - atlas-graphdb-impls - pom - org.apache.curator @@ -276,18 +271,29 @@ + com.google.inject + guice + ${guice.version} + test + + + com.google.inject.extensions - guice-servlet + guice-throwingproviders + ${guice.version} + test - com.google.code.gson - gson + com.google.inject.extensions + guice-multibindings + ${guice.version} + test - com.sun.jersey.contribs - jersey-guice + com.google.code.gson + gson @@ -311,55 +317,94 @@ - com.google.inject - guice + org.springframework + spring-core - org.springframework - spring-core - ${spring.version} + org.springframework + spring-web - org.springframework - spring-web - ${spring.version} + org.springframework + spring-webmvc - org.springframework - spring-webmvc - ${spring.version} + org.springframework.security + spring-security-core - org.springframework.security - spring-security-core - ${spring.security.version} + org.springframework.security + spring-security-web - org.springframework.security - spring-security-web - ${spring.security.version} + org.springframework.security + spring-security-config - org.springframework.security - spring-security-config - ${spring.security.version} + org.springframework.security + spring-security-ldap + + + javax.servlet + javax.servlet-api + + + org.springframework.ldap + spring-ldap-core + + + com.sun.jersey.contribs + jersey-spring + 1.8 + + + org.springframework + spring + + + org.springframework + spring-core + + + org.springframework + spring-web + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + - org.springframework.security - spring-security-ldap - ${spring.security.version} + com.sun.jersey + jersey-servlet + - org.springframework.ldap - spring-ldap-core - ${spring-ldap-core.version} + org.springframework + spring-aop + + + org.aspectj + aspectjrt + 1.8.9 + + + org.aspectj + aspectjweaver + 1.8.9 org.apache.atlas @@ -367,11 +412,6 @@ war - javax.servlet - javax.servlet-api - ${javax.servlet.version} - - org.easymock easymock 3.4 @@ -390,7 +430,8 @@ tests test - + + org.apache.atlas atlas-repository tests @@ -414,10 +455,11 @@ - - org.aspectj - aspectjrt + org.apache.atlas + atlas-repository + tests + test @@ -644,46 +686,6 @@ - org.codehaus.mojo - aspectj-maven-plugin - - 1.7 - - **/*.java - **/*.aj - - true - true - - - org.apache.atlas - atlas-server-api - - - - - - compile_with_aspectj - - compile - - - - - - org.aspectj - aspectjtools - ${aspectj.runtime.version} - - - - org.apache.atlas - atlas-server-api - ${project.version} - - - - com.webcohesion.enunciate enunciate-maven-plugin http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/Atlas.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/Atlas.java b/webapp/src/main/java/org/apache/atlas/Atlas.java index 14c43cc..e29254b 100755 --- a/webapp/src/main/java/org/apache/atlas/Atlas.java +++ b/webapp/src/main/java/org/apache/atlas/Atlas.java @@ -19,9 +19,7 @@ package org.apache.atlas; import org.apache.atlas.security.SecurityProperties; -import org.apache.atlas.setup.SetupException; import org.apache.atlas.web.service.EmbeddedServer; -import org.apache.atlas.web.setup.AtlasSetup; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.Option; @@ -33,6 +31,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.hadoop.util.ShutdownHookManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; import java.util.Iterator; @@ -48,7 +47,7 @@ public final class Atlas { private static final String ATLAS_LOG_DIR = "atlas.log.dir"; public static final String ATLAS_SERVER_HTTPS_PORT = "atlas.server.https.port"; public static final String ATLAS_SERVER_HTTP_PORT = "atlas.server.http.port"; - public static final String ATLAS_SERVER_RUN_SETUP_KEY = "atlas.server.run.setup.on.start"; + private static EmbeddedServer server; @@ -111,28 +110,12 @@ public final class Atlas { final boolean enableTLS = isTLSEnabled(enableTLSFlag, appPort); configuration.setProperty(SecurityProperties.TLS_ENABLED, String.valueOf(enableTLS)); - runSetupIfRequired(configuration); showStartupInfo(buildConfiguration, enableTLS, appPort); server = EmbeddedServer.newServer(appPort, appPath, enableTLS); - server.start(); - } + installLogBridge(); - private static void runSetupIfRequired(Configuration configuration) throws SetupException { - boolean shouldRunSetup = configuration.getBoolean(ATLAS_SERVER_RUN_SETUP_KEY, false); - if (shouldRunSetup) { - LOG.warn("Running setup per configuration {}.", ATLAS_SERVER_RUN_SETUP_KEY); - AtlasSetup atlasSetup = new AtlasSetup(); - try { - atlasSetup.run(); - } catch (SetupException se) { - LOG.error("Failed running setup. Will not start the server."); - throw se; - } - LOG.warn("Finished running setup."); - } else { - LOG.info("Not running setup per configuration {}.", ATLAS_SERVER_RUN_SETUP_KEY); - } + server.start(); } private static void setApplicationHome() { @@ -204,4 +187,14 @@ public final class Atlas { LOG.info("Server starting with TLS ? {} on port {}", enableTLS, appPort); LOG.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); } + + private static void installLogBridge() { + // Optionally remove existing handlers attached to j.u.l root logger + SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5) + + // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during + // the initialization phase of your application + SLF4JBridgeHandler.install(); + } + } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java index f3af37d..6eadc96 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -18,7 +18,6 @@ package org.apache.atlas.notification; import com.google.common.annotations.VisibleForTesting; -import com.google.inject.Inject; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; import org.apache.atlas.listener.EntityChangeListener; @@ -35,7 +34,9 @@ import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.configuration.Configuration; +import org.springframework.stereotype.Component; +import javax.inject.Inject; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -48,6 +49,7 @@ import java.util.Set; /** * Listen to the repository for entity changes and produce entity change notifications. */ +@Component public class NotificationEntityChangeListener implements EntityChangeListener { private final NotificationInterface notificationInterface; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java index e6d5697..2f8245d 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java @@ -19,7 +19,6 @@ package org.apache.atlas.notification; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.google.inject.Singleton; import kafka.consumer.ConsumerTimeoutException; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; @@ -45,6 +44,8 @@ import org.apache.atlas.web.util.DateTimeHelper; import org.apache.commons.configuration.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import javax.inject.Inject; import java.util.ArrayList; @@ -68,7 +69,8 @@ import static org.apache.atlas.notification.hook.HookNotification.HookNotificati /** * Consumer of notifications from hooks e.g., hive hook etc. */ -@Singleton +@Component +@Order(4) public class NotificationHookConsumer implements Service, ActiveStateChangeHandler { private static final Logger LOG = LoggerFactory.getLogger(NotificationHookConsumer.class); private static final String LOCALHOST = "localhost"; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java index 9042e88..98bd381 100644 --- a/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/AllExceptionMapper.java @@ -20,20 +20,19 @@ package org.apache.atlas.web.errors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; -import java.util.concurrent.ThreadLocalRandom; - -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; +import java.util.concurrent.ThreadLocalRandom; /** * Exception mapper for Jersey. * @param */ @Provider -@Singleton +@Component public class AllExceptionMapper implements ExceptionMapper { private static final Logger LOGGER = LoggerFactory.getLogger(AllExceptionMapper.class); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java index ec1767c..f4b8d67 100755 --- a/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/AtlasBaseExceptionMapper.java @@ -21,8 +21,8 @@ package org.apache.atlas.web.errors; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.type.AtlasType; +import org.springframework.stereotype.Component; -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; @@ -34,7 +34,7 @@ import java.util.concurrent.ThreadLocalRandom; * AtlasBaseException mapper for Jersey. */ @Provider -@Singleton +@Component public class AtlasBaseExceptionMapper implements ExceptionMapper { @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java b/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java index 9f97bb2..a33d8d7 100644 --- a/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java +++ b/webapp/src/main/java/org/apache/atlas/web/errors/NotFoundExceptionMapper.java @@ -18,15 +18,15 @@ package org.apache.atlas.web.errors; import org.apache.atlas.typesystem.exception.NotFoundException; +import org.springframework.stereotype.Component; -import javax.inject.Singleton; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import java.util.concurrent.ThreadLocalRandom; @Provider -@Singleton +@Component public class NotFoundExceptionMapper implements ExceptionMapper { @Override public Response toResponse(NotFoundException e) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java index ecc67a7..36f2688 100644 --- a/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java +++ b/webapp/src/main/java/org/apache/atlas/web/filters/ActiveServerFilter.java @@ -23,9 +23,9 @@ import org.apache.atlas.web.service.ServiceState; import org.apache.hadoop.http.HtmlQuoting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; import javax.inject.Inject; -import javax.inject.Singleton; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -46,7 +46,7 @@ import java.io.IOException; * an error SERVICE_UNAVAILABLE. Identification of this state is carried out using * {@link ServiceState} and {@link ActiveInstanceState}. */ -@Singleton +@Component public class ActiveServerFilter implements Filter { private static final Logger LOG = LoggerFactory.getLogger(ActiveServerFilter.class);