From c992d19a71b1687820de893f91d28c904908950e Mon Sep 17 00:00:00 2001 From: Werner Keil <werner.keil@gmx.net> Date: Sat, 18 Aug 2018 23:21:01 +0200 Subject: [PATCH] 14: Change system properties to new TLD Task-Url: https://github.com/unitsofmeasurement/unit-tck/issues/issues/14 --- pom.xml | 8 +- .../units/tck/tests/spi/ServicesTest.java | 235 +++++++++++------- test-audit.xml | 8 + 3 files changed, 154 insertions(+), 97 deletions(-) diff --git a/pom.xml b/pom.xml index 69f7566..df135c2 100644 --- a/pom.xml +++ b/pom.xml @@ -14,12 +14,12 @@ <parent> <groupId>tech.uom</groupId> <artifactId>uom-parent</artifactId> - <version>2.0-SNAPSHOT</version> + <version>2.0-EDR</version> </parent> <licenses> <license> <name>BSD</name> - <url>LICENSE.txt</url> + <url>LICENSE</url> </license> </licenses> <issueManagement> @@ -34,8 +34,8 @@ <!-- Build Settings --> <!-- ======================================================= --> <properties> - <jsr.version>2.0-SNAPSHOT</jsr.version> - <ri.version>2.0-SNAPSHOT</ri.version> + <jsr.version>2.0-EDR</jsr.version> + <ri.version>2.0-EDR</ri.version> <jdkVersion>1.8</jdkVersion> <project.build.javaVersion>${jdkVersion}</project.build.javaVersion> <maven.compile.targetLevel>1.7</maven.compile.targetLevel> diff --git a/src/main/java/tech/units/tck/tests/spi/ServicesTest.java b/src/main/java/tech/units/tck/tests/spi/ServicesTest.java index 4701502..cb662ab 100644 --- a/src/main/java/tech/units/tck/tests/spi/ServicesTest.java +++ b/src/main/java/tech/units/tck/tests/spi/ServicesTest.java @@ -32,8 +32,16 @@ import static org.testng.AssertJUnit.assertNotNull; import static tech.units.tck.TCKRunner.SPEC_ID; import static tech.units.tck.TCKRunner.SPEC_VERSION; + +import java.util.Set; + +import static org.testng.Assert.assertEquals; import static org.testng.AssertJUnit.assertFalse; +import javax.measure.BinaryPrefix; +import javax.measure.MetricPrefix; +import javax.measure.Prefix; +import javax.measure.spi.FormatService; import javax.measure.spi.ServiceProvider; import javax.measure.spi.SystemOfUnitsService; import javax.measure.spi.UnitFormatService; @@ -44,110 +52,151 @@ /** * Test class for Services. + * * @author Werner Keil * @version 1.0, August 16, 2016 * @since 1.0 */ @SpecVersion(spec = SPEC_ID, version = SPEC_VERSION) public class ServicesTest { - private static final String SECTION = "5.4"; - private static final String DESCRIPTION = SECTION + " Services"; + private static final String SECTION = "5.4"; + private static final String DESCRIPTION = SECTION + " Services"; + + // ************************ 5.4 Services + // ************************ + /** + * Access available UnitFormatServices. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A1") + public void testFormatService() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + UnitFormatService service = provider.getFormatService(); + assertNotNull("Section " + SECTION + ": FormatService is null", service); + } + } + + // ************************ 5.4 Services + // ************************ + /** + * Access default UnitFormats in UnitFormatServices. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A2") + public void testFormatServiceDefaultFormat() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + FormatService service = provider.getFormatService(); + assertNotNull("Section " + SECTION + ": UnitFormatService is null", service); + assertNotNull("Section " + SECTION + ": Default UnitFormat is null", service.getUnitFormat()); + assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", + service.getAvailableFormatNames()); + assertFalse("Section " + SECTION + " No available UnitFormat names found", + service.getAvailableFormatNames().isEmpty()); + } + } - // ************************ 5.4 Services - // ************************ - /** - * Access available UnitFormatServices. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A1") - public void testFormatService() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - UnitFormatService service = provider.getUnitFormatService(); - assertNotNull("Section " + SECTION + ": UnitFormatService is null", service); + // ************************ 5.4 Services + // ************************ + /** + * Access available UnitFormats in UnitFormatServices. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A3") + public void testFormatServiceAvailableFormats() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + FormatService service = provider.getFormatService(); + assertNotNull("Section " + SECTION + ": FormatService is null", service); + assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", + service.getAvailableFormatNames()); + assertFalse("Section " + SECTION + " No available UnitFormat names found", + service.getAvailableFormatNames().isEmpty()); + } } - } - - // ************************ 5.4 Services - // ************************ - /** - * Access default UnitFormats in UnitFormatServices. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A2") - public void testFormatServiceDefaultFormat() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - UnitFormatService service = provider.getUnitFormatService(); - assertNotNull("Section " + SECTION + ": UnitFormatService is null", service); - assertNotNull("Section " + SECTION + ": Default UnitFormat is null", service.getUnitFormat()); - assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", service.getAvailableFormatNames()); - assertFalse("Section " + SECTION + " No available UnitFormat names found", service.getAvailableFormatNames().isEmpty()); + + // ************************ 5.4 Services + // ************************ + /** + * Access available SystemOfUnitsServices. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A4") + public void testSystemOfUnitsService() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + SystemOfUnitsService service = provider.getSystemOfUnitsService(); + assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + } } - } - - // ************************ 5.4 Services - // ************************ - /** - * Access available UnitFormats in UnitFormatServices. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A3") - public void testFormatServiceAvailableFormats() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - UnitFormatService service = provider.getUnitFormatService(); - assertNotNull("Section " + SECTION + ": UnitFormatService is null", service); - assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", service.getAvailableFormatNames()); - assertFalse("Section " + SECTION + " No available UnitFormat names found", service.getAvailableFormatNames().isEmpty()); + + // ************************ 5.4 Services + // ************************ + /** + * Access default SystemOfUnits in SystemOfUnitsService. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A5") + public void testSystemOfUnitsServiceDefaultSystem() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + SystemOfUnitsService service = provider.getSystemOfUnitsService(); + assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + assertNotNull("Section " + SECTION + ": Default SystemOfUnits is null", service.getSystemOfUnits()); + } } - } - - // ************************ 5.4 Services - // ************************ - /** - * Access available SystemOfUnitsServices. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A4") - public void testSystemOfUnitsService() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - SystemOfUnitsService service = provider.getSystemOfUnitsService(); - assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + + // ************************ 5.4 Services + // ************************ + /** + * Access available Systems OfUnits in SystemOfUnitsService. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A6") + public void testSystemOfUnitsServiceAvailableSystems() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + SystemOfUnitsService service = provider.getSystemOfUnitsService(); + assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + assertNotNull("Section " + SECTION + ": Available SystemOfUnits are null", + service.getAvailableSystemsOfUnits()); + assertFalse("Section " + SECTION + " No available SystemOfUnits found", + service.getAvailableSystemsOfUnits().isEmpty()); + } } - } - - // ************************ 5.4 Services - // ************************ - /** - * Access default SystemOfUnits in SystemOfUnitsService. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A5") - public void testSystemOfUnitsServiceDefaultSystem() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - SystemOfUnitsService service = provider.getSystemOfUnitsService(); - assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); - assertNotNull("Section " + SECTION + ": Default SystemOfUnits is null", service.getSystemOfUnits()); + + /** + * Access Binary Prefixes in SystemOfUnitsService. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A7") + public void testSystemOfUnitsServicePrefixBinary() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + final SystemOfUnitsService service = provider.getSystemOfUnitsService(); + assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + Set<Prefix> prefixes = service.getPrefixes(BinaryPrefix.class); + assertNotNull("Section " + SECTION + ": Binary Prefixes are null", prefixes); + assertFalse("Section " + SECTION + " No Binary Prefixes found", prefixes.isEmpty()); + assertEquals(8, prefixes.size(), "Section " + SECTION + " Wrong Number of Binary Prefixes"); + } } - } - - // ************************ 5.4 Services - // ************************ - /** - * Access available Systems OfUnits in SystemOfUnitsService. - */ - @Test(groups = {"spi"}, description = DESCRIPTION) - @SpecAssertion(section = SECTION, id = "54-A6") - public void testSystemOfUnitsServiceAvailableSystems() { - for (ServiceProvider provider : ServiceProvider.available()) { - assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); - SystemOfUnitsService service = provider.getSystemOfUnitsService(); - assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); - assertNotNull("Section " + SECTION + ": Available SystemOfUnits are null", service.getAvailableSystemsOfUnits()); - assertFalse("Section " + SECTION + " No available SystemOfUnits found", service.getAvailableSystemsOfUnits().isEmpty()); + + /** + * Access Metric Prefixes in SystemOfUnitsService. + */ + @Test(groups = { "spi" }, description = DESCRIPTION) + @SpecAssertion(section = SECTION, id = "54-A8") + public void testSystemOfUnitsServicePrefixMetric() { + for (ServiceProvider provider : ServiceProvider.available()) { + assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider); + final SystemOfUnitsService service = provider.getSystemOfUnitsService(); + assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service); + Set<Prefix> prefixes = service.getPrefixes(MetricPrefix.class); + assertNotNull("Section " + SECTION + ": Metric Prefixes are null", prefixes); + assertFalse("Section " + SECTION + " No Metric Prefixes found", prefixes.isEmpty()); + assertEquals(20, prefixes.size(), "Section " + SECTION + " Wrong Number of Metric Prefixes"); + } } - } } diff --git a/test-audit.xml b/test-audit.xml index 99d7925..c9750a7 100644 --- a/test-audit.xml +++ b/test-audit.xml @@ -398,6 +398,14 @@ <text>Access available Systems OfUnits in SystemOfUnitsService. </text> </assertion> + <assertion id="54-A7"> + <text>Access Binary Prefixes in SystemOfUnitsService. + </text> + </assertion> + <assertion id="54-A8"> + <text>Access Metric Prefixes in SystemOfUnitsService. + </text> + </assertion> </group> <section id="5.5" title="Obtaining Unit Instances" /> <section id="5.5.1" title="Units Obtained from Unit Systems">