Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 22548 invoked from network); 17 Jan 2007 18:33:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jan 2007 18:33:47 -0000 Received: (qmail 4238 invoked by uid 500); 17 Jan 2007 18:33:53 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 4182 invoked by uid 500); 17 Jan 2007 18:33:53 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 4170 invoked by uid 99); 17 Jan 2007 18:33:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jan 2007 10:33:53 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jan 2007 10:33:46 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id EC8341A981D; Wed, 17 Jan 2007 10:32:41 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r497116 - in /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo: ServerProxy.java server/RunClientMojo.java Date: Wed, 17 Jan 2007 18:32:41 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070117183241.EC8341A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Wed Jan 17 10:32:40 2007 New Revision: 497116 URL: http://svn.apache.org/viewvc?view=rev&rev=497116 Log: GERONIMO-2736 add ability to run app clients in integration tests Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/RunClientMojo.java (with props) Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java?view=diff&rev=497116&r1=497115&r2=497116 ============================================================================== --- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java (original) +++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ServerProxy.java Wed Jan 17 10:32:40 2007 @@ -29,6 +29,7 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.MBeanServerConnection; +import javax.management.ObjectName; // // FIXME: It should be possible to query state with-out any Geronimo classes, @@ -135,6 +136,32 @@ } return fullyStarted; + } + + public String getGeronimoHome() { + String home = null; + + try { + ObjectName systemInfoQuery = new ObjectName("*:name=ServerInfo,j2eeType=GBean,*"); + + getConnection(); + + Set set = this.mbeanConnection.queryNames(systemInfoQuery, null); + + if (set.size() > 0) { + ObjectName found = (ObjectName)set.iterator().next(); + home = (String)this.mbeanConnection.getAttribute(found, "currentBaseDirectory"); + } + + } catch (IOException e) { + log.debug("Connection failure; ignoring", e); + lastError = e; + } catch (Exception e) { + log.debug("Unable to determine if the server home directory", e); + lastError = e; + } + + return home; } public Throwable getLastError() { Added: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/RunClientMojo.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/RunClientMojo.java?view=auto&rev=497116 ============================================================================== --- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/RunClientMojo.java (added) +++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/RunClientMojo.java Wed Jan 17 10:32:40 2007 @@ -0,0 +1,140 @@ +/** + * 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.geronimo.mavenplugins.geronimo.server; + +import java.io.File; + +import org.apache.tools.ant.taskdefs.Java; + +import org.apache.maven.plugin.MojoExecutionException; + +import org.apache.geronimo.mavenplugins.geronimo.ServerProxy; +import org.apache.geronimo.mavenplugins.geronimo.reporting.ReportingMojoSupport; + +import org.codehaus.plexus.util.FileUtils; + +/** + * Execute application client. + * + * @goal run-client + * + * @version $Rev$ $Date$ + */ +public class RunClientMojo extends ReportingMojoSupport +{ + /** + * The id of the client module to be executed + * + * @parameter expression="${moduleId} + * @required + */ + protected String moduleId = null; + + /** + * Set the maximum memory for the forked JVM. + * + * @parameter expression="${maximumMemory}" + */ + private String maximumMemory = null; + + /** + * Time in seconds to wait before terminating the forked JVM. + * + * @parameter expression="${timeout}" default-value="-1" + */ + private int timeout = -1; + + /** + * The arguments + * + * @parameter expression="${arg} + * @optional + */ + protected String[] arg = null; + + protected void doExecute() throws Exception { + ServerProxy server = + new ServerProxy(hostname, port, username, password); + + String geronimoHomeStr = server.getGeronimoHome(); + + log.info("Geronimo Home: " + geronimoHomeStr); + + if (geronimoHomeStr == null) { + throw new MojoExecutionException("Unable to determine Geronimo installation directory"); + } + + File geronimoHome = new File(geronimoHomeStr); + + if (!geronimoHome.exists()) { + throw new MojoExecutionException("Geronimo installation directory does not exist: " + geronimoHomeStr); + } + + log.info("Starting Geronimo client..."); + + Java java = (Java)createTask("java"); + java.setJar(new File(geronimoHome, "bin/client.jar")); + java.setDir(geronimoHome); + java.setFailonerror(true); + java.setFork(true); + + if (timeout > 0) { + java.setTimeout(new Long(timeout * 1000)); + } + + if (maximumMemory != null) { + java.setMaxmemory(maximumMemory); + } + + // Set the properties which we pass to the JVM from the startup script + setSystemProperty(java, "org.apache.geronimo.base.dir", geronimoHome); + setSystemProperty(java, "java.io.tmpdir", new File(geronimoHome, "var/temp")); + setSystemProperty(java, "java.endorsed.dirs", appendSystemPath("java.endorsed.dirs", new File(geronimoHome, "lib/endorsed"))); + setSystemProperty(java, "java.ext.dirs", appendSystemPath("java.ext.dirs", new File(geronimoHome, "lib/ext"))); + + java.createArg().setValue(moduleId); + + for (int i=0;arg != null && i