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 8743 2012-10-07 03:06:20Z schulte $
032 */
033public class RuntimeTest extends TestCase
034{
035    //--RuntimeTest-------------------------------------------------------------
036
037    /** Implementation to test. */
038    private Runtime runtime;
039
040    /** Creates a new {@code RuntimeTest} instance. */
041    public RuntimeTest()
042    {
043        super();
044    }
045
046    /**
047     * Gets the {@code Runtime} implementation tests are performed with.
048     *
049     * @return the {@code Runtime} implementation tests are performed with.
050     */
051    public Runtime getRuntime()
052    {
053        return this.runtime;
054    }
055
056    /**
057     * Sets the {@code Runtime} implementation tests are performed with.
058     *
059     * @param value the {@code Runtime} implementation to perform tests with.
060     */
061    public final void setRuntime( final Runtime value )
062    {
063        this.runtime = value;
064    }
065
066    //-------------------------------------------------------------RuntimeTest--
067    //--Tests-------------------------------------------------------------------
068
069    /**
070     * Tests the {@link Runtime#getAllocatedPercent()} method to return sane
071     * values.
072     */
073    public void testGetAllocatedPercent() throws Exception
074    {
075        assert this.getRuntime() != null;
076
077        final long allocatedPercent = this.getRuntime().getAllocatedPercent();
078        Assert.assertTrue( allocatedPercent >= 0 && allocatedPercent <= 100 );
079    }
080
081    //-------------------------------------------------------------------Tests--
082}