You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2019/09/18 03:16:01 UTC

svn commit: r1867089 - in /turbine/fulcrum/trunk/resourcemanager: ./ src/changes/ src/java/org/apache/fulcrum/resourcemanager/ src/java/org/apache/fulcrum/resourcemanager/impl/ src/test/ src/test/org/apache/fulcrum/resourcemanager/ xdocs/

Author: painter
Date: Wed Sep 18 03:16:01 2019
New Revision: 1867089

URL: http://svn.apache.org/viewvc?rev=1867089&view=rev
Log:
remove dep on fulcrum-pbe and move changes.xml to standard dir

Added:
    turbine/fulcrum/trunk/resourcemanager/src/changes/
    turbine/fulcrum/trunk/resourcemanager/src/changes/changes.xml
Removed:
    turbine/fulcrum/trunk/resourcemanager/xdocs/changes.xml
Modified:
    turbine/fulcrum/trunk/resourcemanager/pom.xml
    turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/ResourceManagerService.java
    turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
    turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
    turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml
    turbine/fulcrum/trunk/resourcemanager/src/test/TestRoleConfig.xml
    turbine/fulcrum/trunk/resourcemanager/src/test/org/apache/fulcrum/resourcemanager/ResourceManagerServiceTest.java

Modified: turbine/fulcrum/trunk/resourcemanager/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/pom.xml?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/pom.xml (original)
+++ turbine/fulcrum/trunk/resourcemanager/pom.xml Wed Sep 18 03:16:01 2019
@@ -1,20 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-   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.
--->
+<!-- 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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -63,11 +57,12 @@
 			<artifactId>avalon-framework-api</artifactId>
 			<version>4.3.1</version>
 		</dependency>
-		<dependency>
-			<groupId>org.apache.fulcrum</groupId>
-			<artifactId>fulcrum-pbe</artifactId>
-			<version>1.0.2-SNAPSHOT</version>
-		</dependency>
+		<!-- <dependency> -->
+		<!-- <groupId>org.apache.fulcrum</groupId> -->
+		<!-- <artifactId>fulcrum-pbe</artifactId> -->
+		<!-- <version>1.0.2-SNAPSHOT</version> -->
+		<!-- </dependency> -->
+
 		<!-- testing dependencies -->
 		<dependency>
 			<groupId>org.apache.fulcrum</groupId>
@@ -86,6 +81,11 @@
 	<build>
 		<sourceDirectory>${basedir}/src/java</sourceDirectory>
 		<testSourceDirectory>${basedir}/src/test</testSourceDirectory>
+		<testResources>
+			<testResource>
+				<directory>src/test/resources</directory>
+			</testResource>
+		</testResources>
 	</build>
 
 	<reporting>

Added: turbine/fulcrum/trunk/resourcemanager/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/changes/changes.xml?rev=1867089&view=auto
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/changes/changes.xml (added)
+++ turbine/fulcrum/trunk/resourcemanager/src/changes/changes.xml Wed Sep 18 03:16:01 2019
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<document>
+  <properties>
+    <title>Fulcrum ResourceManager Service</title>
+    <author email="siegfried.goeschl@it20one.at">Siegfried Goeschl</author>
+  </properties>
+
+  <body>
+    <release version="1.0.2" date="in SVN">
+      <action dev="painter" type="update">
+        JavaDoc update, use commons-lang3
+        Move changes.xml to standard dir
+        Remove deps on fulcrum-pbe
+      </action>
+    </release>  
+    <release version="1.0.1" date="2011-09-20">
+        <action dev="sgoeschl" type="update">
+          Cleaned up the code.
+        </action>
+      <action dev="sgoeschl" type="update">
+        Adding a M2 build
+      </action>    
+      <action dev="sgoeschl" type="update">
+      	Using the FileResourceManager as default for the configuration
+      </action>
+      <action dev="sgoeschl" type="fix">
+      	Fixed a few JavaDoc warnings
+      </action>
+      <action dev="sgoeschl" type="fix">
+        Restricting the access of context-specific information in
+        BaseResourceManagerImpl to protected instead of public
+      </action>
+      <action dev="sgoeschl" type="fix">
+        In response to the suggestions of the mailing list the implementation
+        provides a list of excluded directory names. This list is currently not
+        configurable but hard-coded and contains "CVS" and ".svn".
+      </action>
+      <action dev="sgoeschl" type="fix">
+        Skipping all ".svn" directories otherwise we pick up arbitrary files
+      </action>
+    </release>
+    <release version="1.0.0" date="in CVS">
+      <action dev="sgoeschl" type="add">
+        Initial version
+      </action>
+    </release>
+  </body>
+</document>
+

Modified: turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/ResourceManagerService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/ResourceManagerService.java?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/ResourceManagerService.java (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/ResourceManagerService.java Wed Sep 18 03:16:01 2019
@@ -22,6 +22,7 @@ package org.apache.fulcrum.resourcemanag
 import java.io.IOException;
 import java.net.URL;
 
+
 /**
  * An Avalon service to manage resources based on a domain. The service
  * supports multiple domains and uses a context to locate a resource.
@@ -34,7 +35,10 @@ public interface ResourceManagerService
     // CRUD Functionality
     /////////////////////////////////////////////////////////////////////////
 
-    /**
+    /** Avalon role - used to id the component within the manager */
+    String ROLE = ResourceManagerService.class.getName();
+
+	/**
      * List all available domains.
      *
      * @return list of all available domains

Modified: turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/BaseResourceManager.java Wed Sep 18 03:16:01 2019
@@ -43,498 +43,349 @@ import org.apache.avalon.framework.servi
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.fulcrum.resourcemanager.ResourceManager;
-import org.apache.fulcrum.pbe.PBEService;
 
 /**
- * Base class for a service implementation capturing the Avalon
- * configuration artifats
+ * Base class for a service implementation capturing the Avalon configuration
+ * artifacts
  *
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
 
-public abstract class BaseResourceManager
-	extends AbstractLogEnabled
-    implements Contextualizable, Serviceable, Configurable,
-    	Initializable, Disposable, Reconfigurable, ResourceManager
+public abstract class BaseResourceManager extends AbstractLogEnabled implements Contextualizable, Serviceable,
+		Configurable, Initializable, Disposable, Reconfigurable, ResourceManager 
 {
-    /** the buffer size for copying streams */
-    private static final int BUF_SIZE = 1024;
+	
+	/** the buffer size for copying streams */
+	private static final int BUF_SIZE = 1024;
 
-    /** The context supplied by the avalon framework */
-    private Context context;
+	/** The context supplied by the avalon framework */
+	private Context context;
 
-    /** The service manager supplied by the avalon framework */
-    private ServiceManager serviceManager;
+	/** The service manager supplied by the avalon framework */
+	private ServiceManager serviceManager;
 
-    /** The configuration supplied by the avalon framework */
-    private Configuration configuration;
-
-    /** the Avalon application directory */
-    private File applicationDir;
-
-    /** the Avalon temp directory */
-    private File tempDir;
-
-    /** the name of the domain */
-    private String domain;
-
-    /** the seed to generate the password */
-    private String seed;
-
-    /** use transparent encryption/decryption */
-    private String useEncryption;
-
-    /////////////////////////////////////////////////////////////////////////
-    // Avalon Service Lifecycle Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * Constructor
-     */
-    public BaseResourceManager()
-    {
-        // nothing to do
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException
-    {
-        this.context        = context;
-        this.applicationDir = (File) context.get("urn:avalon:home");
-        this.tempDir        = (File) context.get("urn:avalon:temp");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager serviceManager) throws ServiceException
-    {
-        this.serviceManager = serviceManager;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration configuration) throws ConfigurationException
-    {
-        this.configuration = configuration;
-        this.setDomain( configuration.getAttribute("name") );
-        this.seed = "resourcemanager";
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception
-    {
-        // nothing to do
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    public void dispose()
-    {
-        this.applicationDir = null;
-        this.configuration = null;
-        this.context = null;
-        this.domain = null;
-        this.seed = null;
-        this.serviceManager = null;
-        this.tempDir = null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void reconfigure(Configuration configuration)
-        throws ConfigurationException
-    {
-        this.configure(configuration);
-    }
-
-    /////////////////////////////////////////////////////////////////////////
-    // Service Implementation
-    /////////////////////////////////////////////////////////////////////////
-
-    /**
-     * @return Returns the configuration.
-     */
-    protected Configuration getConfiguration()
-    {
-        return this.configuration;
-    }
-
-    /**
-     * @return Returns the context.
-     */
-    protected Context getContext()
-    {
-        return this.context;
-    }
-
-    /**
-     * @return Returns the serviceManager.
-     */
-    protected ServiceManager getServiceManager()
-    {
-        return this.serviceManager;
-    }
-
-    /**
-     * @return Returns the applicationDir.
-     */
-    protected File getApplicationDir()
-    {
-        return applicationDir;
-    }
-
-    /**
-     * @return Returns the tempDir.
-     */
-    protected File getTempDir()
-    {
-        return tempDir;
-    }
-
-    /**
-     * @return Returns the domain.
-     */
-    public String getDomain()
-    {
-        return domain;
-    }
-
-    /**
-     * Get the content as byte[].
-     * @param content content to convert
-     * @return byte array representation of the object
-     * @throws IOException if unable to read
-     */
-    protected byte[] getContent( Object content )
-    	throws IOException
-    {
-        byte[] result = null;
-
-        if( content instanceof String )
-        {
-            result = ((String) content).getBytes();
-        }
-        else if( content instanceof byte[] )
-        {
-            result = (byte[]) content;
-        }
-        else if( content instanceof InputStream )
-        {
-            result = this.getBytes( (InputStream) content );
-        }
-        else if( content instanceof Properties )
-        {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            ((Properties) content).store( baos, "Created by fulcrum-resourcemanager-service" );
-            result = baos.toByteArray();
-        }
-        else
-        {
-            String msg = "Don't know how to read " + content.getClass().getName();
-            throw new IllegalArgumentException( msg );
-        }
-
-        return result;
-    }
-
-    /**
-     * Extract a byte[] from the input stream.
-     * @param is input stream to read from
-     * @return byte array representation of the object
-     * @throws IOException if unable to read
-     */
-    protected byte[] getBytes( InputStream is )
-    	throws IOException
-    {
-        int ch;
-        byte[] data = null;
-
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        BufferedInputStream isReader = new BufferedInputStream( is );
-        BufferedOutputStream osWriter = new BufferedOutputStream( os );
-
-        while ((ch = isReader.read()) != -1)
-        {
-            osWriter.write(ch);
-        }
-
-        osWriter.flush();
-        data = os.toByteArray();
-        osWriter.close();
-        isReader.close();
-
-        return data;
-    }
-
-    /**
-     * @param domain The domain to set.
-     */
-    protected void setDomain(String domain)
-    {
-        this.domain = domain;
-    }
-
-    /**
-     * @return Returns the useEncryption.
-     */
-    protected String getUseEncryption()
-    {
-        return useEncryption;
-    }
-
-    /**
-     * @param useEncryption The useEncryption to set.
-     */
-    protected void setUseEncryption(String useEncryption)
-    {
-        this.useEncryption = useEncryption;
-    }
-
-    /**
-     * @return the instance of the PBEService
-     */
-    protected PBEService getPBEService()
-    {
-        String service = PBEService.class.getName();
-        PBEService result = null;
-
-        if( this.getServiceManager().hasService(service) )
-        {
-            try
-            {
-                result = (PBEService) this.getServiceManager().lookup(service);
-            }
-            catch (ServiceException e)
-            {
-                String msg = "The PBEService can't be accessed";
-                this.getLogger().error( msg, e );
-                throw new RuntimeException( msg );
-            }
-        }
-        else
-        {
-            String msg = "The PBEService is not registered";
-            throw new RuntimeException( msg );
-        }
-
-        return result;
-    }
-
-    /**
-     * @return the password for the resource manager
-     * @throws Exception generic exception
-     */
-    private char[] getPassword() throws Exception
-	{
-	    return this.getPBEService().createPassword( this.seed.toCharArray() );
-	}
-
-    /**
-     * Reads the given input stream and decrypts it if required
-     * @param is the input stream to be read
-     * @return the content of the input stream
-     * @throws IOException if unable to read
-     */
-    protected byte[] read( InputStream is )
-    	throws IOException
-    {
-        if( this.getUseEncryption().equalsIgnoreCase("true") )
-        {
-            return readEncrypted( is );
-        }
-        else if( this.getUseEncryption().equalsIgnoreCase("auto") )
-        {
-            return readSmartEncrypted( is );
-        }
-        else
-        {
-            return readPlain( is );
-        }
-    }
-
-    /**
-     * Reads from an unencrypted input stream
-     * @param is the source input stream
-     * @return the content of the input stream
-     * @throws IOException if unable to read
-     */
-    private byte[] readPlain( InputStream is )
-    	throws IOException
-    {
-        byte[] result = null;
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        this.copy(is,baos);
-        result = baos.toByteArray();
-        return result;
-    }
-
-    /**
-     * Reads a potentially encrypted input stream.
-     * @param is the source input stream
-     * @return the content of the input stream
-     * @throws IOException if unable to read
-     */
-    private byte[] readSmartEncrypted( InputStream is )
-    	throws IOException
-    {
-        byte[] result = null;
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-        try
-        {
-            char[] password = getPassword();
-            InputStream sdis = this.getPBEService().getSmartInputStream( is, password );
-            this.copy( sdis, baos );
-            result = baos.toByteArray();
-            return result;
-        }
-        catch (IOException e)
-        {
-            String msg = "Failed to process the input stream";
-            this.getLogger().error( msg, e );
-            throw e;
-        }
-        catch (Exception e)
-        {
-            String msg = "Failed to decrypt the input stream";
-            this.getLogger().error( msg, e );
-            throw new IOException( msg );
-        }
-    }
-
-    /**
-     * Reads a potentially encrypted input stream.
-     * @param is the source input stream
-     * @return the content of the input stream
-     * @throws IOException if unable to read
-     */
-    private byte[] readEncrypted( InputStream is )
-    	throws IOException
-    {
-        byte[] result = null;
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-        try
-        {
-            char[] password = getPassword();
-            InputStream sdis = this.getPBEService().getInputStream( is, password );
-            this.copy( sdis, baos );
-            result = baos.toByteArray();
-            return result;
-        }
-        catch (IOException e)
-        {
-            String msg = "Failed to process the input stream";
-            this.getLogger().error( msg, e );
-            throw e;
-        }
-        catch (Exception e)
-        {
-            String msg = "Failed to decrypt the input stream";
-            this.getLogger().error( msg, e );
-            throw new IOException( msg );
-        }
-    }
-
-    /**
-     * Write the given output stream and encrypts it if required. If the
-     * encryption mode is "auto" we also encryt it.
-     *
-     * @param os the output stream to be written
-     * @param content the content to be written
-     * @throws IOException if unable to read
-     */
-    protected void write( OutputStream os, byte[] content )
-    	throws IOException
-    {
-        if( this.getUseEncryption().equalsIgnoreCase("true") )
-        {
-            writeEncrypted( os, content );
-        }
-        else if( this.getUseEncryption().equalsIgnoreCase("auto") )
-        {
-            writeEncrypted( os, content );
-        }
-        else
-        {
-            writePlain( os, content );
-        }
-    }
-
-    /**
-     * Write the given content without encryption.
-     *
-     * @param os the output stream
-     * @param content the content to be written
-     * @throws IOException if unable to read
-     */
-    private void writePlain( OutputStream os, byte[] content )
-    	throws IOException
-    {
-        ByteArrayInputStream bais = new ByteArrayInputStream(content);
-        this.copy( bais, os );
-    }
-
-    /**
-     * Write the given content and encrypt it.
-     *
-     * @param os the output stream
-     * @param content the content to be written
-     * @throws IOException if unable to read
-     */
-    private void writeEncrypted( OutputStream os, byte[] content )
-    	throws IOException
-    {
-        try
-        {
-            char[] password = this.getPassword();
-            ByteArrayInputStream bais = new ByteArrayInputStream(content);
-            OutputStream eos = this.getPBEService().getOutputStream( os, password );
-            this.copy(bais,eos);
-        }
-        catch (IOException e)
-        {
-            String msg = "Failed to process the output stream";
-            this.getLogger().error( msg, e );
-            throw e;
-        }
-        catch (Exception e)
-        {
-            String msg = "Failed to encrypt the input stream";
-            this.getLogger().error( msg, e );
-            throw new IOException( msg );
-        }
-    }
-
-    /**
-     * Pumps the input stream to the output stream.
-     *
-     * @param is the source input stream
-     * @param os the target output stream
-     * @throws IOException the copying failed
-     */
-    private void copy( InputStream is, OutputStream os )
-        throws IOException
-    {
-        byte[] buf = new byte[BUF_SIZE];
-        int n = 0;
-        int total = 0;
-
-        while ((n = is.read(buf)) > 0)
-        {
-            os.write(buf, 0, n);
-            total += n;
-        }
-
-        os.flush();
-        os.close();
-    }
+	/** The configuration supplied by the avalon framework */
+	private Configuration configuration;
+
+	/** the Avalon application directory */
+	private File applicationDir;
+
+	/** the Avalon temp directory */
+	private File tempDir;
+
+	/** the name of the domain */
+	private String domain;
+
+	/** the seed to generate the password */
+	private String seed;
+
+	/** use transparent encryption/decryption */
+	private String useEncryption;
+
+	/////////////////////////////////////////////////////////////////////////
+	// Avalon Service Lifecycle Implementation
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * Constructor
+	 */
+	public BaseResourceManager() 
+	{
+		// nothing to do
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache
+	 * .avalon.framework.context.Context)
+	 */
+	public void contextualize(Context context) throws ContextException 
+	{
+		this.context = context;
+		this.applicationDir = (File) context.get("urn:avalon:home");
+		this.tempDir = (File) context.get("urn:avalon:temp");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.
+	 * framework.service.ServiceManager)
+	 */
+	public void service(ServiceManager serviceManager) throws ServiceException 
+	{
+		this.serviceManager = serviceManager;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.avalon.framework.configuration.Configurable#configure(org.apache.
+	 * avalon.framework.configuration.Configuration)
+	 */
+	public void configure(Configuration configuration) throws ConfigurationException 
+	{
+		this.configuration = configuration;
+		this.setDomain(configuration.getAttribute("name"));
+		this.seed = "resourcemanager";
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.avalon.framework.activity.Initializable#initialize()
+	 */
+	public void initialize() throws Exception 
+	{
+		// nothing to do
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.avalon.framework.activity.Disposable#dispose()
+	 */
+	public void dispose() 
+	{
+		this.applicationDir = null;
+		this.configuration = null;
+		this.context = null;
+		this.domain = null;
+		this.seed = null;
+		this.serviceManager = null;
+		this.tempDir = null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.
+	 * apache.avalon.framework.configuration.Configuration)
+	 */
+	public void reconfigure(Configuration configuration) throws ConfigurationException 
+	{
+		this.configure(configuration);
+	}
+
+	/////////////////////////////////////////////////////////////////////////
+	// Service Implementation
+	/////////////////////////////////////////////////////////////////////////
+
+	/**
+	 * @return Returns the configuration.
+	 */
+	protected Configuration getConfiguration() 
+	{
+		return this.configuration;
+	}
+
+	/**
+	 * @return Returns the context.
+	 */
+	protected Context getContext() 
+	{
+		return this.context;
+	}
+
+	/**
+	 * @return Returns the serviceManager.
+	 */
+	protected ServiceManager getServiceManager() 
+	{
+		return this.serviceManager;
+	}
+
+	/**
+	 * @return Returns the applicationDir.
+	 */
+	protected File getApplicationDir() 
+	{
+		return applicationDir;
+	}
+
+	/**
+	 * @return Returns the tempDir.
+	 */
+	protected File getTempDir() 
+	{
+		return tempDir;
+	}
+
+	/**
+	 * @return Returns the domain.
+	 */
+	public String getDomain() 
+	{
+		return domain;
+	}
+
+	/**
+	 * Get the content as byte[].
+	 * 
+	 * @param content content to convert
+	 * @return byte array representation of the object
+	 * @throws IOException if unable to read
+	 */
+	protected byte[] getContent(Object content) throws IOException 
+	{
+		byte[] result = null;
+
+		if (content instanceof String) 
+		{
+			result = ((String) content).getBytes();
+		} 
+		else if (content instanceof byte[]) 
+		{
+			result = (byte[]) content;
+		} 
+		else if (content instanceof InputStream) 
+		{
+			result = this.getBytes((InputStream) content);
+		} 
+		else if (content instanceof Properties) 
+		{
+			ByteArrayOutputStream baos = new ByteArrayOutputStream();
+			((Properties) content).store(baos, "Created by fulcrum-resourcemanager-service");
+			result = baos.toByteArray();
+		} 
+		else 
+		{
+			String msg = "Don't know how to read " + content.getClass().getName();
+			throw new IllegalArgumentException(msg);
+		}
+
+		return result;
+	}
+
+	/**
+	 * Extract a byte[] from the input stream.
+	 * 
+	 * @param is input stream to read from
+	 * @return byte array representation of the object
+	 * @throws IOException if unable to read
+	 */
+	protected byte[] getBytes(InputStream is) throws IOException 
+	{
+		int ch;
+		byte[] data = null;
+
+		ByteArrayOutputStream os = new ByteArrayOutputStream();
+		BufferedInputStream isReader = new BufferedInputStream(is);
+		BufferedOutputStream osWriter = new BufferedOutputStream(os);
+
+		while ((ch = isReader.read()) != -1) 
+		{
+			osWriter.write(ch);
+		}
+
+		osWriter.flush();
+		data = os.toByteArray();
+		osWriter.close();
+		isReader.close();
+
+		return data;
+	}
+
+	/**
+	 * @param domain The domain to set.
+	 */
+	protected void setDomain(String domain) 
+	{
+		this.domain = domain;
+	}
+
+	/**
+	 * @return Returns the useEncryption.
+	 */
+	protected String getUseEncryption() 
+	{
+		return useEncryption;
+	}
+
+	/**
+	 * @param useEncryption The useEncryption to set.
+	 */
+	protected void setUseEncryption(String useEncryption) 
+	{
+		this.useEncryption = useEncryption;
+	}
+
+
+	/**
+	 * Reads the given input stream and decrypts it if required
+	 * 
+	 * @param is the input stream to be read
+	 * @return the content of the input stream
+	 * @throws IOException if unable to read
+	 */
+	protected byte[] read(InputStream is) throws IOException 
+	{
+		return readPlain(is);
+	}
+
+	/**
+	 * Reads from an unencrypted input stream
+	 * 
+	 * @param is the source input stream
+	 * @return the content of the input stream
+	 * @throws IOException if unable to read
+	 */
+	private byte[] readPlain(InputStream is) throws IOException 
+	{
+		byte[] result = null;
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		this.copy(is, baos);
+		result = baos.toByteArray();
+		return result;
+	}
+
+	/**
+	 * Write the given output stream and encrypts it if required. If the encryption
+	 * mode is "auto" we also encryt it.
+	 *
+	 * @param os      the output stream to be written
+	 * @param content the content to be written
+	 * @throws IOException if unable to read
+	 */
+	protected void write(OutputStream os, byte[] content) throws IOException 
+	{
+		writePlain(os, content);
+	}
+
+	/**
+	 * Write the given content without encryption.
+	 *
+	 * @param os      the output stream
+	 * @param content the content to be written
+	 * @throws IOException if unable to read
+	 */
+	private void writePlain(OutputStream os, byte[] content) throws IOException 
+	{
+		ByteArrayInputStream bais = new ByteArrayInputStream(content);
+		this.copy(bais, os);
+	}
+
+	/**
+	 * Pumps the input stream to the output stream.
+	 *
+	 * @param is the source input stream
+	 * @param os the target output stream
+	 * @throws IOException the copying failed
+	 */
+	private void copy(InputStream is, OutputStream os) throws IOException 
+	{
+		byte[] buf = new byte[BUF_SIZE];
+		int n = 0;
+		while ((n = is.read(buf)) > 0) 
+		{
+			os.write(buf, 0, n);
+		}
+		os.flush();
+		os.close();
+	}
 }

Modified: turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/java/org/apache/fulcrum/resourcemanager/impl/FileResourceManager.java Wed Sep 18 03:16:01 2019
@@ -39,7 +39,9 @@ import org.apache.commons.lang3.StringUt
  *
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
-public class FileResourceManager extends BaseResourceManager {
+public class FileResourceManager extends BaseResourceManager 
+{
+	
 	/** an optinal suffix to filter resources */
 	private String suffix;
 
@@ -62,9 +64,9 @@ public class FileResourceManager extends
 	/**
 	 * Constructor
 	 */
-	public FileResourceManager() {
+	public FileResourceManager() 
+	{
 		super();
-
 		this.useLocator = true;
 		this.defaultDirectoryExcludes = new String[] { "CVS", ".svn" };
 	}
@@ -76,42 +78,43 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.impl.BaseResourceManager#configure(org.
 	 * apache.avalon.framework.configuration.Configuration)
 	 */
-	public void configure(Configuration cfg) throws ConfigurationException {
+	public void configure(Configuration cfg) throws ConfigurationException 
+	{
 		super.configure(cfg);
 
 		// the optional suffix - "*" is the usual wildcard suffix
-
 		this.suffix = cfg.getChild(CONFIG_KEY_SUFFIX).getValue("*");
 
 		// try to locate a resources automagically ?
-
 		this.useLocator = cfg.getChild(CONFIG_KEY_USELOCATOR).getValueAsBoolean(false);
 
 		// are we using encryption/decryption
-
 		this.setUseEncryption(cfg.getChild(CONFIG_KEY_USEENCRYPTION).getValue("false"));
 
 		// locate the directory where we the resources are located
-
 		String currLocationName = cfg.getChild(CONFIG_KEY_LOCATION).getValue();
 		File currLocation = new File(currLocationName);
 
-		if (currLocation.isAbsolute()) {
+		if (currLocation.isAbsolute()) 
+		{
 			this.resourceDir = currLocation;
-		} else {
+		} 
+		else 
+		{
 			this.resourceDir = new File(this.getApplicationDir(), currLocationName);
 		}
 
-		if (this.resourceDir.exists()) {
+		if (this.resourceDir.exists()) 
+		{
 			this.getLogger().debug("Using the resource directory : " + this.resourceDir.getAbsolutePath());
-		} else {
+		} 
+		else 
+		{
 			String msg = "The following resource directory is not found : " + this.resourceDir.getAbsolutePath();
-
 			throw new ConfigurationException(msg);
 		}
 
 		// load the file names of all resources and sort it
-
 		this.createResourceFileNameList();
 	}
 
@@ -120,9 +123,9 @@ public class FileResourceManager extends
 	 * 
 	 * @see org.apache.fulcrum.resourcemanager.impl.BaseResourceManager#dispose()
 	 */
-	public void dispose() {
+	public void dispose() 
+	{
 		super.dispose();
-
 		this.suffix = null;
 		this.useLocator = false;
 		this.resourceDir = null;
@@ -136,7 +139,8 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.impl.BaseResourceManager#reconfigure(org.
 	 * apache.avalon.framework.configuration.Configuration)
 	 */
-	public void reconfigure(Configuration configuration) throws ConfigurationException {
+	public void reconfigure(Configuration configuration) throws ConfigurationException 
+	{
 		super.reconfigure(configuration);
 		this.configure(configuration);
 	}
@@ -151,7 +155,8 @@ public class FileResourceManager extends
 	 * @see
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#exists(java.lang.String)
 	 */
-	public synchronized boolean exists(String resourceName) {
+	public synchronized boolean exists(String resourceName) 
+	{
 		File resourceFile = this.findResourceFile(resourceName, this.resourceFileNameList);
 		return resourceFile != null;
 	}
@@ -161,16 +166,15 @@ public class FileResourceManager extends
 	 * 
 	 * @see org.apache.fulcrum.resourcemanager.ResourceManager#listResources()
 	 */
-	public synchronized String[] listResources() {
+	public synchronized String[] listResources() 
+	{
 		String resourceDirName = this.getResourceDir().getAbsolutePath();
 		String[] fileList = this.resourceFileNameList;
 		String[] result = new String[fileList.length];
 
 		// remove the resource directory name
-
 		for (int i = 0; i < result.length; i++) {
 			String relativeName = fileList[i].substring(resourceDirName.length() + 1, fileList[i].length());
-
 			result[i] = relativeName;
 		}
 
@@ -184,7 +188,8 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#create(java.lang.String,
 	 * java.lang.Object)
 	 */
-	public synchronized void create(String resourcePath, Object resourceContent) throws IOException {
+	public synchronized void create(String resourcePath, Object resourceContent) throws IOException 
+	{
 
 		File resourceFile = new File(this.getResourceDir(), resourcePath);
 		this.getLogger().debug("Creating resource : " + resourceFile.getAbsolutePath());
@@ -192,17 +197,23 @@ public class FileResourceManager extends
 
 		// Try to prevent any leak from the outputstream
 		FileOutputStream fos = null;
-		try {
+		try 
+		{
 			fos = new FileOutputStream(resourceFile);
 			this.write(fos, byteContent);
 			fos.flush();
 			this.createResourceFileNameList();
 			
-		} finally {
-			try {
+		} 
+		finally 
+		{
+			try 
+			{
 				if ( fos != null )
 					fos.close();
-			} catch (IOException warn) {
+			} 
+			catch (IOException warn) 
+			{
 				throw warn;
 			}
 		}
@@ -214,29 +225,35 @@ public class FileResourceManager extends
 	 * @see
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#read(java.lang.String)
 	 */
-	public synchronized byte[] read(String resourcePath) throws IOException {
-
+	public synchronized byte[] read(String resourcePath) throws IOException 
+	{
 		// Result byte array
 		byte[] result = null;
 		File resourceFile = this.findResourceFile(resourcePath, this.resourceFileNameList);
 
-		if (resourceFile != null) {
+		if (resourceFile != null) 
+		{
 			this.getLogger().debug("Loading the resource : " + resourceFile.getAbsolutePath());
 			FileInputStream fis = null;
 
-			try {
+			try 
+			{
 				fis = new FileInputStream(resourceFile);
 				result = this.read(fis);
 
-			} finally {
-				try {
+			} 
+			finally 
+			{
+				try 
+				{
 					if ( fis != null )
 						fis.close();
-				} catch (IOException warn) {
+				} 
+				catch (IOException warn) 
+				{
 					throw warn;
 				}
 			}
-
 			return result;
 		} else {
 			String msg = "Unable to find the resource : " + resourcePath;
@@ -252,7 +269,8 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#update(java.lang.String,
 	 * java.lang.Object)
 	 */
-	public synchronized void update(String resourcePath, Object resourceContent) throws IOException {
+	public synchronized void update(String resourcePath, Object resourceContent) throws IOException 
+	{
 		this.create(resourcePath, resourceContent);
 	}
 
@@ -262,18 +280,17 @@ public class FileResourceManager extends
 	 * @see
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#delete(java.lang.String)
 	 */
-	public synchronized boolean delete(String resourcePath) throws IOException {
+	public synchronized boolean delete(String resourcePath) throws IOException 
+	{
 		boolean result = false;
 		File file = new File(this.getResourceDir(), resourcePath);
 
 		// if a resource was deleted we have to update our resource list
 		// to avoid a stale entry
-
 		if (file.delete()) {
 			this.createResourceFileNameList();
 			result = true;
 		}
-
 		return result;
 	}
 
@@ -284,8 +301,9 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#exists(java.lang.String[],
 	 * java.lang.String)
 	 */
-	public synchronized boolean exists(String[] context, String resourceName) {
-		return (this.locate(context, resourceName) != null);
+	public synchronized boolean exists(String[] context, String resourceName) 
+	{
+		return this.locate(context, resourceName) != null;
 	}
 
 	/*
@@ -295,7 +313,8 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#read(java.lang.String[],
 	 * java.lang.String)
 	 */
-	public synchronized byte[] read(String[] context, String resourceName) throws IOException {
+	public synchronized byte[] read(String[] context, String resourceName) throws IOException 
+	{
 		String resourceFileName = this.createResourceFileName(context, resourceName);
 		return this.read(resourceFileName);
 	}
@@ -307,20 +326,18 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#locate(java.lang.String[],
 	 * java.lang.String)
 	 */
-	public synchronized String locate(String[] context, String resourceName) {
+	public synchronized String locate(String[] context, String resourceName) 
+	{
 		String result = null;
 		String resourceDirName = this.getResourceDir().getAbsolutePath();
 		String resourceFileName = this.createResourceFileName(context, resourceName);
 		File resourceFile = this.findResourceFile(resourceFileName, this.resourceFileNameList);
-
-		if (resourceFile != null) {
+		if (resourceFile != null) 
+		{
 			String temp = resourceFile.getAbsolutePath();
-
 			result = temp.substring(resourceDirName.length() + 1, temp.length());
-
 			result = result.replace('\\', '/');
 		}
-
 		return result;
 	}
 
@@ -331,17 +348,23 @@ public class FileResourceManager extends
 	 * org.apache.fulcrum.resourcemanager.ResourceManager#getResourceURL(java.lang.
 	 * String[], java.lang.String)
 	 */
-	public synchronized URL getResourceURL(String[] context, String resourceName) {
+	public synchronized URL getResourceURL(String[] context, String resourceName) 
+	{
 		String resourceFileName = this.createResourceFileName(context, resourceName);
 		File resourceFile = this.findResourceFile(resourceFileName, this.resourceFileNameList);
-
-		if (resourceFile != null) {
-			try {
+		if (resourceFile != null) 
+		{
+			try 
+			{
 				return resourceFile.toURI().toURL();
-			} catch (MalformedURLException e) {
+			} 
+			catch (MalformedURLException e) 
+			{
 				throw new RuntimeException(e.getMessage());
 			}
-		} else {
+		} 
+		else 
+		{
 			return null;
 		}
 	}
@@ -356,11 +379,13 @@ public class FileResourceManager extends
 	 * @param directory the directory
 	 * @return true if the directory name is excluded
 	 */
-	private boolean isDirectoryExcluded(File directory) {
+	private boolean isDirectoryExcluded(File directory) 
+	{
 		String directoryName = directory.getName();
-
-		for (int i = 0; i < this.defaultDirectoryExcludes.length; i++) {
-			if (this.defaultDirectoryExcludes[i].equals(directoryName)) {
+		for (int i = 0; i < this.defaultDirectoryExcludes.length; i++) 
+		{
+			if (this.defaultDirectoryExcludes[i].equals(directoryName)) 
+			{
 				return true;
 			}
 		}
@@ -399,16 +424,19 @@ public class FileResourceManager extends
 	 * @param resourceList the list of available resources
 	 * @return the resource file or <b>null</b> if it wasn't found
 	 */
-	private File findResourceFile(String resourceName, String[] resourceList) {
+	private File findResourceFile(String resourceName, String[] resourceList) 
+	{
 		File result = null;
 		String tempFileName;
 		String resourceFileName = new File(this.getResourceDir(), resourceName).getAbsolutePath();
+		boolean wasFound = Arrays.binarySearch(resourceList, resourceFileName) >= 0;
 
-		boolean wasFound = (Arrays.binarySearch(resourceList, resourceFileName) >= 0);
-
-		if (wasFound) {
+		if (wasFound) 
+		{
 			result = new File(resourceFileName);
-		} else if (this.isUseLocator()) {
+		} 
+		else if (this.isUseLocator()) 
+		{
 			// create a String[] with the directories contained in the resourceName
 			// e.g. [0]=foor [1]=bar resourceName=empty.groovy
 
@@ -427,10 +455,14 @@ public class FileResourceManager extends
 			File[] fileList = new File[context.length + 1];
 			fileList[0] = new File(this.getResourceDir(), scriptBaseName);
 
-			for (int i = 1; i < context.length + 1; i++) {
-				if (i == 1) {
+			for (int i = 1; i < context.length + 1; i++) 
+			{
+				if (i == 1) 
+				{
 					baseFileName = context[i - 1];
-				} else {
+				} 
+				else 
+				{
 					baseFileName = baseFileName + File.separator + context[i - 1];
 				}
 
@@ -465,28 +497,36 @@ public class FileResourceManager extends
 	 * @param suffix   an optional suffix to filter the result
 	 * @param result   list of all matching resources
 	 */
-	private void findAllResources(File startDir, String suffix, ArrayList<String> result) {
-		if (startDir.isDirectory() && startDir.canRead()) {
-
+	private void findAllResources(File startDir, String suffix, ArrayList<String> result) 
+	{
+		if (startDir.isDirectory() && startDir.canRead()) 
+		{
 			// listFiles could return null
 			File[] list = startDir.listFiles();
-
 			if (list != null) {
 
-				for (int i = 0; i < list.length; i++) {
-					// recursive search for all subdirectories
-
-					if (list[i].isDirectory()) {
-						// check that the subdirectory is not excluded from the seach
-						if (!this.isDirectoryExcluded(list[i])) {
+				for (int i = 0; i < list.length; i++) 
+				{
+					// recursive search for all sub-directories
+					if (list[i].isDirectory()) 
+					{
+						// check that the subd0irectory is not excluded from the search
+						if (!this.isDirectoryExcluded(list[i])) 
+						{
 							this.findAllResources(list[i], suffix, result);
 						}
-					} else {
-						if (!suffix.equals("*")) {
-							if (list[i].getName().endsWith(suffix)) {
+					} 
+					else 
+					{
+						if (!suffix.equals("*")) 
+						{
+							if (list[i].getName().endsWith(suffix)) 
+							{
 								result.add(list[i].getAbsolutePath());
 							}
-						} else {
+						} 
+						else 
+						{
 							result.add(list[i].getAbsolutePath());
 						}
 					}
@@ -502,23 +542,27 @@ public class FileResourceManager extends
 	 * @param resourceName the name of the resource
 	 * @return a file name
 	 */
-	private String createResourceFileName(String[] context, String resourceName) {
+	private String createResourceFileName(String[] context, String resourceName) 
+	{
 		StringBuilder result = new StringBuilder();
-
-		if ((context != null) && (context.length > 0)) {
-			for (int i = 0; i < context.length; i++) {
-				if (context[i] != null) {
+		if (context != null && context.length > 0) 
+		{
+			for (int i = 0; i < context.length; i++) 
+			{
+				if (context[i] != null) 
+				{
 					result.append(context[i]);
 					result.append(File.separator);
-				} else {
-					String msg = "Don't know how to handle <null> in the context";
+				} 
+				else 
+				{
+					String msg = "Turbine does not know how to handle <null> in the context";
 					throw new IllegalArgumentException(msg);
 				}
 			}
 		}
 
 		result.append(resourceName);
-
 		return result.toString();
 	}
 }

Modified: turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/test/TestComponentConfig.xml Wed Sep 18 03:16:01 2019
@@ -23,23 +23,23 @@
   <ResourceManagerService>
     <domain name="groovy">
       <suffix>groovy</suffix>
-      <location>./src/test/resources/scripts</location>
+      <location>src/test/resources/scripts</location>
       <useLocator>true</useLocator>
     </domain>
     <domain name="xslt">
       <suffix>xsl</suffix>
-      <location>./src/test/resources/xslt</location>
+      <location>src/test/resources/xslt</location>
       <useLocator>true</useLocator>
     </domain>
     <domain name="test">
       <suffix>txt</suffix>
-      <location>./src/test/resources/test</location>
+      <location>src/test/resources/test</location>
       <useLocator>false</useLocator>
       <useEncryption>true</useEncryption>
     </domain>
     <domain name="crypto">
       <suffix>txt</suffix>
-      <location>./src/test/resources/crypto</location>
+      <location>src/test/resources/crypto</location>
       <useLocator>false</useLocator>
       <useEncryption>auto</useEncryption>
     </domain>

Modified: turbine/fulcrum/trunk/resourcemanager/src/test/TestRoleConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/test/TestRoleConfig.xml?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/test/TestRoleConfig.xml (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/test/TestRoleConfig.xml Wed Sep 18 03:16:01 2019
@@ -20,19 +20,7 @@
 
 <role-list>
   <role
-    name="org.apache.fulcrum.pbe.PBEService"
-    shorthand="PBEService"
-    default-class="org.apache.fulcrum.pbe.PBEServiceImpl"
-    early-init="true"
-    component-type="merlin"
-    description="Provides Password Based Encyrption using JCA/JCE"
-  />
-  <role
     name="org.apache.fulcrum.resourcemanager.ResourceManagerService"
     default-class="org.apache.fulcrum.resourcemanager.impl.ResourceManagerServiceImpl"
-    shorthand="ResourceManagerService"
-    early-init="true"
-    component-type="merlin"
-    description="Handles the management of resources"
-   />
+    shorthand="ResourceManagerService"/>
 </role-list>

Modified: turbine/fulcrum/trunk/resourcemanager/src/test/org/apache/fulcrum/resourcemanager/ResourceManagerServiceTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/resourcemanager/src/test/org/apache/fulcrum/resourcemanager/ResourceManagerServiceTest.java?rev=1867089&r1=1867088&r2=1867089&view=diff
==============================================================================
--- turbine/fulcrum/trunk/resourcemanager/src/test/org/apache/fulcrum/resourcemanager/ResourceManagerServiceTest.java (original)
+++ turbine/fulcrum/trunk/resourcemanager/src/test/org/apache/fulcrum/resourcemanager/ResourceManagerServiceTest.java Wed Sep 18 03:16:01 2019
@@ -19,49 +19,44 @@ package org.apache.fulcrum.resourcemanag
  * under the License.
  */
 
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Date;
 import java.util.Properties;
 
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
-
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 /**
  * Testing script handling
  *
  * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
  */
-public class ResourceManagerServiceTest extends BaseUnitTest
+public class ResourceManagerServiceTest extends BaseUnit5Test
 {
 	private ResourceManagerService service;
 
-    /**
-     * Defines the testcase name for JUnit.
-     *
-     * @param name the testcase's name.
-     */
-    public ResourceManagerServiceTest(String name)
+    @BeforeEach
+    public void setUp() throws Exception
     {
-        super(name);
-    }
+    	service = (ResourceManagerService) lookup(ResourceManagerService.ROLE);
+    }    
 
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        this.service = (ResourceManagerService) this.lookup(
-            ResourceManagerService.class.getName()
-            );
-    }
 
     /**
      * Test basic CRUD for the domain "script"
      * @throws Exception generic exception
      */
+    @Test
     public void testResourceCRUD() throws Exception
     {
         String temp = null;
@@ -90,6 +85,7 @@ public class ResourceManagerServiceTest
     /**
      * Test getting a list of resources for the domain "xslt"
      */
+    @Test
     public void testListResources() throws Exception
     {
         String [] result = null;
@@ -111,6 +107,7 @@ public class ResourceManagerServiceTest
      * Test getting a list of domains
      * @throws Exception generic exception
      */
+    @Test
     public void testListDomains() throws Exception
     {
         // get a list of available domains
@@ -129,6 +126,7 @@ public class ResourceManagerServiceTest
      * Test the locator
      * @throws Exception generic exception
      */
+    @Test
     public void testLocator() throws Exception
     {
         String resourceDomain = "groovy";
@@ -207,10 +205,10 @@ public class ResourceManagerServiceTest
      * Try to access an unknown domain
      * @throws Exception generic exception
      */
+    @Test
     public void testUnknownDomain() throws Exception
     {
         String[] resourceContext = { "foo" };
-
         assertFalse( this.service.exists( "bogus" ) );
 
         try
@@ -227,6 +225,7 @@ public class ResourceManagerServiceTest
      * Create a resource file using the various input data types
      * @throws Exception generic exception
      */
+    @Test
     public void testCreateResources() throws Exception
     {
         String result = null;
@@ -284,6 +283,7 @@ public class ResourceManagerServiceTest
      * Get the URL of the underlying resource.
      * @throws Exception generic exception
      */
+    @Test
     public void testGetResourceURL() throws Exception
     {
         String resourceDomain = "groovy";
@@ -303,6 +303,7 @@ public class ResourceManagerServiceTest
      * Create a resource file using the various input data types
      * @throws Exception generic exception
      */
+    @Test
     public void testAutoDecrytpion() throws Exception
     {
         String result = null;
@@ -336,6 +337,7 @@ public class ResourceManagerServiceTest
      * to the caching of the JUNIT reports and output onstdout.
      * @throws Exception generic exception
      */
+    @Test
     public void _testLongRunningBehaviour() throws Exception
     {
         for( int i=0; i<10; i++ )