Skip to content

Commit c992d19

Browse files
committed
14: Change system properties to new TLD
Task-Url: https://github.com/unitsofmeasurement/unit-tck/issues/issues/14
1 parent 2f8af3c commit c992d19

3 files changed

Lines changed: 154 additions & 97 deletions

File tree

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
<parent>
1515
<groupId>tech.uom</groupId>
1616
<artifactId>uom-parent</artifactId>
17-
<version>2.0-SNAPSHOT</version>
17+
<version>2.0-EDR</version>
1818
</parent>
1919
<licenses>
2020
<license>
2121
<name>BSD</name>
22-
<url>LICENSE.txt</url>
22+
<url>LICENSE</url>
2323
</license>
2424
</licenses>
2525
<issueManagement>
@@ -34,8 +34,8 @@
3434
<!-- Build Settings -->
3535
<!-- ======================================================= -->
3636
<properties>
37-
<jsr.version>2.0-SNAPSHOT</jsr.version>
38-
<ri.version>2.0-SNAPSHOT</ri.version>
37+
<jsr.version>2.0-EDR</jsr.version>
38+
<ri.version>2.0-EDR</ri.version>
3939
<jdkVersion>1.8</jdkVersion>
4040
<project.build.javaVersion>${jdkVersion}</project.build.javaVersion>
4141
<maven.compile.targetLevel>1.7</maven.compile.targetLevel>

src/main/java/tech/units/tck/tests/spi/ServicesTest.java

Lines changed: 142 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@
3232
import static org.testng.AssertJUnit.assertNotNull;
3333
import static tech.units.tck.TCKRunner.SPEC_ID;
3434
import static tech.units.tck.TCKRunner.SPEC_VERSION;
35+
36+
import java.util.Set;
37+
38+
import static org.testng.Assert.assertEquals;
3539
import static org.testng.AssertJUnit.assertFalse;
3640

41+
import javax.measure.BinaryPrefix;
42+
import javax.measure.MetricPrefix;
43+
import javax.measure.Prefix;
44+
import javax.measure.spi.FormatService;
3745
import javax.measure.spi.ServiceProvider;
3846
import javax.measure.spi.SystemOfUnitsService;
3947
import javax.measure.spi.UnitFormatService;
@@ -44,110 +52,151 @@
4452

4553
/**
4654
* Test class for Services.
55+
*
4756
* @author Werner Keil
4857
* @version 1.0, August 16, 2016
4958
* @since 1.0
5059
*/
5160
@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION)
5261
public class ServicesTest {
53-
private static final String SECTION = "5.4";
54-
private static final String DESCRIPTION = SECTION + " Services";
62+
private static final String SECTION = "5.4";
63+
private static final String DESCRIPTION = SECTION + " Services";
64+
65+
// ************************ 5.4 Services
66+
// ************************
67+
/**
68+
* Access available UnitFormatServices.
69+
*/
70+
@Test(groups = { "spi" }, description = DESCRIPTION)
71+
@SpecAssertion(section = SECTION, id = "54-A1")
72+
public void testFormatService() {
73+
for (ServiceProvider provider : ServiceProvider.available()) {
74+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
75+
UnitFormatService service = provider.getFormatService();
76+
assertNotNull("Section " + SECTION + ": FormatService is null", service);
77+
}
78+
}
79+
80+
// ************************ 5.4 Services
81+
// ************************
82+
/**
83+
* Access default UnitFormats in UnitFormatServices.
84+
*/
85+
@Test(groups = { "spi" }, description = DESCRIPTION)
86+
@SpecAssertion(section = SECTION, id = "54-A2")
87+
public void testFormatServiceDefaultFormat() {
88+
for (ServiceProvider provider : ServiceProvider.available()) {
89+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
90+
FormatService service = provider.getFormatService();
91+
assertNotNull("Section " + SECTION + ": UnitFormatService is null", service);
92+
assertNotNull("Section " + SECTION + ": Default UnitFormat is null", service.getUnitFormat());
93+
assertNotNull("Section " + SECTION + ": Available UnitFormat names are null",
94+
service.getAvailableFormatNames());
95+
assertFalse("Section " + SECTION + " No available UnitFormat names found",
96+
service.getAvailableFormatNames().isEmpty());
97+
}
98+
}
5599

56-
// ************************ 5.4 Services
57-
// ************************
58-
/**
59-
* Access available UnitFormatServices.
60-
*/
61-
@Test(groups = {"spi"}, description = DESCRIPTION)
62-
@SpecAssertion(section = SECTION, id = "54-A1")
63-
public void testFormatService() {
64-
for (ServiceProvider provider : ServiceProvider.available()) {
65-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
66-
UnitFormatService service = provider.getUnitFormatService();
67-
assertNotNull("Section " + SECTION + ": UnitFormatService is null", service);
100+
// ************************ 5.4 Services
101+
// ************************
102+
/**
103+
* Access available UnitFormats in UnitFormatServices.
104+
*/
105+
@Test(groups = { "spi" }, description = DESCRIPTION)
106+
@SpecAssertion(section = SECTION, id = "54-A3")
107+
public void testFormatServiceAvailableFormats() {
108+
for (ServiceProvider provider : ServiceProvider.available()) {
109+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
110+
FormatService service = provider.getFormatService();
111+
assertNotNull("Section " + SECTION + ": FormatService is null", service);
112+
assertNotNull("Section " + SECTION + ": Available UnitFormat names are null",
113+
service.getAvailableFormatNames());
114+
assertFalse("Section " + SECTION + " No available UnitFormat names found",
115+
service.getAvailableFormatNames().isEmpty());
116+
}
68117
}
69-
}
70-
71-
// ************************ 5.4 Services
72-
// ************************
73-
/**
74-
* Access default UnitFormats in UnitFormatServices.
75-
*/
76-
@Test(groups = {"spi"}, description = DESCRIPTION)
77-
@SpecAssertion(section = SECTION, id = "54-A2")
78-
public void testFormatServiceDefaultFormat() {
79-
for (ServiceProvider provider : ServiceProvider.available()) {
80-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
81-
UnitFormatService service = provider.getUnitFormatService();
82-
assertNotNull("Section " + SECTION + ": UnitFormatService is null", service);
83-
assertNotNull("Section " + SECTION + ": Default UnitFormat is null", service.getUnitFormat());
84-
assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", service.getAvailableFormatNames());
85-
assertFalse("Section " + SECTION + " No available UnitFormat names found", service.getAvailableFormatNames().isEmpty());
118+
119+
// ************************ 5.4 Services
120+
// ************************
121+
/**
122+
* Access available SystemOfUnitsServices.
123+
*/
124+
@Test(groups = { "spi" }, description = DESCRIPTION)
125+
@SpecAssertion(section = SECTION, id = "54-A4")
126+
public void testSystemOfUnitsService() {
127+
for (ServiceProvider provider : ServiceProvider.available()) {
128+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
129+
SystemOfUnitsService service = provider.getSystemOfUnitsService();
130+
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
131+
}
86132
}
87-
}
88-
89-
// ************************ 5.4 Services
90-
// ************************
91-
/**
92-
* Access available UnitFormats in UnitFormatServices.
93-
*/
94-
@Test(groups = {"spi"}, description = DESCRIPTION)
95-
@SpecAssertion(section = SECTION, id = "54-A3")
96-
public void testFormatServiceAvailableFormats() {
97-
for (ServiceProvider provider : ServiceProvider.available()) {
98-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
99-
UnitFormatService service = provider.getUnitFormatService();
100-
assertNotNull("Section " + SECTION + ": UnitFormatService is null", service);
101-
assertNotNull("Section " + SECTION + ": Available UnitFormat names are null", service.getAvailableFormatNames());
102-
assertFalse("Section " + SECTION + " No available UnitFormat names found", service.getAvailableFormatNames().isEmpty());
133+
134+
// ************************ 5.4 Services
135+
// ************************
136+
/**
137+
* Access default SystemOfUnits in SystemOfUnitsService.
138+
*/
139+
@Test(groups = { "spi" }, description = DESCRIPTION)
140+
@SpecAssertion(section = SECTION, id = "54-A5")
141+
public void testSystemOfUnitsServiceDefaultSystem() {
142+
for (ServiceProvider provider : ServiceProvider.available()) {
143+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
144+
SystemOfUnitsService service = provider.getSystemOfUnitsService();
145+
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
146+
assertNotNull("Section " + SECTION + ": Default SystemOfUnits is null", service.getSystemOfUnits());
147+
}
103148
}
104-
}
105-
106-
// ************************ 5.4 Services
107-
// ************************
108-
/**
109-
* Access available SystemOfUnitsServices.
110-
*/
111-
@Test(groups = {"spi"}, description = DESCRIPTION)
112-
@SpecAssertion(section = SECTION, id = "54-A4")
113-
public void testSystemOfUnitsService() {
114-
for (ServiceProvider provider : ServiceProvider.available()) {
115-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
116-
SystemOfUnitsService service = provider.getSystemOfUnitsService();
117-
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
149+
150+
// ************************ 5.4 Services
151+
// ************************
152+
/**
153+
* Access available Systems OfUnits in SystemOfUnitsService.
154+
*/
155+
@Test(groups = { "spi" }, description = DESCRIPTION)
156+
@SpecAssertion(section = SECTION, id = "54-A6")
157+
public void testSystemOfUnitsServiceAvailableSystems() {
158+
for (ServiceProvider provider : ServiceProvider.available()) {
159+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
160+
SystemOfUnitsService service = provider.getSystemOfUnitsService();
161+
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
162+
assertNotNull("Section " + SECTION + ": Available SystemOfUnits are null",
163+
service.getAvailableSystemsOfUnits());
164+
assertFalse("Section " + SECTION + " No available SystemOfUnits found",
165+
service.getAvailableSystemsOfUnits().isEmpty());
166+
}
118167
}
119-
}
120-
121-
// ************************ 5.4 Services
122-
// ************************
123-
/**
124-
* Access default SystemOfUnits in SystemOfUnitsService.
125-
*/
126-
@Test(groups = {"spi"}, description = DESCRIPTION)
127-
@SpecAssertion(section = SECTION, id = "54-A5")
128-
public void testSystemOfUnitsServiceDefaultSystem() {
129-
for (ServiceProvider provider : ServiceProvider.available()) {
130-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
131-
SystemOfUnitsService service = provider.getSystemOfUnitsService();
132-
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
133-
assertNotNull("Section " + SECTION + ": Default SystemOfUnits is null", service.getSystemOfUnits());
168+
169+
/**
170+
* Access Binary Prefixes in SystemOfUnitsService.
171+
*/
172+
@Test(groups = { "spi" }, description = DESCRIPTION)
173+
@SpecAssertion(section = SECTION, id = "54-A7")
174+
public void testSystemOfUnitsServicePrefixBinary() {
175+
for (ServiceProvider provider : ServiceProvider.available()) {
176+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
177+
final SystemOfUnitsService service = provider.getSystemOfUnitsService();
178+
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
179+
Set<Prefix> prefixes = service.getPrefixes(BinaryPrefix.class);
180+
assertNotNull("Section " + SECTION + ": Binary Prefixes are null", prefixes);
181+
assertFalse("Section " + SECTION + " No Binary Prefixes found", prefixes.isEmpty());
182+
assertEquals(8, prefixes.size(), "Section " + SECTION + " Wrong Number of Binary Prefixes");
183+
}
134184
}
135-
}
136-
137-
// ************************ 5.4 Services
138-
// ************************
139-
/**
140-
* Access available Systems OfUnits in SystemOfUnitsService.
141-
*/
142-
@Test(groups = {"spi"}, description = DESCRIPTION)
143-
@SpecAssertion(section = SECTION, id = "54-A6")
144-
public void testSystemOfUnitsServiceAvailableSystems() {
145-
for (ServiceProvider provider : ServiceProvider.available()) {
146-
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
147-
SystemOfUnitsService service = provider.getSystemOfUnitsService();
148-
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
149-
assertNotNull("Section " + SECTION + ": Available SystemOfUnits are null", service.getAvailableSystemsOfUnits());
150-
assertFalse("Section " + SECTION + " No available SystemOfUnits found", service.getAvailableSystemsOfUnits().isEmpty());
185+
186+
/**
187+
* Access Metric Prefixes in SystemOfUnitsService.
188+
*/
189+
@Test(groups = { "spi" }, description = DESCRIPTION)
190+
@SpecAssertion(section = SECTION, id = "54-A8")
191+
public void testSystemOfUnitsServicePrefixMetric() {
192+
for (ServiceProvider provider : ServiceProvider.available()) {
193+
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
194+
final SystemOfUnitsService service = provider.getSystemOfUnitsService();
195+
assertNotNull("Section " + SECTION + ": SystemOfUnitsService is null", service);
196+
Set<Prefix> prefixes = service.getPrefixes(MetricPrefix.class);
197+
assertNotNull("Section " + SECTION + ": Metric Prefixes are null", prefixes);
198+
assertFalse("Section " + SECTION + " No Metric Prefixes found", prefixes.isEmpty());
199+
assertEquals(20, prefixes.size(), "Section " + SECTION + " Wrong Number of Metric Prefixes");
200+
}
151201
}
152-
}
153202
}

test-audit.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@
398398
<text>Access available Systems OfUnits in SystemOfUnitsService.
399399
</text>
400400
</assertion>
401+
<assertion id="54-A7">
402+
<text>Access Binary Prefixes in SystemOfUnitsService.
403+
</text>
404+
</assertion>
405+
<assertion id="54-A8">
406+
<text>Access Metric Prefixes in SystemOfUnitsService.
407+
</text>
408+
</assertion>
401409
</group>
402410
<section id="5.5" title="Obtaining Unit Instances" />
403411
<section id="5.5.1" title="Units Obtained from Unit Systems">

0 commit comments

Comments
 (0)