001/*
002 *  jDTAUS Core Test Suite
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.lang.it;
022
023import junit.framework.Assert;
024import junit.framework.TestCase;
025import org.jdtaus.core.lang.Runtime;
026
027/**
028 * Testcase for {@code Runtime} implementations.
029 *
030 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
031 * @version $JDTAUS: RuntimeTest.java 8692 2012-10-01 14:16:57Z schulte $
032 */
033public class RuntimeTest extends TestCase
034{
035    //--RuntimeTest-------------------------------------------------------------
036
037    /** Implementation to test. */
038    private Runtime runtime;
039
040    /**
041     * Gets the {@code Runtime} implementation tests are performed with.
042     *
043     * @return the {@code Runtime} implementation tests are performed with.
044     */
045    public Runtime getRuntime()
046    {
047        return this.runtime;
048    }
049
050    /**
051     * Sets the {@code Runtime} implementation tests are performed with.
052     *
053     * @param value the {@code Runtime} implementation to perform tests with.
054     */
055    public final void setRuntime( final Runtime value )
056    {
057        this.runtime = value;
058    }
059
060    //-------------------------------------------------------------RuntimeTest--
061    //--Tests-------------------------------------------------------------------
062
063    /**
064     * Tests the {@link Runtime#getAllocatedPercent()} method to return sane
065     * values.
066     */
067    public void testGetAllocatedPercent() throws Exception
068    {
069        assert this.getRuntime() != null;
070
071        final long allocatedPercent = this.getRuntime().getAllocatedPercent();
072        Assert.assertTrue( allocatedPercent >= 0 && allocatedPercent <= 100 );
073    }
074
075    //-------------------------------------------------------------------Tests--
076}