maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r430718 [2/2] - in /maven/sandbox/maven-shared-jar: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/shared/ src/main/java/org/apache/maven/shared/j...
Date Fri, 11 Aug 2006 08:21:17 GMT
Added: maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java
(added)
+++ maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,82 @@
+package org.apache.maven.shared.jar.taxon.exposers;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.commons.collections.Bag;
+import org.apache.commons.collections.bag.HashBag;
+import org.apache.maven.shared.jar.taxon.AbstractJarTaxonExposer;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+
+/**
+ * Jar Taxon Exposer - using Majority Timestamp of classes.
+ *
+ * @plexus.component role="org.apache.maven.shared.jar.taxon.JarTaxonExposer" role-hint="timestamp"
+ */
+public class TimestampExposer
+    extends AbstractJarTaxonExposer
+{
+    public String getExposerName()
+    {
+        return "Timestamp";
+    }
+
+    public boolean isAuthoritative()
+    {
+        return false;
+    }
+
+    public void expose()
+    {
+        List entries = getJar().getNameRegexEntryList( ".*" ); //$NON-NLS-1$
+        SimpleDateFormat tsformat = new SimpleDateFormat( "yyyyMMdd" ); //$NON-NLS-1$
+        Bag timestamps = new HashBag();
+        Iterator it = entries.iterator();
+        while ( it.hasNext() )
+        {
+            JarEntry entry = (JarEntry) it.next();
+            long time = entry.getTime();
+            String timestamp = tsformat.format( new Date( time ) );
+            timestamps.add( timestamp );
+        }
+
+        String ts = "";
+        int tsmax = 0;
+        it = timestamps.iterator();
+        while ( it.hasNext() )
+        {
+            String timestamp = (String) it.next();
+            int count = timestamps.getCount( timestamp );
+            if ( count > tsmax )
+            {
+                ts = timestamp;
+                tsmax = count;
+            }
+        }
+
+        if ( StringUtils.isNotEmpty( ts ) )
+        {
+            addVersion( ts );
+        }
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/taxon/exposers/TimestampExposer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/jars/ant.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/ant.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/ant.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/codec.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/codec.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/codec.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/evil-sealed-regex-1.0.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/evil-sealed-regex-1.0.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/evil-sealed-regex-1.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1-debug.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1-debug.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1-debug.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2-debug.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2-debug.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2-debug.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3-debug.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3-debug.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3-debug.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4-debug.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4-debug.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4-debug.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.4.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5-debug.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5-debug.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5-debug.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/helloworld-1.5.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/jars/jxr.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/jars/jxr.jar?rev=430718&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/maven-shared-jar/src/test/jars/jxr.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,94 @@
+package org.apache.maven.shared.jar;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 junit.framework.AssertionFailedError;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Abstract Jar TestCase
+ */
+public class AbstractJarTestCase
+    extends PlexusTestCase
+{
+    protected File basedir;
+
+    protected File testdir;
+
+    public AbstractJarTestCase()
+    {
+        super();
+        String userdir = System.getProperty( "user.dir" );
+        this.basedir = new File( System.getProperty( "basedir", userdir ) );
+        this.testdir = new File( basedir, "src/test" );
+    }
+
+    public File getSampleJarsDirectory()
+    {
+        return new File( testdir, "jars" );
+    }
+
+    public File getTestLocalRepoDirectory()
+    {
+        return new File( testdir, "localrepo" );
+    }
+
+    public void assertContains( String msg, Object expected, Collection coll )
+    {
+        if ( !coll.contains( expected ) )
+        {
+            throw new AssertionFailedError( msg + " collection did not have: " + expected.toString()
);
+        }
+    }
+
+    public void assertNotContainsRegex( String msg, String regex, Collection coll )
+    {
+        List failures = new ArrayList();
+        Pattern pat = Pattern.compile( regex );
+        Matcher mat;
+        Iterator it = coll.iterator();
+        while ( it.hasNext() )
+        {
+            String value = (String) it.next();
+            mat = pat.matcher( value );
+            if ( mat.find() )
+            {
+                failures.add( value );
+            }
+        }
+
+        if ( !failures.isEmpty() )
+        {
+            StringBuffer sb = new StringBuffer();
+            sb.append( msg ).append( " collection has illegal regex \"" ).append( regex ).append(
"\"" );
+            it = failures.iterator();
+            while ( it.hasNext() )
+            {
+                sb.append( "\n   - \"" ).append( it.next() ).append( "\"" );
+            }
+            throw new AssertionFailedError( sb.toString() );
+        }
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,47 @@
+package org.apache.maven.shared.jar;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+
+/**
+ * Jar Test Case
+ */
+public class JarTest
+    extends AbstractJarTestCase
+{
+    private Jar getJar( String filename )
+        throws JarException
+    {
+        File jarfile = new File( getSampleJarsDirectory(), filename );
+        return new Jar( jarfile );
+    }
+
+    public void testSealed()
+        throws JarException
+    {
+        Jar evil = getJar( "evil-sealed-regex-1.0.jar" );
+        assertTrue( evil.isSealed() );
+    }
+
+    public void testNotSealed()
+        throws JarException
+    {
+        Jar codec = getJar( "codec.jar" );
+        assertFalse( codec.isSealed() );
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.shared.jar.classes;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.bcel.classfile.ClassFormatException;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.DescendingVisitor;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.maven.shared.jar.AbstractJarTestCase;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+
+/**
+ * Import Visitor Test
+ */
+public class ImportVisitorTest
+    extends AbstractJarTestCase
+{
+    public void testImportsJxr()
+        throws ClassFormatException, IOException
+    {
+        File jxrjar = new File( getSampleJarsDirectory(), "jxr.jar" );
+        String classname = "org/apache/maven/jxr/DirectoryIndexer.class";
+        ClassParser classParser = new ClassParser( jxrjar.getAbsolutePath(), classname );
+        JavaClass javaClass = classParser.parse();
+
+        ImportVisitor importVisitor = new ImportVisitor( javaClass );
+        DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
+        javaClass.accept( descVisitor );
+
+        List imports = importVisitor.getImports();
+        assertNotNull( "Import List", imports );
+
+        assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );
+
+        assertContains( "imports", "org.apache.maven.jxr.pacman.PackageType", imports );
+        assertContains( "imports", "org.codehaus.plexus.util.IOUtil", imports );
+        assertContains( "imports", "org.apache.oro.text.perl.Perl5Util", imports );
+    }
+
+    public void testImportsAnt()
+        throws ClassFormatException, IOException
+    {
+        File jxrjar = new File( getSampleJarsDirectory(), "ant.jar" );
+        String classname = "org/apache/tools/ant/Target.class";
+        ClassParser classParser = new ClassParser( jxrjar.getAbsolutePath(), classname );
+        JavaClass javaClass = classParser.parse();
+
+        ImportVisitor importVisitor = new ImportVisitor( javaClass );
+        DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
+        javaClass.accept( descVisitor );
+
+        List imports = importVisitor.getImports();
+        assertNotNull( "Import List", imports );
+
+        assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );
+
+        assertContains( "imports", "org.apache.tools.ant.Location", imports );
+        assertContains( "imports", "org.apache.tools.ant.Task", imports );
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,137 @@
+package org.apache.maven.shared.jar.classes;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.jar.AbstractJarTestCase;
+import org.apache.maven.shared.jar.Jar;
+import org.apache.maven.shared.jar.JarException;
+
+import java.io.File;
+
+
+/**
+ * Jar Classes Test Case
+ */
+public class JarClassesAnalyzerTest
+    extends AbstractJarTestCase
+{
+    private JarClasses getJarClasses( String filename )
+        throws JarException
+    {
+        File jarfile = new File( getSampleJarsDirectory(), filename );
+        Jar jar = new Jar( jarfile );
+
+        JarClassesAnalyzer analyzer = new JarClassesAnalyzer();
+        analyzer.analyze( jar );
+
+        JarClasses jclass = jar.getClasses();
+        assertNotNull( "JarClasses", jclass );
+
+        return jclass;
+    }
+
+    public void testAnalyzeJXR()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "jxr.jar" );
+
+        assertTrue( "classes.imports.length > 0", ( jclass.getImports().size() > 0
) );
+        assertTrue( "classes.packages.length > 0", ( jclass.getPackages().size() >
0 ) );
+
+        assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", jclass.getImports() );
+
+        // TODO: test for classes count.
+
+        assertContains( "classes.imports", "org.apache.maven.jxr.JXR", jclass.getImports()
);
+        assertContains( "classes.imports", "org.apache.oro.text.perl.Perl5Util", jclass.getImports()
);
+        assertContains( "classes.imports", "org.codehaus.plexus.util.IOUtil", jclass.getImports()
);
+        assertContains( "classes.packages", "org.apache.maven.jxr.pacman", jclass.getPackages()
);
+    }
+
+    public void testAnalyzeANT()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "ant.jar" );
+
+        assertTrue( "classes.imports.length > 0", ( jclass.getImports().size() > 0
) );
+        assertTrue( "classes.packages.length > 0", ( jclass.getPackages().size() >
0 ) );
+
+        assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", jclass.getImports() );
+
+        assertContains( "classes.imports", "java.util.zip.GZIPInputStream", jclass.getImports()
);
+        assertContains( "classes.imports", "org.apache.tools.ant.XmlLogger$TimedElement",
jclass.getImports() );
+        assertContains( "classes.imports", "org.apache.tools.mail.MailMessage", jclass.getImports()
);
+        assertContains( "classes.packages", "org.apache.tools.ant", jclass.getPackages()
);
+        assertContains( "classes.packages", "org.apache.tools.bzip2", jclass.getPackages()
);
+    }
+
+    public void testAnalyzeJarWithDebug()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.4-debug.jar" );
+
+        assertTrue( "has debug", jclass.isDebugPresent() );
+    }
+
+    public void testAnalyzeJarWithoutDebug()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.4.jar" );
+
+        assertFalse( "no debug present", jclass.isDebugPresent() );
+    }
+
+    public void testAnalyzeJarVersion15()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.5.jar" );
+
+        assertEquals( "jdkrevision", "1.5", jclass.getJdkRevision() );
+    }
+
+    public void testAnalyzeJarVersion14()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.4.jar" );
+
+        assertEquals( "jdkrevision", "1.4", jclass.getJdkRevision() );
+    }
+
+    public void testAnalyzeJarVersion13()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.3.jar" );
+
+        assertEquals( "jdkrevision", "1.3", jclass.getJdkRevision() );
+    }
+
+    public void testAnalyzeJarVersion12()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.2.jar" );
+
+        assertEquals( "jdkrevision", "1.2", jclass.getJdkRevision() );
+    }
+
+    public void testAnalyzeJarVersion11()
+        throws JarException
+    {
+        JarClasses jclass = getJarClasses( "helloworld-1.1.jar" );
+
+        assertEquals( "jdkrevision", "1.1", jclass.getJdkRevision() );
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,92 @@
+package org.apache.maven.shared.jar.taxon;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.jar.AbstractJarTestCase;
+import org.apache.maven.shared.jar.Jar;
+import org.apache.maven.shared.jar.JarAnalyzer;
+
+import java.io.File;
+
+
+/**
+ * Jar Taxon Analyzer Test Case
+ */
+public class JarTaxonAnalyzerTest
+    extends AbstractJarTestCase
+{
+    private JarTaxon getJarTaxon( String filename )
+        throws Exception
+    {
+        File jarfile = new File( getSampleJarsDirectory(), filename );
+        Jar jar = new Jar( jarfile );
+
+        JarAnalyzer analyzer = (JarAnalyzer) lookup( JarAnalyzer.ROLE, "taxon" );
+        analyzer.analyze( jar );
+
+        JarTaxon taxon = jar.getTaxon();
+        assertNotNull( "JarTaxon", taxon );
+
+        return taxon;
+    }
+
+    public void testTaxonAnalyzerWithJXR()
+        throws Exception
+    {
+        JarTaxon taxon = getJarTaxon( "jxr.jar" );
+
+        assertTrue( "taxon.potentials > 0", ( taxon.getPotentials().size() > 0 ) );
+
+        assertEquals( "taxon.groupId", "org.apache.maven", taxon.getGroupId() );
+        assertEquals( "taxon.artifactId", "maven-jxr", taxon.getArtifactId() );
+        assertEquals( "taxon.version", "1.1-SNAPSHOT", taxon.getVersion() );
+        assertEquals( "taxon.name", "Maven JXR", taxon.getName() );
+        assertEquals( "taxon.vendor", "Apache Software Foundation", taxon.getVendor() );
+    }
+
+    /**
+     * Tests Jar with No embedded pom, and no useful manifest.mf information.
+     */
+    public void testTaxonAnalyzerWithCODEC()
+        throws Exception
+    {
+        JarTaxon taxon = getJarTaxon( "codec.jar" );
+
+        assertTrue( "taxon.potentials > 0", ( taxon.getPotentials().size() > 0 ) );
+
+        assertEquals( "taxon.groupId", "org.apache.commons.codec", taxon.getGroupId() );
+        assertEquals( "taxon.artifactId", "codec", taxon.getArtifactId() );
+        // assertEquals( "taxon.version", "codec_release_1_0_0_interim_20030519095102_build",
taxon.getVersion() );
+        assertEquals( "taxon.version", "20030519", taxon.getVersion() );
+        assertEquals( "taxon.name", "codec", taxon.getName() );
+        assertNull( "taxon.vendor", taxon.getVendor() );
+    }
+
+    public void testTaxonAnalyzerWithANT()
+        throws Exception
+    {
+        JarTaxon taxon = getJarTaxon( "ant.jar" );
+
+        assertTrue( "taxon.potentials > 0", ( taxon.getPotentials().size() > 0 ) );
+
+        assertEquals( "taxon.groupId", "org.apache.tools.ant", taxon.getGroupId() );
+        assertEquals( "taxon.artifactId", "ant", taxon.getArtifactId() );
+        assertEquals( "taxon.version", "1.6.5", taxon.getVersion() );
+        // assertEquals( "taxon.name", "Apache Ant", taxon.getName() );
+        assertEquals( "taxon.vendor", "Apache Software Foundation", taxon.getVendor() );
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarTaxonAnalyzerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java?rev=430718&view=auto
==============================================================================
--- maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java
(added)
+++ maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java
Fri Aug 11 01:21:11 2006
@@ -0,0 +1,70 @@
+package org.apache.maven.shared.jar.taxon.exposers;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.shared.jar.AbstractJarTestCase;
+import org.apache.maven.shared.jar.Jar;
+import org.apache.maven.shared.jar.JarException;
+
+import java.io.File;
+
+
+/**
+ * Test Case for Embedded Maven Model Taxon Data.
+ */
+public class EmbeddedMavenModelExposerTest
+    extends AbstractJarTestCase
+{
+    public void testExposerWithJXR()
+        throws JarException
+    {
+        File jxrfile = new File( getSampleJarsDirectory(), "jxr.jar" );
+        Jar jxrjar = new Jar( jxrfile );
+
+        EmbeddedMavenModelExposer exposer = new EmbeddedMavenModelExposer();
+        exposer.setJar( jxrjar );
+        exposer.expose();
+
+        assertTrue( "exposer.isAuthoritative", exposer.isAuthoritative() );
+
+        assertNotNull( "exposer.groupIds", exposer.getGroupIds() );
+        assertFalse( "exposer.groupIds", exposer.getGroupIds().isEmpty() );
+
+        assertNotNull( "exposer.artifactIds", exposer.getArtifactIds() );
+        assertFalse( "exposer.artifactIds", exposer.getArtifactIds().isEmpty() );
+
+        assertNotNull( "exposer.versions", exposer.getVersions() );
+        assertFalse( "exposer.versions", exposer.getVersions().isEmpty() );
+    }
+
+    public void testExposerWithANT()
+        throws JarException
+    {
+        File antfile = new File( getSampleJarsDirectory(), "ant.jar" );
+        Jar antjar = new Jar( antfile );
+
+        EmbeddedMavenModelExposer exposer = new EmbeddedMavenModelExposer();
+        exposer.setJar( antjar );
+        exposer.expose();
+
+        assertTrue( "exposer.isAuthoritative", exposer.isAuthoritative() );
+
+        assertNull( "exposer.groupIds", exposer.getGroupIds() );
+        assertNull( "exposer.artifactIds", exposer.getArtifactIds() );
+        assertNull( "exposer.versions", exposer.getVersions() );
+    }
+}

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/EmbeddedMavenModelExposerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message