Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 87561200D6C for ; Tue, 28 Nov 2017 16:45:39 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8621F160C01; Tue, 28 Nov 2017 15:45:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CDE4A160C15 for ; Tue, 28 Nov 2017 16:45:38 +0100 (CET) Received: (qmail 89325 invoked by uid 500); 28 Nov 2017 15:45:38 -0000 Mailing-List: contact notifications-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@apache.org Delivered-To: mailing list notifications@accumulo.apache.org Received: (qmail 89227 invoked by uid 99); 28 Nov 2017 15:45:37 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2017 15:45:37 +0000 From: GitBox To: notifications@accumulo.apache.org Subject: [GitHub] keith-turner commented on a change in pull request #327: ACCUMULO-4546 Create default log message for IllegalTableTransitionException Message-ID: <151188393732.1666.18210702957748618865.gitbox@gitbox.apache.org> archived-at: Tue, 28 Nov 2017 15:45:39 -0000 keith-turner commented on a change in pull request #327: ACCUMULO-4546 Create default log message for IllegalTableTransitionException URL: https://github.com/apache/accumulo/pull/327#discussion_r153531327 ########## File path: server/base/src/test/java/org/apache/accumulo/server/tables/IllegalTableTransitionExceptionTest.java ########## @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.accumulo.server.tables; + +import static org.junit.Assert.assertEquals; + +import org.apache.accumulo.core.master.state.tables.TableState; +import org.apache.accumulo.server.tables.TableManager.IllegalTableTransitionException; +import org.junit.Test; + +public class IllegalTableTransitionExceptionTest { + + final TableState oldState = TableState.ONLINE; + final TableState newState = TableState.OFFLINE; + final String defaultMsg = "Error transitioning from " + oldState + " state to " + newState + " state"; + + @Test + public void testIllegalTableTransitionExceptionMessage() { + String userMessage = null; + try { + userMessage = "User suppled message - Exception from " + oldState + " state to " + newState + " state"; + throw new TableManager.IllegalTableTransitionException(oldState, newState, userMessage); + } catch (IllegalTableTransitionException e) { + assertEquals(userMessage, e.getMessage()); + } + } + + @Test + public void testIllegalTableTransitionExceptionDefaultMessage() { + try { + throw new TableManager.IllegalTableTransitionException(oldState, newState); + } catch (IllegalTableTransitionException e) { + assertEquals(defaultMsg, e.getMessage()); + } + } + + @Test + public void testIllegalTableTransitionExceptionEmptyMessage() { + try { + throw new TableManager.IllegalTableTransitionException(oldState, newState, ""); Review comment: In addition to `""`, could also try null. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services