geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r597966 - in /geronimo/server/trunk: framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ framework/modules/geronimo-system/src/test/data/ framework/modules/geronimo-system/src/test/java/org/apache/geronimo/sys...
Date Sun, 25 Nov 2007 09:12:57 GMT
Author: djencks
Date: Sun Nov 25 01:12:55 2007
New Revision: 597966

URL: http://svn.apache.org/viewvc?rev=597966&view=rev
Log:
GERONIMO-3630 plugin installer can copy directories from plugin into server.  Also some minor
cleanup.

Added:
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java
      - copied, changed from r597148, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/org/apache/geronimo/system/configuration/GBeanOverrideTest.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
  (with props)
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/
      - copied from r597148, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/copyfiletest/
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/copyfiletest/repository/
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/geronimo-plugin.xml
      - copied unchanged from r597942, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/geronimo-plugin.xml
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/geronimo-plugins.xml
      - copied unchanged from r597942, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/geronimo-plugins.xml
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/org/
      - copied from r597942, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/org/
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/resource.properties
      - copied unchanged from r597942, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/resource.properties
    geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/
    geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/cluster-repository/
    geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/cluster-repository/EMPTY
    geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/master-repository/
    geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/master-repository/EMPTY
Removed:
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/
    geronimo/server/trunk/framework/modules/geronimo-system/src/test/resources/org/apache/geronimo/system/configuration/GBeanOverrideTest.java
Modified:
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
    geronimo/server/trunk/plugins/clustering/clustering/pom.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=597966&r1=597965&r2=597966&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Sun Nov 25 01:12:55 2007
@@ -27,6 +27,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -43,6 +44,7 @@
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.Stack;
+import java.util.TreeSet;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
@@ -135,11 +137,11 @@
         this.serverInfo = serverInfo;
         this.threadPool = threadPool;
         asyncKeys = Collections.synchronizedMap(new HashMap<Object, DownloadResults>());
-        for (ServerInstance instance: servers) {
+        for (ServerInstance instance : servers) {
             this.servers.put(instance.getServerName(), instance);
         }
         if (servers instanceof ReferenceCollection) {
-            ((ReferenceCollection)servers).addReferenceCollectionListener(new ReferenceCollectionListener()
{
+            ((ReferenceCollection) servers).addReferenceCollectionListener(new ReferenceCollectionListener()
{
 
                 public void memberAdded(ReferenceCollectionEvent event) {
                     ServerInstance instance = (ServerInstance) event.getMember();
@@ -677,7 +679,7 @@
                 }
             }
         }
-        
+
         // 2. Check that we meet the Geronimo, JVM versions
         if (metadata.getGeronimoVersion().size() > 0 && !checkGeronimoVersions(metadata.getGeronimoVersion()))
{
             log.error("Cannot install plugin " + toArtifact(metadata.getModuleId()) + " on
Geronimo " + serverInfo.getVersion());
@@ -703,16 +705,16 @@
         if (plugin.getPluginArtifact().size() != 1) {
             throw new IllegalArgumentException("A plugin configuration must include one plugin
artifact, not " + plugin.getPluginArtifact().size());
         }
-        
+
         PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
         List<PrerequisiteType> prereqs = metadata.getPrerequisite();
-        
+
         ArrayList<Dependency> missingPrereqs = new ArrayList<Dependency>();
         for (PrerequisiteType prereq : prereqs) {
             Artifact artifact = toArtifact(prereq.getId());
             try {
                 if (getServerInstance("default").getArtifactResolver().queryArtifacts(artifact).length
== 0) {
-                    missingPrereqs.add(new Dependency(artifact,ImportType.ALL));
+                    missingPrereqs.add(new Dependency(artifact, ImportType.ALL));
                 }
             } catch (NoServerInstanceException e) {
                 throw new RuntimeException("Invalid setup, no default server instance registered");
@@ -915,51 +917,99 @@
             monitor.getResults().setCurrentFile(data.getValue());
             monitor.getResults().setCurrentMessage(
                     "Copying " + data.getValue() + " from plugin to Geronimo installation");
-            Set<URL> set;
-            String sourceFile = data.getValue().trim();
+            copyFile(data, configID);
+            continue;
+        }
+    }
+
+    void copyFile(CopyFileType data, Artifact configID) throws IOException {
+        Set<URL> set;
+        String sourceFile = data.getValue().trim();
+        try {
+            set = configStore.resolve(configID, null, sourceFile);
+        } catch (NoSuchConfigException e) {
+            log.error("Unable to identify module " + configID + " to copy files from");
+            throw new IllegalStateException("Unable to identify module " + configID + " to
copy files from", e);
+        }
+        if (set.size() == 0) {
+            log.error("Installed configuration into repository but cannot locate file to
copy " + sourceFile);
+            return;
+        }
+        if (set.iterator().next().getPath().endsWith("/")) {
+            //directory, get all contents
+            String pattern = sourceFile;
+            if (pattern.endsWith("/")) {
+                pattern = pattern + "**";
+            } else {
+                pattern = pattern + "/**";
+            }
             try {
-                set = configStore.resolve(configID, null, sourceFile);
+                set = new TreeSet<URL>(new Comparator<URL>() {
+
+                    public int compare(URL o1, URL o2) {
+                        return o1.getPath().compareTo(o2.getPath());
+                    }
+                });
+                set.addAll(configStore.resolve(configID, null, pattern));
             } catch (NoSuchConfigException e) {
-                log.error("Unable to identify module " + configID + " to copy files from");
-                throw new IllegalStateException("Unable to identify module " + configID +
" to copy files from", e);
-            }
-            if (set.size() == 0) {
-                log.error("Installed configuration into repository but cannot locate file
to copy " + sourceFile);
-                continue;
-            }
-            boolean relativeToServer = "server".equals(data.getRelativeTo());
-            File targetDir = relativeToServer ? serverInfo.resolveServer(
-                    data.getDestDir()) : serverInfo.resolve(data.getDestDir());
-
-            createDirectory(targetDir);
-            if (!targetDir.isDirectory()) {
-                log.error(
-                        "Plugin install cannot write file " + data.getValue() + " to " +
data.getDestDir() + " because " + targetDir.getAbsolutePath() + " is not a directory");
-                continue;
+                log.error("Unable to list directory " + pattern + " to copy files from");
+                throw new IllegalStateException("Unable to list directory " + pattern + "
to copy files from", e);
             }
-            if (!targetDir.canWrite()) {
-                log.error(
-                        "Plugin install cannot write file " + data.getValue() + " to " +
data.getDestDir() + " because " + targetDir.getAbsolutePath() + " is not writable");
-                continue;
+        }
+        boolean relativeToServer = "server".equals(data.getRelativeTo());
+        String destDir = data.getDestDir();
+        File targetDir = relativeToServer ? serverInfo.resolveServer(
+                destDir) : serverInfo.resolve(destDir);
+
+
+        createDirectory(targetDir);
+        URI targetURI = targetDir.toURI();
+        if (!targetDir.isDirectory()) {
+            log.error(
+                    "Plugin install cannot write file " + data.getValue() + " to " + destDir
+ " because " + targetDir.getAbsolutePath() + " is not a directory");
+            return;
+        }
+        if (!targetDir.canWrite()) {
+            log.error(
+                    "Plugin install cannot write file " + data.getValue() + " to " + destDir
+ " because " + targetDir.getAbsolutePath() + " is not writable");
+            return;
+        }
+        int start = -1;
+        for (URL url : set) {
+            String path = url.getPath();
+            if (start == -1) {
+                if (sourceFile.endsWith("/")) {
+                    start = path.length();
+                    //this entry needs nothing done
+                    continue;
+                } else {
+                    String remove = sourceFile;
+                    int pos = sourceFile.lastIndexOf('/');
+                    if (pos > -1) {
+                        remove = sourceFile.substring(0, pos);
+                    }
+                    start = path.lastIndexOf(remove);
+                }
             }
-            for (URL url : set) {
-                String path = url.getPath();
-                if (path.lastIndexOf('/') > -1) {
-                    path = path.substring(path.lastIndexOf('/'));
-                }
-                File target = new File(targetDir, path);
-                if (!target.exists()) {
-                    if (!target.createNewFile()) {
-                        log.error("Plugin install cannot create new file " + target.getAbsolutePath());
-                        continue;
+            path = path.substring(start);
+            File target = new File(targetURI.resolve(path));
+            if (!target.exists()) {
+                if (path.endsWith("/")) {
+                    if (!target.mkdirs()) {
+                        log.error("Plugin install cannot create directory " + target.getAbsolutePath());
                     }
+                    continue;
                 }
-                if (!target.canWrite()) {
-                    log.error("Plugin install cannot write to file " + target.getAbsolutePath());
+                if (!target.createNewFile()) {
+                    log.error("Plugin install cannot create new file " + target.getAbsolutePath());
                     continue;
                 }
-                copyFile(url.openStream(), new FileOutputStream(target));
             }
+            if (!target.canWrite()) {
+                log.error("Plugin install cannot write to file " + target.getAbsolutePath());
+                continue;
+            }
+            copyFile(url.openStream(), new FileOutputStream(target));
         }
     }
 
@@ -1261,9 +1311,9 @@
     /**
      * Checks for an artifact in a specific repository, where the artifact version
      * might not be resolved yet.
-     * 
+     *
      * @return null if the artifact is not found in the specified repository. otherwise
-     * returns the artifact fully resolved
+     *         returns the artifact fully resolved
      */
     private static Artifact findArtifact(Artifact query, URL repo, String username, String
password, ResultsFileWriteMonitor monitor) throws IOException, FailedLoginException, ParserConfigurationException,
SAXException {
         Artifact verifiedArtifact = null;
@@ -1290,12 +1340,12 @@
             else if (version.toString().indexOf("SNAPSHOT") >= 0 && !(version
instanceof SnapshotVersion)) {
                 // base path for the artifact version in a maven repo
                 URL basePath = new URL(repo, query.getGroupId().replace('.', '/') + "/" +
query.getArtifactId() + "/" + version);
-                
+
                 // get the maven-metadata file
                 Document metadata = getMavenMetadata(basePath, username, password, monitor);
-                
+
                 // determine the snapshot qualifier from the maven-metadata file
-                if (metadata != null) { 
+                if (metadata != null) {
                     NodeList snapshots = metadata.getDocumentElement().getElementsByTagName("snapshot");
                     if (snapshots.getLength() >= 1) {
                         Element snapshot = (Element) snapshots.item(0);
@@ -1319,20 +1369,20 @@
                 }
             }
         }
-        
+
         // Version is not resolved.  Look in maven-metadata.xml and maven-metadata-local.xml
for
         // the available version numbers.  If found then recurse into the enclosing method
with
         // a resolved version number
         else {
-            
+
             // base path for the artifact version in a maven repo
             URL basePath = new URL(repo, query.getGroupId().replace('.', '/') + "/" + query.getArtifactId());
-            
+
             // get the maven-metadata file
             Document metadata = getMavenMetadata(basePath, username, password, monitor);
-            
+
             // determine the available versions from the maven-metadata file
-            if (metadata != null) { 
+            if (metadata != null) {
                 Element root = metadata.getDocumentElement();
                 NodeList list = root.getElementsByTagName("versions");
                 list = ((Element) list.item(0)).getElementsByTagName("version");
@@ -1344,9 +1394,11 @@
                 Arrays.sort(available, new Comparator<Version>() {
                     public int compare(Version o1, Version o2) {
                         return o2.toString().compareTo(o1.toString());
-                    };
+                    }
+
+                    ;
                 });
-                
+
                 for (Version version : available) {
                     if (verifiedArtifact == null) {
                         Artifact newQuery = new Artifact(query.getGroupId(), query.getArtifactId(),
version, query.getType());
@@ -1355,14 +1407,14 @@
                 }
             }
         }
-        
+
         return verifiedArtifact;
     }
-    
-    private static Document getMavenMetadata (URL base, String username, String password,
ResultsFileWriteMonitor monitor) throws IOException, FailedLoginException, ParserConfigurationException,
SAXException{
+
+    private static Document getMavenMetadata(URL base, String username, String password,
ResultsFileWriteMonitor monitor) throws IOException, FailedLoginException, ParserConfigurationException,
SAXException {
         Document doc = null;
         InputStream in = null;
-        
+
         try {
             URL metaURL = new URL(base.toString() + "/maven-metadata.xml");
             in = connect(metaURL, username, password, monitor);
@@ -1383,7 +1435,7 @@
         }
         return doc;
     }
-    
+
     private static boolean testArtifact(Artifact artifact, URL repo, String username, String
password, ResultsFileWriteMonitor monitor) throws IOException, FailedLoginException {
         URL test = getURL(artifact, repo);
         InputStream testStream = connect(test, username, password, monitor, "HEAD");
@@ -1760,7 +1812,7 @@
     private void installConfigXMLData(Artifact configID, PluginArtifactType pluginData) throws
InvalidGBeanException, IOException, NoServerInstanceException {
         if (configManager.isConfiguration(configID)) {
             if (pluginData != null && !pluginData.getConfigXmlContent().isEmpty())
{
-                for (ConfigXmlContentType configXmlContent: pluginData.getConfigXmlContent())
{
+                for (ConfigXmlContentType configXmlContent : pluginData.getConfigXmlContent())
{
                     String serverName = configXmlContent.getServer();
                     ServerInstance serverInstance = getServerInstance(serverName);
                     serverInstance.getAttributeStore().setModuleGBeans(configID, configXmlContent.getGbean(),
configXmlContent.isLoad(), configXmlContent.getCondition());
@@ -1771,7 +1823,7 @@
         }
         if (!pluginData.getConfigSubstitution().isEmpty()) {
             Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getConfigSubstitution());
-            for (Map.Entry<String, Properties> entry: propertiesMap.entrySet()) {
+            for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
                 String serverName = entry.getKey();
                 ServerInstance serverInstance = getServerInstance(serverName);
                 serverInstance.getAttributeStore().addConfigSubstitutions(entry.getValue());
@@ -1779,7 +1831,7 @@
         }
         if (!pluginData.getArtifactAlias().isEmpty()) {
             Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getArtifactAlias());
-            for (Map.Entry<String, Properties> entry: propertiesMap.entrySet()) {
+            for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
                 String serverName = entry.getKey();
                 ServerInstance serverInstance = getServerInstance(serverName);
                 serverInstance.getArtifactResolver().addAliases(entry.getValue());

Copied: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java
(from r597148, geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/org/apache/geronimo/system/configuration/GBeanOverrideTest.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java?p2=geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/GBeanOverrideTest.java&p1=geronimo/server/trunk/framework/modules/geronimo-system/src/test/data/org/apache/geronimo/system/configuration/GBeanOverrideTest.java&r1=597148&r2=597966&rev=597966&view=diff
==============================================================================
    (empty)

Added: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java?rev=597966&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
Sun Nov 25 01:12:55 2007
@@ -0,0 +1,312 @@
+/*
+ * 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.system.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.LifecycleException;
+import org.apache.geronimo.kernel.config.LifecycleMonitor;
+import org.apache.geronimo.kernel.config.LifecycleResults;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.Version;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.apache.geronimo.system.plugin.model.CopyFileType;
+import org.apache.geronimo.system.repository.Maven2Repository;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.system.threads.ThreadPool;
+import org.apache.geronimo.testsupport.TestSupport;
+
+/**
+ * Tests the plugin installer GBean
+ *
+ * @version $Rev$ $Date$
+ */
+public class CopyFileTest extends TestSupport {
+    private static int count = 0;
+    private ServerInfo serverInfo;
+    private ConfigurationStore configStore;
+    private PluginInstallerGBean installer;
+    private Artifact artifact = new Artifact("test", "module", "1.0", "car");
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        //set up test server location
+
+        File serverBase = null;
+        for (int i = 0; i < 100; i++) {
+            serverBase = new File(new File(new File(new File(getBaseDir(), "target"), "test-resources"),
"CopyFileTest"), "server" + count++);
+            if (serverBase.mkdirs()) {
+                break;
+            }
+            if (i == 100) {
+                throw new RuntimeException("Could not create server base: " + serverBase);
+            }
+        }
+        serverInfo = new BasicServerInfo(serverBase.getAbsolutePath(), false);
+        File repoBase = new File(new File(new File(new File(new File(getBaseDir(), "src"),
"test"), "resources"), "copyfiletest"), "repository");
+        if (!repoBase.exists()) {
+            throw new RuntimeException("Could not locate repo :" + repoBase);
+        }
+        Maven2Repository repo = new Maven2Repository(repoBase.toURI(), serverInfo, true);
+        configStore = new RepositoryConfigurationStore(repo);
+        installer = new PluginInstallerGBean(new MockConfigManager(),
+                repo,
+                configStore,
+                serverInfo,
+                new ThreadPool() {
+            public int getPoolSize() {
+                return 0;
+            }
+
+            public int getMaximumPoolSize() {
+                return 0;
+            }
+
+            public int getActiveCount() {
+                return 0;
+            }
+
+            public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
{
+                return false;
+            }
+
+            public void execute(String consumerName, Runnable runnable) {
+                new Thread(runnable).start();
+            }
+        }, new ArrayList<ServerInstance>());
+    }
+
+    public void testCopyFile() throws Exception {
+        CopyFileType copyFile = new CopyFileType();
+        copyFile.setRelativeTo("geronimo");
+        copyFile.setDestDir("");
+        copyFile.setValue("emptyfile1");
+        checkCopy(copyFile);
+        copyFile.setDestDir("foo/bar");
+        checkCopy(copyFile);
+    }
+
+    public void testCopyEmptyDir() throws Exception {
+        CopyFileType copyFile = new CopyFileType();
+        copyFile.setRelativeTo("geronimo");
+        copyFile.setDestDir("");
+        copyFile.setValue("emptydir1");
+        checkCopy(copyFile);
+        copyFile.setDestDir("foo/bar");
+        checkCopy(copyFile);
+    }
+
+    public void testCopyDir() throws Exception {
+        CopyFileType copyFile = new CopyFileType();
+        copyFile.setRelativeTo("geronimo");
+        copyFile.setDestDir("");
+        copyFile.setValue("dir1");
+        File dir = checkCopy(copyFile);
+        assertTrue(new File(dir, "emptydir1").exists());
+        assertTrue(new File(dir, "emptyfile1").exists());
+        copyFile.setDestDir("foo/bar");
+        dir = checkCopy(copyFile);
+        assertTrue(new File(dir, "emptydir1").exists());
+        assertTrue(new File(dir, "emptyfile1").exists());
+    }
+
+    public void testCopyDirs() throws Exception {
+        CopyFileType copyFile = new CopyFileType();
+        copyFile.setRelativeTo("geronimo");
+        copyFile.setDestDir("");
+        copyFile.setValue("dir1/");
+        File dir = checkCopy(copyFile);
+        assertTrue(new File(dir, "emptydir1").exists());
+        assertTrue(new File(dir, "emptyfile1").exists());
+        copyFile.setDestDir("foo/bar");
+        dir = checkCopy(copyFile);
+        assertTrue(new File(dir, "emptydir1").exists());
+        assertTrue(new File(dir, "emptyfile1").exists());
+    }
+
+    private File checkCopy(CopyFileType copyFile) throws IOException {
+        installer.copyFile(copyFile, artifact);
+        File target;
+        if (copyFile.getValue().endsWith("/")) {
+            target = serverInfo.resolve("");
+        } else {
+            target = serverInfo.resolve(("".equals(copyFile.getDestDir())? "": copyFile.getDestDir()
+ '/') + copyFile.getValue());
+        }
+        assertTrue(target.getPath(), target.exists());
+        return target;
+    }
+
+    private static class MockConfigManager implements ConfigurationManager {
+
+        public boolean isInstalled(Artifact configurationId) {
+            return false;
+        }
+
+        public Artifact[] getInstalled(Artifact query) {
+            return new Artifact[0];
+        }
+
+        public Artifact[] getLoaded(Artifact query) {
+            return new Artifact[0];
+        }
+
+        public Artifact[] getRunning(Artifact query) {
+            return new Artifact[0];
+        }
+
+        public boolean isLoaded(Artifact configID) {
+            return false;
+        }
+
+        public List listStores() {
+            return Collections.EMPTY_LIST;
+        }
+
+        public ConfigurationStore[] getStores() {
+            return new ConfigurationStore[0];
+        }
+
+        public ConfigurationStore getStoreForConfiguration(Artifact configuration) {
+            return null;
+        }
+
+        public List listConfigurations(AbstractName store) throws NoSuchStoreException {
+            return Collections.EMPTY_LIST;
+        }
+
+        public boolean isRunning(Artifact configurationId) {
+            return false;
+        }
+
+        public List listConfigurations() {
+            return null;
+        }
+
+        public boolean isConfiguration(Artifact artifact) {
+            return false;
+        }
+
+        public Configuration getConfiguration(Artifact configurationId) {
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(Artifact configurationId) throws NoSuchConfigException,
LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(ConfigurationData configurationData) throws
NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(ConfigurationData configurationData, LifecycleMonitor
monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults unloadConfiguration(Artifact configurationId) throws NoSuchConfigException
{
+            return null;
+        }
+
+        public LifecycleResults unloadConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException {
+            return null;
+        }
+
+        public LifecycleResults startConfiguration(Artifact configurationId) throws NoSuchConfigException,
LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults startConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults stopConfiguration(Artifact configurationId) throws NoSuchConfigException
{
+            return null;
+        }
+
+        public LifecycleResults stopConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException {
+            return null;
+        }
+
+        public LifecycleResults restartConfiguration(Artifact configurationId) throws NoSuchConfigException,
LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults restartConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId) throws NoSuchConfigException,
LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, LifecycleMonitor
monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, Version version)
throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, Version version,
LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(ConfigurationData configurationData)
throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public LifecycleResults reloadConfiguration(ConfigurationData configurationData,
LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            return null;
+        }
+
+        public void uninstallConfiguration(Artifact configurationId) throws IOException,
NoSuchConfigException {
+
+        }
+
+        public ArtifactResolver getArtifactResolver() {
+            return null;
+        }
+
+        public boolean isOnline() {
+            return true;
+        }
+
+        public void setOnline(boolean online) {
+        }
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/clustering/clustering/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/clustering/pom.xml?rev=597966&r1=597965&r2=597966&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/clustering/pom.xml (original)
+++ geronimo/server/trunk/plugins/clustering/clustering/pom.xml Sun Nov 25 01:12:55 2007
@@ -84,6 +84,8 @@
                     <category>Clustering</category>
                     <instance>
                         <plugin-artifact>
+                            <copy-file relative-to="geronimo" dest-dir="">cluster-repository</copy-file>
+                            <copy-file relative-to="geronimo" dest-dir="">master-repository</copy-file>
                             <config-xml-content>
                                 <gbean name="Node">
                                     <attribute name="nodeName">#{clusterNodeName}</attribute>

Added: geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/cluster-repository/EMPTY
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/cluster-repository/EMPTY?rev=597966&view=auto
==============================================================================
    (empty)

Added: geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/master-repository/EMPTY
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/clustering/src/main/resources/master-repository/EMPTY?rev=597966&view=auto
==============================================================================
    (empty)



Mime
View raw message