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; 011 012import java.util.ServiceLoader; 013 014/** 015 * TCK bootstrap class loading the {@link org.javamoney.tck.JSR354TestConfiguration}. 016 */ 017public final class TCKTestSetup { 018 019 private static final JSR354TestConfiguration TEST_CONFIG = loadTestConfiguration(); 020 021 private TCKTestSetup() { 022 } 023 024 /** 025 * Loads the test configuration setup from the ServiceLoader. 026 * @return 027 */ 028 private static JSR354TestConfiguration loadTestConfiguration() { 029 try { 030 return ServiceLoader.load(JSR354TestConfiguration.class).iterator() 031 .next(); 032 } catch (Exception e) { 033 throw new IllegalStateException("No valid implementation of " 034 + JSR354TestConfiguration.class.getName() 035 + " is registered with the ServiceLoader."); 036 } 037 } 038 039 /** 040 * Get the current test configuration setup. 041 * @return the test configuration, not null. 042 */ 043 public static JSR354TestConfiguration getTestConfiguration() { 044 return TEST_CONFIG; 045 } 046 047}