Browsed by
Category: Uncategorized

Mockito verify fails, shows additional empty line

Mockito verify fails, shows additional empty line

When running JUnit tests on a legacy code base at work I got the familiar “Argument(s) are different! [….] Actual invocation has different arguments” notice from Mockito. I ran the tests from the command line, but as I could see no difference between the expected and actual output I re-ran the tests inside IntelliJ to investigate further, resulting in this: Notice the trailing newline in the actual request made. From the reported error above it wasn’t straight forward figuring out…

Read More Read More

Camel testing: bean, ref or beanType must be provided

Camel testing: bean, ref or beanType must be provided

I recently got this error in Camel during unit testing: In case others come across the same issue, I thought I’d do a quick write-up on what the solution in my specific scenario was. Consider these production code extracts: The unit test: When running the unit test, I got the error referenced in the title: To get the test to work, just a very small adjustment to the production code was required: I’m running Camel 3.18.1.

Resolving “Error [ERR_REQUIRE_ESM]: require() of ES Module” in NextJS

Resolving “Error [ERR_REQUIRE_ESM]: require() of ES Module” in NextJS

In my BlitzJS project (which in turn utilizes NextJS), I ran into this error: Error: require() of ES Module /home/me/project/node_modules/three/examples/jsm/controls/DragControls.js from /home/me/project/node_modules/3d-force-graph/dist/3d-force-graph.common.js not supported. Instead change the require of DragControls.js in /home/me/project/node_modules/3d-force-graph/dist/3d-force-graph.common.js to a dynamic import() which is available in all CommonJS modules. The code causing the error was this: A quick refactor (for refernece including some additional code) resolved the issue:

Converting .msg to PDF using Python on Windows

Converting .msg to PDF using Python on Windows

I recently needed to convert a bunch of .msg files to PDF. I didn’t want to install any additional 3rd party software other than the Python libraries I needed. As the code would run on Windows servers, I though I’d utilize the excellen win32com Python package, and use only native Windows applications for performing the actual converting. I didn’t find a way to convert .msg to PDF in one, so I solved it by first using Outlook to convert the…

Read More Read More

Running Flask CLI and API

Running Flask CLI and API

Note to self: Here’s a super simple starting point for setting up a Flask application that supports both API and CLI interaction. To run it, run this command: To “map” the CLI to a custom app name, add a setup.py file with contents like this: Restart the Flask app. Now, uses can interact with the CLI like this:

Updating Jenkins CI behind corporate firewall

Updating Jenkins CI behind corporate firewall

Our Jenkins CI server (https://jenkins.company.com) doesn’t have access to Internet (neither directly nor through a proxy), yet we need to update both Jenkins itself as well as the Jenkins plugins. We’ve set up another of our servers, https://jenkins-repo.company.com, as a Jenkins mirror site, which on a regular basis runs this command in a cron job: The /srv/mirrors/jenkins folder is hosted by Nginx. As the rsync’ed files contain references to https://updates.jenkins.io, Jenkins will try and contact https://updates.jenkins.io when downloading the updated…

Read More Read More

Setting up Visual Studio for developing SharePoint online site provisioning software

Setting up Visual Studio for developing SharePoint online site provisioning software

We’re in the process of setting up SharePoint Online as our Intranet platform, and are looking to automate site creation using something like Azure Functions. Currently, I’m developing the business logic for creating the new sites, including setting the correct permissions, theme, links and so forth. I’m using Visual Studio for this project. I’m new to both SharePoint Online as .NET, and as tutorials on setting up Visual Studio with regards to SharePoint Online provisioning seems to be lacking, I…

Read More Read More

Docker automatically stopped

Docker automatically stopped

This morning I found that the Docker service on one our linux servers for no apparent reason had stopped. From the entries in syslog I could see that Docker had been going up and down since about 06:34 in the morning. Extract from syslog: I came across https://www.claudiokuenzler.com/blog/689/rancher-error-response-from-daemon-dockerd-deleted-no-such-file-or-directory, and from the comment section there I was led to check what the unattended upgrades had been doing this morning, and found this: On this particular linux server we don’t really wish…

Read More Read More

openpyxl’s “load_workbook” return empty list of sheets

openpyxl’s “load_workbook” return empty list of sheets

Consider this code: When using one of my xlsx-files as input, my code produced the output Sheet names: [] followed by this expection: After some investigating, I found that the file had been saved as “Strict Open XML Spreadsheet (xlsx)” instead of “Excel Workbook (xslx)”. Both files for some reason have the same file extension, but the former was not supported by the openpyxl library. Saving the file as “Excel Workbok (xslx)” got the code working again.

Adding “–version” parameter to “python3 setup.py”

Adding “–version” parameter to “python3 setup.py”

When building Python packages using setuptools, you typically manually set the upcoming package version in setup.py. For my use case, I found it better to provide the version number on the command line such as this: setuptools isn’t very fond of command line parameters, so I made a quick-n-dirty hack to work around this limitation: