ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1375591 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/osgi/p2/P2Descriptor.java src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java
Date Tue, 21 Aug 2012 14:57:47 GMT
Author: hibou
Date: Tue Aug 21 14:57:47 2012
New Revision: 1375591

URL: http://svn.apache.org/viewvc?rev=1375591&view=rev
Log:
Test and fix the detection of the 'zipped' bundles

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java?rev=1375591&r1=1375590&r2=1375591&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java Tue Aug 21 14:57:47
2012
@@ -132,8 +132,9 @@ public class P2Descriptor extends RepoDe
             if (source == null) {
                 continue;
             }
+            String compression = md.getAllArtifacts()[0].getExtraAttribute("compression");
             DefaultArtifact sourceArtifact = BundleInfoAdapter.buildArtifact(
-                md.getModuleRevisionId(), getBaseUri(), source, "source", null);
+                md.getModuleRevisionId(), getBaseUri(), source, "source", compression);
             md.addArtifact(BundleInfoAdapter.CONF_NAME_DEFAULT, sourceArtifact);
         }
         sourceURIs = null;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java?rev=1375591&r1=1375590&r2=1375591&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java Tue Aug 21 14:57:47
2012
@@ -295,8 +295,9 @@ public class P2MetadataParser implements
             // });
             addChild(new TouchpointDataHandler(), new ChildElementHandler() {
                 public void childHanlded(DelegetingHandler child) throws SAXParseException
{
-                    if (((TouchpointDataHandler) child).zipped) {
-                        bundleInfo.setHasInnerClasspath(true);                        
+                    Boolean zipped = ((TouchpointDataHandler) child).zipped;
+                    if (zipped != null) {
+                        bundleInfo.setHasInnerClasspath(zipped.booleanValue());         
              
                     }
                     if (!bundleInfo.isSource()) {
                         // we only care about parsing the manifest if it is a source
@@ -688,7 +689,7 @@ public class P2MetadataParser implements
 
         String manifest;
 
-        boolean zipped;
+        Boolean zipped;
 
         public TouchpointDataHandler() {
             super(TOUCHPOINTDATA);
@@ -714,18 +715,20 @@ public class P2MetadataParser implements
 
         String manifest;
 
-        boolean zipped;
+        Boolean zipped;
 
         public InstructionsHandler() {
             super(INSTRUCTIONS);
             addChild(new InstructionHandler(), new ChildElementHandler() {
                 public void childHanlded(DelegetingHandler child) {
+                    manifest = null;
+                    zipped = null;
+                    String buffer = ((InstructionHandler) child).getBufferedChars().trim();
                     String key = ((InstructionHandler) child).key;
                     if ("manifest".equals(key)) {
-                        manifest = ((InstructionHandler) child).getBufferedChars();
-                    } else if ("zipped".equals(key)) {
-                        zipped = Boolean.valueOf(
-                            ((InstructionHandler) child).getBufferedChars().trim()).booleanValue();
+                        manifest = buffer;
+                    } else if ("zipped".equals(key) && buffer.length() != 0) {
+                        zipped = Boolean.valueOf(buffer);
                     }
                 }
             });

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java?rev=1375591&r1=1375590&r2=1375591&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java Tue Aug 21 14:57:47
2012
@@ -18,7 +18,6 @@
 package org.apache.ivy.osgi.p2;
 
 import java.io.File;
-import java.text.ParseException;
 
 import junit.framework.TestCase;
 
@@ -37,7 +36,6 @@ import org.apache.ivy.core.resolve.Resol
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.osgi.core.BundleInfo;
 import org.apache.ivy.osgi.updatesite.UpdateSiteResolver;
-import org.apache.ivy.plugins.resolver.DependencyResolver;
 
 public class P2DescriptorTest extends TestCase {
 
@@ -45,7 +43,9 @@ public class P2DescriptorTest extends Te
 
     private IvySettings settings;
 
-    private UpdateSiteResolver resolver;
+    private UpdateSiteResolver p2SourceResolver;
+
+    private UpdateSiteResolver p2ZippedResolver;
 
     private Ivy ivy;
 
@@ -54,13 +54,17 @@ public class P2DescriptorTest extends Te
     protected void setUp() throws Exception {
         settings = new IvySettings();
 
-        resolver = new UpdateSiteResolver();
-        resolver.setName("p2-sources");
-        resolver.setUrl(new File("test/test-p2/sources").toURL().toExternalForm());
-        resolver.setSettings(settings);
-        settings.addResolver(resolver);
-
-        settings.setDefaultResolver("p2-sources");
+        p2SourceResolver = new UpdateSiteResolver();
+        p2SourceResolver.setName("p2-sources");
+        p2SourceResolver.setUrl(new File("test/test-p2/sources").toURL().toExternalForm());
+        p2SourceResolver.setSettings(settings);
+        settings.addResolver(p2SourceResolver);
+
+        p2ZippedResolver = new UpdateSiteResolver();
+        p2ZippedResolver.setName("p2-zipped");
+        p2ZippedResolver.setUrl(new File("test/test-p2/zipped").toURL().toExternalForm());
+        p2ZippedResolver.setSettings(settings);
+        settings.addResolver(p2ZippedResolver);
 
         cache = new File("build/cache");
         cache.mkdirs();
@@ -79,18 +83,20 @@ public class P2DescriptorTest extends Te
         data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
     }
 
-    public void testResolve() throws Exception {
+    public void testResolveSource() throws Exception {
+        settings.setDefaultResolver("p2-sources");
+
         ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
             "org.apache.ivy", "2.2.0.final_20100923230623");
 
-        ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
-                false), data);
+        ResolvedModuleRevision rmr = p2SourceResolver.getDependency(
+            new DefaultDependencyDescriptor(mrid, false), data);
         assertNotNull(rmr);
         assertEquals(mrid, rmr.getId());
 
         assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
 
-        DownloadReport report = resolver.download(rmr.getDescriptor().getAllArtifacts(),
+        DownloadReport report = p2SourceResolver.download(rmr.getDescriptor().getAllArtifacts(),
             new DownloadOptions());
         assertNotNull(report);
 
@@ -105,7 +111,7 @@ public class P2DescriptorTest extends Te
             assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
 
             // test to ask to download again, should use cache
-            DownloadReport report2 = resolver.download(new Artifact[] {artifact},
+            DownloadReport report2 = p2SourceResolver.download(new Artifact[] {artifact},
                 new DownloadOptions());
             assertNotNull(report2);
 
@@ -118,4 +124,66 @@ public class P2DescriptorTest extends Te
             assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
         }
     }
+
+    public void testResolveNotZipped() throws Exception {
+        settings.setDefaultResolver("p2-zipped");
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
+            "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");
+
+        ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(
+            new DefaultDependencyDescriptor(mrid, false), data);
+        assertNotNull(rmr);
+        assertEquals(mrid, rmr.getId());
+
+        assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
+
+        DownloadOptions options = new DownloadOptions();
+        options.setExpandCompressed(true);
+        DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(),
+            options);
+        assertNotNull(report);
+
+        assertEquals(1, report.getArtifactsReports().length);
+
+        Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
+        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
+        assertNotNull(ar);
+
+        assertEquals(artifact, ar.getArtifact());
+        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
+        assertNull(ar.getUncompressedLocalDir());
+    }
+
+    public void testResolveZipped() throws Exception {
+        settings.setDefaultResolver("p2-zipped");
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
+            "org.apache.ant", "1.8.3.v20120321-1730");
+
+        ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(
+            new DefaultDependencyDescriptor(mrid, false), data);
+        assertNotNull(rmr);
+        assertEquals(mrid, rmr.getId());
+
+        assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
+
+        DownloadOptions options = new DownloadOptions();
+        options.setExpandCompressed(true);
+        DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(),
+            options);
+        assertNotNull(report);
+
+        assertEquals(2, report.getArtifactsReports().length);
+
+        for (int i = 0; i < 2; i++) {
+            Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i];
+            ArtifactDownloadReport ar = report.getArtifactReport(artifact);
+            assertNotNull(ar);
+    
+            assertEquals(artifact, ar.getArtifact());
+            assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
+            assertNotNull(ar.getUncompressedLocalDir());
+        }
+    }
 }



Mime
View raw message