2 * This file is part of storage-units. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of storage-units,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
7 package de
.xn__ho_hia
.storage_unit
;
9 import java
.lang
.reflect
.Constructor
;
10 import java
.lang
.reflect
.InvocationTargetException
;
11 import java
.lang
.reflect
.Modifier
;
13 import org
.junit
.Assert
;
14 import org
.junit
.Test
;
16 import de
.xn__ho_hia
.quality
.suppression
.CompilerWarnings
;
17 import de
.xn__ho_hia
.storage_unit
.StorageUnits
;
20 * General test cases for the {@link StorageUnits} class.
22 public class StorageUnitsTest
{
25 * Ensures that the constructor of the {@link StorageUnits} class is private.
27 * The class should never be instantiated. Instead use the static factory methods to construct storage units.
29 * @throws NoSuchMethodException
30 * Should not fail in case the StorageUnits class has a constructor..
31 * @throws IllegalAccessException
32 * Should not fail in case the StorageUnits class has a constructor..
33 * @throws InvocationTargetException
34 * Should not fail in case the StorageUnits class has a constructor..
35 * @throws InstantiationException
36 * Should not fail in case the StorageUnits class has a constructor..
39 @SuppressWarnings({ CompilerWarnings
.NLS
, CompilerWarnings
.STATIC_METHOD
})
40 public void shouldDeclarePrivateConstructor()
41 throws NoSuchMethodException
, IllegalAccessException
, InvocationTargetException
, InstantiationException
{
43 final Constructor
<StorageUnits
> constructor
= StorageUnits
.class.getDeclaredConstructor();
46 final boolean isPrivate
= Modifier
.isPrivate(constructor
.getModifiers());
49 Assert
.assertTrue("Constructor is not private", isPrivate
);
50 constructor
.setAccessible(true);
51 constructor
.newInstance();