Package gov.nasa.jpf.conformanceChecker.checkers

Source Code of gov.nasa.jpf.conformanceChecker.checkers.MissingMethodCheckerTest

//
// Copyright (C) 2012 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration
// (NASA).  All Rights Reserved.
//
// This software is distributed under the NASA Open Source Agreement
// (NOSA), version 1.3.  The NOSA has been approved by the Open Source
// Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
// directory tree for the complete NOSA document.
//
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
//
package gov.nasa.jpf.conformanceChecker.checkers;

import static gov.nasa.jpf.conformanceChecker.util.MaybeVersion.*;
import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;

import gov.nasa.jpf.conformanceChecker.providers.ProviderFactory;
import gov.nasa.jpf.conformanceChecker.providers.StandardClassProvider;
import gov.nasa.jpf.conformanceChecker.util.MaybeVersion;
import gov.nasa.jpf.jvm.ClassInfo;

import org.junit.Test;
import static org.easymock.EasyMock.*;
import static java.lang.reflect.Modifier.*;
import static gov.nasa.jpf.conformanceChecker.util.MockFactory.*;


public class MissingMethodCheckerTest {
 
  @Test
  public void testSuccess1() {
    ClassInfo model =
        cls("java.lang.Object",
            method(PUBLIC, "java.lang.String", "toString", new String[]{})
            );
    ClassInfo standard =
        cls("java.lang.Object",
            method(PUBLIC, "java.lang.String", "toString", new String[]{})
            );
    Map<MaybeVersion, ClassInfo> versions = new HashMap<MaybeVersion, ClassInfo>();
    versions.put(just(6), standard);
    StandardClassProvider provider = createMock(StandardClassProvider.class);
    expect(provider.loadClassInfo("java.lang.Object")).andReturn(versions);
    replay(provider);
    ProviderFactory.setStandardProvider(provider);
   
    MissingMethodChecker checker = new MissingMethodChecker();
    assertTrue(checker.check(model));   
  }
 
  @Test
  public void testSuccess2() {
    ClassInfo model =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PUBLIC, "java.lang.String", "substring", new String[]{"int"})
            );
    ClassInfo standard =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PUBLIC, "java.lang.String", "substring", new String[]{"int"})
            );
    Map<MaybeVersion, ClassInfo> versions = new HashMap<MaybeVersion, ClassInfo>();
    versions.put(just(6), standard);
    StandardClassProvider provider = createMock(StandardClassProvider.class);
    expect(provider.loadClassInfo("java.lang.String")).andReturn(versions);
    replay(provider);
    ProviderFactory.setStandardProvider(provider);
   
    MissingMethodChecker checker = new MissingMethodChecker();
    assertTrue(checker.check(model));   
  }
 
  @Test
  public void testFailure1() {
    ClassInfo model =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PUBLIC, "java.lang.String", "substring", new String[]{"int"})
            );
    ClassInfo standard =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PUBLIC, "java.lang.String", "substring", new String[]{"int","int"})
            );
    Map<MaybeVersion, ClassInfo> versions = new HashMap<MaybeVersion, ClassInfo>();
    versions.put(just(6), standard);
    StandardClassProvider provider = createMock(StandardClassProvider.class);
    expect(provider.loadClassInfo("java.lang.String")).andReturn(versions);
    replay(provider);
    ProviderFactory.setStandardProvider(provider);
   
    MissingMethodChecker checker = new MissingMethodChecker();
    assertFalse(checker.check(model));   
  }
 
  @Test
  public void testFailure2() {
    ClassInfo model =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PROTECTED, "java.lang.String", "substring", new String[]{"int"})
            );
    ClassInfo standard =
        cls("java.lang.String",
            method(PUBLIC, "java.lang.String", "toString", new String[]{}),
            method(PUBLIC, "java.lang.String", "substring", new String[]{"int"})
            );
    Map<MaybeVersion, ClassInfo> versions = new HashMap<MaybeVersion, ClassInfo>();
    versions.put(just(6), standard);
    StandardClassProvider provider = createMock(StandardClassProvider.class);
    expect(provider.loadClassInfo("java.lang.String")).andReturn(versions);
    replay(provider);
    ProviderFactory.setStandardProvider(provider);
   
    MissingMethodChecker checker = new MissingMethodChecker();
    assertFalse(checker.check(model));   
  }

}
TOP

Related Classes of gov.nasa.jpf.conformanceChecker.checkers.MissingMethodCheckerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.