001/*
002 * Units of Measurement TCK
003 * Copyright © 2005-2023, 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;
031
032import static org.testng.Assert.assertNotNull;
033import static org.hamcrest.MatcherAssert.assertThat;
034import static org.hamcrest.Matchers.empty;
035import static org.hamcrest.core.Is.is;
036import static org.hamcrest.core.IsNot.not;
037import static tech.units.tck.TCKRunner.SPEC_ID;
038import static tech.units.tck.TCKRunner.SPEC_VERSION;
039import static tech.units.tck.TCKSetup.getConfiguration;
040import static tech.units.tck.util.TestUtils.MSG_NO_TCK_CONFIG;
041import static tech.units.tck.util.TestGroups.CORE;
042
043import org.jboss.test.audit.annotations.SpecAssertion;
044import org.jboss.test.audit.annotations.SpecVersion;
045import org.testng.annotations.Test;
046
047import java.util.Collection;
048
049/**
050 * Tests the ServiceConfiguration
051 * @author Werner Keil
052 * @version 2.1, October 4, 2023
053 * @since 1.0
054 */
055@SpecVersion(spec = SPEC_ID, version = SPEC_VERSION)
056public class TCKSetupTest{
057
058        private static final String SECTION_NUM = "0";
059        
060        /** Tests the test setup */
061    @SpecAssertion(
062            section = SECTION_NUM,
063            id = "Setup",
064            note = "Tests that a TestConfiguration is registered with the JDK ServiceLoader.")
065    @Test(groups = { CORE }, description = "TCK Setup: ensure TCK Configuration is registered and available.")
066    public void testTestSetup(){
067        assertNotNull(getConfiguration(), MSG_NO_TCK_CONFIG);
068    }
069
070    /** Tests the quantity configuration */
071    @SpecAssertion(
072            section = SECTION_NUM,
073            id = "Setup",
074            note = "Checks that TestConfiguration.getQuantityClasses() returns a non empty collection of quantity " +
075                    "implementations")
076    @Test(groups = { CORE }, description = "Checks that Quantity classes are registered for testing.")
077    public void testQuantityConfiguration(){
078        @SuppressWarnings("rawtypes")
079        Collection<Class> quantityClasses = getConfiguration().getQuantityClasses();
080        assertNotNull(quantityClasses, "TCK Test Configuration quantity classes are null.");
081        assertThat("TCK Test Configuration quantity classes are missing.", quantityClasses, is(not(empty())));
082    }
083}