Java Code Examples for javax.measure.spi.ServiceProvider#current()

The following examples show how to use javax.measure.spi.ServiceProvider#current() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnitServicesTest.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the default system of units.
 */
@Test
public void testDefaultSystemOfUnits() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits().getUnits();
    assertTrue("METRE",                units.contains(Units.METRE));
    assertTrue("KILOMETRE",            units.contains(Units.KILOMETRE));
    assertTrue("CUBIC_METRE",          units.contains(Units.CUBIC_METRE));
    assertTrue("METRES_PER_SECOND",    units.contains(Units.METRES_PER_SECOND));
    assertTrue("KILOMETRES_PER_HOUR",  units.contains(Units.KILOMETRES_PER_HOUR));
    assertTrue("NAUTICAL_MILE",        units.contains(Units.NAUTICAL_MILE));
    assertTrue("STATUTE_MILE",         units.contains(Units.STATUTE_MILE));
    assertTrue("DEGREE",               units.contains(Units.DEGREE));
    assertTrue("RADIAN",               units.contains(Units.RADIAN));
    assertTrue("GRAD",                 units.contains(Units.GRAD));
}
 
Example 2
Source File: UnitServicesTest.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the "SI" system of units.
 */
@Test
public void testSI() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI").getUnits();
    assertTrue ("METRE",                units.contains(Units.METRE));
    assertTrue ("KILOMETRE",            units.contains(Units.KILOMETRE));
    assertTrue ("CUBIC_METRE",          units.contains(Units.CUBIC_METRE));
    assertTrue ("METRES_PER_SECOND",    units.contains(Units.METRES_PER_SECOND));
    assertFalse("KILOMETRES_PER_HOUR",  units.contains(Units.KILOMETRES_PER_HOUR));
    assertFalse("NAUTICAL_MILE",        units.contains(Units.NAUTICAL_MILE));
    assertFalse("STATUTE_MILE",         units.contains(Units.STATUTE_MILE));
    assertFalse("DEGREE",               units.contains(Units.DEGREE));
    assertTrue ("RADIAN",               units.contains(Units.RADIAN));
    assertFalse("GRAD",                 units.contains(Units.GRAD));
}
 
Example 3
Source File: UnitServicesTest.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the "SI + accepted" system of units.
 */
@Test
public void testAccepted() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI + accepted").getUnits();
    assertTrue ("METRE",                units.contains(Units.METRE));
    assertTrue ("KILOMETRE",            units.contains(Units.KILOMETRE));
    assertTrue ("CUBIC_METRE",          units.contains(Units.CUBIC_METRE));
    assertTrue ("METRES_PER_SECOND",    units.contains(Units.METRES_PER_SECOND));
    assertTrue ("KILOMETRES_PER_HOUR",  units.contains(Units.KILOMETRES_PER_HOUR));
    assertFalse("NAUTICAL_MILE",        units.contains(Units.NAUTICAL_MILE));
    assertFalse("STATUTE_MILE",         units.contains(Units.STATUTE_MILE));
    assertTrue ("DEGREE",               units.contains(Units.DEGREE));
    assertTrue ("RADIAN",               units.contains(Units.RADIAN));
    assertFalse("GRAD",                 units.contains(Units.GRAD));
}
 
Example 4
Source File: UnitServicesTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the "Imperial" system of units.
 */
@Test
public void testImperial() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("Imperial").getUnits();
    assertFalse("METRE",                units.contains(Units.METRE));
    assertFalse("KILOMETRE",            units.contains(Units.KILOMETRE));
    assertFalse("CUBIC_METRE",          units.contains(Units.CUBIC_METRE));
    assertFalse("METRES_PER_SECOND",    units.contains(Units.METRES_PER_SECOND));
    assertFalse("KILOMETRES_PER_HOUR",  units.contains(Units.KILOMETRES_PER_HOUR));
    assertTrue ("STATUTE_MILE",         units.contains(Units.STATUTE_MILE));
    assertFalse("DEGREE",               units.contains(Units.DEGREE));
    assertFalse("RADIAN",               units.contains(Units.RADIAN));
    assertFalse("GRAD",                 units.contains(Units.GRAD));
}
 
Example 5
Source File: UnitServicesTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests {@link UnitServices#getAvailableFormatNames()}.
 */
@Test
public void testGetAvailableFormatNames() {
    final ServiceProvider provider = ServiceProvider.current();
    assertSetEquals(Arrays.asList("SYMBOL", "UCUM", "NAME"),
            provider.getUnitFormatService().getAvailableFormatNames());
}
 
Example 6
Source File: UnitServicesTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Tests {@link UnitServices#getUnitFormat(String)}.
 */
@Test
public void testGetUnitFormat() {
    final ServiceProvider provider = ServiceProvider.current();
    final UnitFormat f = provider.getUnitFormatService().getUnitFormat("name");
    ((org.apache.sis.measure.UnitFormat) f).setLocale(Locale.US);
    assertEquals("CUBIC_METRE", "cubic meter", f.format(Units.CUBIC_METRE));
}
 
Example 7
Source File: ServiceProviderTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test
  public void testCurrent() throws Exception {
ServiceProvider provider = ServiceProvider.current();
assertNotNull(provider);
assertEquals("UCUMServiceProvider", provider.toString());
  }