001/* 002 * Units of Measurement TCK 003 * Copyright © 2005-2019, Jean-Marie Dautelle, Werner Keil, Otavio Santana. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, 008 * are permitted provided that the following conditions are met: 009 * 010 * 1. Redistributions of source code must retain the above copyright notice, 011 * this list of conditions and the following disclaimer. 012 * 013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 014 * and the following disclaimer in the documentation and/or other materials provided with the distribution. 015 * 016 * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products 017 * derived from this software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package tech.units.tck.tests.unit; 031 032import static tech.units.tck.TCKRunner.SPEC_ID; 033import static tech.units.tck.TCKRunner.SPEC_VERSION; 034 035import java.util.Map; 036 037import javax.measure.Dimension; 038 039import org.jboss.test.audit.annotations.SpecAssertion; 040import org.jboss.test.audit.annotations.SpecVersion; 041import org.testng.annotations.Test; 042 043import tech.units.tck.TCKSetup; 044import tech.units.tck.util.TestUtils; 045 046/** 047 * Unit Dimension Tests 048 * 049 * @author Werner Keil 050 * @author Almas Shaikh 051 * @version 1.1, July 5, 2019 052 * @since 1.0 053 */ 054@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION) 055public class UnitDimensionTest { 056 private static final String SECTION = "4.2.5"; 057 058 /** 059 * Test that Dimension implementations override equals. 060 */ 061 @SpecAssertion(section = SECTION, id = "425-A1") 062 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override equals.") 063 public void testEquals() { 064 for (@SuppressWarnings("rawtypes") 065 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 066 TestUtils.testHasPublicMethod("Section "+ SECTION, type, boolean.class, "equals", Object.class); 067 } 068 } 069 070 /** 071 * Test that Dimension implementations override hashCode. 072 */ 073 @SpecAssertion(section = SECTION, id = "425-A2") 074 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override hashCode.") 075 public void testHashcode() { 076 for (@SuppressWarnings("rawtypes") 077 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 078 TestUtils.testHasPublicMethod("Section "+ SECTION, type, int.class, "hashCode"); 079 } 080 } 081 082 /** 083 * Test that Dimension implementations override multiply. 084 */ 085 @SpecAssertion(section = SECTION, id = "425-A3") 086 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override multiply.") 087 public void testMultiply() { 088 for (@SuppressWarnings("rawtypes") 089 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 090 TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "multiply", Dimension.class); 091 } 092 } 093 094 /** 095 * Test that Dimension implementations override divide. 096 */ 097 @SpecAssertion(section = SECTION, id = "425-A4") 098 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override divide.") 099 public void testDivide() { 100 for (@SuppressWarnings("rawtypes") 101 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 102 TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "divide", Dimension.class); 103 } 104 } 105 106 /** 107 * Test that Dimension implementations override root. 108 */ 109 @SpecAssertion(section = SECTION, id = "425-A5") 110 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override root.") 111 public void testRoot() { 112 for (@SuppressWarnings("rawtypes") 113 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 114 TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "root", int.class); 115 } 116 } 117 118 /** 119 * Test that Dimension implementations override pow. 120 */ 121 @SpecAssertion(section = SECTION, id = "425-A6") 122 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override pow.") 123 public void testPow() { 124 for (@SuppressWarnings("rawtypes") 125 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 126 TestUtils.testHasPublicMethod("Section "+ SECTION, type, Dimension.class, "pow", int.class); 127 } 128 } 129 130 /** 131 * Test that Dimension implementations override getBaseDimensions. 132 */ 133 @SpecAssertion(section = SECTION, id = "425-A7") 134 @Test(groups = {"core"}, description = SECTION + " Ensure registered Dimension classes override getBaseDimensions.") 135 public void testGetBaseDimensions() { 136 for (@SuppressWarnings("rawtypes") 137 Class type : TCKSetup.getConfiguration().getDimensionClasses()) { 138 TestUtils.testHasPublicMethod("Section "+ SECTION, type, Map.class, "getBaseDimensions"); 139 } 140 } 141}