Concordion: How to compare two files? - concordion

I am new to Concordion. I have created a sample project and trying to compare two files with the help of concordion.Kinldy let me know Do we have any tag in concordion which can compare two files?

My solution.
In your HTML file :
<span concordion:set="#urlFileA">/path/fileA.json</span>
<span concordion:set="#urlFileB">/path/fileB.json</span>
<span concordion:assertTrue="compareTo(#urlFileA,#urlFileB)">true</span>
In your fixture :
public boolean compareTo(String urlFileA,String urlFileB){
// Get both file with File and FileInputStream to read files
// Compare .....
// Then return true or false
}

Related

How to access any .json from windows file explorer in vuejs

I looked up how to access a .json file without saving it to my code base but was not able to find it - all posts are like this one: How to acces external json file objects in vue.js app
where they assumed that I could save the .json file in the code base like so: import json from './json/data.json' - they are going to call it json, it is in json folder from the file named data.json.
In my case, on the contrary, when the user tries to read their own .json file saved in their windows file explorer's "Download" folder, there can be one or multiple files, and the user will select any one of them to be accessed and read by the website.
Me as a developer don't own the file that the user will select, don't know which file the user will choose, therefore don't know the name of the file or the file content, and so, I cannot have that file saved in the code base.
Is there a way for me to enable the user to select any .json file they want, have that accessed and read?
Thank you.
UPDATE: from the suggestions from the comment section, fileSelector appears as null in the dev tool
<input type="file" id="file-selector" accept="application/JSON" multiple>
interface HTMLInputEvent extends Event {
target: HTMLInputElement & EventTarget;
}
mounted() {
const fileSelector = document.getElementById('file-selector');
fileSelector.addEventListener('change', (event: HTMLInputEvent) => {
let files: any = event.target.files[0];
const fileList = event.target.files;
console.log(fileList);
});
}
Apparently you're using Typescript, so your error is at runtime or at build time?
the type of the event argument doesn't seem correct to me, try:
fileSelector.addEventListener('change', (event: Event) => {
const files = (e.target as HTMLInputElement).files
})

Read local JSON files when dynamically creating functional tests in Intern

I am creating functional tests dynamically using Intern v4 and dojo 1.7. To accomplish this I am assigning registerSuite to a variable and attaching each test to the Tests property in registerSuite:
var registerSuite = intern.getInterface('object').registerSuite;
var assert = intern.getPlugin('chai').assert;
// ...........a bunch more code .........
registerSuite.tests['test_name'] = function() {
// READ JSON FILE HERE
var JSON = 'filename.json';
// ....... a bunch more code ........
}
That part is working great. The challenge I am having is that I need to read information from a different JSON file for each test I am dynamically creating. I cannot seem to find a way to read a JSON file while the dojo javascript is running (I want to call it in the registerSuite.tests function where it says // READ JSON FILE HERE). I have tried dojo's xhr.get, node's fs, intern's this.remote.get, nothing seems to work.
I can get a static JSON file with define(['dojo/text!./generated_tests.json']) but this does not help me because there are an unknown number of JSON files with unknown filenames, so I don't have the information I would need to call them in the declare block.
Please let me know if my description is unclear. Any help would be greatly appreciated!
Since you're creating functional tests, they'll always run in Node, so you have access to the Node environment. That means you could do something like:
var registerSuite = intern.getPlugin('interface.object').registerSuite;
var assert = intern.getPlugin('chai').assert;
var tests = {};
tests['test_name'] = function () {
var JSON = require('filename.json');
// or require.nodeRequire('filename.json')
// or JSON.parse(require('fs').readFileSync('filename.json', {
// encoding: 'utf8'
// }))
}
registerSuite('my suite', tests);
Another thing to keep in mind is assigning values to registerSuite.tests won't (or shouldn't) actually do anything. You'll need to call registerSuite, passing it your suite name and tests object, to actually register tests.

How to generate Json file after execution finish

I'm working with cucumber and protractor and to generate reports i'm using
cucumber-html-reporter I already add the configuration to generate the report
var options = {
theme: 'bootstrap',
jsonFile: 'reporter/cucumber_report.json',
output: 'reporter/cucumber_report.html',
reportSuiteAsScenarios: true,
launchReport: true,
};
defineSupportCode(function({ After }) {
After((scenario)=> {
reporter.generate(options);
});
});
but i'm not generate the json file with this code, I search in google and the code to generate the json file should be add into the cucumberOpts in the conf.js but i'm not sure what's the code should be into cucumberOpts to generate the json file and the convert into report.
I hope you can help me guys.
Maybe this can help you, it's for Typescript but the code is almost the same. You can export the file in an After-hook. The link is for CucumberJS 1, if you look into the master branch you can also find the CucumberJS 2 solution
The advantage of this in comparison to generating the JSON file with the format option is that you can modify the JSON before saving
Hope it helps
For people that still have this problem, in my case the problem was that I was using cucumber v1 instead cucumber v2. For this case I should use registerHandler instead After this is the complete example:
defineSupportCode(function({registerHandler}) {
registerHandler('AfterFeatures', function (features) {
reporter.generate(options);
});
});
Hope this help u guys.

Is it poosible to covert .html file to .jsp

User will upload .htm file and that uploaded file i have to convert to .jsp .
User will give me plain html file only with design and required fields. When he will upload I have to parse ans copy all html content also i have to add additional scripts and jstl code in jsp file. Is there any easy way to do this.
Thanks in advance
Handle it through file extension through servlet.
private String extractFileName(Part part) {
String contentDisp = part.getHeader("content-disposition");
String[] items = contentDisp.split(";");
for (String s : items) {
if (s.trim().startsWith("filename")) {
String cccfileName = s.substring(s.indexOf("=") + 2, s.length() - 1);
return cccfileName.substring(cccfileName.lastIndexOf("."), cccfileName.length());
}
}
return "";
}
Use it like String fileNameExt = extractFileName(part); and change the file extension to .jsp, it should work.

How to get multiple selected file in grails?

I am trying to get multiple selected files and save into mysql
GSP CODE :
<input type="file" name="file_attachemnt" id="file_attachemnt" multiple/>
Controller Code For multiple file get
def all = request.getFileNames()
all.each {name ->
def file = request.getFile(name)
def CommonsMultipartFile uploadedFile =file
def fileName = uploadedFile.originalFilename
println "file name "+fileName;
def fileExtent=FilenameUtils.getExtension(fileName);
}
But in controller side only one file i get.. even if i selected e.g 3 files
Give this a try. Not sure but I don't think much has changed since the 1.3.x days and this works there.
request.getMultiFileMap().file_attachemnt.each {
println it.originalFilename
}
Try this code
params.list("file_attachemnt").each{
// your code here
}