|
| 1 | +/* |
| 2 | + * Copyright 2016, 2017 DTCC, Fujitsu Australia Software Technology, IBM - All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * Unless required by applicable law or agreed to in writing, software |
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + * See the License for the specific language governing permissions and |
| 12 | + * limitations under the License. |
| 13 | + */ |
| 14 | + |
| 15 | +package org.hyperledger.fabric.sdk.exception; |
| 16 | + |
| 17 | +import org.junit.Rule; |
| 18 | +import org.junit.Test; |
| 19 | +import org.junit.rules.ExpectedException; |
| 20 | + |
| 21 | +public class FabricExceptionsTest { |
| 22 | + |
| 23 | + @Rule |
| 24 | + public ExpectedException thrown = ExpectedException.none(); |
| 25 | + |
| 26 | + @Test |
| 27 | + public void testBaseException1() throws BaseException { |
| 28 | + |
| 29 | + thrown.expect(BaseException.class); |
| 30 | + thrown.expectMessage("test"); |
| 31 | + |
| 32 | + throw new BaseException("test"); |
| 33 | + |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testBaseException2() throws BaseException { |
| 38 | + |
| 39 | + thrown.expect(BaseException.class); |
| 40 | + thrown.expectMessage("test"); |
| 41 | + |
| 42 | + throw new BaseException(new BaseException("test")); |
| 43 | + |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void testBaseException3() throws BaseException { |
| 48 | + |
| 49 | + thrown.expect(BaseException.class); |
| 50 | + thrown.expectMessage("test"); |
| 51 | + |
| 52 | + throw new BaseException(new BaseException("test")); |
| 53 | + |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void testChaincodeEndorsementPolicyParseException1() throws ChaincodeEndorsementPolicyParseException { |
| 58 | + |
| 59 | + thrown.expect(ChaincodeEndorsementPolicyParseException.class); |
| 60 | + thrown.expectMessage("test"); |
| 61 | + |
| 62 | + throw new ChaincodeEndorsementPolicyParseException("test"); |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void testChaincodeEndorsementPolicyParseException2() throws ChaincodeEndorsementPolicyParseException { |
| 68 | + |
| 69 | + thrown.expect(ChaincodeEndorsementPolicyParseException.class); |
| 70 | + thrown.expectMessage("test"); |
| 71 | + |
| 72 | + throw new ChaincodeEndorsementPolicyParseException("test", |
| 73 | + new ChaincodeEndorsementPolicyParseException("test")); |
| 74 | + |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void testChaincodeException() throws ChaincodeException { |
| 79 | + BaseException baseException = new BaseException("test"); |
| 80 | + thrown.expect(ChaincodeException.class); |
| 81 | + thrown.expectMessage("test"); |
| 82 | + |
| 83 | + throw new ChaincodeException("test", baseException); |
| 84 | + |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public void testCryptoException1() throws CryptoException { |
| 89 | + |
| 90 | + thrown.expect(CryptoException.class); |
| 91 | + thrown.expectMessage("test"); |
| 92 | + |
| 93 | + throw new CryptoException("test"); |
| 94 | + |
| 95 | + } |
| 96 | + |
| 97 | + @Test |
| 98 | + public void testCryptoException2() throws CryptoException { |
| 99 | + |
| 100 | + thrown.expect(CryptoException.class); |
| 101 | + thrown.expectMessage("test"); |
| 102 | + |
| 103 | + throw new CryptoException("test", new CryptoException("test")); |
| 104 | + |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + public void testEventHubException1() throws EventHubException { |
| 109 | + |
| 110 | + thrown.expect(EventHubException.class); |
| 111 | + thrown.expectMessage("test"); |
| 112 | + |
| 113 | + throw new EventHubException("test"); |
| 114 | + |
| 115 | + } |
| 116 | + |
| 117 | + @Test |
| 118 | + public void testEventHubException2() throws EventHubException { |
| 119 | + |
| 120 | + thrown.expect(EventHubException.class); |
| 121 | + thrown.expectMessage("test"); |
| 122 | + |
| 123 | + throw new EventHubException(new CryptoException("test")); |
| 124 | + |
| 125 | + } |
| 126 | + |
| 127 | + @Test |
| 128 | + public void testEventHubException3() throws EventHubException { |
| 129 | + |
| 130 | + thrown.expect(EventHubException.class); |
| 131 | + thrown.expectMessage("test"); |
| 132 | + |
| 133 | + throw new EventHubException("test", new CryptoException("test")); |
| 134 | + |
| 135 | + } |
| 136 | + |
| 137 | + @Test |
| 138 | + public void testExecuteException1() throws ExecuteException { |
| 139 | + |
| 140 | + thrown.expect(ExecuteException.class); |
| 141 | + thrown.expectMessage("test"); |
| 142 | + |
| 143 | + throw new ExecuteException("test"); |
| 144 | + |
| 145 | + } |
| 146 | + |
| 147 | + @Test |
| 148 | + public void testExecuteException2() throws ExecuteException { |
| 149 | + |
| 150 | + thrown.expect(ExecuteException.class); |
| 151 | + thrown.expectMessage("test"); |
| 152 | + |
| 153 | + throw new ExecuteException("test", new ExecuteException("test")); |
| 154 | + |
| 155 | + } |
| 156 | + |
| 157 | + @Test |
| 158 | + public void testGetTCertBatchException() throws GetTCertBatchException { |
| 159 | + |
| 160 | + thrown.expect(GetTCertBatchException.class); |
| 161 | + thrown.expectMessage("test"); |
| 162 | + |
| 163 | + throw new GetTCertBatchException("test", new ExecuteException("test")); |
| 164 | + |
| 165 | + } |
| 166 | + |
| 167 | + @Test |
| 168 | + public void testInvalidArgumentException1() throws InvalidArgumentException { |
| 169 | + |
| 170 | + thrown.expect(InvalidArgumentException.class); |
| 171 | + thrown.expectMessage("test"); |
| 172 | + |
| 173 | + throw new InvalidArgumentException("test"); |
| 174 | + |
| 175 | + } |
| 176 | + |
| 177 | + @Test |
| 178 | + public void testInvalidArgumentException2() throws InvalidArgumentException { |
| 179 | + |
| 180 | + thrown.expect(InvalidArgumentException.class); |
| 181 | + thrown.expectMessage("test"); |
| 182 | + |
| 183 | + throw new InvalidArgumentException(new InvalidArgumentException("test")); |
| 184 | + |
| 185 | + } |
| 186 | + |
| 187 | + @Test |
| 188 | + public void testInvalidArgumentException3() throws InvalidArgumentException { |
| 189 | + |
| 190 | + thrown.expect(InvalidArgumentException.class); |
| 191 | + thrown.expectMessage("test"); |
| 192 | + |
| 193 | + throw new InvalidArgumentException("test", new InvalidArgumentException("test")); |
| 194 | + |
| 195 | + } |
| 196 | + |
| 197 | + @Test |
| 198 | + public void testInvalidTransactionException1() throws InvalidTransactionException { |
| 199 | + |
| 200 | + thrown.expect(InvalidTransactionException.class); |
| 201 | + thrown.expectMessage("test"); |
| 202 | + |
| 203 | + throw new InvalidTransactionException("test"); |
| 204 | + |
| 205 | + } |
| 206 | + |
| 207 | + @Test |
| 208 | + public void testInvalidTransactionException2() throws InvalidTransactionException { |
| 209 | + |
| 210 | + thrown.expect(InvalidTransactionException.class); |
| 211 | + thrown.expectMessage("test"); |
| 212 | + |
| 213 | + throw new InvalidTransactionException("test", new InvalidTransactionException("test")); |
| 214 | + |
| 215 | + } |
| 216 | + |
| 217 | + @Test |
| 218 | + public void testInvokeException() throws InvokeException { |
| 219 | + |
| 220 | + BaseException baseException = new BaseException("test"); |
| 221 | + thrown.expect(InvokeException.class); |
| 222 | + thrown.expectMessage("test"); |
| 223 | + |
| 224 | + throw new InvokeException("test", baseException); |
| 225 | + |
| 226 | + } |
| 227 | + |
| 228 | + @Test |
| 229 | + public void testNoAvailableTCertException() throws NoAvailableTCertException { |
| 230 | + |
| 231 | + thrown.expect(NoAvailableTCertException.class); |
| 232 | + thrown.expectMessage("test"); |
| 233 | + |
| 234 | + throw new NoAvailableTCertException("test"); |
| 235 | + |
| 236 | + } |
| 237 | + |
| 238 | + @Test |
| 239 | + public void testNoValidPeerException() throws NoValidPeerException { |
| 240 | + |
| 241 | + thrown.expect(NoValidPeerException.class); |
| 242 | + thrown.expectMessage("test"); |
| 243 | + |
| 244 | + throw new NoValidPeerException("test"); |
| 245 | + |
| 246 | + } |
| 247 | + |
| 248 | + @Test |
| 249 | + public void testPeerException1() throws PeerException { |
| 250 | + |
| 251 | + thrown.expect(PeerException.class); |
| 252 | + thrown.expectMessage("test"); |
| 253 | + |
| 254 | + throw new PeerException("test"); |
| 255 | + |
| 256 | + } |
| 257 | + |
| 258 | + @Test |
| 259 | + public void testPeerException2() throws PeerException { |
| 260 | + |
| 261 | + thrown.expect(PeerException.class); |
| 262 | + thrown.expectMessage("test"); |
| 263 | + |
| 264 | + throw new PeerException("test", new PeerException("test")); |
| 265 | + |
| 266 | + } |
| 267 | + |
| 268 | + @Test |
| 269 | + public void testProposalException1() throws ProposalException { |
| 270 | + |
| 271 | + thrown.expect(ProposalException.class); |
| 272 | + thrown.expectMessage("test"); |
| 273 | + |
| 274 | + throw new ProposalException("test"); |
| 275 | + |
| 276 | + } |
| 277 | + |
| 278 | + @Test |
| 279 | + public void testProposalException2() throws ProposalException { |
| 280 | + |
| 281 | + thrown.expect(ProposalException.class); |
| 282 | + thrown.expectMessage("test"); |
| 283 | + |
| 284 | + throw new ProposalException(new ProposalException("test")); |
| 285 | + |
| 286 | + } |
| 287 | + |
| 288 | + @Test |
| 289 | + public void testProposalException3() throws ProposalException { |
| 290 | + |
| 291 | + thrown.expect(ProposalException.class); |
| 292 | + thrown.expectMessage("test"); |
| 293 | + |
| 294 | + throw new ProposalException("test", new ProposalException("test")); |
| 295 | + |
| 296 | + } |
| 297 | + |
| 298 | + @Test |
| 299 | + public void testQueryException() throws QueryException { |
| 300 | + BaseException baseException = new BaseException("test"); |
| 301 | + thrown.expect(QueryException.class); |
| 302 | + thrown.expectMessage("test"); |
| 303 | + |
| 304 | + throw new QueryException("test", baseException); |
| 305 | + |
| 306 | + } |
| 307 | + |
| 308 | + @Test |
| 309 | + public void testTransactionException1() throws TransactionException { |
| 310 | + thrown.expect(TransactionException.class); |
| 311 | + thrown.expectMessage("test"); |
| 312 | + |
| 313 | + throw new TransactionException("test"); |
| 314 | + |
| 315 | + } |
| 316 | + |
| 317 | + @Test |
| 318 | + public void testTransactionException2() throws TransactionException { |
| 319 | + thrown.expect(TransactionException.class); |
| 320 | + thrown.expectMessage("test"); |
| 321 | + |
| 322 | + throw new TransactionException(new TransactionException("test")); |
| 323 | + |
| 324 | + } |
| 325 | + |
| 326 | + @Test |
| 327 | + public void testTransactionException3() throws TransactionException { |
| 328 | + thrown.expect(TransactionException.class); |
| 329 | + thrown.expectMessage("test"); |
| 330 | + |
| 331 | + throw new TransactionException("test", new TransactionException("test")); |
| 332 | + |
| 333 | + } |
| 334 | +} |
0 commit comments