Author: tolusha
Date: 2010-06-14 05:00:21 -0400 (Mon, 14 Jun 2010)
New Revision: 2566
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java
Log:
EXOJCR-756: replace file operations on privileged file operations
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -203,7 +203,7 @@
final File temp;
try
{
- temp = File.createTempFile("extractor", null);
+ temp = PrivilegedFileHelper.createTempFile("extractor", null);
}
catch (IOException e)
{
@@ -221,7 +221,7 @@
// should never happend actually
if (!temp.delete())
{
- temp.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(temp);
}
return r;
}
@@ -250,7 +250,7 @@
// delete file
if (!temp.delete())
{
- temp.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(temp);
}
}
};
@@ -265,7 +265,7 @@
if (!temp.delete())
{
- temp.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(temp);
}
// use empty string reader as fallback
return new StringReader("");
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -104,7 +104,7 @@
*/
public long getLength()
{
- return file.length();
+ return PrivilegedFileHelper.length(file);
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -2389,7 +2389,7 @@
swapFile.spoolDone();
}
- long vlen = swapFile.length();
+ long vlen = PrivilegedFileHelper.length(swapFile);
if (vlen <= Integer.MAX_VALUE)
{
streamLength = (int)vlen;
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -82,7 +82,7 @@
{
public Object run() throws Exception
{
- long fileSize = file.length();
+ long fileSize = PrivilegedFileHelper.length(file);
if (fileSize > maxBufferSize)
{
@@ -251,7 +251,8 @@
+ tempFile.getAbsolutePath() + ". Destination:
" + file.getAbsolutePath());
}
- copyClose(PrivilegedFileHelper.fileInputStream(tempFile),
PrivilegedFileHelper.fileOutputStream(file));
+ copyClose(PrivilegedFileHelper.fileInputStream(tempFile),
PrivilegedFileHelper
+ .fileOutputStream(file));
}
}
else
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -34,7 +34,7 @@
* For use in TransienValueData (may be shared in the Workspace cache with another
Sessions). Spool
* files used in ValueData for incoming values managed by SpoolFile class. Spool file may
be created
* with constructor or be obtained from static method createTempFile(String, String,
File), which
- * itself create physical file using File.createTempFile(prefix, suffix, directory) call.
Spool file
+ * itself create physical file using PrivilegedFileHelper.createTempFile(prefix, suffix,
directory) call. Spool file
* may be acquired for usage by any object (SpoolFile.acquire(Object)). Till this object
will call
* release (SpoolFile.release(Object)) or will be garbage collected it's impossible
to delete the
* spool file (by File.delete() method).
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -177,8 +177,8 @@
private void swapBuffers() throws IOException
{
byte[] data = ((ByteArrayOutputStream)out).toByteArray();
- fileBuffer = File.createTempFile("decoderBuffer", ".tmp");
- fileBuffer.deleteOnExit();
+ fileBuffer = PrivilegedFileHelper.createTempFile("decoderBuffer",
".tmp");
+ PrivilegedFileHelper.deleteOnExit(fileBuffer);
out = new BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(fileBuffer),
bufferSize);
out.write(data);
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -159,7 +159,7 @@
+ " in the user directory, we will try to create it in the temp
directory", e);
try
{
- file = File.createTempFile("Statistics" + category, "-" +
System.currentTimeMillis() + ".csv");
+ file = PrivilegedFileHelper.createTempFile("Statistics" + category,
"-" + System.currentTimeMillis() + ".csv");
pw = new PrintWriter(file);
}
catch (IOException e1)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -182,8 +182,8 @@
}
session.save();
- File destFile = File.createTempFile("multyValueExportStream",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("multyValueExportStream",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportDocumentView(testNode.getPath(), outStream, false, false);
outStream.close();
@@ -253,8 +253,8 @@
}
session.save();
- File destFile = File.createTempFile("multyValueExportStream",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("multyValueExportStream",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
SAXTransformerFactory saxFact =
(SAXTransformerFactory)SAXTransformerFactory.newInstance();
@@ -333,8 +333,8 @@
session.save();
testNode.lock(true, true);
- File destFile = File.createTempFile("docLockNodeExport",
".xml");
- destFile.deleteOnExit();
+ File destFile = PrivilegedFileHelper.createTempFile("docLockNodeExport",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportDocumentView(firstNode.getPath(), outStream, false, false);
@@ -354,9 +354,9 @@
{
Session newSession = repository.login(this.credentials /*
- *
session.getCredentials
- * ()
- */);
+
* session.getCredentials
+
* ()
+
*/);
newSession.setNamespacePrefix("newjcr",
"http://www.jcp.org/jcr/1.0");
@@ -383,9 +383,9 @@
{
Session newSession = repository.login(this.credentials /*
- *
session.getCredentials
- * ()
- */);
+
* session.getCredentials
+
* ()
+
*/);
newSession.setNamespacePrefix("newjcr",
"http://www.jcp.org/jcr/1.0");
Node testNode =
newSession.getRootNode().addNode("jcr:testExportNamespaceRemaping");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -64,8 +64,8 @@
testNode.setProperty("prop" + i + "_binary", valList.get(i),
PropertyType.BINARY);
}
session.save();
- File destFile =
File.createTempFile("testWorkspaceExportImportValuesSysView",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("testWorkspaceExportImportValuesSysView",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportWorkspaceSystemView(outStream, false, false);
outStream.close();
@@ -73,7 +73,8 @@
testNode.remove();
session.save();
- session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
+ ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -117,8 +118,8 @@
session.save();
- File destFile = File.createTempFile("testExportImportValuesSysView",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("testExportImportValuesSysView",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(file.getPath(), outStream, false, false);
outStream.close();
@@ -126,7 +127,8 @@
folder.remove();
session.save();
- session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
+ ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -141,8 +143,8 @@
testNode.setProperty("prop" + i + "_binary", valList.get(i),
PropertyType.BINARY);
}
session.save();
- File destFile = File.createTempFile("testExportImportValuesSysView",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("testExportImportValuesSysView",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(testNode.getPath(), outStream, false, false);
outStream.close();
@@ -150,7 +152,8 @@
testNode.remove();
session.save();
- session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
+ ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -356,8 +359,8 @@
Node destParentNode) throws RepositoryException, IOException,
TransformerConfigurationException, SAXException
{
Node exportNode = parentNode.getNode(nodeName);
- File destFile = File.createTempFile("testExportImport",
".xml");
- destFile.deleteOnExit();
+ File destFile = PrivilegedFileHelper.createTempFile("testExportImport",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
if (isSystemView)
@@ -396,8 +399,8 @@
session.save();
}
- session.importXML(destParentNode != null ? destParentNode.getPath() :
root.getPath(), PrivilegedFileHelper.fileInputStream(
- destFile), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ session.importXML(destParentNode != null ? destParentNode.getPath() :
root.getPath(), PrivilegedFileHelper
+ .fileInputStream(destFile), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
session.save();
assertTrue(parentNode.hasNode(nodeName));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -168,8 +168,8 @@
Node testNode = root.addNode("refNode");
testNode.addMixin("mix:referenceable");
session.save();
- File destFile = File.createTempFile("testExportReferenceableNodes",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("testExportReferenceableNodes",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(testNode.getPath(), outStream, false, false);
outStream.close();
@@ -217,8 +217,8 @@
session.save();
testNode.lock(true, true);
- File destFile = File.createTempFile("sysLockNodeExport",
".xml");
- destFile.deleteOnExit();
+ File destFile = PrivilegedFileHelper.createTempFile("sysLockNodeExport",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(firstNode.getPath(), outStream, false, false);
@@ -253,7 +253,7 @@
}
session.save();
- File destFile = File.createTempFile("xmlTest", ".xml");
+ File destFile = PrivilegedFileHelper.createTempFile("xmlTest",
".xml");
OutputStream outputStream2 = PrivilegedFileHelper.fileOutputStream(destFile);
SAXTransformerFactory saxFact =
(SAXTransformerFactory)TransformerFactory.newInstance();
@@ -313,8 +313,8 @@
}
session.save();
- File destFile = File.createTempFile("sysMultyValueExportStream",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("sysMultyValueExportStream",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(testNode.getPath(), outStream, false, false);
outStream.close();
@@ -367,8 +367,8 @@
}
session.save();
- File destFile = File.createTempFile("multyValueExportStreamSkipBinary",
".xml");
- destFile.deleteOnExit();
+ File destFile =
PrivilegedFileHelper.createTempFile("multyValueExportStreamSkipBinary",
".xml");
+ PrivilegedFileHelper.deleteOnExit(destFile);
OutputStream outStream = PrivilegedFileHelper.fileOutputStream(destFile);
session.exportSystemView(testNode.getPath(), outStream, true, false);
outStream.close();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -109,8 +109,8 @@
assertTrue(accessManager.hasPermission(testRoot.getACL(),
PermissionType.SET_PROPERTY, new Identity("exo")));
assertFalse(accessManager.hasPermission(testRoot.getACL(), PermissionType.READ, new
Identity("exo")));
- File tmp = File.createTempFile("testAclImpormt", "tmp");
- tmp.deleteOnExit();
+ File tmp = PrivilegedFileHelper.createTempFile("testAclImpormt",
"tmp");
+ PrivilegedFileHelper.deleteOnExit(tmp);
serialize(testRoot, false, true, tmp);
testRoot.remove();
session.save();
@@ -154,8 +154,8 @@
assertTrue(accessManager.hasPermission(testRoot.getACL(),
PermissionType.SET_PROPERTY, new Identity("exo")));
assertFalse(accessManager.hasPermission(testRoot.getACL(), PermissionType.READ, new
Identity("exo")));
- File tmp = File.createTempFile("testAclImpormt", "tmp");
- tmp.deleteOnExit();
+ File tmp = PrivilegedFileHelper.createTempFile("testAclImpormt",
"tmp");
+ PrivilegedFileHelper.deleteOnExit(tmp);
serialize(testRoot, true, true, tmp);
testRoot.remove();
session.save();
@@ -495,10 +495,10 @@
}
String versionHistory = testRoot.getVersionHistory().getUUID();
- File versionableNodeContent =
File.createTempFile("versionableNodeContent", "tmp");
- File vhNodeContent = File.createTempFile("vhNodeContent",
"tmp");
- versionableNodeContent.deleteOnExit();
- vhNodeContent.deleteOnExit();
+ File versionableNodeContent =
PrivilegedFileHelper.createTempFile("versionableNodeContent", "tmp");
+ File vhNodeContent = PrivilegedFileHelper.createTempFile("vhNodeContent",
"tmp");
+ PrivilegedFileHelper.deleteOnExit(versionableNodeContent);
+ PrivilegedFileHelper.deleteOnExit(vhNodeContent);
serialize(testRoot, false, true, versionableNodeContent);
serialize(testRoot.getVersionHistory(), false, true, vhNodeContent);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -251,7 +251,7 @@
// export
- File tmp = File.createTempFile("__exojcr_TestSysView__",
".tmp");
+ File tmp = PrivilegedFileHelper.createTempFile("__exojcr_TestSysView__",
".tmp");
OutputStream xmlOut = PrivilegedFileHelper.fileOutputStream(tmp);
sysview.getSession().exportSystemView(ref.getPath(), xmlOut, false, false);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -113,7 +113,7 @@
// create test file
byte[] data = new byte[1024]; // 1Kb
- File testFile = File.createTempFile(prefix, ".tmp");
+ File testFile = PrivilegedFileHelper.createTempFile(prefix, ".tmp");
FileOutputStream tempOut = PrivilegedFileHelper.fileOutputStream(testFile);
Random random = new Random();
@@ -123,7 +123,7 @@
tempOut.write(data);
}
tempOut.close();
- testFile.deleteOnExit(); // delete on test exit
+ PrivilegedFileHelper.deleteOnExit(testFile);
return testFile;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -143,8 +143,8 @@
ses.save();
// Cereate backup
- File backup = File.createTempFile("full-backup", ".xml");
- backup.deleteOnExit();
+ File backup = PrivilegedFileHelper.createTempFile("full-backup",
".xml");
+ PrivilegedFileHelper.deleteOnExit(backup);
ses.exportWorkspaceSystemView(PrivilegedFileHelper.fileOutputStream(backup), false,
false);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.ConfigurationHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -139,8 +140,8 @@
public void testAddWorkspaceWithIvalidVs() throws RepositoryConfigurationException,
Exception
{
- File file = File.createTempFile("test", ".dat");
- file.deleteOnExit();
+ File file = PrivilegedFileHelper.createTempFile("test",
".dat");
+ PrivilegedFileHelper.deleteOnExit(file);
WorkspaceEntry workspaceEntry =
helper.getNewWs("WsInvalidVs", isDefaultWsMultiDb,
wsEntry.getContainer().getParameterValue(
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -68,8 +68,8 @@
node1.setProperty("p1", 2);
defSession.save();
- File content = File.createTempFile("data", ".xml");
- content.deleteOnExit();
+ File content = PrivilegedFileHelper.createTempFile("data",
".xml");
+ PrivilegedFileHelper.deleteOnExit(content);
OutputStream os = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(content));
defSession.exportSystemView(defRoot.getPath(), os, false, false);
os.close();
@@ -86,7 +86,8 @@
defRep = (RepositoryImpl)service.getDefaultRepository();
defRep.configWorkspace(workspaceEntry);
- defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(content)));
+ defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper
+ .fileInputStream(content)));
doTestOnWorkspace(workspaceEntry.getName());
}
@@ -136,8 +137,8 @@
node1.setProperty("p1", 2);
defSession.save();
- File content = File.createTempFile("data", ".xml");
- content.deleteOnExit();
+ File content = PrivilegedFileHelper.createTempFile("data",
".xml");
+ PrivilegedFileHelper.deleteOnExit(content);
OutputStream os = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(content));
defSession.exportSystemView(node1.getPath(), os, false, false);
os.close();
@@ -156,7 +157,8 @@
try
{
- defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(content)));
+ defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper
+ .fileInputStream(content)));
fail();
}
catch (RepositoryException e)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -19,6 +19,7 @@
import org.exoplatform.services.jcr.impl.core.query.BaseQueryTest;
import org.exoplatform.services.jcr.impl.core.query.ErrorLog;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.util.HashSet;
@@ -31,132 +32,158 @@
*
* @version $Id: $
*/
-public class TestErrorLog extends BaseQueryTest {
- ErrorLog log;
+public class TestErrorLog extends BaseQueryTest
+{
+ ErrorLog log;
- File file;
+ File file;
- private static final int SIZE = 100;
+ private static final int SIZE = 100;
- public void setUp() throws Exception {
- super.setUp();
- file = File.createTempFile("error", "log");
- if (file.exists()) {
- file.delete();
- }
- }
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ file = PrivilegedFileHelper.createTempFile("error", "log");
+ if (file.exists())
+ {
+ file.delete();
+ }
+ }
- public void tearDown() throws Exception {
- super.tearDown();
- log.clear();
- file.delete();
- }
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ log.clear();
+ file.delete();
+ }
- public void testConcurrentWrite() throws Exception {
+ public void testConcurrentWrite() throws Exception
+ {
- class Loader extends Thread {
- private String name;
+ class Loader extends Thread
+ {
+ private String name;
- public Loader(String n) {
- name = n;
- }
+ public Loader(String n)
+ {
+ name = n;
+ }
- public void run() {
- /*
- * try { for (int i = 0; i < SIZE; i++) {
- * log.append(ErrorLog.ADD,name + i); //System.out.println(name
- * + i); } log.flush(); } catch (Exception e) {
- * System.out.println(e); }
- */
+ @Override
+ public void run()
+ {
+ /*
+ * try { for (int i = 0; i < SIZE; i++) {
+ * log.append(ErrorLog.ADD,name + i); //System.out.println(name
+ * + i); } log.flush(); } catch (Exception e) {
+ * System.out.println(e); }
+ */
- try {
- HashSet<String> add = new HashSet<String>();
- HashSet<String> rem = new HashSet<String>();
+ try
+ {
+ HashSet<String> add = new HashSet<String>();
+ HashSet<String> rem = new HashSet<String>();
- for (int j = 0; j < 10; j++) {
- add.clear();
- for (int i = 0; i < 10; i++) {
- int el = j * 10 + i;
- add.add(name + el);
- }
- log.writeChanges(rem, add);
- }
+ for (int j = 0; j < 10; j++)
+ {
+ add.clear();
+ for (int i = 0; i < 10; i++)
+ {
+ int el = j * 10 + i;
+ add.add(name + el);
+ }
+ log.writeChanges(rem, add);
+ }
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
+ }
+ catch (Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+ }
- log = new ErrorLog(file, SearchIndex.DEFAULT_ERRORLOG_FILE_SIZE);
+ log = new ErrorLog(file, SearchIndex.DEFAULT_ERRORLOG_FILE_SIZE);
- Thread one = new Loader("first");
- Thread two = new Loader("second");
- one.start();
- two.start();
- one.join();
- two.join();
+ Thread one = new Loader("first");
+ Thread two = new Loader("second");
+ one.start();
+ two.start();
+ one.join();
+ two.join();
- List<String> list = log.readList();
+ List<String> list = log.readList();
- int lost_first = 0;
- int lost_second = 0;
- for (int i = 0; i < SIZE; i++) {
- String firstname = ErrorLog.ADD + " first" + i;
- String secondname = ErrorLog.ADD + " second" + i;
- int ffinded = 0;
- int sfinded = 0;
- for (int j = 0; j < list.size(); j++) {
- if (list.get(j).equals(firstname)) {
- ffinded++;
- }
- if (list.get(j).equals(secondname)) {
- sfinded++;
- }
- }
- if (ffinded == 0) {
- System.out.println(firstname + " NOT FINDED");
- }
- if (ffinded > 1) {
- System.out.println(firstname + " DUPLICATED");
- }
- if (sfinded == 0) {
- System.out.println(secondname + " NOT FINDED");
- }
- if (sfinded > 1) {
- System.out.println(secondname + " DUPLICATED");
- }
- }
+ int lost_first = 0;
+ int lost_second = 0;
+ for (int i = 0; i < SIZE; i++)
+ {
+ String firstname = ErrorLog.ADD + " first" + i;
+ String secondname = ErrorLog.ADD + " second" + i;
+ int ffinded = 0;
+ int sfinded = 0;
+ for (int j = 0; j < list.size(); j++)
+ {
+ if (list.get(j).equals(firstname))
+ {
+ ffinded++;
+ }
+ if (list.get(j).equals(secondname))
+ {
+ sfinded++;
+ }
+ }
+ if (ffinded == 0)
+ {
+ System.out.println(firstname + " NOT FINDED");
+ }
+ if (ffinded > 1)
+ {
+ System.out.println(firstname + " DUPLICATED");
+ }
+ if (sfinded == 0)
+ {
+ System.out.println(secondname + " NOT FINDED");
+ }
+ if (sfinded > 1)
+ {
+ System.out.println(secondname + " DUPLICATED");
+ }
+ }
- assertEquals("There is mismatch of expected writed messages count ",
- 200, list.size());
- assertEquals("First thread has lost apdates", 0, lost_first);
- assertEquals("Second thread has lost apdates", 0, lost_second);
- }
+ assertEquals("There is mismatch of expected writed messages count ", 200,
list.size());
+ assertEquals("First thread has lost apdates", 0, lost_first);
+ assertEquals("Second thread has lost apdates", 0, lost_second);
+ }
- public void testExctractNotifyList() throws Exception {
- log = new ErrorLog(file, SearchIndex.DEFAULT_ERRORLOG_FILE_SIZE);
+ public void testExctractNotifyList() throws Exception
+ {
+ log = new ErrorLog(file, SearchIndex.DEFAULT_ERRORLOG_FILE_SIZE);
- Set<String> removed = new HashSet<String>();
- Set<String> added = new HashSet<String>();
+ Set<String> removed = new HashSet<String>();
+ Set<String> added = new HashSet<String>();
- for (int i = 0; i < 10; i++) {
- added.add("uuidadd" + i);
- }
+ for (int i = 0; i < 10; i++)
+ {
+ added.add("uuidadd" + i);
+ }
- for (int i = 0; i < 5; i++) {
- removed.add("uuidrem" + i);
- }
+ for (int i = 0; i < 5; i++)
+ {
+ removed.add("uuidrem" + i);
+ }
- log.writeChanges(removed, added);
+ log.writeChanges(removed, added);
- Set<String> rem = new HashSet<String>();
- Set<String> add = new HashSet<String>();
+ Set<String> rem = new HashSet<String>();
+ Set<String> add = new HashSet<String>();
- log.readChanges(rem, add);
+ log.readChanges(rem, add);
- assertTrue(rem.containsAll(removed));
- assertTrue(add.containsAll(added));
- }
+ assertTrue(rem.containsAll(removed));
+ assertTrue(add.containsAll(added));
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -54,7 +54,7 @@
@Override
public void setUp() throws Exception
{
- test_mapp = File.createTempFile("temp", "mapping");
+ test_mapp = PrivilegedFileHelper.createTempFile("temp",
"mapping");
// Fill the namespace mappings file by prefix uri pairs
@@ -73,7 +73,7 @@
props.store(PrivilegedFileHelper.fileOutputStream(test_mapp), "");
props.clear();
- test_mapp.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(test_mapp);
}
@Override
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -49,8 +49,8 @@
// Create ValueData instants
ByteArrayPersistedValueData vd = new ByteArrayPersistedValueData(11, buf);
- File out = File.createTempFile("test", ".data");
- out.deleteOnExit();
+ File out = PrivilegedFileHelper.createTempFile("test",
".data");
+ PrivilegedFileHelper.deleteOnExit(out);
//serialize
ObjectOutputStream oos = new
ObjectOutputStream(PrivilegedFileHelper.fileOutputStream(out));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -68,7 +68,7 @@
long jcrwrite = 0;
long jcrread = 0;
- File jcrfile = File.createTempFile("jcr", "test");
+ File jcrfile = PrivilegedFileHelper.createTempFile("jcr",
"test");
ObjectWriterImpl jcrout = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(jcrfile));
System.out.println(" WRITE START");
@@ -108,7 +108,7 @@
long javaWrite = 0;
long javaRead = 0;
- File jfile = File.createTempFile("java", "test");
+ File jfile = PrivilegedFileHelper.createTempFile("java",
"test");
ObjectOutputStream jout = new
ObjectOutputStream(PrivilegedFileHelper.fileOutputStream(jfile));
it = logs.iterator();
@@ -137,7 +137,7 @@
System.out.println(" JCR s- " + (jcrwrite));
// System.out.println(" Java s- " + (javaWrite));
- System.out.println(" JCR file size - " + jcrfile.length());
+ System.out.println(" JCR file size - " +
PrivilegedFileHelper.length(jcrfile));
// System.out.println(" Java file size - " + jfile.length());
System.out.println(" JCR des- " + (jcrread));
// System.out.println(" Java des- " + (javaRead));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -75,7 +75,7 @@
it = list.iterator();
- File jcrfile = File.createTempFile("jcr", "test");
+ File jcrfile = PrivilegedFileHelper.createTempFile("jcr",
"test");
ObjectWriterImpl jcrout = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(jcrfile));
long t1 = System.currentTimeMillis();
@@ -112,7 +112,7 @@
long javaRead = 0;
for (int j = 0; j < iterations; j++)
{
- File jfile = File.createTempFile("java", "test");
+ File jfile = PrivilegedFileHelper.createTempFile("java",
"test");
ObjectOutputStream jout = new
ObjectOutputStream(PrivilegedFileHelper.fileOutputStream(jfile));
it = list.iterator();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -104,7 +104,7 @@
protected File serializeLogs(List<TransactionChangesLog> logs) throws
IOException, UnknownClassIdException
{
- File jcrfile = File.createTempFile("jcr", "test");
+ File jcrfile = PrivilegedFileHelper.createTempFile("jcr",
"test");
ObjectWriterImpl jcrout = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(jcrfile));
TransactionChangesLogWriter wr = new TransactionChangesLogWriter();
@@ -184,8 +184,8 @@
}
else
{
- File file = File.createTempFile("tempFile",
"tmp");
- file.deleteOnExit();
+ File file =
PrivilegedFileHelper.createTempFile("tempFile", "tmp");
+ PrivilegedFileHelper.deleteOnExit(file);
copy(((StreamPersistedValueData)valueData).getStream(),
PrivilegedFileHelper
.fileOutputStream(file));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -126,7 +126,7 @@
root.save();
// Serialize with JCR
- File jcrfile = File.createTempFile("jcr", "test");
+ File jcrfile = PrivilegedFileHelper.createTempFile("jcr",
"test");
ObjectWriterImpl jcrout = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(jcrfile));
TransactionChangesLog l = pl.pushChanges().get(0);
TransactionChangesLogWriter wr = new TransactionChangesLogWriter();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -42,7 +42,7 @@
{
final byte[] buffer = createBLOBTempData(45);
- File test = File.createTempFile("testEOF", "");
+ File test = PrivilegedFileHelper.createTempFile("testEOF",
"");
ObjectWriter ow = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(test));
ow.write(buffer);
@@ -72,7 +72,7 @@
public void testReadBoolean() throws Exception
{
- File test = File.createTempFile("testEOF", "");
+ File test = PrivilegedFileHelper.createTempFile("testEOF",
"");
ObjectWriter ow = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(test));
ow.writeBoolean(true);
@@ -101,7 +101,7 @@
public void testReadInt() throws Exception
{
- File test = File.createTempFile("testEOF", "");
+ File test = PrivilegedFileHelper.createTempFile("testEOF",
"");
ObjectWriter ow = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(test));
ow.writeInt(24);
@@ -131,7 +131,7 @@
public void testReadLong() throws Exception
{
- File test = File.createTempFile("testEOF", "");
+ File test = PrivilegedFileHelper.createTempFile("testEOF",
"");
ObjectWriter ow = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(test));
ow.writeLong(24);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -121,9 +121,9 @@
TesterItemsPersistenceListener pl = new
TesterItemsPersistenceListener(this.session);
File tempFile = this.createBLOBTempFile(160);
- tempFile.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(tempFile);
- log.info("MOVE: file size = " + tempFile.length() + " bytes");
+ log.info("MOVE: file size = " + PrivilegedFileHelper.length(tempFile) +
" bytes");
Node file = root.addNode("testMove_",
"nt:folder").addNode("childNode2", "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -91,12 +91,12 @@
{
TesterItemsPersistenceListener pl = new
TesterItemsPersistenceListener(this.session);
- File tempFile = File.createTempFile("tempFile", "doc");
- File tempFile2 = File.createTempFile("tempFile", "doc");
- File tempFile3 = File.createTempFile("tempFile", "doc");
- tempFile.deleteOnExit();
- tempFile2.deleteOnExit();
- tempFile3.deleteOnExit();
+ File tempFile = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ File tempFile2 = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ File tempFile3 = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ PrivilegedFileHelper.deleteOnExit(tempFile);
+ PrivilegedFileHelper.deleteOnExit(tempFile2);
+ PrivilegedFileHelper.deleteOnExit(tempFile3);
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(tempFile);
FileOutputStream fos2 = PrivilegedFileHelper.fileOutputStream(tempFile2);
@@ -117,9 +117,9 @@
fos2.close();
fos3.close();
- log.info("FILE for VERVION #1 : file size = " + tempFile.length() +
" bytes");
- log.info("FILE for VERVION #2 : file size = " + tempFile2.length() +
" bytes");
- log.info("FILE for VERVION #3 : file size = " + tempFile3.length() +
" bytes");
+ log.info("FILE for VERVION #1 : file size = " +
PrivilegedFileHelper.length(tempFile) + " bytes");
+ log.info("FILE for VERVION #2 : file size = " +
PrivilegedFileHelper.length(tempFile2) + " bytes");
+ log.info("FILE for VERVION #3 : file size = " +
PrivilegedFileHelper.length(tempFile3) + " bytes");
Node srcVersionNode = root.addNode("nt_file_node", "nt:file");
Node contentNode = srcVersionNode.addNode("jcr:content",
"nt:resource");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -195,8 +195,8 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(blobFiles.get(j))),
content.getProperty(
- "jcr:data").getStream());
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(blobFiles.get(j))), content
+ .getProperty("jcr:data").getStream());
}
n1.remove();
currenSession.save();
@@ -229,7 +229,7 @@
// create test file
byte[] data = new byte[1024]; // 1Kb
- File testFile = File.createTempFile(IdGenerator.generate(), ".tmp");
+ File testFile = PrivilegedFileHelper.createTempFile(IdGenerator.generate(),
".tmp");
FileOutputStream tempOut = PrivilegedFileHelper.fileOutputStream(testFile);
Random random = new Random();
@@ -246,8 +246,8 @@
tempOut.write(data);
}
tempOut.close();
- testFile.deleteOnExit(); // delete on test exit
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + testFile.length());
+ PrivilegedFileHelper.deleteOnExit(testFile);
+ log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
return testFile;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -62,7 +62,7 @@
if (testFile == null)
{
testFile = createBLOBTempFile(this.getClass().getSimpleName() + "_", 2
* 1024); // 2M
- testFile.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(testFile);
}
root.getNodes();
@@ -425,7 +425,7 @@
// test after save
// first 2M of stream data must be same as on setProperty()
compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, 0,
- testFile.length());
+ PrivilegedFileHelper.length(testFile));
compareStream(new ByteArrayInputStream(update1String.getBytes()),
testRoot.getProperty(pname).getStream(), 0,
pos, update1String.length());
@@ -452,15 +452,15 @@
long fmem = Runtime.getRuntime().freeMemory();
- exv.update(PrivilegedFileHelper.fileInputStream(testFile), testFile.length(),
pos);
+ exv.update(PrivilegedFileHelper.fileInputStream(testFile),
PrivilegedFileHelper.length(testFile), pos);
long fmemAfter = Runtime.getRuntime().freeMemory();
- if ((fmemAfter - fmem) >= (pos + testFile.length()))
+ if ((fmemAfter - fmem) >= (pos + PrivilegedFileHelper.length(testFile)))
log.warn("Free memory must not be increased on value of the new Value size
but does. Was " + fmem
+ " current " + fmemAfter);
- assertEquals("Value data length must be increased ", pos +
testFile.length(), exv.getLength());
+ assertEquals("Value data length must be increased ", pos +
PrivilegedFileHelper.length(testFile), exv.getLength());
// apply to the Property and save
p.setValue(exv);
@@ -468,11 +468,12 @@
EditableBinaryValue newexv =
(EditableBinaryValue)testRoot.getProperty(pname).getValue();
- assertEquals("Value data length must be increased ", pos +
testFile.length(), newexv.getLength());
+ assertEquals("Value data length must be increased ", pos +
PrivilegedFileHelper.length(testFile), newexv
+ .getLength());
// update inside the big data
int npos = 5;
- newexv.update(PrivilegedFileHelper.fileInputStream(testFile), testFile.length(),
npos);
+ newexv.update(PrivilegedFileHelper.fileInputStream(testFile),
PrivilegedFileHelper.length(testFile), npos);
// apply to the Property and save
p.setValue(newexv);
@@ -484,7 +485,7 @@
assertEquals("Value content is wrong ", content.substring(0, npos), new
String(buff));
compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, npos,
- testFile.length());
+ PrivilegedFileHelper.length(testFile));
}
public void testAddLength_BigValue() throws Exception
@@ -628,7 +629,7 @@
Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
- long pos = exv.getLength() - (testFile.length() - 20);
+ long pos = exv.getLength() - (PrivilegedFileHelper.length(testFile) - 20);
exv.setLength(pos);
@@ -784,7 +785,7 @@
String update1String = "update#1";
- long pos = testFile.length();
+ long pos = PrivilegedFileHelper.length(testFile);
exv.update(new ByteArrayInputStream(update1String.getBytes()),
update1String.length(), pos);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -123,7 +123,8 @@
assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
InputStream etalon, tested;
- compareStream(etalon = PrivilegedFileHelper.fileInputStream(testFile), tested =
PrivilegedFileHelper.fileInputStream(vsfile));
+ compareStream(etalon = PrivilegedFileHelper.fileInputStream(testFile), tested =
+ PrivilegedFileHelper.fileInputStream(vsfile));
etalon.close();
tested.close();
}
@@ -152,7 +153,8 @@
try
{
fch = openCASChannel(digestType);
- fch.write(new String(propertyId), new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile)));
+ fch.write(new String(propertyId), new StreamPersistedValueData(0,
PrivilegedFileHelper
+ .fileInputStream(testFile)));
fch.commit();
fail("RecordAlreadyExistsException should be thrown, record exists");
@@ -326,8 +328,8 @@
CASableIOSupport.HASHFILE_ORDERNUMBER));
assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
- assertEquals("Storage size must be increased on size of ONE file ",
initialSize + testFile.length(),
- calcDirSize(rootDir));
+ assertEquals("Storage size must be increased on size of ONE file ",
initialSize
+ + PrivilegedFileHelper.length(testFile), calcDirSize(rootDir));
}
/**
@@ -347,7 +349,7 @@
for (int i = 0; i < 20; i++)
{
File f = createBLOBTempFile(300);
- addedSize += f.length();
+ addedSize += PrivilegedFileHelper.length(f);
fch.write(propertyId, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
}
fch.commit();
@@ -382,8 +384,8 @@
fch.commit();
}
- assertEquals("Storage size must be increased on size of ONE file ",
initialSize + testFile.length(),
- calcDirSize(rootDir));
+ assertEquals("Storage size must be increased on size of ONE file ",
initialSize
+ + PrivilegedFileHelper.length(testFile), calcDirSize(rootDir));
}
/**
@@ -404,7 +406,7 @@
propertyId = IdGenerator.generate();
File f = createBLOBTempFile(300);
- addedSize += f.length();
+ addedSize += PrivilegedFileHelper.length(f);
FileIOChannel fch = openCASChannel(digestType);
fch.write(propertyId, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
@@ -446,8 +448,8 @@
fch.delete(propertyId);
fch.commit();
- assertEquals("Storage size must be unchanged after the delete ",
initialSize + testFile.length(),
- calcDirSize(rootDir));
+ assertEquals("Storage size must be unchanged after the delete ",
initialSize
+ + PrivilegedFileHelper.length(testFile), calcDirSize(rootDir));
}
/**
@@ -475,7 +477,7 @@
propertyId = pid;
File f = createBLOBTempFile(fileSizeKb);
- addedSize += (fileSize = f.length());
+ addedSize += (fileSize = PrivilegedFileHelper.length(f));
FileIOChannel fch = openCASChannel(digestType);
fch.write(pid, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
@@ -516,7 +518,7 @@
for (int i = 0; i < 5; i++)
{
File f = createBLOBTempFile(450);
- addedSize += (m1fileSize = f.length());
+ addedSize += (m1fileSize = PrivilegedFileHelper.length(f));
StreamPersistedValueData v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
@@ -548,7 +550,7 @@
// new file
m2filesCount++;
File f = createBLOBTempFile(350);
- addedSize += (m2fileSize = f.length()); // add size
+ addedSize += (m2fileSize = PrivilegedFileHelper.length(f)); // add size
v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
}
fch.write(property2MultivaluedId, v);
@@ -576,7 +578,7 @@
else
{
File f = createBLOBTempFile(425);
- addedSize += f.length();
+ addedSize += PrivilegedFileHelper.length(f);
v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
}
FileIOChannel vfch = openCASChannel(digestType);
@@ -644,7 +646,7 @@
if (sf.isDirectory())
size += calcDirSize(sf);
else
- size += sf.length();
+ size += PrivilegedFileHelper.length(sf);
}
return size;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -73,7 +73,7 @@
byte[] buf = "0123456789".getBytes();
File file = PrivilegedFileHelper.file(rootDir,
"testReadFromIOChannel0");
- file.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(file);
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
@@ -140,7 +140,7 @@
assertTrue(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel1").exists());
assertTrue(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel2").exists());
- assertEquals(10, PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel0").length());
+ assertEquals(10, PrivilegedFileHelper.length(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel0")));
channel.delete("testWriteToIOChannel");
channel.commit();
@@ -158,7 +158,7 @@
File f = channel.getFile("testWriteUpdate", 0);
assertTrue(f.exists());
- assertEquals(10, f.length());
+ assertEquals(10, PrivilegedFileHelper.length(f));
byte[] buf1 = "qwerty".getBytes();
channel.write("testWriteUpdate",
testerTransientValueData.getTransientValueData(buf1, 0));
@@ -166,7 +166,7 @@
f = channel.getFile("testWriteUpdate", 0);
assertTrue(f.exists());
- assertEquals(6, f.length());
+ assertEquals(6, PrivilegedFileHelper.length(f));
channel.delete("testWriteUpdate");
channel.commit();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -98,7 +99,7 @@
generator.nextBytes(smallValue);
values[i] = testRoot.getSession().getValueFactory().createValue(new
ByteArrayInputStream(smallValue));
}
-
+
if (values.length == 1)
{
prop = testRoot.setProperty("binaryProperty", values[0]);
@@ -154,7 +155,7 @@
// TreeFileIOChannel always returns a File. But if this file doesn't
// really exists is size is 0.
File value = channels.get(i).getFile(propertyId, i);
- if (value.length() == 0)
+ if (PrivilegedFileHelper.length(value) == 0)
{
throw new Exception("");
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -96,13 +96,13 @@
if (src == null || !src.exists())
{
src = createBLOBTempFile(7 * 1024); // 7M
- src.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(src);
}
if (srcSerialization == null || !srcSerialization.exists())
{
- srcSerialization = File.createTempFile("srcSerialization",
".tmp");
- srcSerialization.deleteOnExit();
+ srcSerialization =
PrivilegedFileHelper.createTempFile("srcSerialization", ".tmp");
+ PrivilegedFileHelper.deleteOnExit(srcSerialization);
OutputStream out = PrivilegedFileHelper.fileOutputStream(srcSerialization);
ObjectWriter ow = new ObjectWriterImpl(out);
@@ -126,7 +126,7 @@
testDir = PrivilegedFileHelper.file("target/TestValueFileIOHelper");
testDir.mkdirs();
- dest = File.createTempFile("vdftest", "", testDir);
+ dest = PrivilegedFileHelper.createTempFile("vdftest", "",
testDir);
}
@Override
@@ -140,7 +140,7 @@
public void testCopySerialization() throws Exception
{
- System.out.println("=== test Serialization, file size: " +
srcSerialization.length());
+ System.out.println("=== test Serialization, file size: " +
PrivilegedFileHelper.length(srcSerialization));
// copy via InputStream
long start = System.currentTimeMillis();
@@ -174,7 +174,7 @@
// clean and recreate file
dest.delete();
- dest = File.createTempFile("vdftest", "", testDir);
+ dest = PrivilegedFileHelper.createTempFile("vdftest", "",
testDir);
// copy via NIO
start = System.currentTimeMillis();
@@ -204,7 +204,7 @@
+ (System.currentTimeMillis() - start));
// check length
- assertEquals(srcSerialization.length(), dest.length());
+ assertEquals(PrivilegedFileHelper.length(srcSerialization),
PrivilegedFileHelper.length(dest));
}
public void testCopyFileToFile() throws Exception
@@ -213,7 +213,7 @@
io.copyClose(PrivilegedFileHelper.fileInputStream(src),
PrivilegedFileHelper.fileOutputStream(dest));
// check length
- assertEquals(src.length(), dest.length());
+ assertEquals(PrivilegedFileHelper.length(src), PrivilegedFileHelper.length(dest));
// check content
// InputStream srcin = PrivilegedFileHelper.fileInputStream(src);
@@ -229,7 +229,7 @@
public void testCopyBytesToFile() throws Exception
{
- System.out.println("=== test copyBytesToFile, file size: " +
src.length());
+ System.out.println("=== test copyBytesToFile, file size: " +
PrivilegedFileHelper.length(src));
// copy via InputStream
long start = System.currentTimeMillis();
@@ -257,17 +257,18 @@
// clean and recreate file
dest.delete();
- dest = File.createTempFile("vdftest", "", testDir);
+ dest = PrivilegedFileHelper.createTempFile("vdftest", "",
testDir);
// copy via NIO
start = System.currentTimeMillis();
- io.copyClose(new BufferedInputStream(PrivilegedFileHelper.fileInputStream(src)),
PrivilegedFileHelper.fileOutputStream(dest));
+ io.copyClose(new BufferedInputStream(PrivilegedFileHelper.fileInputStream(src)),
PrivilegedFileHelper
+ .fileOutputStream(dest));
// io.copyClose(new
URL("http://jboss1.exoua-int:8089/browser/02.zip").openStream(), new
// FileOutputStream(dest));
System.out.println("\t=== NIO time " + (System.currentTimeMillis() -
start));
// check length
- assertEquals(src.length(), dest.length());
+ assertEquals(PrivilegedFileHelper.length(src), PrivilegedFileHelper.length(dest));
// check content
// InputStream srcin = PrivilegedFileHelper.fileInputStream(src);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -176,7 +176,7 @@
// create test file
byte[] data = new byte[1024]; // 1Kb
- File testFile = File.createTempFile("randomsizefile", ".tmp");
+ File testFile = PrivilegedFileHelper.createTempFile("randomsizefile",
".tmp");
FileOutputStream tempOut = PrivilegedFileHelper.fileOutputStream(testFile);
for (int i = 0; i < sizeInb; i += 1024)
@@ -192,8 +192,8 @@
tempOut.write(data);
}
tempOut.close();
- testFile.deleteOnExit(); // delete on test exit
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + testFile.length());
+ PrivilegedFileHelper.deleteOnExit(testFile);
+ log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
return testFile;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -117,7 +117,7 @@
size += r;
}
- assertEquals(testFile.length(), size);
+ assertEquals(PrivilegedFileHelper.length(testFile), size);
}
// for read on another node of a cluster
@@ -135,7 +135,7 @@
size += r;
}
- assertEquals(testFile.length(), size);
+ assertEquals(PrivilegedFileHelper.length(testFile), size);
}
public void testAddNTFiles() throws Exception
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -88,7 +88,7 @@
{
// create test file
testFile = createBLOBTempFile(1024);
- dataSize = (int)testFile.length();
+ dataSize = (int)PrivilegedFileHelper.length(testFile);
TEST_FILE = testFile.getAbsolutePath();
}
else
@@ -254,9 +254,9 @@
repository
.login(
this.credentials /*
-
* session.getCredentials(
-
* )
-
*/,
+
*
session.getCredentials(
+
* )
+
*/,
"ws1"));
readed.start();
readers.add(readed);
@@ -271,10 +271,12 @@
}
log.info("Begin cleaner...");
- DeleteThread cleaner = new DeleteThread(repository.login(this.credentials /*
-
* session.getCredentials
-
* ()
-
*/, "ws1"));
+ DeleteThread cleaner =
+ new DeleteThread(repository.login(this.credentials /*
+
* session.getCredentials
+
* ()
+
*/,
+ "ws1"));
cleaner.start();
log.info("<<<<<<<<<<<<<<<<<<<<
Wait cycle
>>>>>>>>>>>>>>>>>>>>>");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -72,13 +72,13 @@
log.info("Execution time after adding and saving (local big):" +
((endTime - startTime) / 1000) + "s");
// Exporting repository content
- File file = File.createTempFile("tesSysExport", ".xml");
+ File file = PrivilegedFileHelper.createTempFile("tesSysExport",
".xml");
BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(file));
session.exportSystemView(testLocalBigFiles.getPath(), bufferedOutputStream, false,
false);
bufferedOutputStream.flush();
bufferedOutputStream.close();
- assertTrue(file.length() > 0);
+ assertTrue(PrivilegedFileHelper.length(file) > 0);
// removing source node
testLocalBigFiles.remove();
@@ -96,12 +96,12 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
- .getStream());
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty(
+ "jcr:data").getStream());
n1.remove();
session.save();
- file.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(file);
file.delete();
}
@@ -136,13 +136,13 @@
log.info("Execution time after adding and saving (local big):" +
((endTime - startTime) / 1000) + "s");
// Exporting repository content
- File file = File.createTempFile("tesDocExport", ".xml");
+ File file = PrivilegedFileHelper.createTempFile("tesDocExport",
".xml");
BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(file));
session.exportDocumentView(testLocalBigFiles.getPath(), bufferedOutputStream,
false, false);
bufferedOutputStream.flush();
bufferedOutputStream.close();
- assertTrue(file.length() > 0);
+ assertTrue(PrivilegedFileHelper.length(file) > 0);
// removing source node
testLocalBigFiles.remove();
@@ -160,12 +160,12 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE2)),
content.getProperty("jcr:data")
- .getStream());
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE2)),
content.getProperty(
+ "jcr:data").getStream());
n1.remove();
session.save();
- file.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(file);
file.delete();
}
@@ -196,13 +196,13 @@
log.info("Execution time after adding and saving (local big):" +
((endTime - startTime) / 1000) + "s");
// Exporting repository content
- File file = File.createTempFile("tesSysExport", ".xml");
+ File file = PrivilegedFileHelper.createTempFile("tesSysExport",
".xml");
BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(file));
session.exportSystemView(testLocalBigFiles.getPath(), bufferedOutputStream, false,
false);
bufferedOutputStream.flush();
bufferedOutputStream.close();
- assertTrue(file.length() > 0);
+ assertTrue(PrivilegedFileHelper.length(file) > 0);
// removing source node
testLocalBigFiles.remove();
@@ -220,12 +220,12 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
- .getStream());
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty(
+ "jcr:data").getStream());
n1.remove();
session.save();
- file.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(file);
file.delete();
}
@@ -266,13 +266,13 @@
}
// Exporting repository content
- File file = File.createTempFile("tesSysExport", ".xml");
+ File file = PrivilegedFileHelper.createTempFile("tesSysExport",
".xml");
BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(file));
session.exportSystemView(testLocalBigFiles.getPath(), bufferedOutputStream, false,
false);
bufferedOutputStream.flush();
bufferedOutputStream.close();
- assertTrue(file.length() > 0);
+ assertTrue(PrivilegedFileHelper.length(file) > 0);
// removing source node
testLocalBigFiles.remove();
@@ -292,12 +292,12 @@
Node lbf = n1.getNode("bigFile" + i);
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
- .getStream());
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty(
+ "jcr:data").getStream());
}
n1.remove();
session.save();
- file.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(file);
file.delete();
}
@@ -308,7 +308,7 @@
// create test file
byte[] data = new byte[1024]; // 1Kb
- File testFile = File.createTempFile("exportImportFileTest",
".tmp");
+ File testFile =
PrivilegedFileHelper.createTempFile("exportImportFileTest", ".tmp");
FileOutputStream tempOut = PrivilegedFileHelper.fileOutputStream(testFile);
Random random = new Random();
@@ -325,8 +325,8 @@
tempOut.write(data);
}
tempOut.close();
- testFile.deleteOnExit(); // delete on test exit
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + testFile.length());
+ PrivilegedFileHelper.deleteOnExit(testFile);
+ log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
return testFile;
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -517,7 +517,7 @@
// byte SYMBOL = 65; // symbol A
// byte[] data = new byte[BUFFER_SIZE]; // 1KB
// Arrays.fill(data, (byte) SYMBOL); // symbol A
- // File testFile = File.createTempFile(prefix, ".tmp");
+ // File testFile = PrivilegedFileHelper.createTempFile(prefix, ".tmp");
// FileOutputStream tempOut = PrivilegedFileHelper.fileOutputStream(testFile);
// for (int i = 0; i < sizeInKb; i++) {
// tempOut.write(data);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -113,7 +113,7 @@
testRoot = PrivilegedFileHelper.file("target/fstest");
testRoot.mkdirs();
- testRoot.deleteOnExit();
+ PrivilegedFileHelper.deleteOnExit(testRoot);
}
@Override
@@ -301,7 +301,9 @@
String fileName = SIDGenerator.generate();
String prefix = fileName.substring(0, 24); // time + addr hash prefix
String rnd = fileName.substring(24); // random name
- File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator
+ prefix + File.separator + buildPathX(rnd));
+ File dir =
+ PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator +
prefix + File.separator
+ + buildPathX(rnd));
dir.mkdirs();
File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fileName);
try
@@ -547,7 +549,9 @@
String fileName = filter.getName();
String prefix = fileName.substring(0, 24); // time + addr hash prefix
String rnd = fileName.substring(24); // random name
- File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator +
prefix + File.separator + buildPathX(rnd));
+ File dir =
+ PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator + prefix +
File.separator
+ + buildPathX(rnd));
String[] ls = filter != null ? dir.list(filter) : dir.list();
if (ls == null)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -56,7 +56,7 @@
// vd.setMaxBufferSize(200*1024);
// assertNull(vd.getFile()); // not spooling by default until getAsStream()
will be call
- File serf = File.createTempFile("serialization", "test");
+ File serf = PrivilegedFileHelper.createTempFile("serialization",
"test");
ObjectWriter wr = new
ObjectWriterImpl(PrivilegedFileHelper.fileOutputStream(serf));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -65,8 +65,8 @@
testNtFileContent.setProperty("jcr:data", new
ByteArrayInputStream(TEST_BINARY_CONTENT));
session1.save();
- File outputFile = File.createTempFile("jcr_bin_test-",
".tmp");
- outputFile.deleteOnExit();
+ File outputFile = PrivilegedFileHelper.createTempFile("jcr_bin_test-",
".tmp");
+ PrivilegedFileHelper.deleteOnExit(outputFile);
session1.exportDocumentView(testNode.getPath(),
PrivilegedFileHelper.fileOutputStream(outputFile), false, false);
@@ -75,7 +75,8 @@
try
{
- session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
+ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
session1.save();
testNode = session1.getRootNode().getNode(TEST_NODE);
@@ -114,8 +115,8 @@
InputStream storedData =
ntFile.getProperty("jcr:content/jcr:data").getStream();
assertTrue("BEFORE EXPORT/IMPORT. Binary content must be same",
checkBinaryEquals(etalonData, storedData));
- File outputFile = File.createTempFile("jcr_bin_test", ".tmp");
- outputFile.deleteOnExit();
+ File outputFile = PrivilegedFileHelper.createTempFile("jcr_bin_test",
".tmp");
+ PrivilegedFileHelper.deleteOnExit(outputFile);
session2.exportDocumentView(testNode.getPath(),
PrivilegedFileHelper.fileOutputStream(outputFile), false, false);
@@ -124,7 +125,8 @@
try
{
- session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
+ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
testNode = session1.getRootNode().getNode(TEST_NODE);
ntFile = testNode.getNode(TEST_NTFILE);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java 2010-06-14
08:44:23 UTC (rev 2565)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java 2010-06-14
09:00:21 UTC (rev 2566)
@@ -44,12 +44,12 @@
public void testBigFileRestore() throws Exception
{
- File tempFile = File.createTempFile("tempFile", "doc");
- File tempFile2 = File.createTempFile("tempFile", "doc");
- File tempFile3 = File.createTempFile("tempFile", "doc");
- tempFile.deleteOnExit();
- tempFile2.deleteOnExit();
- tempFile3.deleteOnExit();
+ File tempFile = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ File tempFile2 = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ File tempFile3 = PrivilegedFileHelper.createTempFile("tempFile",
"doc");
+ PrivilegedFileHelper.deleteOnExit(tempFile);
+ PrivilegedFileHelper.deleteOnExit(tempFile2);
+ PrivilegedFileHelper.deleteOnExit(tempFile3);
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(tempFile);
FileOutputStream fos2 = PrivilegedFileHelper.fileOutputStream(tempFile2);
@@ -70,9 +70,9 @@
fos2.close();
fos3.close();
- log.info("FILE for VERSION #1 : file size = " + tempFile.length() +
" bytes");
- log.info("FILE for VERSION #2 : file size = " + tempFile2.length() +
" bytes");
- log.info("FILE for VERSION #3 : file size = " + tempFile3.length() +
" bytes");
+ log.info("FILE for VERSION #1 : file size = " +
PrivilegedFileHelper.length(tempFile) + " bytes");
+ log.info("FILE for VERSION #2 : file size = " +
PrivilegedFileHelper.length(tempFile2) + " bytes");
+ log.info("FILE for VERSION #3 : file size = " +
PrivilegedFileHelper.length(tempFile3) + " bytes");
Node file = root.addNode("nt_file_node", "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
@@ -117,6 +117,7 @@
// restore version v2 again
file.restore(v2, true);
- compareStream(PrivilegedFileHelper.fileInputStream(tempFile2),
file.getNode("jcr:content").getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile2),
file.getNode("jcr:content")
+ .getProperty("jcr:data").getStream());
}
}