You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2017/01/28 12:46:17 UTC

[4/6] maven-archetype git commit: Remove WikiArchetypeDataSource, implementation only used in test

Remove WikiArchetypeDataSource, implementation only used in test


Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/fbf678b6
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/fbf678b6
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/fbf678b6

Branch: refs/heads/master
Commit: fbf678b62cb90c3a4d070545ccc1c46105120581
Parents: 69a9513
Author: rfscholte <rf...@apache.org>
Authored: Fri Jan 27 21:24:21 2017 +0100
Committer: rfscholte <rf...@apache.org>
Committed: Fri Jan 27 21:24:21 2017 +0100

----------------------------------------------------------------------
 .../source/WikiArchetypeDataSource.java         | 140 -------------------
 .../source/WikiArchetypeDataSourceTest.java     |  79 -----------
 2 files changed, 219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/fbf678b6/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
deleted file mode 100644
index 92e3a60..0000000
--- a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSource.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.apache.maven.archetype.source;
-
-/*
- * 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.
- */
-
-import org.apache.maven.archetype.catalog.Archetype;
-import org.apache.maven.archetype.catalog.ArchetypeCatalog;
-import org.apache.maven.archetype.source.ArchetypeDataSource;
-import org.apache.maven.archetype.source.ArchetypeDataSourceException;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.net.URL;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * An archetype data source getting its content from a Confluence Wiki page.
- * By default, <a href="http://docs.codehaus.org/display/MAVENUSER/Archetypes+List">MAVENUSER/Archetypes List</a>
- * is used.
- *
- * @author            Jason van Zyl
- */
-@Component( role = ArchetypeDataSource.class, hint = "wiki" )
-public class WikiArchetypeDataSource
-    implements ArchetypeDataSource
-{
-    private static String DEFAULT_ARCHETYPE_INVENTORY_PAGE =
-        "http://docs.codehaus.org/pages/viewpagesrc.action?pageId=48400";
-
-    static String cleanup( String val )
-    {
-        val = val.replaceAll( "\\r|\\n|\\s{2,}|\\[|\\|[^\\]]+]|\\]", "" );
-        return val;
-    }
-
-    static String cleanupUrl( String val )
-    {
-        return val.replaceAll( "\\r|\\n|\\s{2,}|\\[|\\]|\\&nbsp;", "" );
-    }
-
-    public ArchetypeCatalog getArchetypeCatalog( ProjectBuildingRequest buildingRequest, Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        ArchetypeCatalog ac = new ArchetypeCatalog();
-        ac.setArchetypes( getArchetypes( properties ) );
-        return ac;
-    }
-
-    public List<Archetype> getArchetypes( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        String url = properties.getProperty( "url" );
-
-        if ( url == null )
-        {
-            url = DEFAULT_ARCHETYPE_INVENTORY_PAGE;
-        }
-
-        List<Archetype> archetypes = new ArrayList<Archetype>();
-
-        String pageSource = "";
-        InputStream in = null;
-        try
-        {
-            in = new URL( cleanupUrl( url ) ).openStream();
-
-            pageSource = IOUtil.toString( in );
-        }
-        catch ( IOException e )
-        {
-            throw new ArchetypeDataSourceException( "Error retrieving list of archetypes from " + url );
-        }
-        finally
-        {
-            IOUtil.close( in );
-        }
-
-        // | ArtifactId | GroupId | Version | Repository | Description |
-        Pattern ptn =
-            Pattern.compile(
-                "<br>\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_. ]+)\\|([-a-zA-Z0-9_.:/ \\[\\],]+)\\|(.*) \\|"
-            );
-
-        Matcher m = ptn.matcher( pageSource );
-
-        while ( m.find() )
-        {
-            Archetype archetype = new Archetype();
-
-            archetype.setArtifactId( m.group( 1 ).trim() );
-
-            archetype.setGroupId( m.group( 2 ).trim() );
-
-            String version = m.group( 3 ).trim();
-            if ( version.equals( "" ) )
-            {
-                version = "RELEASE";
-            }
-            archetype.setVersion( version );
-
-            archetype.setRepository( cleanupUrl( m.group( 4 ).trim() ) );
-
-            archetype.setDescription( cleanup( m.group( 5 ).trim() ) );
-
-            archetypes.add( archetype );
-        }
-        return archetypes;
-    }
-
-    public void updateCatalog( ProjectBuildingRequest buildingRequest, Archetype archetype )
-        throws ArchetypeDataSourceException
-    {
-        throw new UnsupportedOperationException( "Not supported yet." );
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/fbf678b6/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
----------------------------------------------------------------------
diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java b/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
deleted file mode 100644
index 4d8936f..0000000
--- a/archetype-common/src/test/java/org/apache/maven/archetype/source/WikiArchetypeDataSourceTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.apache.maven.archetype.source;
-
-/*
- * 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.
- */
-
-import org.apache.maven.archetype.catalog.Archetype;
-import org.apache.maven.archetype.catalog.ArchetypeCatalog;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.codehaus.plexus.PlexusTestCase;
-
-import java.io.File;
-import java.util.Properties;
-
-/** @author Jason van Zyl */
-public class WikiArchetypeDataSourceTest
-    extends PlexusTestCase
-{
-    private static final String[][] REFERENCE =
-        {
-            { "appfuse-basic-jsf", "org.appfuse.archetypes", "2.0", "http://static.appfuse.org/releases",
-                "AppFuse archetype for creating a web application with Hibernate, Spring and JSF" },
-            { "maven-archetype-profiles", "org.apache.maven.archetypes", "RELEASE", "http://repo.maven.apache.org/maven2", "" },
-            { "struts2-archetype-starter", "org.apache.struts", "2.0.9-SNAPSHOT",
-                "http://people.apache.org/repo/m2-snapshot-repository",
-                "A starter Struts 2 application with Sitemesh, DWR, and Spring" },
-            { "maven-archetype-har", "net.sf.maven-har", "0.9", "", "Hibernate Archive" },
-            { "maven-archetype-archetype", "org.apache.maven.archetypes", "RELEASE", "", "" }
-        };
-
-    public void testWikiArchetypeDataSource()
-        throws Exception
-    {
-        File wikiSource = new File( getBasedir(), "src/test/resources/wiki/wiki-source.txt" );
-
-        assertTrue( wikiSource.exists() );
-
-        Properties p = new Properties();
-        p.put( "url", wikiSource.toURI().toURL().toExternalForm() );
-
-        ArchetypeDataSource ads = new WikiArchetypeDataSource();
-
-        ProjectBuildingRequest buildingRequest = null;
-        
-        ArchetypeCatalog catalog = ads.getArchetypeCatalog( buildingRequest, p );
-
-        int catalogSize = catalog.getArchetypes().size();
-
-        assertEquals( REFERENCE.length, catalogSize );
-
-        for ( int i = 0; i < catalogSize; i++ )
-        {
-            String[] reference = REFERENCE[i];
-
-            Archetype ar = (Archetype) catalog.getArchetypes().get( i );
-
-            assertEquals( "#" + i + " artifactId", reference[0], ar.getArtifactId() );
-            assertEquals( "#" + i + " groupId", reference[1], ar.getGroupId() );
-            assertEquals( "#" + i + " version", reference[2], ar.getVersion() );
-            assertEquals( "#" + i + " repository", reference[3], ar.getRepository() );
-            assertEquals( "#" + i + " description", reference[4], ar.getDescription() );
-        }
-    }
-}