Several months ago I upgraded to MacOS Sierra. As a side effect(bug?) my Sitecom usb-hub, holding 7 ports having it’s own power supply, disappeared from the mac. I searched for the internet for a solution, but there weren’t many answers. Also most of the answers concerned other brand usb-hubs. None of the answers helped my out. If only I read which computer usb ports not to use in combination with by it’s own power supplied usb devices, I wouldn’t have lived with a rather immobile keyboard on my desk that long.
Xcode 9 beta and JSon objects
Actually I had in mind writing on JSon in Swift 3(Xcode 8.3.3), but scope creep occurred as Xcode 9 was released (on me). This creep turned into one big Xcode and GitHub lesson. So this blog is about several Swift JSon projects -now in a supporting role, because the main star of this blog is Xcode 9. Xcode is also the star because it’s faster than it’s predecessor 8 as the same counts for the new Simulator version 10. Next GitHub is integrated a a step further. And on top Swift 4 handles JSon far more elegant than ‘old fashioned’ JSONserialise-way. Probably making SwiftyJSon obsolete too.
Next we merge the two main class programs for the former post into a single application. After execution of this package paths, xml filenames and accompanying content are printed to our NetBeans console.
Earlier I recommended Java beginners to save the main programs in their Hello World project. It’s time to leave this one project approach. As a Java-for-testers beginners you better start a new project for every single problem you encounter. You can always copy the core of your solution to the package where you need it not ‘contaminating’ the project you are actually working on with maybe useless code. Which allows me referring Occam’s razor blade. Today his medieval approach is more useful to us as agile testers in stripping the ‘borrowed’ code than for instance ISQTB. Applying his blade probably gives you the leanest code you need to perform your job. Analysing xml files for example.
In my former post I provided the java code to search for xml-files in our logs- directory and write these filenames including their pathname to a text file named “FilteredLogFileList.txt” in the project directory. I also described how to create the logs-folder and fill it with files.
I use this setup as my starting point for the next step. Here we take a single well formatted xml-file and present it’s content in the NetBeans console. This is easier than you think. Java knows a lot of libraries to perform specific tasks and reading xml-files is one of them. If you used dummyXMLs you can use dummy2.xml in the rest of this post.
This post gives you the material to select or filter files in a directory. It is not a ‘real’ tutorial, but rather gives you means to play with the code with immediate results. By playing you get quicker understanding how things work. At least I do. The code filters xml-files, but by changing one line of code you can filter any extension you wish. After you ran the java program you end up having a text file containing the list of files which met your criteria. I do suppose you already have finished the HelloWorld.java part with succes. Otherwise finish this first. YouTube is full of HelloWorlds. You can use this project or create a new fresh one if you prefer.