Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-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 C54CC17701 for ; Thu, 16 Apr 2015 06:43:12 +0000 (UTC) Received: (qmail 97840 invoked by uid 500); 16 Apr 2015 06:43:09 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 97811 invoked by uid 500); 16 Apr 2015 06:43:09 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 97801 invoked by uid 99); 16 Apr 2015 06:43:09 -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; Thu, 16 Apr 2015 06:43:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7766DE0FB8; Thu, 16 Apr 2015 06:43:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: ilgrosso@apache.org To: commits@syncope.apache.org Date: Thu, 16 Apr 2015 06:43:11 -0000 Message-Id: <759fa9a9cd9142cca3c00eb5b97c309a@git.apache.org> In-Reply-To: <78f549b253d94b8f98c24f1ecf10e3c5@git.apache.org> References: <78f549b253d94b8f98c24f1ecf10e3c5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] syncope git commit: Merge from 1_2_X Merge from 1_2_X Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/5c049cdf Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/5c049cdf Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/5c049cdf Branch: refs/heads/master Commit: 5c049cdf4777a1126b657a28fdb8682e42a179a7 Parents: 6736d4e 5e31bab Author: Francesco Chicchiriccò Authored: Thu Apr 16 08:43:02 2015 +0200 Committer: Francesco Chicchiriccò Committed: Thu Apr 16 08:43:02 2015 +0200 ---------------------------------------------------------------------- .../java/org/apache/syncope/client/lib/ConcurrencyTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/5c049cdf/client/lib/src/test/java/org/apache/syncope/client/lib/ConcurrencyTest.java ---------------------------------------------------------------------- diff --cc client/lib/src/test/java/org/apache/syncope/client/lib/ConcurrencyTest.java index cbd7793,0000000..a20cb59 mode 100644,000000..100644 --- a/client/lib/src/test/java/org/apache/syncope/client/lib/ConcurrencyTest.java +++ b/client/lib/src/test/java/org/apache/syncope/client/lib/ConcurrencyTest.java @@@ -1,73 -1,0 +1,77 @@@ +/* + * 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.syncope.client.lib; + +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.StringUtils; +import org.apache.syncope.common.rest.api.service.ResourceService; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConcurrencyTest { + + private static final Logger LOG = LoggerFactory.getLogger(ConcurrencyTest.class); + + private static final int THREAD_NUMBER = 1000; + + private static final SyncopeClient client = + new SyncopeClientFactoryBean().setAddress("http://url").create("username", "password"); + + @Test + public void multiThreadTest() + throws InterruptedException { + + for (int i = 0; i < THREAD_NUMBER; i++) { + Thread execution = new Thread("Th-" + StringUtils.leftPad(String.valueOf(i), 5, '0')) { + + @Override + public void run() { + + try { + client.getService(ResourceService.class); + + LOG.info(getName() + " completed successfully!"); + } catch (Exception e) { + LOG.error(getName() + " did not complete", e); + } + } + }; - execution.start(); ++ try { ++ execution.start(); ++ } catch(OutOfMemoryError e) { ++ // ignore ++ } + } + + Thread.sleep(THREAD_NUMBER); + } + + @Test + public void multiCallTest() { + try { + for (int i = 0; i < THREAD_NUMBER; i++) { + client.getService(ResourceService.class); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } +}