public void TransformTest() throws FactoryException, MismatchedDimensionException, TransformException {
double latitude = 46.72;
double longitude = 16;
double x = -25097.740155822;
double y = 175686.952118893;
CRSAuthorityFactory crsFactory = CRS.getAuthorityFactory("EPSG");
CoordinateOperationAuthorityFactory opFactory = (CoordinateOperationAuthorityFactory) crsFactory;
CoordinateOperation datumOperation = opFactory.createCoordinateOperation("3966");
CoordinateReferenceSystem targetCRS = crsFactory.createCoordinateReferenceSystem("31253");
targetCRS = AbstractCRS.castOrCopy(targetCRS).forConvention(AxesConvention.DISPLAY_ORIENTED);
CoordinateOperation targetOperation = CRS.findOperation(datumOperation.getSourceCRS(), targetCRS, null);
/*
* We have two operations to concatenate
*/
MathTransform step1 = datumOperation.getMathTransform().inverse();
MathTransform step2 = targetOperation.getMathTransform();
MathTransform completeTransform = MathTransforms.concatenate(step1, step2);
/*
* transform to x,y in one step
*/
DirectPosition source = new DirectPosition2D(latitude, longitude);
DirectPosition target = completeTransform.transform(source, null);
double[] coordinate = target.getCoordinate();
Assert.assertEquals(x, coordinate[0], 0.1);
Assert.assertEquals(y, coordinate[1], 0.1);
}