Author: olamy
Date: Sat Oct 29 22:56:45 2011
New Revision: 1195067

URL: http://svn.apache.org/viewvc?rev=1195067&view=rev
Log:
[MRM-1175] archiva-consumer-plugin-archetype: generates code that does not 
compile
fix archetype generation

Added:
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
   (with props)
Modified:
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java
    
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java

Modified: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: 
http://svn.apache.org/viewvc/archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1195067&r1=1195066&r2=1195067&view=diff
==============================================================================
--- 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
 (original)
+++ 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
 Sat Oct 29 22:56:45 2011
@@ -9,5 +9,8 @@
     <fileSet filtered="true" packaged="true">
       <directory>src/test/java</directory>
     </fileSet>
+    <fileSet filtered="true" packaged="false">
+      <directory>src/test/resources</directory>
+    </fileSet>
   </fileSets>
 </archetype-descriptor>
\ No newline at end of file

Modified: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml
URL: 
http://svn.apache.org/viewvc/archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml?rev=1195067&r1=1195066&r2=1195067&view=diff
==============================================================================
--- 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml
 (original)
+++ 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/pom.xml
 Sat Oct 29 22:56:45 2011
@@ -42,6 +42,12 @@
       <version>2.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.9</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -67,6 +73,7 @@
         </executions>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <source>1.5</source>

Modified: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java
URL: 
http://svn.apache.org/viewvc/archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java?rev=1195067&r1=1195066&r2=1195067&view=diff
==============================================================================
--- 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java
 (original)
+++ 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java
 Sat Oct 29 22:56:45 2011
@@ -1,6 +1,7 @@
 package $package;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.archiva.configuration.ArchivaConfiguration;
@@ -14,6 +15,16 @@ import org.codehaus.plexus.personality.p
 import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+
+import javax.annotation.PostConstruct;
+
 /**
  * <code>SimpleArtifactConsumer</code>
  * 
@@ -24,24 +35,29 @@ public class SimpleArtifactConsumer
     extends AbstractMonitoredConsumer
     implements KnownRepositoryContentConsumer, RegistryListener, Initializable
 {
+
+    private Logger log = LoggerFactory.getLogger( SimpleArtifactConsumer.class 
);
+
     /**
-     * @plexus.configuration default-value="simple-artifact-consumer"
+     * default-value="simple-artifact-consumer"
      */
-    private String id;
+    private String id = "simple-artifact-consumer";
 
     /**
-     * @plexus.configuration default-value="Simple consumer to illustrate how 
to consume the contents of a repository."
+     *
      */
-    private String description;
+    private String description = "Simple consumer to illustrate how to consume 
the contents of a repository.";
 
     /**
-     * @plexus.requirement
+     *
      */
+    @Inject
     private FileTypes filetypes;
 
     /**
-     * @plexus.requirement
+     *
      */
+    @Inject
     private ArchivaConfiguration configuration;
 
     private List propertyNameTriggers = new ArrayList();
@@ -49,26 +65,52 @@ public class SimpleArtifactConsumer
     private List includes = new ArrayList();
 
     /** current repository being scanned */
-    private ManagedRepositoryConfiguration repository;
+    private ManagedRepository repository;
+
+    public void beginScan( ManagedRepository repository )
+        throws ConsumerException
+    {
+        this.repository = repository;
+        log.info( "Beginning scan of repository [" + this.repository.getId() + 
"]" );
+    }
+
+    public void beginScan( ManagedRepository repository, Date whenGathered )
+        throws ConsumerException
+    {
+        this.repository = repository;
+        log.info( "Beginning scan of repository [" + this.repository.getId() + 
"]" );
+    }
 
-    public void beginScan( ManagedRepositoryConfiguration repository )
+    public void beginScan( ManagedRepository repository, Date whenGathered, 
boolean executeOnEntireRepo )
         throws ConsumerException
     {
         this.repository = repository;
-        getLogger().info( "Beginning scan of repository [" + 
this.repository.getId() + "]" );
+        log.info( "Beginning scan of repository [" + this.repository.getId() + 
"]" );
     }
 
     public void processFile( String path )
         throws ConsumerException
     {
-        getLogger().info( "Processing entry [" + path + "] from repository [" 
+ this.repository.getId() + "]" );
+        log.info( "Processing entry [" + path + "] from repository [" + 
this.repository.getId() + "]" );
+    }
+
+    public void processFile( String path, boolean executeOnEntireRepo )
+        throws ConsumerException
+    {
+        log.info( "Processing entry [" + path + "] from repository [" + 
this.repository.getId() + "]" );
     }
 
     public void completeScan()
     {
-        getLogger().info( "Finished scan of repository [" + 
this.repository.getId() + "]" );
+        log.info( "Finished scan of repository [" + this.repository.getId() + 
"]" );
     }
 
+    public void completeScan( boolean executeOnEntireRepo )
+    {
+        log.info( "Finished scan of repository [" + this.repository.getId() + 
"]" );
+    }
+
+
     /**
      * Used by archiva to determine if the consumer wishes to process all of a 
repository's entries or just those that
      * have been modified since the last scan.
@@ -100,6 +142,7 @@ public class SimpleArtifactConsumer
         includes.addAll( filetypes.getFileTypePatterns( 
FileTypes.INDEXABLE_CONTENT ) );
     }
 
+    @PostConstruct
     public void initialize()
         throws InitializationException
     {

Modified: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
URL: 
http://svn.apache.org/viewvc/archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java?rev=1195067&r1=1195066&r2=1195067&view=diff
==============================================================================
--- 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
 (original)
+++ 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
 Sat Oct 29 22:56:45 2011
@@ -21,84 +21,80 @@ package $package;
 
 import java.io.File;
 
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.logging.Logger;
 import org.easymock.EasyMock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.inject.Inject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import junit.framework.TestCase;
 
 /**
  * <code>SimpleArtifactConsumerTest</code>
  */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = 
{"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
 public class SimpleArtifactConsumerTest
-    extends PlexusTestCase
+    extends TestCase
 {
+    @Inject
     private SimpleArtifactConsumer consumer;
 
     private File repoDir;
 
-    private ManagedRepositoryConfiguration testRepository;
+    private ManagedRepository testRepository;
 
-    private Logger mockLogger;
+    private Logger log = LoggerFactory.getLogger( SimpleArtifactConsumer.class 
);
 
-    protected void setUp()
+    @Before
+    public void setUp()
         throws Exception
     {
         super.setUp();
         String consumerRole = KnownRepositoryContentConsumer.class.getName();
-        consumer = (SimpleArtifactConsumer) lookup( consumerRole, 
"simple-artifact-consumer" );
 
         setUpMockRepository();
-        setupMockLogger();
-    }
 
-    private void setupMockLogger()
-    {       
-        mockLogger = (Logger) EasyMock.createNiceMock(Logger.class); 
-        consumer.enableLogging( mockLogger );
     }
 
+
+
     private void setUpMockRepository()
     {
-        repoDir = new java.io.File( getBasedir(), "/target/test-consumer-repo" 
);
+        repoDir = new java.io.File( "target/test-consumer-repo" );
         repoDir.mkdirs();
         repoDir.deleteOnExit();
 
-        testRepository = new ManagedRepositoryConfiguration();
+        testRepository = new ManagedRepository();
         testRepository.setName( "Test-Consumer-Repository" );
         testRepository.setId( "test-consumer-repository" );
         testRepository.setLocation( repoDir.getAbsolutePath() );
     }
 
+    @Test
     public void testBeginScan()
         throws Exception
     {
-        mockLogger.info( "Beginning scan of repository 
[test-consumer-repository]" );
-        EasyMock.expectLastCall();
-        EasyMock.replay(mockLogger);
+        log.info( "Beginning scan of repository [test-consumer-repository]" );
 
         consumer.beginScan( testRepository );
 
-        EasyMock.verify();
     }
 
+    @Test
     public void testProcessFile()
         throws Exception
     {
-        mockLogger.info( "Beginning scan of repository 
[test-consumer-repository]" );
-        EasyMock.expectLastCall();
-        mockLogger.info( "Processing entry 
[org/simple/test/testartifact/testartifact/1.0/testartifact-1.0.pom]"
-            + " from repository [test-consumer-repository]" );
-        EasyMock.expectLastCall();
-        mockLogger.info( "Processing entry 
[org/simple/test/testartifact/testartifact/1.1/testartifact-1.1.pom]"
-            + " from repository [test-consumer-repository]" );
-        EasyMock.expectLastCall();
-        EasyMock.replay(mockLogger);
-
         consumer.beginScan( testRepository );
         consumer.processFile( 
"org/simple/test/testartifact/testartifact/1.0/testartifact-1.0.pom" );
         consumer.processFile( 
"org/simple/test/testartifact/testartifact/1.1/testartifact-1.1.pom" );
-        EasyMock.verify(mockLogger);
     }
 
 }

Added: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
URL: 
http://svn.apache.org/viewvc/archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml?rev=1195067&view=auto
==============================================================================
--- 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
 (added)
+++ 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
 Sat Oct 29 22:56:45 2011
@@ -0,0 +1,34 @@
+<?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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns:context="http://www.springframework.org/schema/context";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context 
+           
http://www.springframework.org/schema/context/spring-context-3.0.xsd";
+       default-lazy-init="true">
+  <context:annotation-config/>
+  <context:component-scan base-package="$package"/>
+
+
+
+</beans>
\ No newline at end of file

Propchange: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
archiva/sandbox/trunk/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to