From 510db4c46faa3a2e135809081bc0d4698b478544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristiano=20Gavi=C3=A3o?= Date: Thu, 15 Jan 2015 08:24:16 -0300 Subject: [PATCH 1/2] FELIX-4764 - Added GZIP support --- .../felix/bundlerepository/impl/DataModelHelperImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java index 9a4d785bc40..e3fa6493152 100644 --- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java +++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java @@ -34,6 +34,7 @@ import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; +import java.util.zip.GZIPInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -108,6 +109,11 @@ public Repository repository(final URL url) throws Exception entry = zin.getNextEntry(); } } + else + if (url.getPath().endsWith(".gz")) + { + is = new GZIPInputStream(FileUtil.openURL(url)); + } else { is = FileUtil.openURL(url); From 3af84b7d62d0665a791e31dc77da422e3d2cecd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristiano=20Gavi=C3=A3o?= Date: Mon, 30 Mar 2015 18:30:02 -0300 Subject: [PATCH 2/2] added test case for FELIX-4764 --- .../impl/DataModelHelperTest.java | 15 +++++++++++++++ .../src/test/resources/spec_repository.gz | Bin 0 -> 3347 bytes 2 files changed, 15 insertions(+) create mode 100644 bundlerepository/src/test/resources/spec_repository.gz diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java index 3953fd3b2bd..758539bff5e 100644 --- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java +++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java @@ -18,11 +18,14 @@ */ package org.apache.felix.bundlerepository.impl; +import java.net.URL; import java.util.jar.Attributes; import junit.framework.TestCase; import org.apache.felix.bundlerepository.DataModelHelper; +import org.apache.felix.bundlerepository.Repository; import org.apache.felix.bundlerepository.Resource; +import static org.junit.Assert.*; public class DataModelHelperTest extends TestCase { @@ -62,4 +65,16 @@ public void testRequirementFilter() throws Exception r.setFilter("(&(package=javax.transaction)(partial=true)(mandatory:<*partial))"); assertEquals("(&(package=javax.transaction)(partial=true)(mandatory:<*partial))", r.getFilter()); } + + public void testGzipResource() throws Exception { + URL urlArchive = getClass().getResource("/spec_repository.gz"); + assertNotNull("GZ archive was not found", urlArchive); + Repository repository1 = dmh.repository(urlArchive); + + URL urlRepo = getClass().getResource("/spec_repository.xml"); + assertNotNull("Repository file was not found", urlRepo); + Repository repository2 = dmh.repository(urlRepo); + assertEquals(repository1.getName(), repository2.getName()); + assertEquals(repository1.getResources().length, repository2.getResources().length); + } } diff --git a/bundlerepository/src/test/resources/spec_repository.gz b/bundlerepository/src/test/resources/spec_repository.gz new file mode 100644 index 0000000000000000000000000000000000000000..8f065b83f4e6665766bdb0cf4982deca8b4fefa7 GIT binary patch literal 3347 zcmV+u4eatCiwFp#of%aC19Na?V_$M*aBp*IbZ>HbE_iKh0PS5{bKABOe)q3n^H9Yz z7InY)ByPv2O{SicvCl+KJAKN4Bq+h52ps~ltp575yh)TLQluo?5Vd_sEfNG5`z;p0 zV!`j@uTNt~d!(LV+`Xza^m;|3uE{Ot4zDUxX;=G|Uw=9K_*1odrhQ>1bp^FF$u&8m z+VzB(@V^1K<&1b#`^=}VMI_Xuy}urOKG)zU^)&9%GmU%Nm_r$pyV7IERKf)(tWP6D zkJ2%9rO-8PKxt6|SIOo%-35nK5O1RMe z43(xe^}6;R3Y=;0qI>VoKLpQ?$y{@})TV+iYu4zKNhcBn1);_hhY{C=XQNgv>Idom zj;i2>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