test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java

Print this page

        

*** 54,106 **** * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package tck.java.time.calendar; import static org.testng.Assert.assertEquals; ! import static org.testng.Assert.assertNotNull; ! import static org.testng.Assert.fail; ! import static org.testng.Assert.assertSame; ! import static org.testng.Assert.assertTrue; ! ! import java.io.File; ! import java.io.IOException; ! import java.util.HashMap; ! import java.util.Map; ! import java.util.ServiceLoader; import java.time.LocalDate; ! import java.time.temporal.Chrono; ! import java.time.temporal.ChronoLocalDate; ! import java.time.temporal.ISOChrono; ! import java.time.DateTimeException; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Tests that a custom Chronology is available via the ServiceLoader. ! * The CopticChrono is configured via META-INF/services/java.time.temporal.Chrono. */ @Test ! public class TestServiceLoader { @Test(groups={"tck"}) public void test_CopticServiceLoader() { ! Chrono chrono = Chrono.of("Coptic"); ! ChronoLocalDate<?> copticDate = chrono.date(1729, 4, 27); LocalDate ld = LocalDate.from(copticDate); assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate"); } - @Test(groups="implementation") - public void test_copticServiceLoader() { - Map<String, Chrono> chronos = new HashMap<>(); - ServiceLoader<Chrono> loader = ServiceLoader.load(Chrono.class, null); - for (Chrono<?> chrono : loader) { - chronos.put(chrono.getId(), chrono); - } - assertNotNull(chronos.get("Coptic"), "CopticChrono not found"); - } - } --- 54,84 ---- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package tck.java.time.chrono; import static org.testng.Assert.assertEquals; ! import java.time.LocalDate; ! import java.time.chrono.Chronology; ! import java.time.chrono.ChronoLocalDate; import org.testng.annotations.Test; /** * Tests that a custom Chronology is available via the ServiceLoader. ! * The CopticChronology is configured via META-INF/services/java.time.chrono.Chronology. */ @Test ! public class TCKTestServiceLoader { @Test(groups={"tck"}) public void test_CopticServiceLoader() { ! Chronology chrono = Chronology.of("Coptic"); ! ChronoLocalDate copticDate = chrono.date(1729, 4, 27); LocalDate ld = LocalDate.from(copticDate); assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate"); } }