Return-Path: Delivered-To: apmail-activemq-camel-dev-archive@locus.apache.org Received: (qmail 48071 invoked from network); 18 Dec 2008 06:14:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Dec 2008 06:14:45 -0000 Received: (qmail 12723 invoked by uid 500); 18 Dec 2008 06:14:52 -0000 Delivered-To: apmail-activemq-camel-dev-archive@activemq.apache.org Received: (qmail 12697 invoked by uid 500); 18 Dec 2008 06:14:52 -0000 Mailing-List: contact camel-dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-dev@activemq.apache.org Received: (qmail 12685 invoked by uid 99); 18 Dec 2008 06:14:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Dec 2008 22:14:52 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 74.125.92.144 as permitted sender) Received: from [74.125.92.144] (HELO qw-out-1920.google.com) (74.125.92.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Dec 2008 06:14:30 +0000 Received: by qw-out-1920.google.com with SMTP id 9so130434qwj.26 for ; Wed, 17 Dec 2008 22:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=xUtmOJccjjbp2fyiGlm6nQukju0GEup3E/H/cK+qWtA=; b=xJamUU7H5lQbGGwDSDjh6pmevV1BuVrhGvz/T67TC/iwgCu0AwBgJvzC6JFlk+ccsq P9lx6YQ+IGQ8dw1tAjQ5mgtkRy6VeZnwjmUO6pu3HQZYrJ6sBAoqNIsRvMl7TrNVPs3r U9/t+HR7r0cUhIq+6rGRU6/lG1j6PwccC/YJ8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=X3/Th8XKMJuod0Tm9HF7DgclpY7Lvof1Sgmu0BEDLHyJzQ7eV0vY2NHjYUt4/5bRPF dCKxKeCidip8mdzmIGZNZrMw7Wwwfw6d9yPJnGRM760vomENTVmhsxYtol1KygEzRQWX N5fAd+P8Wicr1UaP8lNG1CM4fa1rmWwOO8qKw= Received: by 10.214.217.10 with SMTP id p10mr1988198qag.197.1229580849930; Wed, 17 Dec 2008 22:14:09 -0800 (PST) Received: by 10.214.216.9 with HTTP; Wed, 17 Dec 2008 22:14:09 -0800 (PST) Message-ID: <5380c69c0812172214h2df64308l86b8baedcea79c49@mail.gmail.com> Date: Thu, 18 Dec 2008 07:14:09 +0100 From: "Claus Ibsen" To: camel-dev@activemq.apache.org Subject: Re: MockEndpoint - sleep for empty tests is flawed? In-Reply-To: <5380c69c0812172146v2d3b0562n14d04643578e4dd5@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5380c69c0812172146v2d3b0562n14d04643578e4dd5@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I created a ticket for it https://issues.apache.org/activemq/browse/CAMEL-1196 And attached a better patch. Runs fine now. all core tests passes. On Thu, Dec 18, 2008 at 6:46 AM, Claus Ibsen wrote: > Hi > > Is there a flaw in MockEndpoint with sleep for empty tests? > For instance if I have this code I would expect it to wait 10 sec > before stopping, but it doesn't. > > public void testManually() throws Exception { > deleteDirectory("./target/exclusiveread"); > MockEndpoint mock = getMockEndpoint("mock:result"); > mock.setSleepForEmptyTest(10000); > mock.expectedMessageCount(0); > > mock.assertIsSatisfied(); > } > > > Fixing the code in MockEndpoint to this seems to fix it, and it's a > bit more readable, what it does > > > > > public void assertIsSatisfied(long timeoutForEmptyEndpoints) > throws InterruptedException { > LOG.info("Asserting: " + this + " is satisfied"); > if (expectedCount == 0) { > if (timeoutForEmptyEndpoints > 0) { > LOG.debug("Sleeping for: " + timeoutForEmptyEndpoints > + " millis to check there really are no messages received"); > Thread.sleep(timeoutForEmptyEndpoints); > } else { > waitForCompleteLatch(); > } > assertEquals("Received message count", expectedCount, > getReceivedCounter()); > } else if (expectedCount > 0) { > if (expectedCount != getReceivedCounter()) { > waitForCompleteLatch(); > } > assertEquals("Received message count", expectedCount, > getReceivedCounter()); > } else if (expectedMinimumCount > 0 && getReceivedCounter() < > expectedMinimumCount) { > waitForCompleteLatch(); > } > > > Feedback from other riders is welcome ;) > > -- > > /Claus Ibsen > Apache Camel Committer > Blog: http://davsclaus.blogspot.com/ > -- /Claus Ibsen Apache Camel Committer Blog: http://davsclaus.blogspot.com/