Git Immersion

I have recently migrated all of my source code repositories from Subversion to Git and have been using it extensively at work. Coming from Subversion to Git is a pretty major shift in how things work, but thankfully I found a great resource for learning the Ins and Outs of Git.

Git Immersion is an excellent resource for anyone who is interested in learning Git. It walks you through all of the major functions of Git as a series of small and precise labs.

If you need further assistance, you can also find a complete online copy of the book Pro Git available here.

Read More...


Create/Access Dynamically Created Shell Variables

The Problem

Recently I was developing some shell scripts (ShellScripts on GitHub) and needed to reference a variable that had a dynamically created name. Essentially I had some values defined in a properties file that were named "client_1, client_2, ... , client_N" where N is not known until run-time of the script. I could easily build the names of all of the variables in a string, but ho do I then convert that String name into an actual variable? After searching high and low, I found the solution.

The Solution

The first step is to create a variable that holds the dynamically created varialbe name:
varName=client_$n

To get the name of the newly created variable, you access it like this:
${varName}

To get the value of the newly created variable, you access it like this:
${!varName}

Reference

Read More...


Arquillian ClassNotFoundException Issues

If you are testing your JEE application using Arquillian and running in to issues with ClassNotFoundExcpetions, the solution is pretty simple. To resolve the issue, simply add the class and/or package to your Deployment Descriptor in your test. This will add the classes to the Archive sent to the container when the tests run.

Adding a Local Package

Adding an entire package to your deployment archive is fairly simple as Arquillian provides a number of methods for you to use. The easiest was though is to tell your archive to add all the classes in given package and all of its sub-packages. This can be done by using

addPackages(true, "your.package.name");

Adding a Maven Dependency

Sometimes the offending classes will not be part of your code, but instead will come from one of your Maven dependencies. This generally happens when you are testing your UI and your code needs additional 3rd part libraries. Adding these Maven resources to your deployment archive is a snap. First you will need to create a Maven Dependency Resolver:

final MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml");
  

Then you will need to add the required dependency to your archive by calling addAsLibraries, replacing the variables with the correct information for the dependency you want to add.

final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").addAsLibraries(resolver.artifact("<dep_groupid>:<dep_artifactid>:<dep_version>").resolveAsFiles());

Read More...


Script for Generating Self-signed Certificates for use in Java

If you are in need of some self-signed certificates for use in Java, and are using Linux, then I have developed a small shell script that will do all the work for you. You can find the source code on GitHub.

If you are running Windows, then you will not be able to use the shell script, however, you can follow the steps in either of my previous articles to generate your keys.

Read More...


Setting Subversion Properties

When using subversion from the command line, it is helpful to know how to set subversion properties. This is particularly useful when you need to set the ignore properties to things like eclipse project files, or compiled class files, are not checked in by mistake. In order to work with Subversion properties, there are 3 commands that you should be aware of.

svn propset

propset is the first command you should be aware of. This command can be used to set a property to a new value. It is good for when the property only has a single value, like true/false, or a number.
svn propset PROPNAME [PROPVAL | -F VALFILE] PATH...
Example, to set the End of Line hanling for a file, you would use
svn propset svn:eol-style "LF" somefile.txt

svn propedit

propedit is the second command you should be aware of. This command is good when you need to set a property that takes multiple values, especially if they are seperated by a newline. It is the preferred command to use when setting the Ignore property for subversion.
svn propedit PROPNAME TARGET...
When you issue this command, it will open the default editor for your system, and allow you to enter the values for the property. For example, to set the ignore property, you could use the following command, and then enter the names of all of the files/directories you want ignored.
svn propedit svn:ignore .
Using the . will set the property on the current working directory.

svn propget

propget is the third command you should be aware of. You can use this command to confirm that your property has been set correctly.
svn propget PROPNAME [TARGET[@REV]...]
For example, you can confirm your ignore property is set correctly by using the following command.
svn propget svn:ignore

References

Read More...