Skip to content

Commit

Permalink
14: Change system properties to new TLD
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Aug 18, 2018
1 parent 2f8af3c commit c992d19
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 97 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
235 changes: 142 additions & 93 deletions src/main/java/tech/units/tck/tests/spi/ServicesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
}
}
}
8 changes: 8 additions & 0 deletions test-audit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit c992d19

Please sign in to comment.