001/*
002 * acme4j - Java ACME client
003 *
004 * Copyright (C) 2016 Richard "Shred" Körber
005 *   http://acme4j.shredzone.org
006 *
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
013 */
014package org.shredzone.acme4j.exception;
015
016import static org.assertj.core.api.Assertions.assertThat;
017
018import java.io.IOException;
019
020import org.junit.jupiter.api.Test;
021
022/**
023 * Unit tests for {@link AcmeException}.
024 */
025public class AcmeExceptionTest {
026
027    @Test
028    public void testAcmeException() {
029        var ex = new AcmeException();
030        assertThat(ex.getMessage()).isNull();
031        assertThat(ex.getCause()).isNull();
032    }
033
034    @Test
035    public void testMessageAcmeException() {
036        var message = "Failure";
037        var ex = new AcmeException(message);
038        assertThat(ex.getMessage()).isEqualTo(message);
039        assertThat(ex.getCause()).isNull();
040    }
041
042    @Test
043    public void testCausedAcmeException() {
044        var message = "Failure";
045        var cause = new IOException("No network");
046
047        var ex = new AcmeException(message, cause);
048        assertThat(ex.getMessage()).isEqualTo(message);
049        assertThat(ex.getCause()).isEqualTo(cause);
050    }
051
052}