Skip to content

Commit

Permalink
Merge pull request #2252 from zspitzer/test-cleanup-29-sept-2023
Browse files Browse the repository at this point in the history
cleanup and enable passing tests
  • Loading branch information
zspitzer authored Sep 29, 2023
2 parents fa48d15 + f3886b3 commit 97c130f
Show file tree
Hide file tree
Showing 60 changed files with 300 additions and 258 deletions.
10 changes: 8 additions & 2 deletions test/_testRunner.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ component {
if ( bundle.totalPass eq 0 && ( bundle.totalFail + bundle.totalError ) eq 0 ){
systemOutput( TAB & " (skipped)", true );
} else {
var skippedSummary = (bundle.totalSkipped gt 0) ? ", #bundle.totalSkipped# skipped" : "";
systemOutput( TAB & " (#bundle.totalPass# tests passed in #NumberFormat(bundle.totalDuration)# ms#skippedSummary#)", true );
var didntPassSummary = (bundle.totalSkipped gt 0) ? ", #bundle.totalSkipped# skipped" : "";
if ( bundle.totalError > 0 ){
didntPassSummary &= ", #bundle.totalError# ERRORED";
}
if ( bundle.totalFail > 0 ){
didntPassSummary &= ", #bundle.totalFail# FAILED";
}
systemOutput( TAB & " (#bundle.totalPass# tests passed in #NumberFormat(bundle.totalDuration)# ms#didntPassSummary#)", true );
}
//mem("non_heap");
//mem("heap");
Expand Down
File renamed without changes.
58 changes: 23 additions & 35 deletions test/general/_JSR223.cfc → test/general/JSR223.cfc
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {
component extends="org.lucee.cfml.test.LuceeTestCase" skip=true {

public function beforeTests(){
ScriptEngineManager=createObject('java','javax.script.ScriptEngineManager');
Expand All @@ -11,67 +11,50 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {

local.engine =manager.getEngineByName("CFML");
assertEquals("cfml",engine.factory.languageName);

local.engine =manager.getEngineByName("Lucee");
assertEquals("lucee",engine.factory.languageName);


}

public void function testGetEngineByExtension(){
local.engine =manager.getEngineByExtension("cfm");
assertEquals("cfml",engine.factory.languageName);

local.engine =manager.getEngineByExtension("lucee");
assertEquals("lucee",engine.factory.languageName);

// reference
local.engine =manager.getEngineByExtension("js");
assertEquals("ECMAScript",engine.factory.languageName);
if (getJavaVersion() lte 11){
// reference
local.engine =manager.getEngineByExtension("js");
assertEquals("ECMAScript",engine.factory.languageName);
}
}

public void function testGetEngineByMimeType(){
local.engine =manager.getEngineByMimeType("application/cfml");
assertEquals("cfml",engine.factory.languageName);

local.engine =manager.getEngineByMimeType("application/lucee");
assertEquals("lucee",engine.factory.languageName);

// reference
local.engine =manager.getEngineByMimeType("application/javascript");
assertEquals("ECMAScript",engine.factory.languageName);
if (getJavaVersion() lte 11) {
// reference
local.engine =manager.getEngineByMimeType("application/javascript");
assertEquals("ECMAScript",engine.factory.languageName);
}
}


public void function testGetEngineFactories(){
local.names=[];
loop array="#manager.getEngineFactories()#" item="local.factory" {
names.append(factory.languageName);

}

assertTrue(names.contains("lucee"));
assertTrue(names.contains("cfml"));
assertTrue(names.contains("ECMAScript"));
if (getJavaVersion() lte 11)
assertTrue(names.contains("ECMAScript"));
}

public void function testPutGet(){
local.testValue="Susi #now()#";

local.engine =manager.getEngineByName("CFML");
engine.put('test',testValue);
assertEquals(testValue,engine.get('test'));

local.engine =manager.getEngineByName("Lucee");
engine.put('test',testValue);
assertEquals(testValue,engine.get('test'));
}



public void function testEvalReturnValue(){
_testEvalReturnValue(manager.getEngineByName("CFML"));
_testEvalReturnValue(manager.getEngineByName("Lucee"));
}
private void function _testEvalReturnValue(required engine){
engine.put('cont',false);
Expand All @@ -82,9 +65,8 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {

}

public void function testEvalScopes(){
public void function testEvalScopes() skip=true{
_testEvalScopes(manager.getEngineByName("CFML"));
_testEvalScopes(manager.getEngineByName("Lucee"));
}
private void function _testEvalScopes(required engine){
engine.eval('url.test=1;');
Expand All @@ -95,7 +77,6 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {

public void function testEvalInterpreter(){
_testEvalInterpreter(manager.getEngineByName("CFML"));
_testEvalInterpreter(manager.getEngineByName("Lucee"));
}
private void function _testEvalInterpreter(required engine){
engine.eval('susi.sorglos=1;');
Expand All @@ -105,15 +86,22 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {

public void function testEvalFunction(){
_testEvalFunction(manager.getEngineByName("CFML"));
_testEvalFunction(manager.getEngineByName("Lucee"));
}
private void function _testEvalFunction(required engine){
// udf
assertEquals("udf",engine.eval('function test(){return "udf";}; x=test();'));
// closure
assertEquals("closure",engine.eval('test=function (){return "closure";}; x=test();'));
// lambda
assertEquals("lambda",engine.eval('test=()->"lambda"; x=test();'));
// assertEquals("lambda",engine.eval('test=()->"lambda"; x=test();'));
}

private function getJavaVersion() {
var raw=server.java.version;
var arr=listToArray(raw,'.');
if(arr[1]==1) // version 1-9
return arr[2];
return arr[1];
}

}
Expand Down
16 changes: 8 additions & 8 deletions test/general/_Parser.cfc → test/general/Parser.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
function run( testResults , testBox ) {
describe( "Test suite for Parser", function() {
describe( "Checking array and structure with invalid variable notation", function() {
it( title='Checking array value with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking array value with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=1}
);
expect(local.result.filecontent.trim()).toBe("invalid identifier");
});

it( title='Checking array variable with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking array variable with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=2}
);
expect(local.result.filecontent.trim()).toBe("invalid identifier");
});

it( title='Checking structure value with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking structure value with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=3}
);
expect(local.result.filecontent.trim()).toBe("invalid identifier");
});

it( title='Checking structure variable with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking structure variable with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=4}
Expand All @@ -40,31 +40,31 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
});

describe( "Checking with interpreter", function() {
it( title='array value with evaluate function', body=function( currentSpec ) {
xit( title='array value with evaluate function', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=5}
);
expect(local.result.filecontent.trim()).toBe("Syntax Error, invalid Expression [['a','b','c'].3]");
});

it( title='Checking array variable with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking array variable with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=6}
);
expect(local.result.filecontent.trim()).toBe("invalid identifier");
});

it( title='Checking structure value with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking structure value with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=7}
);
expect(local.result.filecontent.trim()).toBe("Syntax Error, invalid Expression [{'3':'C'}.3]");
});

it( title='Checking structure variable with invalid variable notation', body=function( currentSpec ) {
xit( title='Checking structure variable with invalid variable notation', body=function( currentSpec ) {
local.result = _InternalRequest(
template:"#variables.uri#/test.cfm",
forms:{Scene=8}
Expand Down
2 changes: 1 addition & 1 deletion test/tickets/_LDEV0228.cfc → test/tickets/LDEV0228.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component extends="org.lucee.cfml.test.LuceeTestCase" labels="xml" {
function run( testResults , testBox ) {
describe( "Checking XMLTransform()", function() {
it('With xsl:include', function( currentSpec ) {
xit('With xsl:include', function( currentSpec ) {
try {
uri=createURI("LDEV0228/test.cfm");
local.result = _InternalRequest(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/tickets/_LDEV0240.cfc → test/tickets/LDEV0240.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component extends="org.lucee.cfml.test.LuceeTestCase"{
public function run( testResults , testBox ) {
describe( title="Test suite for LDEV-240 ( checking with the files in same folders )", body=function() {
it(title="Creating object for a component which has an init() with package access, from a cfm file of same folder", body=function( currentSpec ) {
xit(title="Creating object for a component which has an init() with package access, from a cfm file of same folder", body=function( currentSpec ) {
uri = createURI("LDEV0240/test.cfm");
result = _InternalRequest(
template:uri,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/tickets/_LDEV0406.cfc → test/tickets/LDEV0406.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{

function run(){
describe( title="Test suite for restInitApplication()", body=function(){
it(title="Without password argument", body=function(){
xit(title="Without password argument", body=function(){
restInitApplication( dirPath=expandPath("./LDEV0406/api1/"), serviceMapping="api1" );
});

Expand All @@ -26,7 +26,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{
});

describe( title="Test suite for restDeleteApplication()", body=function(){
it(title="Without password argument", body=function(){
xit(title="Without password argument", body=function(){
restDeleteApplication( dirPath=expandPath("./LDEV0406/api2/") );
});

Expand Down
78 changes: 78 additions & 0 deletions test/tickets/LDEV0499.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<cfcomponent extends="org.lucee.cfml.test.LuceeTestCase" labels="pdf">
<cfscript>
function run( testResults , testBox ) {
describe( "Test suite for LDEV-499", function() {
it("Checking CFdocument with encryption, without attribute userpassword", function( currentSpec ) {
var result = CFdocumentWithoutAttribute();
// expect(result).toBeTypeOf('Struct');
expect(result.Encryption).toBe('No Security');
});

it("Checking CFdocument with encryption, with attribute userpassword='' while creating pdf", function( currentSpec ) {
var result = CFdocumentWithEncryption();
expect(result.Encryption).toBe('No Security');
});

it("Checking CFdocument with encryption, with attribute password='' while reading pdf", function( currentSpec ) {
var result = CFdocumentWitheEmptyValueUserPassword();
expect(result.Encryption).toBe('No Security');
});

it("Checking CFdocument with encryption, with password", function( currentSpec ) {
var result = CFdocumentWithPassword();
expect(result.Encryption).toBe('Password Security');
});

});
}
// private function//
private string function createURI(string calledName){
var baseURI="/test/#listLast(getDirectoryFromPath(getCurrenttemplatepath()),"\/")#/";
return baseURI&""&calledName;
}
</cfscript>

<cffunction name="CFdocumentWithoutAttribute" access="private" returntype="Struct">
<cfset var testPDF=getTempFile(getTempDirectory(), "LDEV0499", "pdf")>
<cfdocument format="PDF" overwrite="true" encryption="40-bit" filename="#testPDF#">
<cfdocumentsection>
Lucee test documents
</cfdocumentsection>
</cfdocument>
<cfpdf action="read" name="pdfDetails" source="#testPDF#"/>
<cfreturn pdfDetails>
</cffunction>

<cffunction name="CFdocumentWithEncryption" access="private" returntype="Struct">
<cfset var testPDF=getTempFile(getTempDirectory(), "LDEV0499", "pdf")>
<cfdocument format="PDF" overwrite="true" userpassword="" encryption="40-bit" filename="#testPDF#">
<cfdocumentsection>
Lucee test documents
</cfdocumentsection>
</cfdocument>
<cfpdf action="read" name="pdfDetails" source="#testPDF#"/>
<cfreturn pdfDetails>
</cffunction>

<cffunction name="CFdocumentWitheEmptyValueUserPassword" access="private" returntype="Struct">
<cfset var testPDF=getTempFile(getTempDirectory(), "LDEV0499", "pdf")>
<cfdocument format="PDF" overwrite="true" encryption="40-bit" filename="#testPDF#">
<cfdocumentsection>
Lucee test documents
</cfdocumentsection>
</cfdocument>
<cfpdf action="read" name="pdfDetails" source="#testPDF#" password=""/>
<cfreturn pdfDetails>
</cffunction>

<cffunction name="CFdocumentWithPassword" access="private" returntype="Struct">
<cfset var testPDF=getTempFile(getTempDirectory(), "LDEV0499", "pdf")>
<cfdocument format="PDF" overwrite="true" encryption="40-bit" filename="#testPDF#" userpassword="Lucee">
<cfdocumentsection>
Lucee test documents
</cfdocumentsection>
</cfdocument>
<cfpdf action="read" name="pdfDetails" source="#testPDF#" password="Lucee"/>
<cfreturn pdfDetails>
</cffunction>
</cfcomponent>
Binary file added test/tickets/LDEV0499/test.pdf
Binary file not shown.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/tickets/_LDEV0590.cfc → test/tickets/LDEV0590.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
local.result = MakeRequest("1_1");
expect(left(result.filecontent.trim(), 100)).notToBe("");
});
it("Calling direct function & checking its closure's variables scope", function( currentSpec ) {
xit("Calling direct function & checking its closure's variables scope", function( currentSpec ) {
local.result = MakeRequest("1_2");
expect(left(result.filecontent.trim(), 100)).notToBe("");
});
it("Calling indirect function & checking its variables scope", function( currentSpec ) {
local.result = MakeRequest("2_1");
expect(left(result.filecontent.trim(), 100)).notToBe("");
});
it("Calling indirect function & checking its closure's variables scope", function( currentSpec ) {
xit("Calling indirect function & checking its closure's variables scope", function( currentSpec ) {
local.result = MakeRequest("2_2");
expect(left(result.filecontent.trim(), 100)).notToBe("");
});
Expand Down
2 changes: 1 addition & 1 deletion test/tickets/_LDEV0594.cfc → test/tickets/LDEV0594.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="org.lucee.cfml.test.LuceeTestCase"{
component extends="org.lucee.cfml.test.LuceeTestCase" skip=true {
public function beforeAll(){
myTestResults = structNew();
myTestResults.result1 = "";
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion test/tickets/LDEV0595/test.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<cfset imgfile = "../../artifacts/image.jpg" />
<cfimage source="#imgfile#" name="myImage" />
<cfset imageGrayscale(myImage) />
<cfimage action="WRITE" source="#myImage#" destination="#imgfile#_grayscale.jpg" overwrite="yes" />
<cfset dest = getTempFile(getTempDirectory(), "LDEV0595", "jpg")>
<cfimage action="WRITE" source="#myImage#" destination="#dest#" overwrite="yes" />
done
<cfcatch type="any">
#cfcatch.Message#
Expand Down
4 changes: 2 additions & 2 deletions test/tickets/_LDEV0596.cfc → test/tickets/LDEV0596.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
it( title='attributes directly with cfoutput' , body=function(){
directAttributesforcfoutput();
});
it( title='attributes used as attributes collection in cfoutput' , body=function(){
xit( title='attributes used as attributes collection in cfoutput' , body=function(){
attributesCollectionforcfoutput();
});
});
describe( 'attributes with cfloop', function() {
it( title='attributes used directly in cfloop', body=function(){
directAttributesforcfloop();
});
it( title='attributes used as attributes collection in cfloop', body=function(){
xit( title='attributes used as attributes collection in cfloop', body=function(){
attributesCollectionforcfloop();
});
});
Expand Down
File renamed without changes.
Loading

0 comments on commit 97c130f

Please sign in to comment.