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 org.junit.jupiter.api.Test; 019 020/** 021 * Unit tests for {@link AcmeProtocolException}. 022 */ 023public class AcmeProtocolExceptionTest { 024 025 @Test 026 public void testAcmeProtocolException() { 027 var msg = "Bad content"; 028 var ex = new AcmeProtocolException(msg); 029 assertThat(ex).isInstanceOf(RuntimeException.class); 030 assertThat(ex.getMessage()).isEqualTo(msg); 031 assertThat(ex.getCause()).isNull(); 032 } 033 034 @Test 035 public void testCausedAcmeProtocolException() { 036 var message = "Bad content"; 037 var cause = new NumberFormatException("Not a number: abc"); 038 var ex = new AcmeProtocolException(message, cause); 039 assertThat(ex.getMessage()).isEqualTo(message); 040 assertThat(ex.getCause()).isEqualTo(cause); 041 } 042 043}