Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-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 EBEE1100CC for ; Wed, 26 Feb 2014 23:32:11 +0000 (UTC) Received: (qmail 94415 invoked by uid 500); 26 Feb 2014 23:32:11 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 94375 invoked by uid 500); 26 Feb 2014 23:32:11 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 94368 invoked by uid 99); 26 Feb 2014 23:32:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Feb 2014 23:32:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Feb 2014 23:32:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CDC6C23888E2; Wed, 26 Feb 2014 23:31:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1572347 - /felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java Date: Wed, 26 Feb 2014 23:31:49 -0000 To: commits@felix.apache.org From: pderop@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140226233149.CDC6C23888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pderop Date: Wed Feb 26 23:31:49 2014 New Revision: 1572347 URL: http://svn.apache.org/r1572347 Log: Added createDependenciesWithCallbackInstance test Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java?rev=1572347&r1=1572346&r2=1572347&view=diff ============================================================================== --- felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java (original) +++ felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java Wed Feb 26 23:31:49 2014 @@ -593,4 +593,47 @@ public class ComponentTest { c.remove(d); Assert.assertEquals("Component stopped, should be unavailable", false, c.isAvailable()); } + + @Test + public void createDependenciesWithCallbackInstance() { + final Ensure e = new Ensure(); + ComponentImpl c = new ComponentImpl(); + c.setImplementation(new Object() { + void start() { + e.step(2); + } + + void stop() { + e.step(4); + } + }); + + Object callbackInstance = new Object() { + void add() { + e.step(1); + } + + void remove() { + e.step(5); + } + }; + + DependencyImpl d = new DependencyImpl(); + d.setCallbacks(callbackInstance, "add", "remove"); + d.setRequired(true); + // add the dependency to the component + c.add(d); + // start the component + c.start(); + // make the dependency available, we expect the add callback + // to be invoked here, then start is called. + d.add(new EventImpl()); + e.step(3); + // remove the dependency, should trigger the stop, then remove callback + d.remove(new EventImpl()); + e.step(6); + c.stop(); + c.remove(d); + Assert.assertEquals("Component stopped, should be unavailable", false, c.isAvailable()); + } }