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 020/** 021 * Tests the FormatProviderSpi. 022 */ 023@SpecVersion(spec = "JSR 354", version = "1.0.0") 024public class FormattingSPITest { 025 026 // ********************************* C. Prodivding Amount Formats 027 028 /** 029 * Test registered MonetaryAmountFormatProviderSpi (one is 030 * required), 031 * especially bad case behaviour for 032 * invalid 033 * input. 034 */ 035 @Test(description = "4.5.3 Test if a MonetaryAmountFormatProviderSpi instance is registered.") 036 @SpecAssertion(id = "453-A1", section = "4.5.3") 037 public void testMonetaryAmountFormatProviderSpiIsRegistered() { 038 ServiceLoader l = null; 039 try { 040 l = ServiceLoader.load(MonetaryAmountFormatProviderSpi.class); 041 } catch (Exception e) { 042 Assert.fail("Failure during check for loaded MonetaryAmountFormatProviderSpi.", e); 043 } 044 Assert.assertTrue(l.iterator().hasNext(), 045 "No instance of MonetaryAmountFormatProviderSpi provided by implementation."); 046 } 047 048}