/**
* Tests the {@link AllAuthoritiesFactory#createCoordinateReferenceSystem} method.
*/
@Test
public void testCreateCRS() throws FactoryException {
final CRSAuthorityFactory auto = ReferencingFactoryFinder.getCRSAuthorityFactory("AUTO", null);
final CRSAuthorityFactory crs = ReferencingFactoryFinder.getCRSAuthorityFactory("CRS", null);
final CRSAuthorityFactory all = AllAuthoritiesFactory.DEFAULT;
CoordinateReferenceSystem actual, expected;
actual = all.createCoordinateReferenceSystem("CRS:84");
expected = crs.createCoordinateReferenceSystem( "84");
assertSame(expected, actual);
assertSame(expected, all.createObject("CRS:84"));
actual = all .createCoordinateReferenceSystem("AUTO:42001,0,0");
expected = auto.createCoordinateReferenceSystem( "42001,0,0");
assertSame(expected, actual);
assertSame(expected, all.createObject("AUTO:42001,0,0"));
actual = all.createCoordinateReferenceSystem("CRS:27");
expected = crs.createCoordinateReferenceSystem( "27");
assertSame(expected, actual);
assertSame(expected, all.createObject("CRS:27"));
try {
all.createCoordinateReferenceSystem("84");
fail("Should not work without authority.");
} catch (NoSuchAuthorityCodeException exception) {
// This is the expected exception.
assertEquals("84", exception.getAuthorityCode());
}
try {
all.createCoordinateReferenceSystem("FOO:84");
fail("Should not work with unknown authority.");
} catch (NoSuchAuthorityCodeException exception) {
// This is the expected exception.
assertEquals("FOO", exception.getAuthority());
}