VersionHelper { public void ensureVersionCompatible(final String rawVersion) throws Exception { String version = parseVersion(rawVersion); VersionScheme scheme = new GenericVersionScheme(); VersionConstraint constraint = scheme.parseVersionConstraint(VERSION_CONSTRAINT); Version _version = scheme.parseVersion(version); log.debug("Version: " + _version); if (!constraint.containsVersion(_version)) { log.error("Incompatible install4j version detected"); log.error("Raw version: " + rawVersion); log.error("Detected version: " + _version); log.error("Compatible version constraint: " + constraint); throw new MojoExecutionException("Unsupported install4j version: " + rawVersion); } } VersionHelper(final Log log); String fetchVersion(final AntHelper ant, final File install4jc); String parseVersion(final String rawVersion); void ensureVersionCompatible(final String rawVersion);  }
@Test public void ensureVersionCompatible() throws Exception { helper.ensureVersionCompatible("install4j version 6.0.4 XXX"); }
@Test(expected = MojoExecutionException.class) public void ensureOldVersionFails() throws Exception { helper.ensureVersionCompatible("install4j version 5.1.3 XXX"); }