You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/01/08 02:15:41 UTC
[GitHub] sijie commented on a change in pull request #921: Add descriptive message for TooManyRequestsException
sijie commented on a change in pull request #921: Add descriptive message for TooManyRequestsException
URL: https://github.com/apache/bookkeeper/pull/921#discussion_r160068468
##########
File path: bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BKExceptionTest.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed 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.bookkeeper.client.api;
+
+import static org.apache.bookkeeper.client.api.BKException.Code.UnexpectedConditionException;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.lang.reflect.Field;
+import org.junit.Test;
+
+/**
+ * Tests for BKException methods.
+ */
+public class BKExceptionTest {
+
+ @Test
+ public void testGetMessage() throws Exception {
+ Field[] fields = BKException.Code.class.getFields();
+ int count = 0;
+ for (Field f : fields) {
+ if (f.getType() == Integer.TYPE && !f.getName().equals("UNINITIALIZED")) {
+ int code = f.getInt(null);
+ String msg = BKException.getMessage(code);
+ if (code == UnexpectedConditionException) {
+ assertThat(msg, equalTo("Unexpected condition"));
Review comment:
any reason why not use "assertEquals"?
----------------------------------------------------------------
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