001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.junit; 019 020import com.google.errorprone.annotations.RestrictedApi; 021import org.junit.jupiter.api.Assertions; 022 023/** 024 * JUnit4-compatible shim that delegates all calls to JUnit5 {@link Assertions}. Exists so that 025 * third-party test utilities(especially hadoop mini cluster related classes) compiled against 026 * JUnit4 can resolve {@code org.junit.Assert} without pulling in the real junit4 dependency. 027 */ 028public final class Assert { 029 030 private Assert() { 031 } 032 033 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 034 public static void assertTrue(String message, boolean condition) { 035 Assertions.assertTrue(condition, message); 036 } 037 038 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 039 public static void assertTrue(boolean condition) { 040 Assertions.assertTrue(condition); 041 } 042 043 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 044 public static void assertFalse(String message, boolean condition) { 045 Assertions.assertFalse(condition, message); 046 } 047 048 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 049 public static void assertFalse(boolean condition) { 050 Assertions.assertFalse(condition); 051 } 052 053 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 054 public static void fail(String message) { 055 Assertions.fail(message); 056 } 057 058 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 059 public static void fail() { 060 Assertions.fail(); 061 } 062 063 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 064 public static void assertEquals(String message, Object expected, Object actual) { 065 Assertions.assertEquals(expected, actual, message); 066 } 067 068 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 069 public static void assertEquals(Object expected, Object actual) { 070 Assertions.assertEquals(expected, actual); 071 } 072 073 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 074 public static void assertEquals(String message, long expected, long actual) { 075 Assertions.assertEquals(expected, actual, message); 076 } 077 078 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 079 public static void assertEquals(long expected, long actual) { 080 Assertions.assertEquals(expected, actual); 081 } 082 083 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 084 public static void assertEquals(double expected, double actual, double delta) { 085 Assertions.assertEquals(expected, actual, delta); 086 } 087 088 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 089 public static void assertEquals(String message, double expected, double actual, double delta) { 090 Assertions.assertEquals(expected, actual, delta, message); 091 } 092 093 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 094 public static void assertEquals(float expected, float actual, float delta) { 095 Assertions.assertEquals(expected, actual, delta); 096 } 097 098 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 099 public static void assertEquals(String message, float expected, float actual, float delta) { 100 Assertions.assertEquals(expected, actual, delta, message); 101 } 102 103 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 104 public static void assertNotEquals(String message, Object unexpected, Object actual) { 105 Assertions.assertNotEquals(unexpected, actual, message); 106 } 107 108 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 109 public static void assertNotEquals(Object unexpected, Object actual) { 110 Assertions.assertNotEquals(unexpected, actual); 111 } 112 113 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 114 public static void assertNotEquals(String message, long unexpected, long actual) { 115 Assertions.assertNotEquals(unexpected, actual, message); 116 } 117 118 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 119 public static void assertNotEquals(long unexpected, long actual) { 120 Assertions.assertNotEquals(unexpected, actual); 121 } 122 123 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 124 public static void assertNotEquals(double unexpected, double actual, double delta) { 125 Assertions.assertNotEquals(unexpected, actual, delta); 126 } 127 128 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 129 public static void assertNotEquals(String message, double unexpected, double actual, 130 double delta) { 131 Assertions.assertNotEquals(unexpected, actual, delta, message); 132 } 133 134 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 135 public static void assertNotNull(String message, Object object) { 136 Assertions.assertNotNull(object, message); 137 } 138 139 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 140 public static void assertNotNull(Object object) { 141 Assertions.assertNotNull(object); 142 } 143 144 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 145 public static void assertNull(String message, Object object) { 146 Assertions.assertNull(object, message); 147 } 148 149 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 150 public static void assertNull(Object object) { 151 Assertions.assertNull(object); 152 } 153 154 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 155 public static void assertSame(String message, Object expected, Object actual) { 156 Assertions.assertSame(expected, actual, message); 157 } 158 159 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 160 public static void assertSame(Object expected, Object actual) { 161 Assertions.assertSame(expected, actual); 162 } 163 164 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 165 public static void assertNotSame(String message, Object unexpected, Object actual) { 166 Assertions.assertNotSame(unexpected, actual, message); 167 } 168 169 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 170 public static void assertNotSame(Object unexpected, Object actual) { 171 Assertions.assertNotSame(unexpected, actual); 172 } 173 174 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 175 public static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) { 176 Assertions.assertArrayEquals(expecteds, actuals, message); 177 } 178 179 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 180 public static void assertArrayEquals(Object[] expecteds, Object[] actuals) { 181 Assertions.assertArrayEquals(expecteds, actuals); 182 } 183 184 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 185 public static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) { 186 Assertions.assertArrayEquals(expecteds, actuals, message); 187 } 188 189 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 190 public static void assertArrayEquals(byte[] expecteds, byte[] actuals) { 191 Assertions.assertArrayEquals(expecteds, actuals); 192 } 193 194 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 195 public static void assertArrayEquals(String message, char[] expecteds, char[] actuals) { 196 Assertions.assertArrayEquals(expecteds, actuals, message); 197 } 198 199 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 200 public static void assertArrayEquals(char[] expecteds, char[] actuals) { 201 Assertions.assertArrayEquals(expecteds, actuals); 202 } 203 204 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 205 public static void assertArrayEquals(String message, short[] expecteds, short[] actuals) { 206 Assertions.assertArrayEquals(expecteds, actuals, message); 207 } 208 209 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 210 public static void assertArrayEquals(short[] expecteds, short[] actuals) { 211 Assertions.assertArrayEquals(expecteds, actuals); 212 } 213 214 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 215 public static void assertArrayEquals(String message, int[] expecteds, int[] actuals) { 216 Assertions.assertArrayEquals(expecteds, actuals, message); 217 } 218 219 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 220 public static void assertArrayEquals(int[] expecteds, int[] actuals) { 221 Assertions.assertArrayEquals(expecteds, actuals); 222 } 223 224 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 225 public static void assertArrayEquals(String message, long[] expecteds, long[] actuals) { 226 Assertions.assertArrayEquals(expecteds, actuals, message); 227 } 228 229 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 230 public static void assertArrayEquals(long[] expecteds, long[] actuals) { 231 Assertions.assertArrayEquals(expecteds, actuals); 232 } 233 234 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 235 public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, 236 double delta) { 237 Assertions.assertArrayEquals(expecteds, actuals, delta, message); 238 } 239 240 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 241 public static void assertArrayEquals(double[] expecteds, double[] actuals, double delta) { 242 Assertions.assertArrayEquals(expecteds, actuals, delta); 243 } 244 245 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 246 public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, 247 float delta) { 248 Assertions.assertArrayEquals(expecteds, actuals, delta, message); 249 } 250 251 @RestrictedApi(explanation = "Only for thirdparty code, use JUnit5 Assertions in HBase") 252 public static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) { 253 Assertions.assertArrayEquals(expecteds, actuals, delta); 254 } 255}