forked from lucee/Lucee
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDEV-3312 use nio for fileSetAttribute readonly
- Loading branch information
Showing
4 changed files
with
38 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase"{ | ||
function beforeAll(){ | ||
variables.base = GetDirectoryFromPath(getcurrentTemplatepath()); | ||
variables.path = base&"LDEV2410\example.txt"; | ||
if(!directoryExists(base&"LDEV2410")){ | ||
directoryCreate(base&'LDEV2410'); | ||
} | ||
variables.testfile = getTempFile( getTempDirectory(), "LDEV-2410", ".txt" ); | ||
} | ||
|
||
function run( testResults, testBox ){ | ||
describe( "test case for LDEV-2410", function() { | ||
|
||
it(title = "checking the file with READONLY Attribute", body = function( currentSpec ) { | ||
variables.myfile = FileOpen(path, "write"); | ||
FileWrite(path,"I am in readonly file"); | ||
fileSetAttribute(path,'readonly'); | ||
expect(getfileinfo(path).canRead).toBe(true); | ||
expect(getfileinfo(path).canWrite).toBe(false); | ||
FileWrite( testfile, "I am in readonly file" ); | ||
FileSetAttribute( testfile, 'readonly' ); | ||
var info = getFileInfo( testfile ); | ||
expect( info.canRead ).toBe( true ); | ||
expect( info.canWrite ).toBe( false ); | ||
expect (function(){ | ||
FileWrite( testfile, "I am in readonly file" ); | ||
}).toThrow(); | ||
}); | ||
|
||
it(title = "checking the file with NORMAL Attribute", body = function( currentSpec ) { | ||
FileSetAttribute( testfile, 'normal' ); | ||
info = getFileInfo( testfile ); | ||
expect( info.canWrite ).toBe( true ); | ||
FileWrite( testfile, "I am in normal (writable) file" ); | ||
}); | ||
// this fails on windows, disabling | ||
it(title = "checking the file with NORMAL Attribute", skip=true, body = function( currentSpec ) { | ||
fileSetAttribute(path,'normal'); | ||
FileWrite(path,"I am in normal file"); | ||
expect(getfileinfo(path).canRead).toBe(true); | ||
expect(getfileinfo(path).canWrite).toBe(true); | ||
}); | ||
}); | ||
} | ||
|
||
function afterAll(){ | ||
if(directoryExists(base&"LDEV2410")){ | ||
directoryDelete(base&"LDEV2410",true); | ||
if ( FileExists( variables.testfile ) ) { | ||
FileDelete( variables.testfile ); | ||
} | ||
} | ||
|
||
} |