ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1500605 - in /ace/trunk/org.apache.ace.obr: src/org/apache/ace/obr/storage/file/BundleFileStore.java test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java
Date Mon, 08 Jul 2013 08:36:03 GMT
Author: bramk
Date: Mon Jul  8 08:36:03 2013
New Revision: 1500605

URL: http://svn.apache.org/r1500605
Log:
Fixed itest npe failures introduced in r1498701

Modified:
    ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
    ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java

Modified: ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java?rev=1500605&r1=1500604&r2=1500605&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
(original)
+++ ace/trunk/org.apache.ace.obr/src/org/apache/ace/obr/storage/file/BundleFileStore.java
Mon Jul  8 08:36:03 2013
@@ -89,6 +89,8 @@ public class BundleFileStore implements 
 
     public String put(InputStream data, String fileName) throws IOException {
 
+        if(fileName == null)
+            fileName = "";
         File tempFile = downloadToTempFile(data);
 
         ResourceMetaData metaData = ResourceMetaData.getBundleMetaData(tempFile);
@@ -101,10 +103,10 @@ public class BundleFileStore implements 
 
         File storeLocation = getResourceFile(metaData);
         if (storeLocation == null) {
-            throw new IOException("Failed to store resource (filename = " + fileName + ")");
+            throw new IOException("Failed to store resource (filename = " +  fileName  +
")");
         }
         if (storeLocation.exists()) {
-            m_log.log(LogService.LOG_ERROR, "Resource already existed in OBR (filename =
" + fileName + ")");
+            m_log.log(LogService.LOG_ERROR, "Resource already existed in OBR (filename =
" +  fileName  + ")");
             return null;
         }
 

Modified: ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java?rev=1500605&r1=1500604&r2=1500605&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java
(original)
+++ ace/trunk/org.apache.ace.obr/test/org/apache/ace/obr/storage/file/BundleFileStoreTest.java
Mon Jul  8 08:36:03 2013
@@ -39,6 +39,7 @@ import org.apache.ace.test.utils.FileUti
 import org.apache.ace.test.utils.TestUtils;
 import org.osgi.framework.Constants;
 import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.log.LogService;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -67,6 +68,9 @@ public class BundleFileStoreTest {
         props.put(OBRFileStoreConstants.FILE_LOCATION_KEY, m_directory.getAbsolutePath());
         m_bundleStore.updated(props);
 
+        // set a null object on for log
+        TestUtils.configureObject(m_bundleStore, LogService.class);
+
         // create a mock MetadataGenerator
         m_metadata = new MockMetadataGenerator();
         TestUtils.configureObject(m_bundleStore, MetadataGenerator.class, m_metadata);
@@ -258,7 +262,7 @@ public class BundleFileStoreTest {
         assert filePath2 == null;
     }
 
-    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found")
+    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found.*")
     public void putBundleFail() throws Exception {
         File bundle = createTmpResource(null, "1.0.0");
         String filePath = m_bundleStore.put(new FileInputStream(bundle), null);
@@ -294,13 +298,13 @@ public class BundleFileStoreTest {
         assert file.exists();
     }
 
-    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found")
+    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found.*")
     public void putArtifactFail1() throws Exception {
         File bundle = createTmpResource(null, null);
         m_bundleStore.put(new FileInputStream(bundle), null);
     }
 
-    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found")
+    @Test(groups = { UNIT }, expectedExceptions = { IOException.class }, expectedExceptionsMessageRegExp
= "Not a valid bundle and no filename found.*")
     public void putArtifactFail2() throws Exception {
         File bundle = createTmpResource(null, null);
         m_bundleStore.put(new FileInputStream(bundle), "");



Mime
View raw message