Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1E131180E9 for ; Sat, 3 Oct 2015 00:02:06 +0000 (UTC) Received: (qmail 52958 invoked by uid 500); 3 Oct 2015 00:02:05 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 52890 invoked by uid 500); 3 Oct 2015 00:02:05 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 52881 invoked by uid 99); 3 Oct 2015 00:02:05 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Oct 2015 00:02:05 +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 3A1AD180973 for ; Sat, 3 Oct 2015 00:02:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.794 X-Spam-Level: * X-Spam-Status: No, score=1.794 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.006] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id uTkdkbicvYax for ; Sat, 3 Oct 2015 00:02:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 2FEEB203BB for ; Sat, 3 Oct 2015 00:02:03 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A397CE0252 for ; Sat, 3 Oct 2015 00:02:02 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 693C43A04DB for ; Sat, 3 Oct 2015 00:02:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1706507 - in /sling/trunk/testing/mocks/osgi-mock/src: main/java/org/apache/sling/testing/mock/osgi/ test/java/org/apache/sling/testing/mock/osgi/ Date: Sat, 03 Oct 2015 00:02:02 -0000 To: commits@sling.apache.org From: sseifert@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151003000202.693C43A04DB@svn01-us-west.apache.org> Author: sseifert Date: Sat Oct 3 00:02:01 2015 New Revision: 1706507 URL: http://svn.apache.org/viewvc?rev=1706507&view=rev Log: SLING-5088 deprecate activate/deactivate methods without bundleContext parameter because there is a small risk for memory leaks Modified: sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferncesTest.java sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java Modified: sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java?rev=1706507&r1=1706506&r2=1706507&view=diff ============================================================================== --- sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java (original) +++ sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java Sat Oct 3 00:02:01 2015 @@ -129,7 +129,10 @@ public final class MockOsgi { * Simulate activation of service instance. Invokes the @Activate annotated method. * @param target Service instance. * @return true if activation method was called. False if no activate method is defined. + * @deprecated Please use {@link #activate(Object, BundleContext)} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean activate(Object target) { return MockOsgi.activate(target, (Dictionary)null); } @@ -137,9 +140,22 @@ public final class MockOsgi { /** * Simulate activation of service instance. Invokes the @Activate annotated method. * @param target Service instance. + * @param bundleContext Bundle context + * @return true if activation method was called. False if no activate method is defined. + */ + public static boolean activate(Object target, BundleContext bundleContext) { + return MockOsgi.activate(target, bundleContext, (Dictionary)null); + } + + /** + * Simulate activation of service instance. Invokes the @Activate annotated method. + * @param target Service instance. * @param properties Properties * @return true if activation method was called. False if no activate method is defined. + * @deprecated Please use {@link #activate(Object, BundleContext, Dictionary))} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean activate(Object target, Dictionary properties) { Dictionary mergedProperties = propertiesMergeWithOsgiMetadata(target, properties); ComponentContext componentContext = newComponentContext(mergedProperties); @@ -151,7 +167,10 @@ public final class MockOsgi { * @param target Service instance. * @param properties Properties * @return true if activation method was called. False if no activate method is defined. + * @deprecated Please use {@link #activate(Object, BundleContext, Map)))} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean activate(Object target, Map properties) { return activate(target, toDictionary(properties)); } @@ -184,7 +203,10 @@ public final class MockOsgi { * Simulate deactivation of service instance. Invokes the @Deactivate annotated method. * @param target Service instance. * @return true if deactivation method was called. False if no deactivate method is defined. + * @deprecated Please use {@link #deactivate(Object, BundleContext)} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean deactivate(Object target) { return MockOsgi.deactivate(target, (Dictionary)null); } @@ -192,9 +214,22 @@ public final class MockOsgi { /** * Simulate deactivation of service instance. Invokes the @Deactivate annotated method. * @param target Service instance. + * @param bundleContext Bundle context. + * @return true if deactivation method was called. False if no deactivate method is defined. + */ + public static boolean deactivate(Object target, BundleContext bundleContext) { + return MockOsgi.deactivate(target, bundleContext, (Dictionary)null); + } + + /** + * Simulate deactivation of service instance. Invokes the @Deactivate annotated method. + * @param target Service instance. * @param properties Properties * @return true if deactivation method was called. False if no deactivate method is defined. + * @deprecated Please use {@link #deactivate(Object, BundleContext, Dictionary))} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean deactivate(Object target, Dictionary properties) { Dictionary mergedProperties = propertiesMergeWithOsgiMetadata(target, properties); ComponentContext componentContext = newComponentContext(mergedProperties); @@ -206,7 +241,10 @@ public final class MockOsgi { * @param target Service instance. * @param properties Properties * @return true if deactivation method was called. False if no deactivate method is defined. + * @deprecated Please use {@link #deactivate(Object, BundleContext, Map)))} + * and shutdown the bundle context after usage. */ + @Deprecated public static boolean deactivate(Object target, Map properties) { return deactivate(target, toDictionary(properties)); } Modified: sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferncesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferncesTest.java?rev=1706507&r1=1706506&r2=1706507&view=diff ============================================================================== --- sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferncesTest.java (original) +++ sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferncesTest.java Sat Oct 3 00:02:01 2015 @@ -73,7 +73,7 @@ public class MockBundleContextDynamicRef service = new Service3(); MockOsgi.injectServices(service, bundleContext); - MockOsgi.activate(service); + MockOsgi.activate(service, bundleContext); bundleContext.registerService(Service3.class.getName(), service, null); assertDependency1(dependency1a); Modified: sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java URL: http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java?rev=1706507&r1=1706506&r2=1706507&view=diff ============================================================================== --- sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java (original) +++ sling/trunk/testing/mocks/osgi-mock/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java Sat Oct 3 00:02:01 2015 @@ -99,7 +99,7 @@ public class OsgiServiceUtilTest { assertEquals(1, reference3Configs.size()); assertEquals(200, reference3Configs.get(0).get(Constants.SERVICE_RANKING)); - assertTrue(MockOsgi.deactivate(service3)); + assertTrue(MockOsgi.deactivate(service3, bundleContext)); assertNull(service3.getComponentContext()); } @@ -128,7 +128,7 @@ public class OsgiServiceUtilTest { Service4 service4 = new Service4(); assertTrue(MockOsgi.injectServices(service4, bundleContext)); - assertFalse(MockOsgi.activate(service4)); + assertFalse(MockOsgi.activate(service4, bundleContext)); assertSame(service1, service4.getReference1()); } @@ -140,12 +140,12 @@ public class OsgiServiceUtilTest { @Test(expected=NoScrMetadataException.class) public void testActivateNoMetadata() { - MockOsgi.activate(new Object()); + MockOsgi.activate(new Object(), bundleContext); } @Test(expected=NoScrMetadataException.class) public void testDeactivateNoMetadata() { - MockOsgi.deactivate(new Object()); + MockOsgi.deactivate(new Object(), bundleContext); } @Test(expected=NoScrMetadataException.class)