001/*
002 * Copyright (c) 2012, 2013, Werner Keil, Credit Suisse (Anatole Tresch). Licensed under the Apache
003 * License, Version 2.0 (the "License"); you may not use this file except in compliance with the
004 * License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
005 * Unless required by applicable law or agreed to in writing, software distributed under the License
006 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
007 * or implied. See the License for the specific language governing permissions and limitations under
008 * the License. Contributors: Anatole Tresch - initial version.
009 */
010package org.javamoney.tck.tests.spi;
011
012import org.jboss.test.audit.annotations.SpecAssertion;
013import org.jboss.test.audit.annotations.SpecVersion;
014import org.testng.Assert;
015import org.testng.annotations.Test;
016
017import javax.money.spi.MonetaryAmountFormatProviderSpi;
018import java.util.ServiceLoader;
019
020import static org.testng.Assert.assertTrue;
021import static org.testng.Assert.fail;
022
023/**
024 * Created by Anatole on 10.03.14.
025 */
026@SpecVersion(spec = "JSR 354", version = "1.0.0")
027public class FormattingSPITest {
028
029    // ********************************* C. Prodivding Amount Formats
030
031    /**
032     * Test registered MonetaryAmountFormatProviderSpi (one is
033     * required),
034     * especially bad case behaviour for
035     * invalid
036     * input.
037     */
038    @Test(description = "4.5.3 Test if a MonetaryAmountFormatProviderSpi instance is registered.")
039    @SpecAssertion(id = "453-A1", section = "4.5.3")
040    public void testMonetaryAmountFormatProviderSpiIsRegistered() {
041        ServiceLoader l = null;
042        try {
043            l = ServiceLoader.load(MonetaryAmountFormatProviderSpi.class);
044        } catch (Exception e) {
045            Assert.fail("Failure during check for loaded MonetaryAmountFormatProviderSpi.", e);
046        }
047        Assert.assertTrue(l.iterator().hasNext(),
048                "No instance of MonetaryAmountFormatProviderSpi provided by implementation.");
049    }
050
051}