| 1 | /* |
| 2 | * jDTAUS Core Test Suite |
| 3 | * Copyright (C) 2005 Christian Schulte |
| 4 | * <cs@schulte.it> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | package org.jdtaus.core.lang.it; |
| 22 | |
| 23 | import junit.framework.Assert; |
| 24 | import junit.framework.TestCase; |
| 25 | import org.jdtaus.core.lang.Runtime; |
| 26 | |
| 27 | /** |
| 28 | * Testcase for {@code Runtime} implementations. |
| 29 | * |
| 30 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 31 | * @version $JDTAUS: RuntimeTest.java 8743 2012-10-07 03:06:20Z schulte $ |
| 32 | */ |
| 33 | public class RuntimeTest extends TestCase |
| 34 | { |
| 35 | //--RuntimeTest------------------------------------------------------------- |
| 36 | |
| 37 | /** Implementation to test. */ |
| 38 | private Runtime runtime; |
| 39 | |
| 40 | /** Creates a new {@code RuntimeTest} instance. */ |
| 41 | public RuntimeTest() |
| 42 | { |
| 43 | super(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Gets the {@code Runtime} implementation tests are performed with. |
| 48 | * |
| 49 | * @return the {@code Runtime} implementation tests are performed with. |
| 50 | */ |
| 51 | public Runtime getRuntime() |
| 52 | { |
| 53 | return this.runtime; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Sets the {@code Runtime} implementation tests are performed with. |
| 58 | * |
| 59 | * @param value the {@code Runtime} implementation to perform tests with. |
| 60 | */ |
| 61 | public final void setRuntime( final Runtime value ) |
| 62 | { |
| 63 | this.runtime = value; |
| 64 | } |
| 65 | |
| 66 | //-------------------------------------------------------------RuntimeTest-- |
| 67 | //--Tests------------------------------------------------------------------- |
| 68 | |
| 69 | /** |
| 70 | * Tests the {@link Runtime#getAllocatedPercent()} method to return sane |
| 71 | * values. |
| 72 | */ |
| 73 | public void testGetAllocatedPercent() throws Exception |
| 74 | { |
| 75 | assert this.getRuntime() != null; |
| 76 | |
| 77 | final long allocatedPercent = this.getRuntime().getAllocatedPercent(); |
| 78 | Assert.assertTrue( allocatedPercent >= 0 && allocatedPercent <= 100 ); |
| 79 | } |
| 80 | |
| 81 | //-------------------------------------------------------------------Tests-- |
| 82 | } |