Skip to content

Commit

Permalink
UNITSOFMEASUREMENT-158: Add Tests according to Spec Chapter 5
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Jul 2, 2016
1 parent 1c36ec9 commit 7feb781
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 28 deletions.
5 changes: 3 additions & 2 deletions pom.xml
Expand Up @@ -365,11 +365,11 @@
<!-- Additional repositories -->
<!-- Helps to resolve Parent POM and Snapshot artifacts -->
<repositories>
<repository>
<!-- repository>
<id>geotoolkit</id>
<name>Geotoolkit.org project</name>
<url>http://maven.geotoolkit.org</url>
</repository>
</repository -->
<repository>
<id>jcenter</id>
<name>JCenter</name>
Expand All @@ -392,6 +392,7 @@
<url>http://oss.jfrog.org/artifactory/libs-snapshot</url>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>bintray-release</id>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tec/units/tck/tests/spi/ServicesTest.java
Expand Up @@ -56,7 +56,7 @@ public class ServicesTest {
*/
@Test(groups = {"spi"}, description = DESCRIPTION)
@SpecAssertion(section = SECTION, id = "54-A1")
public void testFormatServices() {
public void testFormatService() {
for (ServiceProvider provider : ServiceProvider.available()) {
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
UnitFormatService service = provider.getUnitFormatService();
Expand Down Expand Up @@ -106,7 +106,7 @@ public void testFormatServiceAvailableFormats() {
*/
@Test(groups = {"spi"}, description = DESCRIPTION)
@SpecAssertion(section = SECTION, id = "54-A4")
public void testSystemOfUnitsServices() {
public void testSystemOfUnitsService() {
for (ServiceProvider provider : ServiceProvider.available()) {
assertNotNull("Section " + SECTION + ": ServiceProvider is null", provider);
SystemOfUnitsService service = provider.getSystemOfUnitsService();
Expand Down
51 changes: 28 additions & 23 deletions src/main/java/tec/units/tck/tests/unit/UnitDimensionTest.java
@@ -1,5 +1,5 @@
/*
* Unit-API - Units of Measurement API for Java Copyright (c) 2005-2015, Jean-Marie Dautelle, Werner
* Units of Measurement TCK for Java Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner
* Keil, V2COM.
*
* All rights reserved.
Expand Down Expand Up @@ -30,11 +30,15 @@

import static tec.units.tck.TCKRunner.SPEC_ID;
import static tec.units.tck.TCKRunner.SPEC_VERSION;

import java.util.Map;

import javax.measure.Dimension;

import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

import tec.units.tck.TCKSetup;
import tec.units.tck.util.TestUtils;

Expand All @@ -45,88 +49,89 @@
*/
@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION)
public class UnitDimensionTest {

private static final String SECTION = "4.2.4";

/**
* Test that Dimension implementations override equals.
*/
@SpecAssertion(section = "4.2.4", id = "424-A1")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override equals.")
@SpecAssertion(section = SECTION, id = "424-A1")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override equals.")
public void testUnitEquals() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.1", type, boolean.class, "equals", Object.class);
TestUtils.testHasPublicMethod("Section "+ SECTION, type, boolean.class, "equals", Object.class);
}
}

/**
* Test that Dimension implementations override hashCode.
*/
@SpecAssertion(section = "4.2.4", id = "424-A2")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override hashCode.")
@SpecAssertion(section = SECTION, id = "424-A2")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override hashCode.")
public void testUnitHashcode() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, int.class, "hashCode");
TestUtils.testHasPublicMethod("Section "+ SECTION, type, int.class, "hashCode");
}
}

/**
* Test that Dimension implementations override multiply.
*/
@SpecAssertion(section = "4.2.4", id = "424-A3")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override multiply.")
@SpecAssertion(section = SECTION, id = "424-A3")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override multiply.")
public void testUnitMultiply() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "multiply", Dimension.class);
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "multiply", Dimension.class);
}
}

/**
* Test that Dimension implementations override divide.
*/
@SpecAssertion(section = "4.2.4", id = "424-A4")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override divide.")
@SpecAssertion(section = SECTION, id = "424-A4")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override divide.")
public void testUnitDivide() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "divide", Dimension.class);
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "divide", Dimension.class);
}
}

/**
* Test that Dimension implementations override root.
*/
@SpecAssertion(section = "4.2.4", id = "424-A5")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override root.")
@SpecAssertion(section = SECTION, id = "424-A5")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override root.")
public void testUnitRoot() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "root", int.class);
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "root", int.class);
}
}

/**
* Test that Dimension implementations override pow.
*/
@SpecAssertion(section = "4.2.4", id = "424-A6")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override pow.")
@SpecAssertion(section = SECTION, id = "424-A6")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override pow.")
public void testUnitPow() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, Dimension.class, "pow", int.class);
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "pow", int.class);
}
}

/**
* Test that Dimension implementations override getBaseDimensions.
*/
@SpecAssertion(section = "4.2.4", id = "424-A7")
@Test(groups = {"core"}, description = "4.2.4 Ensure registered Dimension classes override getBaseDimensions.")
@SpecAssertion(section = SECTION, id = "424-A7")
@Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override getBaseDimensions.")
public void testUnitGetProductDimensions() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getDimensionClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.4", type, Map.class, "getBaseDimensions");
TestUtils.testHasPublicMethod("Section "+ SECTION, type, Map.class, "getBaseDimensions");
}
}
}
Expand Up @@ -86,7 +86,7 @@ public void testGetSystemUnit() {
*/
@SpecAssertion(section = "4.2.1", id = "421-A4")
@Test(groups = {"core"}, description = "4.2.1 Ensure registered Unit classes implement getBaseUnits.")
public void testGetProductUnits() {
public void testGetBaseUnits() {
for (@SuppressWarnings("rawtypes")
Class type : TCKSetup.getConfiguration().getUnitClasses()) {
TestUtils.testHasPublicMethod("Section 4.2.1", type, "getBaseUnits");
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/test-audit.xml
Expand Up @@ -173,6 +173,26 @@
<text>Ensure the hashCode() operation is implemented.
</text>
</assertion>
<assertion id="424-A3">
<text>Ensure registered Dimension classes override multiply.
</text>
</assertion>
<assertion id="424-A4">
<text>Ensure registered Dimension classes override divide.
</text>
</assertion>
<assertion id="424-A5">
<text>Ensure registered Dimension classes override root.
</text>
</assertion>
<assertion id="424-A6">
<text>Ensure registered Dimension classes override pow.
</text>
</assertion>
<assertion id="424-A7">
<text>Ensure registered Dimension classes override getBaseDimensions.
</text>
</assertion>
</group>
</section>

Expand Down

0 comments on commit 7feb781

Please sign in to comment.