Skip to content

Commit 7feb781

Browse files
committed
UNITSOFMEASUREMENT-158: Add Tests according to Spec Chapter 5
Task-Url: https://java.net/jira/browse/UNITSOFMEASUREMENT-158
1 parent 1c36ec9 commit 7feb781

5 files changed

Lines changed: 54 additions & 28 deletions

File tree

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,11 @@
365365
<!-- Additional repositories -->
366366
<!-- Helps to resolve Parent POM and Snapshot artifacts -->
367367
<repositories>
368-
<repository>
368+
<!-- repository>
369369
<id>geotoolkit</id>
370370
<name>Geotoolkit.org project</name>
371371
<url>http://maven.geotoolkit.org</url>
372-
</repository>
372+
</repository -->
373373
<repository>
374374
<id>jcenter</id>
375375
<name>JCenter</name>
@@ -392,6 +392,7 @@
392392
<url>http://oss.jfrog.org/artifactory/libs-snapshot</url>
393393
</repository>
394394
</repositories>
395+
395396
<distributionManagement>
396397
<repository>
397398
<id>bintray-release</id>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class ServicesTest {
5656
*/
5757
@Test(groups = {"spi"}, description = DESCRIPTION)
5858
@SpecAssertion(section = SECTION, id = "54-A1")
59-
public void testFormatServices() {
59+
public void testFormatService() {
6060
for (ServiceProvider provider : ServiceProvider.available()) {
6161
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
6262
UnitFormatService service = provider.getUnitFormatService();
@@ -106,7 +106,7 @@ public void testFormatServiceAvailableFormats() {
106106
*/
107107
@Test(groups = {"spi"}, description = DESCRIPTION)
108108
@SpecAssertion(section = SECTION, id = "54-A4")
109-
public void testSystemOfUnitsServices() {
109+
public void testSystemOfUnitsService() {
110110
for (ServiceProvider provider : ServiceProvider.available()) {
111111
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
112112
SystemOfUnitsService service = provider.getSystemOfUnitsService();

src/main/java/tec/units/tck/tests/unit/UnitDimensionTest.java

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Unit-API - Units of Measurement API for Java Copyright (c) 2005-2015, Jean-Marie Dautelle, Werner
2+
* Units of Measurement TCK for Java Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner
33
* Keil, V2COM.
44
*
55
* All rights reserved.
@@ -30,11 +30,15 @@
3030

3131
import static tec.units.tck.TCKRunner.SPEC_ID;
3232
import static tec.units.tck.TCKRunner.SPEC_VERSION;
33+
3334
import java.util.Map;
35+
3436
import javax.measure.Dimension;
37+
3538
import org.jboss.test.audit.annotations.SpecAssertion;
3639
import org.jboss.test.audit.annotations.SpecVersion;
3740
import org.testng.annotations.Test;
41+
3842
import tec.units.tck.TCKSetup;
3943
import tec.units.tck.util.TestUtils;
4044

@@ -45,88 +49,89 @@
4549
*/
4650
@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION)
4751
public class UnitDimensionTest {
48-
52+
private static final String SECTION = "4.2.4";
53+
4954
/**
5055
* Test that Dimension implementations override equals.
5156
*/
52-
@SpecAssertion(section = "4.2.4", id = "424-A1")
53-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override equals.")
57+
@SpecAssertion(section = SECTION, id = "424-A1")
58+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override equals.")
5459
public void testUnitEquals() {
5560
for (@SuppressWarnings("rawtypes")
5661
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
57-
TestUtils.testHasPublicMethod("Section 4.2.1", type, boolean.class, "equals", Object.class);
62+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, boolean.class, "equals", Object.class);
5863
}
5964
}
6065

6166
/**
6267
* Test that Dimension implementations override hashCode.
6368
*/
64-
@SpecAssertion(section = "4.2.4", id = "424-A2")
65-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override hashCode.")
69+
@SpecAssertion(section = SECTION, id = "424-A2")
70+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override hashCode.")
6671
public void testUnitHashcode() {
6772
for (@SuppressWarnings("rawtypes")
6873
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
69-
TestUtils.testHasPublicMethod("Section 4.2.4", type, int.class, "hashCode");
74+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, int.class, "hashCode");
7075
}
7176
}
7277

7378
/**
7479
* Test that Dimension implementations override multiply.
7580
*/
76-
@SpecAssertion(section = "4.2.4", id = "424-A3")
77-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override multiply.")
81+
@SpecAssertion(section = SECTION, id = "424-A3")
82+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override multiply.")
7883
public void testUnitMultiply() {
7984
for (@SuppressWarnings("rawtypes")
8085
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
81-
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "multiply", Dimension.class);
86+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "multiply", Dimension.class);
8287
}
8388
}
8489

8590
/**
8691
* Test that Dimension implementations override divide.
8792
*/
88-
@SpecAssertion(section = "4.2.4", id = "424-A4")
89-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override divide.")
93+
@SpecAssertion(section = SECTION, id = "424-A4")
94+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override divide.")
9095
public void testUnitDivide() {
9196
for (@SuppressWarnings("rawtypes")
9297
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
93-
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "divide", Dimension.class);
98+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "divide", Dimension.class);
9499
}
95100
}
96101

97102
/**
98103
* Test that Dimension implementations override root.
99104
*/
100-
@SpecAssertion(section = "4.2.4", id = "424-A5")
101-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override root.")
105+
@SpecAssertion(section = SECTION, id = "424-A5")
106+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override root.")
102107
public void testUnitRoot() {
103108
for (@SuppressWarnings("rawtypes")
104109
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
105-
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "root", int.class);
110+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "root", int.class);
106111
}
107112
}
108113

109114
/**
110115
* Test that Dimension implementations override pow.
111116
*/
112-
@SpecAssertion(section = "4.2.4", id = "424-A6")
113-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override pow.")
117+
@SpecAssertion(section = SECTION, id = "424-A6")
118+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override pow.")
114119
public void testUnitPow() {
115120
for (@SuppressWarnings("rawtypes")
116121
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
117-
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "pow", int.class);
122+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "pow", int.class);
118123
}
119124
}
120125

121126
/**
122127
* Test that Dimension implementations override getBaseDimensions.
123128
*/
124-
@SpecAssertion(section = "4.2.4", id = "424-A7")
125-
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override getBaseDimensions.")
129+
@SpecAssertion(section = SECTION, id = "424-A7")
130+
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override getBaseDimensions.")
126131
public void testUnitGetProductDimensions() {
127132
for (@SuppressWarnings("rawtypes")
128133
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
129-
TestUtils.testHasPublicMethod("Section 4.2.4", type, Map.class, "getBaseDimensions");
134+
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Map.class, "getBaseDimensions");
130135
}
131136
}
132137
}

src/main/java/tec/units/tck/tests/unit/UnitInterfaceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void testGetSystemUnit() {
8686
*/
8787
@SpecAssertion(section = "4.2.1", id = "421-A4")
8888
@Test(groups = {"core"}, description = "4.2.1 Ensure registered Unit classes implement getBaseUnits.")
89-
public void testGetProductUnits() {
89+
public void testGetBaseUnits() {
9090
for (@SuppressWarnings("rawtypes")
9191
Class type : TCKSetup.getConfiguration().getUnitClasses()) {
9292
TestUtils.testHasPublicMethod("Section 4.2.1", type, "getBaseUnits");

src/main/resources/test-audit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,26 @@
173173
<text>Ensure the hashCode() operation is implemented.
174174
</text>
175175
</assertion>
176+
<assertion id="424-A3">
177+
<text>Ensure registered Dimension classes override multiply.
178+
</text>
179+
</assertion>
180+
<assertion id="424-A4">
181+
<text>Ensure registered Dimension classes override divide.
182+
</text>
183+
</assertion>
184+
<assertion id="424-A5">
185+
<text>Ensure registered Dimension classes override root.
186+
</text>
187+
</assertion>
188+
<assertion id="424-A6">
189+
<text>Ensure registered Dimension classes override pow.
190+
</text>
191+
</assertion>
192+
<assertion id="424-A7">
193+
<text>Ensure registered Dimension classes override getBaseDimensions.
194+
</text>
195+
</assertion>
176196
</group>
177197
</section>
178198

0 commit comments

Comments
 (0)