Skip to content

Commit

Permalink
# WARNING: head commit changed in the meantime
Browse files Browse the repository at this point in the history
98: Update JUnit

Task-Url: unitsofmeasurement/uom-demos#98
  • Loading branch information
keilw committed Nov 4, 2020
1 parent 3eddd3c commit f4fc74f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
11 changes: 2 additions & 9 deletions ucum/src/main/java/systems/uom/ucum/spi/UCUMServiceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@
import javax.measure.spi.FormatService;
import javax.measure.spi.ServiceProvider;
import javax.measure.spi.SystemOfUnitsService;
import javax.measure.spi.UnitFormatService;

import tech.units.indriya.spi.AbstractServiceProvider;

/**
* This class implements the {@link ServiceProvider} interface and hereby uses the JDK {@link java.util.ServiceLoader} to load the services required.
*
* @author Werner Keil
* @version 1.0
* @version 2.0
*/
public final class UCUMServiceProvider extends AbstractServiceProvider {

Expand All @@ -52,12 +50,7 @@ public int getPriority() {
public SystemOfUnitsService getSystemOfUnitsService() {
return new UCUMSystemService();
}

@Override
public UnitFormatService getUnitFormatService() {
return new UCUMFormatService();
}


@Override
public FormatService getFormatService() {
return new UCUMFormatService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public class UCUMFormat135Test extends UCUMFormatTestBase {

@Test
public void testParseUCUMCSM3PerSecond() {
final UnitFormat unitFormat = ServiceProvider.current().getUnitFormatService().getUnitFormat("CI");
final UnitFormat unitFormat = ServiceProvider.current().getFormatService().getUnitFormat("CI");
final Unit<?> dst = unitFormat.parse("m3/s");
assertEquals("m3/s",FORMAT_CS.format(dst));
}

@Test
public void testParseUCUMCSComplexDenominator() {
final UnitFormat unitFormat = ServiceProvider.current().getUnitFormatService().getUnitFormat("CI");
final UnitFormat unitFormat = ServiceProvider.current().getFormatService().getUnitFormat("CI");
final Unit<?> dst = unitFormat.parse("m/(bar.s)");
assertEquals("m/(bar.s)",FORMAT_CS.format(dst));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,43 +44,43 @@ public class UnitFormatServiceTest {

@Test
public void testGetService() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNotNull(ufs.getUnitFormat());
assertEquals("Parsing", ufs.getUnitFormat().getClass().getSimpleName());
}

@Test
public void testGetCIFound() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNotNull(ufs.getUnitFormat("CI"));
}

@Test
public void testGetCSFound() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNotNull(ufs.getUnitFormat("CS"));
}

@Test
public void testGetPrintFound() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNotNull(ufs.getUnitFormat("Print"));
}

@Test
public void testGetFormatNotFound() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNull(ufs.getUnitFormat("XYZ"));
}

@Test
public void testGetFormatNotFoundEither() throws Exception {
UnitFormatService ufs = ServiceProvider.current().getUnitFormatService();
UnitFormatService ufs = ServiceProvider.current().getFormatService();
assertNotNull(ufs);
assertNotNull(ufs.getUnitFormat("UCUM"));
}
Expand Down

0 comments on commit f4fc74f

Please sign in to comment.