/* 
 * Mutability Detector
 *
 * Copyright 2009 Graham Allan
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * 		http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.mutabilitydetector.benchmarks;

import static org.junit.Assert.assertEquals;
import static org.mutabilitydetector.AnalysisSession.createWithCurrentClassPath;
import static org.mutabilitydetector.CheckerRunner.createWithCurrentClasspath;
import static org.mutabilitydetector.ImmutableAssert.assertDefinitelyNotImmutable;
import static org.mutabilitydetector.ImmutableAssert.assertImmutable;

import org.junit.Before;
import org.junit.Test;
import org.mutabilitydetector.CheckerRunner;
import org.mutabilitydetector.checkers.AbstractTypeToFieldChecker;
import org.mutabilitydetector.checkers.IMutabilityChecker;
import org.mutabilitydetector.checkers.info.SessionCheckerRunner;
import org.mutabilitydetector.checkers.info.TypeStructureInformation;



public class AbstractTypeToFieldCheckerTest {

	IMutabilityChecker checker;

	@Before
	public void setUp() {
		SessionCheckerRunner runner = new SessionCheckerRunner(createWithCurrentClassPath(), 
															   createWithCurrentClasspath());
		TypeStructureInformation typeInfo = new TypeStructureInformation(runner);
		checker = new AbstractTypeToFieldChecker(typeInfo);
	}

	@Test
	public void testImmutableExamplePassesCheck() throws Exception {
		new CheckerRunner(null).run(checker, ImmutableExample.class);

		assertImmutable(checker.result());		
		assertEquals(checker.reasons().size(), 0);
	}
	
	@Test
	public void testMutableByAssigningInterfaceTypeToFieldFailsCheck() throws Exception {
		new CheckerRunner(null).run(checker, MutableByAssigningInterfaceToField.class);
		
		assertDefinitelyNotImmutable(checker.result());
	}
	
	@Test
	public void testMutableByAssigningAbstractClassToFieldFailsCheck() throws Exception {
		new CheckerRunner(null).run(checker, MutableByAssigningAbstractTypeToField.class);
		assertDefinitelyNotImmutable(checker.result());
	}

}

@@ -1072,53 +1072,8 @@
 st;%0A
-import org.mutabilitydetector.CheckerRunner;%0A
 impo
@@ -1418,18 +1418,17 @@
 %09@Before
-%0A%09
+ 
 public v
@@ -1714,26 +1714,25 @@
 ;%0A%09%7D%0A%0A%09@Test
-%0A%09
+ 
 public void 
@@ -1786,38 +1786,43 @@
 ion %7B%0A%09%09
-new CheckerRunner(null
+createWithCurrentClasspath(
 ).run(ch
@@ -1941,34 +1941,33 @@
  0);%0A%09%7D%0A%09%0A%09@Test
-%0A%09
+ 
 public void test
@@ -2038,38 +2038,43 @@
 ion %7B%0A%09%09
-new CheckerRunner(null
+createWithCurrentClasspath(
 ).run(ch
@@ -2187,18 +2187,17 @@
 %09%0A%09@Test
-%0A%09
+ 
 public v
@@ -2280,30 +2280,35 @@
 %7B%0A%09%09
-new CheckerRunner(null
+createWithCurrentClasspath(
 ).ru

Tidy up test.