You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by da...@apache.org on 2011/11/24 17:35:15 UTC
svn commit: r1205919 - in /aries/trunk/util: util-r42/
util-r42/src/main/java/org/apache/aries/util/
util-r42/src/main/java/org/apache/aries/util/filesystem/impl/
util-r42/src/main/java/org/apache/aries/util/manifest/
util-r42/src/test/java/org/apache/...
Author: davidb
Date: Thu Nov 24 16:35:12 2011
New Revision: 1205919
URL: http://svn.apache.org/viewvc?rev=1205919&view=rev
Log:
Remove dependency on SLF4J. Change the SLF4J log calls (which were used to log exceptions only) into throw new IORuntimeException.
Added:
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java (with props)
Modified:
aries/trunk/util/util-r42/pom.xml
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileImpl.java
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileSystemImpl.java
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/NestedZipDirectory.java
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipDirectory.java
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipFileImpl.java
aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/BundleManifest.java
aries/trunk/util/util-r42/src/test/java/org/apache/aries/util/filesystem/FileSystemTest.java
aries/trunk/util/util/pom.xml
Modified: aries/trunk/util/util-r42/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/pom.xml?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/pom.xml (original)
+++ aries/trunk/util/util-r42/pom.xml Thu Nov 24 16:35:12 2011
@@ -81,16 +81,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.aries.testsupport</groupId>
<artifactId>org.apache.aries.testsupport.unit</artifactId>
<version>0.3</version>
Added: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java?rev=1205919&view=auto
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java (added)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java Thu Nov 24 16:35:12 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+package org.apache.aries.util;
+
+import java.io.IOException;
+
+/**
+ * This unchecked exception wraps an IOException.
+ */
+public class IORuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param message A detail message.
+ * @param cause The original IOException.
+ */
+ public IORuntimeException(String message, IOException cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param cause The original IOException.
+ */
+ public IORuntimeException(IOException cause) {
+ super(cause);
+ }
+
+ /**
+ * @see java.lang.Throwable#getCause()
+ */
+ @Override
+ public IOException getCause() {
+ return (IOException) super.getCause();
+ }
+}
Propchange: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/IORuntimeException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileImpl.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileImpl.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileImpl.java Thu Nov 24 16:35:12 2011
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
@@ -42,7 +43,7 @@ public class FileImpl implements IFile
protected File rootDirFile;
/** The name of this file in the vFS */
private String name;
-
+
/**
* @param f this file.
* @param rootFile the root of the vFS.
@@ -52,11 +53,11 @@ public class FileImpl implements IFile
file = f;
this.rootDirFile = rootFile;
rootDir = rootFile.getAbsolutePath();
-
+
if (f.equals(rootFile)) name = "";
else name = file.getAbsolutePath().substring(rootDir.length() + 1).replace('\\', '/');
}
-
+
public IDirectory convert()
{
return null;
@@ -120,11 +121,11 @@ public class FileImpl implements IFile
{
if (obj == null) return false;
if (obj == this) return true;
-
+
if (obj.getClass() == getClass()) {
return file.equals(((FileImpl)obj).file);
}
-
+
return false;
}
@@ -133,7 +134,7 @@ public class FileImpl implements IFile
{
return file.hashCode();
}
-
+
@Override
public String toString()
{
@@ -141,7 +142,14 @@ public class FileImpl implements IFile
}
public IDirectory convertNested() {
- if (isDirectory()) return convert();
- else return FileSystemImpl.getFSRoot(file, getParent());
+ if (isDirectory()) {
+ return convert();
+ } else {
+ try {
+ return FileSystemImpl.getFSRoot(file, getParent());
+ } catch (IORuntimeException e) {
+ return null;
+ }
+ }
}
}
\ No newline at end of file
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileSystemImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileSystemImpl.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileSystemImpl.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/FileSystemImpl.java Thu Nov 24 16:35:12 2011
@@ -26,21 +26,17 @@ import java.io.InputStream;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class FileSystemImpl {
-
- private static final Logger _logger = LoggerFactory.getLogger(FileSystemImpl.class.getName());
-
/**
* This method gets the IDirectory that represents the root of a virtual file
* system. The provided file can either identify a directory, or a zip file.
- *
+ *
* @param fs the zip file.
* @return the root of the virtual FS.
*/
@@ -55,17 +51,16 @@ public class FileSystemImpl {
try {
dir = new ZipDirectory(fs, parent);
} catch (IOException e) {
- _logger.error ("IOException in IDirectory.getFSRoot", e);
+ throw new IORuntimeException("IOException in IDirectory.getFSRoot", e);
}
}
}
else {
- // since this method does not throw an exception but just returns null, make sure we do not lose the error
- _logger.error("File not found in IDirectory.getFSRoot", new FileNotFoundException(fs.getPath()));
+ throw new IORuntimeException("File not found in IDirectory.getFSRoot", new FileNotFoundException(fs.getPath()));
}
return dir;
}
-
+
/**
* Check whether a file is actually a valid zip
* @param zip
@@ -77,11 +72,10 @@ public class FileSystemImpl {
zf.close();
return true;
} catch (IOException e) {
- _logger.debug("Not a valid zip: "+zip);
- return false;
+ throw new IORuntimeException("Not a valid zip: "+zip, e);
}
}
-
+
/**
* Check whether a file is actually a valid zip
* @param zip
@@ -94,8 +88,7 @@ public class FileSystemImpl {
zis = new ZipInputStream(zip.open());
return zis.getNextEntry() != null;
} catch (IOException e) {
- _logger.debug("Not a valid zip: "+zip);
- return false;
+ throw new IORuntimeException("Not a valid zip: "+zip, e);
} finally {
IOUtils.close(zis);
}
@@ -106,21 +99,20 @@ public class FileSystemImpl {
try {
tempFile = File.createTempFile("inputStreamExtract", ".zip");
} catch (IOException e1) {
- _logger.error ("IOException in IDirectory.getFSRoot", e1);
- return null;
+ throw new IORuntimeException("IOException in IDirectory.getFSRoot", e1);
}
- FileOutputStream fos = null;
+ FileOutputStream fos = null;
try {
fos = new FileOutputStream(tempFile);
- IOUtils.copy(is, fos);
+ IOUtils.copy(is, fos);
} catch (IOException e) {
return null;
} finally {
IOUtils.close(fos);
}
-
+
IDirectory dir = getFSRoot(tempFile, null);
-
+
if(dir == null)
return null;
else
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/NestedZipDirectory.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/NestedZipDirectory.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/NestedZipDirectory.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/NestedZipDirectory.java Thu Nov 24 16:35:12 2011
@@ -31,33 +31,29 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class NestedZipDirectory extends NestedZipFile implements IDirectory {
-
- private static final Logger logger = LoggerFactory.getLogger(NestedZipDirectory.class.getName());
-
public NestedZipDirectory(IFile archive, ZipEntry entry, NestedZipDirectory parent, NestedCloseableDirectory cache) {
super(archive, entry, parent, cache);
}
-
+
public NestedZipDirectory(IFile archive, String pathInZip, NestedZipDirectory parent, NestedCloseableDirectory cache) {
super(archive, pathInZip, parent, cache);
}
-
+
public NestedZipDirectory(IFile archive) {
super(archive);
}
-
+
public NestedZipDirectory(NestedZipDirectory other, NestedCloseableDirectory cache) {
super(other, cache);
}
-
+
public IDirectory convert() {
return this;
}
@@ -73,7 +69,7 @@ public class NestedZipDirectory extends
public List<IFile> listAllFiles() {
return listFiles(true);
}
-
+
private List<IFile> listFiles(boolean includeFilesInNestedSubdirs) {
Map<String, ZipEntry> entriesByName = new LinkedHashMap<String, ZipEntry>();
for (ZipEntry entry : getAllEntries()) {
@@ -88,10 +84,10 @@ public class NestedZipDirectory extends
if (ze.isDirectory()) files.add(new NestedZipDirectory(archive, ze, parent, cache));
else files.add(new NestedZipFile(archive, ze, parent, cache));
}
-
+
return files;
}
-
+
private List<? extends ZipEntry> getAllEntries() {
if (cache != null && !!!cache.isClosed()) {
return Collections.list(cache.getZipFile().entries());
@@ -99,37 +95,36 @@ public class NestedZipDirectory extends
ZipInputStream zis = null;
try {
zis = new ZipInputStream(archive.open());
-
+
List<ZipEntry> result = new ArrayList<ZipEntry>();
ZipEntry entry = zis.getNextEntry();
while (entry != null) {
result.add(entry);
entry = zis.getNextEntry();
}
-
- return result;
+
+ return result;
} catch (IOException e) {
- logger.error("IOException reading nested ZipFile", e);
- return Collections.emptyList();
+ throw new IORuntimeException("IOException reading nested ZipFile", e);
} finally {
IOUtils.close(zis);
}
- }
+ }
}
-
+
private NestedZipDirectory buildParent(ZipEntry entry, Map<String,ZipEntry> entries) {
NestedZipDirectory result = this;
-
+
String path = entry.getName().substring(getNameInZip().length());
String[] segments = path.split("/");
-
+
if (segments != null && segments.length > 1) {
StringBuilder entryPath = new StringBuilder(getNameInZip());
for (int i=0; i<segments.length-1; i++) {
String p = segments[i];
entryPath.append(p).append("/");
ZipEntry ze = entries.get(entryPath.toString());
-
+
if (ze != null) {
result = new NestedZipDirectory(archive, ze, result, cache);
} else {
@@ -137,7 +132,7 @@ public class NestedZipDirectory extends
}
}
}
-
+
return result;
}
@@ -155,30 +150,29 @@ public class NestedZipDirectory extends
ZipEntry p = zip.getEntry(path.toString());
if (p != null) entries.put(path.toString(), p);
}
-
+
ze = zip.getEntry(name);
-
+
} else {
ZipInputStream zis = null;
-
+
try {
zis = new ZipInputStream(archive.open());
-
+
ze = zis.getNextEntry();
-
+
while (ze != null && !!!ze.getName().equals(name)) {
if (name.startsWith(ze.getName())) entries.put(ze.getName(), ze);
-
+
ze = zis.getNextEntry();
}
} catch (IOException e) {
- logger.error("IOException reading nested ZipFile", e);
- return null;
+ throw new IORuntimeException("IOException reading nested ZipFile", e);
} finally {
IOUtils.close(zis);
}
}
-
+
if (ze != null) {
NestedZipDirectory parent = buildParent(ze, entries);
if (ze.isDirectory()) return new NestedZipDirectory(archive, ze, parent, cache);
@@ -188,7 +182,7 @@ public class NestedZipDirectory extends
}
}
-
+
public boolean isDirectory() {
return true;
}
@@ -207,11 +201,9 @@ public class NestedZipDirectory extends
public ICloseableDirectory toCloseable() {
try {
- return new NestedCloseableDirectory(archive, this);
+ return new NestedCloseableDirectory(archive, this);
} catch (IOException e) {
- logger.error("Exception while creating extracted version of nested zip file", e);
- return null;
- }
+ throw new IORuntimeException("Exception while creating extracted version of nested zip file", e);
+ }
}
-
}
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipDirectory.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipDirectory.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipDirectory.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipDirectory.java Thu Nov 24 16:35:12 2011
@@ -30,26 +30,23 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* A directory in the zip.
*/
public class ZipDirectory extends ZipFileImpl implements IDirectory
{
- private static final Logger logger = LoggerFactory.getLogger(ZipDirectory.class.getName());
-
/** The root of the zip FS. */
private final IDirectory root;
private final boolean zipRoot;
-
+
/**
* Constructs a directory in the zip.
- *
+ *
* @param zip1 the zip file.
* @param entry1 the entry in the zip representing this dir.
* @param parent the parent directory.
@@ -66,7 +63,7 @@ public class ZipDirectory extends ZipFil
* @param file
* @param fs
* @param parent
- * @throws MalformedURLException
+ * @throws MalformedURLException
*/
public ZipDirectory(File fs, IDirectory parent) throws MalformedURLException
{
@@ -74,7 +71,7 @@ public class ZipDirectory extends ZipFil
root = (parent == null) ? this : parent.getRoot();
zipRoot = true;
}
-
+
public ZipDirectory(ZipDirectory other, ZipCloseableDirectory cache) {
super(other, cache);
root = other.root;
@@ -84,11 +81,11 @@ public class ZipDirectory extends ZipFil
public IFile getFile(String name)
{
IFile result = null;
-
+
String entryName = isZipRoot() ? name : getNameInZip() + "/" + name;
-
+
ZipEntry entryFile = getEntry(entryName);
-
+
if (entryFile != null) {
if (!!!entryFile.isDirectory()) {
result = new ZipFileImpl(zip, entryFile, buildParent(entryFile), cache);
@@ -107,24 +104,24 @@ public class ZipDirectory extends ZipFil
private ZipDirectory buildParent(ZipEntry foundEntry)
{
ZipDirectory result = this;
-
+
String name = foundEntry.getName();
-
+
name = name.substring(getNameInZip().length());
-
+
String[] paths = name.split("/");
-
+
StringBuilder baseBuilderCrapThingToGetRoundFindBugs = new StringBuilder(getNameInZip());
-
+
if (!!!isZipRoot()) baseBuilderCrapThingToGetRoundFindBugs.append('/');
- // Build 'result' as a chain of ZipDirectories. This will only work if java.util.ZipFile recognises every
- // directory in the chain as being a ZipEntry in its own right.
+ // Build 'result' as a chain of ZipDirectories. This will only work if java.util.ZipFile recognises every
+ // directory in the chain as being a ZipEntry in its own right.
outer: if (paths != null && paths.length > 1) {
for (int i = 0; i < paths.length - 1; i++) {
String path = paths[i];
baseBuilderCrapThingToGetRoundFindBugs.append(path);
ZipEntry dirEntry = getEntry(baseBuilderCrapThingToGetRoundFindBugs.toString());
- if (dirEntry == null) {
+ if (dirEntry == null) {
result = this;
break outer;
}
@@ -149,7 +146,7 @@ public class ZipDirectory extends ZipFil
{
return listFiles(true);
}
-
+
private List<IFile> listFiles(boolean includeFilesInNestedSubdirs)
{
List<IFile> files = new ArrayList<IFile>();
@@ -168,15 +165,15 @@ public class ZipDirectory extends ZipFil
}
}
-
+
closeZipFile(z);
- return files;
+ return files;
}
-
+
/**
* This method works out if the provided entry is inside this directory. It
* returns false if it is not, or if it is in a sub-directory.
- *
+ *
* @param possibleEntry
* @param whether files in subdirectories are to be included
* @return true if it is in this directory.
@@ -210,7 +207,7 @@ public class ZipDirectory extends ZipFil
return false;
}
- public InputStream open()
+ public InputStream open()
{
throw new UnsupportedOperationException();
}
@@ -219,11 +216,11 @@ public class ZipDirectory extends ZipFil
{
return root;
}
-
+
public boolean isZipRoot() {
return zipRoot;
}
-
+
// Although we only delegate to our super class if we removed this Findbugs
// would correctly point out that we add fields in this class, but do not
// take them into account for the equals method. In fact this is not a problem
@@ -235,17 +232,17 @@ public class ZipDirectory extends ZipFil
{
return super.equals(other);
}
-
+
@Override
public int hashCode()
{
return super.hashCode();
}
-
+
private ZipEntry getEntry(String entryName) {
ZipFile z = openZipFile();
ZipEntry entryFile = null;
-
+
if (z != null) {
entryFile = z.getEntry(entryName);
closeZipFile(z);
@@ -257,8 +254,7 @@ public class ZipDirectory extends ZipFil
try {
return new ZipCloseableDirectory(zip, this);
} catch (IOException e) {
- logger.error("IOException opening zip file", this);
- return null;
+ throw new IORuntimeException("IOException opening zip file: " + this, e);
}
}
}
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipFileImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipFileImpl.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipFileImpl.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/filesystem/impl/ZipFileImpl.java Thu Nov 24 16:35:12 2011
@@ -28,19 +28,15 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* An implementation of IFile that represents a file entry in a zip.
*/
public class ZipFileImpl implements IFile
{
- /** A logger */
- private static final Logger logger = LoggerFactory.getLogger(ZipFileImpl.class.getName());
-
/** The name of the file */
private String name;
/** The size of the file */
@@ -59,10 +55,10 @@ public class ZipFileImpl implements IFil
private final String zipPathToRoot;
/** The closeable directory that caches the open ZipFile */
protected final ZipCloseableDirectory cache;
-
+
/**
* This constructor is used to create a file entry within the zip.
- *
+ *
* @param zip1 the zip file the entry is in.
* @param entry1 the entry this IFile represents.
* @param parent1 the parent directory.
@@ -71,25 +67,25 @@ public class ZipFileImpl implements IFil
{
this.zip = zip1;
this.entry = entry1;
-
+
this.zipPathToRoot = parent1.getZipPathToRoot();
name = zipPathToRoot + entry1.getName();
-
+
if (entry1.isDirectory()) name = name.substring(0, name.length() - 1);
-
+
lastModified = entry1.getTime();
size = entry1.getSize();
-
+
url = ((ZipFileImpl)parent1).url;
-
+
this.parent = parent1;
this.cache = cache;
}
-
+
/**
* This is called to construct the root directory of the zip.
- *
+ *
* @param zip1 the zip file this represents.
* @param fs the file on the fs.
* @param rootName the name of this zipfile relative to the IFile filesystem root
@@ -99,7 +95,7 @@ public class ZipFileImpl implements IFil
{
this.zip = zip1;
this.entry = null;
-
+
if (parent == null) {
name = "";
zipPathToRoot = "";
@@ -109,13 +105,13 @@ public class ZipFileImpl implements IFil
name = parent.getName() + "/" + zip1.getName();
zipPathToRoot = name+"/";
}
-
+
lastModified = zip1.lastModified();
size = zip1.length();
url = zip1.toURI().toURL().toExternalForm();
this.cache = null;
}
-
+
public ZipFileImpl(ZipFileImpl other, ZipCloseableDirectory cache) {
name = other.name;
size = other.size;
@@ -134,17 +130,17 @@ public class ZipFileImpl implements IFil
public String getZipPathToRoot() {
return zipPathToRoot;
}
-
+
public IDirectory convert()
{
return null;
}
-
+
public IDirectory convertNested() {
if (isDirectory()) return convert();
- else if (FileSystemImpl.isValidZip(this)) return new NestedZipDirectory(this);
+ else if (FileSystemImpl.isValidZip(this)) return new NestedZipDirectory(this);
else return null;
- }
+ }
public long getLastModified()
{
@@ -155,8 +151,8 @@ public class ZipFileImpl implements IFil
{
return name;
}
-
- public String getNameInZip()
+
+ public String getNameInZip()
{
if (entry == null) return "";
else {
@@ -191,7 +187,7 @@ public class ZipFileImpl implements IFil
InputStream is = new SpecialZipInputStream(entry);
return is;
}
-
+
public IDirectory getRoot()
{
return parent.getRoot();
@@ -200,11 +196,11 @@ public class ZipFileImpl implements IFil
public URL toURL() throws MalformedURLException
{
URL result;
-
+
if(name.equals(zipPathToRoot))
result = new URL(url);
else {
-
+
String entryURL = "jar:" + url + "!/";
if(entry != null)
entryURL += entry.getName();
@@ -213,7 +209,7 @@ public class ZipFileImpl implements IFil
}
result = new URL(entryURL);
}
-
+
return result;
}
@@ -222,11 +218,11 @@ public class ZipFileImpl implements IFil
{
if (obj == null) return false;
if (obj == this) return true;
-
+
if (obj.getClass() == getClass()) {
return toString().equals(obj.toString());
}
-
+
return false;
}
@@ -242,7 +238,7 @@ public class ZipFileImpl implements IFil
if (name != null && name.length() != 0) return url.substring(5)+ "/" + name;
else return url.substring(5);
}
-
+
ZipFile openZipFile(){
ZipFile z = null;
@@ -251,15 +247,13 @@ public class ZipFileImpl implements IFil
} else {
try {
z = new ZipFile(zip);
- } catch (ZipException e) {
- logger.error ("ZipException in ZipFileImpl.openZipFile", e);
} catch (IOException e) {
- logger.error ("IOException in ZipFileImpl.openZipFile", e);
+ throw new IORuntimeException("IOException in ZipFileImpl.openZipFile", e);
}
}
return z;
}
-
+
void closeZipFile(ZipFile z){
if (cache != null && cache.getZipFile() == z) {
// do nothing
@@ -268,11 +262,11 @@ public class ZipFileImpl implements IFil
z.close();
}
catch (IOException e) {
- logger.error ("IOException in ZipFileImpl.closeZipFile", e);
+ throw new IORuntimeException("IOException in ZipFileImpl.closeZipFile", e);
}
}
}
-
+
/**
* A simple class to delegate to the InputStream of the constructor
* and to call close on the zipFile when we close the stream.
@@ -282,25 +276,25 @@ public class ZipFileImpl implements IFil
private ZipFile zipFile;
private InputStream is;
-
+
public SpecialZipInputStream(ZipEntry anEntry){
try{
this.zipFile = openZipFile();
this.is = zipFile.getInputStream(anEntry);
}
catch (ZipException e) {
- logger.error ("ZipException in SpecialZipInputStream()", e);
+ throw new IORuntimeException("ZipException in SpecialZipInputStream()", e);
} catch (IOException e) {
- logger.error ("IOException in SpecialZipInputStream()", e);
+ throw new IORuntimeException("IOException in SpecialZipInputStream()", e);
}
}
-
+
@Override
public int read() throws IOException
{
return is.read();
}
-
+
@Override
public void close() throws IOException{
//call close on the input stream, probably does nothing
@@ -308,7 +302,7 @@ public class ZipFileImpl implements IFil
//call close on the zip file, important for tidying up
closeZipFile(zipFile);
}
-
+
}
}
Modified: aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/BundleManifest.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/BundleManifest.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/BundleManifest.java (original)
+++ aries/trunk/util/util-r42/src/main/java/org/apache/aries/util/manifest/BundleManifest.java Thu Nov 24 16:35:12 2011
@@ -28,15 +28,13 @@ import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.internal.MessageUtil;
import org.apache.aries.util.io.IOUtils;
-import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValueMap;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Entity class to retrieve and represent a bundle manifest (valid or invalid).
@@ -44,12 +42,11 @@ import org.slf4j.LoggerFactory;
public class BundleManifest
{
private static final String MANIFEST_PATH = "META-INF/MANIFEST.MF";
- private static final Logger _logger = LoggerFactory.getLogger(BundleManifest.class.getName());
/**
* Read a manifest from a jar input stream. This will find the manifest even if it is NOT
* the first file in the archive.
- *
+ *
* @param is
* @return
*/
@@ -66,22 +63,21 @@ public class BundleManifest
if (entry.getName().equals(MANIFEST_PATH))
return new BundleManifest(jarIs);
}
-
+
return null;
}
}
catch (IOException e) {
- _logger.error ("IOException in BundleManifest()", e);
- return null;
+ throw new IORuntimeException("IOException in BundleManifest()", e);
}
finally {
IOUtils.close(jarIs);
}
}
-
+
/**
* Retrieve a BundleManifest from the given jar file
- *
+ *
* @param f
* @return
*/
@@ -99,17 +95,16 @@ public class BundleManifest
return fromBundle(is);
}
} catch (IOException e) {
- _logger.error ("IOException in BundleManifest.fromBundle(IFile)", e);
- return null;
+ throw new IORuntimeException("IOException in BundleManifest.fromBundle(IFile)", e);
}
finally {
IOUtils.close(is);
}
}
-
+
/**
* Retrieve a bundle manifest from the given jar file, which can be exploded or compressed
- *
+ *
* @param f
* @return
*/
@@ -121,8 +116,7 @@ public class BundleManifest
return new BundleManifest(new FileInputStream(manifestFile));
}
catch (IOException e) {
- _logger.error ("IOException in BundleManifest.fromBundle(File)", e);
- return null;
+ throw new IORuntimeException("IOException in BundleManifest.fromBundle(File)", e);
}
else
return null;
@@ -132,17 +126,16 @@ public class BundleManifest
return fromBundle(new FileInputStream(f));
}
catch (IOException e) {
- _logger.error ("IOException in BundleManifest.fromBundle(File)", e);
- return null;
+ throw new IORuntimeException("IOException in BundleManifest.fromBundle(File)", e);
}
}
else {
throw new IllegalArgumentException(MessageUtil.getMessage("UTIL0016E", f.getAbsolutePath()));
}
}
-
+
private Manifest manifest;
-
+
/**
* Create a BundleManifest object from the InputStream to the manifest (not to the bundle)
* @param manifestIs
@@ -151,7 +144,7 @@ public class BundleManifest
public BundleManifest(InputStream manifestIs) throws IOException {
this(ManifestProcessor.parseManifest(manifestIs));
}
-
+
/**
* Create a BundleManifest object from a common Manifest object
* @param m
@@ -159,7 +152,7 @@ public class BundleManifest
public BundleManifest(Manifest m) {
manifest = m;
}
-
+
public String getSymbolicName() {
String rawSymName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
@@ -168,29 +161,29 @@ public class BundleManifest
NameValuePair info = ManifestHeaderProcessor.parseBundleSymbolicName(rawSymName);
result = info.getName();
}
-
+
return result;
}
-
+
public Version getVersion() {
String specifiedVersion = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
Version result = (specifiedVersion == null) ? Version.emptyVersion : new Version(specifiedVersion);
-
+
return result;
}
-
+
public String getManifestVersion() {
return manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION);
}
-
+
public Attributes getRawAttributes() {
return manifest.getMainAttributes();
}
-
+
public Manifest getRawManifest() {
return manifest;
}
-
+
public boolean isValid() {
return getManifestVersion() != null && getSymbolicName() != null;
}
Modified: aries/trunk/util/util-r42/src/test/java/org/apache/aries/util/filesystem/FileSystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/util/util-r42/src/test/java/org/apache/aries/util/filesystem/FileSystemTest.java?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util-r42/src/test/java/org/apache/aries/util/filesystem/FileSystemTest.java (original)
+++ aries/trunk/util/util-r42/src/test/java/org/apache/aries/util/filesystem/FileSystemTest.java Thu Nov 24 16:35:12 2011
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -40,6 +41,7 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.apache.aries.unittest.junit.Assert;
+import org.apache.aries.util.IORuntimeException;
import org.apache.aries.util.io.IOUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -55,7 +57,7 @@ public class FileSystemTest
* Make sure we correctly understand the content of the application when the
* application is an exploded directory. This test just checks that the
* root directory returns the expected information.
- *
+ *
* @throws IOException
*/
@Test(expected=UnsupportedOperationException.class)
@@ -64,14 +66,14 @@ public class FileSystemTest
File baseDir = new File(getTestResourceDir(), "/app1");
File manifest = new File(baseDir, "META-INF/APPLICATION.MF");
IDirectory dir = FileSystem.getFSRoot(baseDir);
-
+
runBasicRootDirTests(dir, baseDir.length(), manifest.lastModified());
}
-
+
/**
* Make sure we correctly understand the directory structure for exploded
* directories.
- *
+ *
* @throws IOException
*/
@Test
@@ -81,16 +83,16 @@ public class FileSystemTest
IDirectory dir = FileSystem.getFSRoot(baseDir);
File desiredFile = new File(baseDir, "META-INF/APPLICATION.MF");
-
+
runBasicDirTest(dir, desiredFile.length(), desiredFile.lastModified());
runBasicDirTest(dir.toCloseable(), desiredFile.length(), desiredFile.lastModified());
}
-
+
/**
* Make sure we correctly understand the content of the application when the
* application is a zip. This test just checks that the
* root directory returns the expected information.
- *
+ *
* @throws IOException
*/
@Test(expected=UnsupportedOperationException.class)
@@ -98,15 +100,15 @@ public class FileSystemTest
{
File baseDir = new File("fileSystemTest/app2.zip");
IDirectory dir = FileSystem.getFSRoot(baseDir);
-
+
runBasicRootDirTests(dir, baseDir.length(), baseDir.lastModified());
}
-
+
/**
* Make sure we correctly understand the content of the application when the
* application is a zip. This test just checks that the
* root directory returns the expected information.
- *
+ *
* @throws IOException
*/
@Test(expected=UnsupportedOperationException.class)
@@ -114,24 +116,27 @@ public class FileSystemTest
{
File baseDir = new File("fileSystemTest/app2.zip");
ICloseableDirectory dir = FileSystem.getFSRoot(new FileInputStream(baseDir));
-
+
try {
runBasicRootDirTests(dir, baseDir.length(), baseDir.lastModified());
} finally {
dir.close();
}
}
-
+
@Test
public void testInvalidFSRoot() throws IOException
{
File baseDir = new File(getTestResourceDir(), "/app1");
File manifest = new File(baseDir, "META-INF/APPLICATION.MF");
- IDirectory dir = FileSystem.getFSRoot(manifest);
-
- assertNull(dir);
+ try {
+ IDirectory dir = FileSystem.getFSRoot(manifest);
+ fail("Should have thrown an IORuntimeException");
+ } catch (IORuntimeException e) {
+ // good!
+ }
}
-
+
/**
* Make sure that operations work on zip files nested in file IDirectories
* @throws IOException
@@ -139,21 +144,21 @@ public class FileSystemTest
@Test
public void nestedZipInDirectory() throws IOException
{
- IDirectory dir = FileSystem.getFSRoot(new File("").getAbsoluteFile());
-
+ IDirectory dir = FileSystem.getFSRoot(new File("").getAbsoluteFile());
+
// base convert does not do nested zips
IDirectory zip = dir.getFile("fileSystemTest/app2.zip").convert();
assertNull(zip);
-
+
// basic conversion works
zip = dir.getFile("fileSystemTest/app2.zip").convertNested();
assertNotNull(zip);
-
+
// we get the parent and our path right
assertNotNull(zip.getParent());
assertEquals("fileSystemTest", zip.getParent().getName());
assertEquals("fileSystemTest/app2.zip", zip.getName());
-
+
// files inside the nested zip have the correct path as well
IFile appMf = zip.getFile("META-INF/APPLICATION.MF");
assertNotNull(appMf);
@@ -163,14 +168,14 @@ public class FileSystemTest
// root is right
assertFalse(zip.isRoot());
assertEquals(dir, zip.getRoot());
- assertEquals(dir, appMf.getRoot());
-
+ assertEquals(dir, appMf.getRoot());
+
// check URLs are correct
checkManifest(appMf.toURL().openStream());
-
+
runBasicDirTest(zip, "fileSystemTest/app2.zip/", appMf.getSize(), appMf.getLastModified());
}
-
+
/**
* Make sure that the operations work with zip files inside other zip files. Performance is not going to be great though :)
*/
@@ -178,20 +183,20 @@ public class FileSystemTest
public void nestedZipInZip() throws IOException
{
IDirectory outer = FileSystem.getFSRoot(new File("fileSystemTest/outer.zip"));
-
+
IFile innerFile = outer.getFile("app2.zip");
assertNotNull(innerFile);
IDirectory inner = innerFile.convertNested();
assertNotNull(inner);
-
- File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
-
+
+ File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
+
// no size information when stream reading :(
runBasicDirTest(inner, "app2.zip/", -1, desiredFile.lastModified());
runBasicDirTest(inner.toCloseable(), "app2.zip/", desiredFile.length(), desiredFile.lastModified());
}
-
+
/**
* Make sure that the operations work with zip files inside other zip files. Performance is not going to be great though :)
*/
@@ -205,25 +210,25 @@ public class FileSystemTest
IDirectory inner = innerFile.convertNested();
assertNotNull(inner);
-
- File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
-
+
+ File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
+
// no size information when stream reading :(
runBasicDirTest(inner, "app2.zip/", -1, desiredFile.lastModified());
runBasicDirTest(inner.toCloseable(), "app2.zip/", desiredFile.length(), desiredFile.lastModified());
} finally {
outer.close();
-
+
Field f = outer.getClass().getDeclaredField("tempFile");
-
+
f.setAccessible(true);
assertFalse(((File)f.get(outer)).exists());
}
}
-
+
/**
* Make sure we correctly understand the directory structure for zips.
- *
+ *
* @throws IOException
*/
@Test
@@ -233,16 +238,16 @@ public class FileSystemTest
IDirectory dir = FileSystem.getFSRoot(baseDir);
assertTrue(dir.toString(), dir.toString().endsWith("app2.zip"));
-
+
File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
-
+
runBasicDirTest(dir, desiredFile.length(), desiredFile.lastModified());
runBasicDirTest(dir.toCloseable(), desiredFile.length(), desiredFile.lastModified());
}
-
+
/**
* Make sure we correctly understand the directory structure for zips.
- *
+ *
* @throws IOException
*/
@Test
@@ -253,22 +258,22 @@ public class FileSystemTest
try {
File desiredFile = new File(new File(getTestResourceDir(), "/app1"), "META-INF/APPLICATION.MF");
-
+
runBasicDirTest(dir, desiredFile.length(), desiredFile.lastModified());
runBasicDirTest(dir.toCloseable(), desiredFile.length(), desiredFile.lastModified());
} finally {
dir.close();
}
}
-
+
@Test
public void zipCloseableZipSimplePerformanceTest() throws IOException
{
int N = 100000;
File baseDir = new File("fileSystemTest/app2.zip");
- ZipFile zip = new ZipFile(baseDir);
-
+ ZipFile zip = new ZipFile(baseDir);
+
long start = System.currentTimeMillis();
for (int i=0; i<N; i++) {
ZipEntry ze = zip.getEntry("META-INF/APPLICATION.MF");
@@ -277,9 +282,9 @@ public class FileSystemTest
}
long duration = System.currentTimeMillis() - start;
-
- // normal zip files
-
+
+ // normal zip files
+
ICloseableDirectory dir = FileSystem.getFSRoot(baseDir).toCloseable();
start = System.currentTimeMillis();
@@ -289,18 +294,18 @@ public class FileSystemTest
is.close();
}
long duration2 = System.currentTimeMillis() - start;
-
+
dir.close();
// within an order of magnitude
assertTrue("ZipFile: "+duration+", IDirectory: "+duration2 , duration2 < 10*duration );
-
-
+
+
// nested zip files
-
+
IDirectory outer = FileSystem.getFSRoot(new File("fileSystemTest/outer.zip"));
IFile innerFile = outer.getFile("app2.zip");
dir = innerFile.convertNested().toCloseable();
-
+
start = System.currentTimeMillis();
for (int i=0; i<N; i++) {
IFile appMf = dir.getFile("META-INF/APPLICATION.MF");
@@ -308,17 +313,17 @@ public class FileSystemTest
is.close();
}
long duration3 = System.currentTimeMillis() - start;
-
+
dir.close();
// within an order of magnitude
assertTrue("ZipFile: "+duration+", IDirectory: "+duration3 , duration3 < 10*duration );
-
+
}
-
+
/**
* Zip up the app1 directory to create a zippped version before running any
* tests.
- *
+ *
* @throws IOException
*/
@BeforeClass
@@ -328,28 +333,28 @@ public class FileSystemTest
zipFile.getParentFile().mkdirs();
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
- int index = new File(getTestResourceDir(), "/app1").getAbsolutePath().length();
+ int index = new File(getTestResourceDir(), "/app1").getAbsolutePath().length();
writeEnties(out, new File(getTestResourceDir(), "/app1"), index);
out.close();
-
+
zipFile = new File("outer.zip");
out = new ZipOutputStream(new FileOutputStream(zipFile));
- index = new File("fileSystemTest").getAbsolutePath().length();
+ index = new File("fileSystemTest").getAbsolutePath().length();
writeEnties(out, new File("fileSystemTest"), index);
out.close();
-
+
if (!!!zipFile.renameTo(new File("fileSystemTest/outer.zip"))) throw new IOException("Rename failed");
}
-
+
private static File getTestResourceDir() {
File root = new File("").getAbsoluteFile();
-
+
if (root.getName().equals("target")) return new File("../src/test/resources");
else return new File("src/test/resources");
}
-
+
/**
* Make sure the test zip is deleted afterwards.
*/
@@ -358,12 +363,12 @@ public class FileSystemTest
{
IOUtils.deleteRecursive(new File("fileSystemTest"));
}
-
+
/**
* This method writes the given directory into the provided zip output stream.
* It removes the first <code>index</code> bytes from the absolute path name
* when building the zip.
- *
+ *
* @param zos the zip output stream to use
* @param f the directory to write into the zip.
* @param index how much of the file name to chop off.
@@ -371,21 +376,21 @@ public class FileSystemTest
*/
public static void writeEnties(ZipOutputStream zos, File f, int index) throws IOException {
File[] files = f.listFiles();
-
+
if (files != null) {
for (File file : files) {
String fileName = file.getAbsolutePath().substring(index + 1);
-
+
// Bug 1954: replace any '\' characters with '/' - required by ZipEntry
fileName = fileName.replace('\\', '/');
-
+
if (file.isDirectory()) fileName = fileName + "/";
-
+
ZipEntry ze = new ZipEntry(fileName);
ze.setSize(file.length());
ze.setTime(file.lastModified());
zos.putNextEntry(ze);
-
+
if (file.isFile()) {
InputStream is = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
@@ -395,19 +400,19 @@ public class FileSystemTest
}
zos.closeEntry();
-
+
if (file.isDirectory()) {
writeEnties(zos, file, index);
}
}
}
}
-
+
/**
* This method makes sure that the data is correctly understood from disk. It
* is called for both the file and zip versions of the test to ensure we have
* consistent results.
- *
+ *
* @param dir The IDirectory for the root of the vFS.
* @param len The size of the file.
* @param time The time the file was last updated.
@@ -417,27 +422,27 @@ public class FileSystemTest
{
assertEquals("The root file system name is not correct", "", dir.getName());
assertEquals("The size of the file is not correct", len, dir.getSize());
-
+
// This assertion just isn't working on Hudson as of build #79
// assertEquals("The last modified time of the file is not correct", time, dir.getLastModified());
-
+
assertNull("I managed to get a parent of a root", dir.getParent());
assertTrue("The root dir does not know it is a dir", dir.isDirectory());
assertFalse("The root dir has an identity crisis and thinks it is a file", dir.isFile());
dir.open();
}
-
+
private void runBasicDirTest(IDirectory dir, long len, long time) throws IOException
{
runBasicDirTest(dir, "", len, time);
}
-
+
/**
* This method makes sure that the data is correctly understood from disk. It
* is called for both the file and zip versions of the test to ensure we have
* consistent results.
- *
+ *
* @param dir The IDirectory for the root of the vFS.
* @param len The size of the file.
* @param time The time the file was last updated.
@@ -446,14 +451,14 @@ public class FileSystemTest
private void runBasicDirTest(IDirectory dir, String namePrefix, long len, long time) throws IOException
{
assertNull("for some reason our fake app has a fake blueprint file.", dir.getFile("OSGI-INF/blueprint/aries.xml"));
-
+
IFile file = dir.getFile("META-INF/APPLICATION.MF");
-
+
assertNotNull("we could not find the application manifest", file);
-
+
assertNull(file.convert());
assertNull(file.convertNested());
-
+
assertEquals(namePrefix+"META-INF/APPLICATION.MF", file.getName().replace('\\', '/'));
assertTrue("The last update time is not within 2 seconds of the expected value. Expected: " + time + " Actual: " + file.getLastModified(), Math.abs(time - file.getLastModified()) < 2000);
@@ -461,29 +466,29 @@ public class FileSystemTest
assertEquals(namePrefix+"META-INF", file.getParent().getName());
assertFalse(file.isDirectory());
assertTrue(file.isFile());
-
+
List<IFile> files = dir.listFiles();
filterOutSvn(files);
assertEquals(1, files.size());
List<IFile> allFiles = dir.listAllFiles();
- filterOutSvn(allFiles);
+ filterOutSvn(allFiles);
assertEquals(3, allFiles.size());
-
+
assertEquals(namePrefix+"META-INF", allFiles.get(1).getParent().getName());
-
+
IFile metaInf = files.get(0);
-
+
assertTrue(metaInf.isDirectory());
assertEquals(namePrefix+"META-INF", metaInf.getName());
assertNotNull(metaInf.convert());
-
+
files = metaInf.convert().listAllFiles();
filterOutSvn(files);
- assertEquals(2, files.size());
-
+ assertEquals(2, files.size());
+
for (IFile aFile : dir) {
- if (!aFile.getName().contains(".svn")) {
+ if (!aFile.getName().contains(".svn")) {
assertTrue(aFile.isDirectory());
assertEquals(namePrefix+"META-INF", aFile.getName());
assertNotNull(aFile.convert());
@@ -491,13 +496,13 @@ public class FileSystemTest
}
checkManifest(file.open());
-
+
IFile applicationMF2 = dir.getFile("META-INF/APPLICATION.MF");
-
+
Assert.assertEqualsContract(file, applicationMF2, dir);
Assert.assertHashCodeEquals(file, applicationMF2, true);
}
-
+
private void filterOutSvn(Collection<IFile> files) {
Iterator<IFile> its = files.iterator();
while (its.hasNext()) {
@@ -505,11 +510,11 @@ public class FileSystemTest
if (f.getName().toLowerCase().contains(".svn")) its.remove();
}
}
-
+
private void checkManifest(InputStream is) throws IOException {
Manifest man = new Manifest(is);
//remember to close the input stream after use
is.close();
- assertEquals("com.travel.reservation", man.getMainAttributes().getValue("Application-SymbolicName"));
+ assertEquals("com.travel.reservation", man.getMainAttributes().getValue("Application-SymbolicName"));
}
}
Modified: aries/trunk/util/util/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/util/util/pom.xml?rev=1205919&r1=1205918&r2=1205919&view=diff
==============================================================================
--- aries/trunk/util/util/pom.xml (original)
+++ aries/trunk/util/util/pom.xml Thu Nov 24 16:35:12 2011
@@ -89,16 +89,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.aries.testsupport</groupId>
<artifactId>org.apache.aries.testsupport.unit</artifactId>
<version>0.4</version>