From commits-return-3707-apmail-ace-commits-archive=ace.apache.org@ace.apache.org Thu Oct 10 14:11:47 2013 Return-Path: X-Original-To: apmail-ace-commits-archive@www.apache.org Delivered-To: apmail-ace-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 97C3E10544 for ; Thu, 10 Oct 2013 14:11:47 +0000 (UTC) Received: (qmail 22783 invoked by uid 500); 10 Oct 2013 14:11:46 -0000 Delivered-To: apmail-ace-commits-archive@ace.apache.org Received: (qmail 22731 invoked by uid 500); 10 Oct 2013 14:11:43 -0000 Mailing-List: contact commits-help@ace.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ace.apache.org Delivered-To: mailing list commits@ace.apache.org Received: (qmail 22669 invoked by uid 99); 10 Oct 2013 14:11:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 14:11:42 +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; Thu, 10 Oct 2013 14:11:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 83FDE2388B43; Thu, 10 Oct 2013 14:11:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1530984 [5/5] - in /ace/trunk: org.apache.ace.agent.itest/ org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ org.apache.ace.agent.update.itest/ org.apache.ace.agent.update.itest/conf/ org.apache.ace.agent.update.itest/src/org/apac... Date: Thu, 10 Oct 2013 14:11:14 -0000 To: commits@ace.apache.org From: jawi@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131010141117.83FDE2388B43@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java?rev=1530984&r1=1530983&r2=1530984&view=diff ============================================================================== --- ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java (original) +++ ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java Thu Oct 10 14:11:13 2013 @@ -21,9 +21,11 @@ package org.apache.ace.it; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ace.test.utils.Util.properties; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; +import java.net.ConnectException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -36,6 +38,7 @@ import java.util.concurrent.TimeUnit; import junit.framework.TestCase; +import org.apache.ace.test.constants.TestConstants; import org.apache.felix.dm.Component; import org.apache.felix.dm.ComponentDependencyDeclaration; import org.apache.felix.dm.ComponentStateListener; @@ -128,6 +131,11 @@ public class IntegrationTestBase extends * configure("org.apache.felix.http", * "org.osgi.service.http.port", "1234"); * + * + * @param pid + * the configuration PID to configure; + * @param configuration + * the configuration key/values (as pairs). */ protected void configure(String pid, String... configuration) throws IOException { Properties props = properties(configuration); @@ -137,6 +145,60 @@ public class IntegrationTestBase extends } /** + * Configures the "org.apache.felix.http" and waits until the service is actually ready to process requests. + *

+ * The reason that this method exists is that configuring the Felix HTTP bundle causes it to actually stop and + * restart, which is done asynchronously. This means that we cannot be sure that depending code is always able to + * directly use the HTTP service after its been configured. + *

+ * + * @param port + * the new port to run the HTTP service on; + * @param configuration + * the extra (optional) configuration key/values (as pairs). + * @see #configure(String, String...) + */ + protected void configureHttpService(int port, String... configuration) throws IOException, InterruptedException { + final String httpPID = "org.apache.felix.http"; + final String portProperty = "org.osgi.service.http.port"; + final String expectedPort = Integer.toString(port); + + // Do not track this configuration (yet)... + Properties props = properties(configuration); + props.put(portProperty, expectedPort); + + Configuration config = getConfiguration(httpPID); + config.update(props); + + // This ugly warth is necessary as Felix HTTP currently brings the entire service down & up if it gets + // reconfigured. There is no other way for us to tell whether the server is ready to accept calls... + URL url = new URL(String.format("http://localhost:%d/", port)); + int tries = 50; + boolean ready = false; + do { + Thread.sleep(50); + + try { + InputStream is = url.openStream(); + is.close(); + ready = true; + } + catch (ConnectException exception) { + // Not there yet... + } + catch (FileNotFoundException exception) { + // Ok; expected... + ready = true; + } + } + while (!ready && tries-- > 0); + + if (tries == 0) { + throw new IOException("Failed waiting on HTTP service?!"); + } + } + + /** * The 'after' callback will be called after all components from {@link #getDependencies} have been started.
*
* The {@link #after} callback is most useful for configuring additional services after all mandatory services are @@ -476,6 +538,11 @@ public class IntegrationTestBase extends m_dependencyManager.add(component); } + System.setProperty("org.apache.ace.server.port", Integer.toString(TestConstants.PORT)); + + // Ensure the HTTP service is running on the port we expect... + configureHttpService(TestConstants.PORT); + // Call back the implementation... configureProvisionedServices(); @@ -486,10 +553,6 @@ public class IntegrationTestBase extends } configureAdditionalServices(); - - // Wait for CM to settle or we may get "socket closed" due to HTTP service restarts - // JaWi: no longer needed with Felix HTTP v2.2.1? - // Thread.sleep(500); } catch (InterruptedException e) { fail("Interrupted while waiting for services to get started."); Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1530984&r1=1530983&r2=1530984&view=diff ============================================================================== --- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java (original) +++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java Thu Oct 10 14:11:13 2013 @@ -114,11 +114,11 @@ public class VaadinClient extends com.va private static long SESSION_ID = 1; - private static String targetRepo = "target"; - private static String shopRepo = "shop"; - private static String deployRepo = "deployment"; - private static String customerName = "apache"; - private static String endpoint = "/repository"; + private static final String targetRepo = "target"; + private static final String shopRepo = "shop"; + private static final String deployRepo = "deployment"; + private static final String customerName = "apache"; + private static final String endpoint = "/repository"; private volatile AuthenticationService m_authenticationService; private volatile BundleContext m_context; @@ -1029,7 +1029,7 @@ public class VaadinClient extends com.va RepositoryAdminLoginContext context = m_admin.createLoginContext(user); // @formatter:off - context.setObrBase(m_obrUrl) + context .add(context.createShopRepositoryContext() .setLocation(m_repository).setCustomer(customerName).setName(shopRepo).setWriteable()) .add(context.createTargetRepositoryContext()