From 18c14cf47df384eb7084e23e86950f3eb520372b Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Mon, 30 Sep 2024 18:12:24 +0200
Subject: [PATCH] ControlTest: remove usage of deprecated ISvcLocator APIs

---
 AtlasTest/ControlTest/test/CircularDep_test.cxx      |  8 +++-----
 AtlasTest/ControlTest/test/ClearStore_test.cxx       |  7 ++-----
 AtlasTest/ControlTest/test/DataProxy_test.cxx        | 12 +++---------
 .../ControlTest/test/ElementLinkVector_test.cxx      |  8 +++-----
 AtlasTest/ControlTest/test/ElementLink_test.cxx      |  6 ++----
 AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx |  9 +++------
 AtlasTest/ControlTest/test/SGDataLink_test.cxx       |  5 +----
 .../ControlTest/test/StoreGateSvcClient_test.cxx     |  9 +++------
 AtlasTest/ControlTest/test/StoreID_test.cxx          | 12 ++++--------
 9 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/AtlasTest/ControlTest/test/CircularDep_test.cxx b/AtlasTest/ControlTest/test/CircularDep_test.cxx
index 58c3dc4953e8..d979bc60ddc0 100644
--- a/AtlasTest/ControlTest/test/CircularDep_test.cxx
+++ b/AtlasTest/ControlTest/test/CircularDep_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #undef NDEBUG
@@ -44,10 +44,8 @@ int main() {
   }  
 
   assert(pSvcLoc);
-  StoreGateSvc* pSG;
-  
-  const bool CREATEIF(true);
-  assert((pSvcLoc->service("StoreGateSvc", pSG, CREATEIF)).isSuccess());
+
+  SmartIF<StoreGateSvc> pSG(pSvcLoc->service("StoreGateSvc"));
   assert(pSG);
 
   Circular *circ0(new Circular), *circ1(new Circular);
diff --git a/AtlasTest/ControlTest/test/ClearStore_test.cxx b/AtlasTest/ControlTest/test/ClearStore_test.cxx
index 491a19396233..69c67dc916b3 100644
--- a/AtlasTest/ControlTest/test/ClearStore_test.cxx
+++ b/AtlasTest/ControlTest/test/ClearStore_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 /***************************************************************************
@@ -8,7 +8,6 @@
  ATLAS Collaboration
  ***************************************************************************/
 
-// $Id: ClearStore_test.cxx,v 1.1 2007-07-10 01:14:31 calaf Exp $
 
 #include <iostream>
 
@@ -32,9 +31,7 @@ int main() {
   }  
   assert(pSvcLoc);
 
-  StoreGateSvc* pStore(nullptr);
-  static const bool CREATE(true);
-  assert((pSvcLoc->service("StoreGateSvc", pStore, CREATE)).isSuccess());
+  SmartIF<StoreGateSvc> pStore(pSvcLoc->service("StoreGateSvc"));
   assert(pStore);
   
   cout << "*** ClearStore_test run standard testRecord a first time ***" << endl;
diff --git a/AtlasTest/ControlTest/test/DataProxy_test.cxx b/AtlasTest/ControlTest/test/DataProxy_test.cxx
index 6afa1a11e3f2..6751d7472c4e 100644
--- a/AtlasTest/ControlTest/test/DataProxy_test.cxx
+++ b/AtlasTest/ControlTest/test/DataProxy_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #undef NDEBUG
@@ -20,8 +20,6 @@
 
 #include <cassert>
 
-const bool CREATEIF(true);
-
 struct Bla{
   Bla(): i(0) {}
   Bla(int m): i(m) {}
@@ -85,9 +83,7 @@ int main() {
   assert( (DataProxy_cast<Bla>(&transientProxy))->i == 77 );
 
 
-  IConversionSvc* pIConvSvc(nullptr);
-  StatusCode cs((pSvcLoc->service("EventPersistencySvc", pIConvSvc, CREATEIF)));
-  assert(cs.isSuccess());
+  SmartIF<IConversionSvc> pIConvSvc(pSvcLoc->service("EventPersistencySvc"));
   assert(pIConvSvc);
   // create a transient address with IOA.
   TransientAddress* tGen = new TransientAddress(ClassID_traits<Foo>::ID(),
@@ -114,9 +110,7 @@ int main() {
   fptr->doNothing(); //remove warning
 
 
-  IProxyProviderSvc* pIPPSvc(nullptr);
-  StatusCode psc(pSvcLoc->service("ProxyProviderSvc", pIPPSvc, CREATEIF));
-  assert( psc.isSuccess() );
+  SmartIF<IProxyProviderSvc> pIPPSvc(pSvcLoc->service("ProxyProviderSvc"));
   assert( pIPPSvc );
 
   TransientAddress* tad = new TransientAddress(ClassID_traits<Bla>::ID(), "bla");
diff --git a/AtlasTest/ControlTest/test/ElementLinkVector_test.cxx b/AtlasTest/ControlTest/test/ElementLinkVector_test.cxx
index 1afdf4bddc80..f11c8bb0c994 100644
--- a/AtlasTest/ControlTest/test/ElementLinkVector_test.cxx
+++ b/AtlasTest/ControlTest/test/ElementLinkVector_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TestTools/SGassert.h"
@@ -133,10 +133,8 @@ int main() {
     return 0;
   }  
   assert(pSvcLoc);
-  StoreGateSvc* pSG;
-  
-  const bool CREATEIF(true);
-  assert((pSvcLoc->service("StoreGateSvc", pSG, CREATEIF)).isSuccess());
+
+  SmartIF<StoreGateSvc> pSG(pSvcLoc->service("StoreGateSvc"));
   assert(pSG);
 
   linkVector(*pSG);
diff --git a/AtlasTest/ControlTest/test/ElementLink_test.cxx b/AtlasTest/ControlTest/test/ElementLink_test.cxx
index b793b3a08a30..8b7fd524dd82 100644
--- a/AtlasTest/ControlTest/test/ElementLink_test.cxx
+++ b/AtlasTest/ControlTest/test/ElementLink_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TestTools/FLOATassert.h"
@@ -134,9 +134,7 @@ int main(int argc, char** argv) {
     std::cerr << " This test cannot be run without init Gaudi" << endl;
   }
   assert(pSvcLoc);
-  StoreGateSvc* pSG;
-  const bool CREATEIF(true);
-  assert((pSvcLoc->service("StoreGateSvc", pSG, CREATEIF)).isSuccess());
+  SmartIF<StoreGateSvc> pSG(pSvcLoc->service("StoreGateSvc"));
   assert(pSG);
 
   StatusCode sc;
diff --git a/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx b/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx
index 81d33c49f427..8ef9e12a5454 100644
--- a/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx
+++ b/AtlasTest/ControlTest/test/ProxyProviderSvc_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 /** @file ProxyProviderSvc_test.cxx
@@ -180,12 +180,9 @@ int main ATLAS_NOT_THREAD_SAFE () {
   }  
   assert( pSvcLoc );
 
-  StoreGateSvc* pStore(nullptr);
-  static const bool CREATE(true);
-  assert( (pSvcLoc->service("StoreGateSvc", pStore, CREATE)).isSuccess() );
+  SmartIF<StoreGateSvc> pStore(pSvcLoc->service("StoreGateSvc"));
   assert( pStore );
-  IProxyProviderSvc* pIPPSvc;
-  assert( (pSvcLoc->service("ProxyProviderSvc", pIPPSvc, CREATE)).isSuccess() );
+  SmartIF<IProxyProviderSvc> pIPPSvc(pSvcLoc->service("ProxyProviderSvc"));
   assert( pIPPSvc );
 
   pIPPSvc->addProvider(new TestProvider<Foo>("aFoo"));
diff --git a/AtlasTest/ControlTest/test/SGDataLink_test.cxx b/AtlasTest/ControlTest/test/SGDataLink_test.cxx
index 8bece003ceae..7b820dc60da0 100644
--- a/AtlasTest/ControlTest/test/SGDataLink_test.cxx
+++ b/AtlasTest/ControlTest/test/SGDataLink_test.cxx
@@ -349,10 +349,7 @@ int main() {
   errorcheck::ReportMessage::hideErrorLocus();
 
   assert(pSvcLoc);
-  StoreGateSvc* pSG;
-  
-  const bool CREATEIF(true);
-  assert((pSvcLoc->service("StoreGateSvc", pSG, CREATEIF)).isSuccess());
+  SmartIF<StoreGateSvc> pSG(pSvcLoc->service("StoreGateSvc"));
   assert(pSG);
 
   Foo* pFoo = new Foo;
diff --git a/AtlasTest/ControlTest/test/StoreGateSvcClient_test.cxx b/AtlasTest/ControlTest/test/StoreGateSvcClient_test.cxx
index c7c3c1278841..180edf51d248 100644
--- a/AtlasTest/ControlTest/test/StoreGateSvcClient_test.cxx
+++ b/AtlasTest/ControlTest/test/StoreGateSvcClient_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 /***************************************************************************
@@ -284,9 +284,7 @@ int main ATLAS_NOT_THREAD_SAFE () {
   }  
   assert(pSvcLoc);
 
-  StoreGateSvc* pStore(nullptr);
-  static const bool CREATE(true);
-  assert((pSvcLoc->service("StoreGateSvc", pStore, CREATE)).isSuccess());
+  SmartIF<StoreGateSvc> pStore(pSvcLoc->service("StoreGateSvc"));
   assert(pStore);
 
   testRecord(*pStore);
@@ -337,8 +335,7 @@ int main ATLAS_NOT_THREAD_SAFE () {
 
   ///////
 
-  StoreGateSvc* detStore(nullptr);
-  assert((pSvcLoc->service("DetectorStore", detStore, CREATE)).isSuccess());
+  SmartIF<StoreGateSvc> detStore(pSvcLoc->service("DetectorStore"));
   assert(detStore);
 
   testRecord(*detStore);
diff --git a/AtlasTest/ControlTest/test/StoreID_test.cxx b/AtlasTest/ControlTest/test/StoreID_test.cxx
index 404d85d3ca66..7bdf284fe00d 100644
--- a/AtlasTest/ControlTest/test/StoreID_test.cxx
+++ b/AtlasTest/ControlTest/test/StoreID_test.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
 */
 
 /***************************************************************************
@@ -8,7 +8,6 @@
  ATLAS Collaboration
  ***************************************************************************/
 
-// $Id: StoreID_test.cxx 770224 2016-08-26 01:59:31Z ssnyder $
 
 #include <iostream>
 
@@ -32,18 +31,15 @@ int main() {
   }  
   assert(pSvcLoc);
 
-  StoreGateSvc* pStore(nullptr);
-  static const bool CREATE(true);
-  assert((pSvcLoc->service("StoreGateSvc", pStore, CREATE)).isSuccess());
+  SmartIF<StoreGateSvc> pStore(pSvcLoc->service("StoreGateSvc"));
   assert(pStore);
-  
   assert(pStore->storeID() == StoreID::EVENT_STORE);
 
-  assert((pSvcLoc->service("DetectorStore", pStore)).isSuccess());
+  pStore = pSvcLoc->service("DetectorStore");
   assert(pStore);
   assert(pStore->storeID() == StoreID::DETECTOR_STORE);
   
-  assert((pSvcLoc->service("ConditionStore", pStore, CREATE)).isSuccess());
+  pStore = pSvcLoc->service("ConditionStore");
   assert(pStore);
   assert(pStore->storeID() == StoreID::CONDITION_STORE);
   
-- 
GitLab