<commit_before>/*
 * Copyright 2008 the original author or authors.
 *
 * 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 samples.junit4.suppressmethod;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.powermock.api.easymock.PowerMock.suppressMethod;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import samples.suppressmethod.SuppressMethod;

@RunWith(PowerMockRunner.class)
@PrepareForTest(SuppressMethod.class)
public class SuppressMethodTest {

	@Test
	public void testGetObject() throws Exception {
		suppressMethod(SuppressMethod.class, "getObject");

		SuppressMethod tested = new SuppressMethod();
		assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
	}

	@Test
	public void testSuppressMultipleMethods() throws Exception {
		suppressMethod(SuppressMethod.class, "getObject", "getShort");

		SuppressMethod tested = new SuppressMethod();
		assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
		assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
	}

	@Test
	public void testGetObjectStatic() throws Exception {
		suppressMethod(SuppressMethod.class, "getObjectStatic");

		assertNull("A method returning Object should return null after suppressing method code.", SuppressMethod.getObjectStatic());
	}

	@Test
	public void testGetByte() throws Exception {
		suppressMethod(SuppressMethod.class, "getByte");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a byte should return 0 after suppressing method code.", 0, tested.getByte());
	}

	@Test
	public void testGetShort() throws Exception {
		suppressMethod(SuppressMethod.class, "getShort");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
	}

	@Test
	public void testGetInt() throws Exception {
		suppressMethod(SuppressMethod.class, "getInt");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning an int should return 0 after suppressing method code.", 0, tested.getInt());
	}

	@Test
	public void testGetLong() throws Exception {
		suppressMethod(SuppressMethod.class, "getLong");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a long should return 0 after suppressing method code.", 0, tested.getLong());
	}

	@Test
	public void testGetBoolean() throws Exception {
		suppressMethod(SuppressMethod.class, "getBoolean");

		SuppressMethod tested = new SuppressMethod();
		assertFalse("A method returning a boolean should return false after suppressing method code.", tested.getBoolean());
	}

	@Test
	public void testGetFloat() throws Exception {
		suppressMethod(SuppressMethod.class, "getFloat");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a float should return 0.0f after suppressing method code.", 0.0f, tested.getFloat(), 0);
	}

	@Test
	public void testGetDouble() throws Exception {
		suppressMethod(SuppressMethod.class, "getDouble");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a double should return 0.0d after suppressing method code.", 0.0d, tested.getDouble(), 0);
	}

	@Test
	public void testGetDouble_parameter() throws Exception {
		suppressMethod(SuppressMethod.class, "getDouble", new Class<?>[] { double.class });

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a double should return 0.0d after suppressing method code.", 0.0d, tested.getDouble(8.7d), 0);
	}

	@Test
	public void testInvokeVoid() throws Exception {
		suppressMethod(SuppressMethod.class, "invokeVoid", new Class<?>[] { StringBuilder.class });

		SuppressMethod tested = new SuppressMethod();
		// Should not cause an NPE when suppressing code.
		tested.invokeVoid(null);
	}

	@Test
	public void testInvokeVoid_noParameterTypeSupplied() throws Exception {
		suppressMethod(SuppressMethod.class, "invokeVoid");

		SuppressMethod tested = new SuppressMethod();
		// Should not cause an NPE when suppressing code.
		tested.invokeVoid(null);
	}
}<commit_msg>Added a new ignored test that demonstrate that PowerMock doesn't yet have support to suppress methods in super classes only.<commit_after>/*
 * Copyright 2008 the original author or authors.
 *
 * 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 samples.junit4.suppressmethod;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.powermock.api.easymock.PowerMock.suppressMethod;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import samples.suppressmethod.SuppressMethod;
import samples.suppressmethod.SuppressMethodParent;

@RunWith(PowerMockRunner.class)
@PrepareForTest(SuppressMethod.class)
public class SuppressMethodTest {

	@Test
	public void testGetObject() throws Exception {
		suppressMethod(SuppressMethod.class, "getObject");

		SuppressMethod tested = new SuppressMethod();
		assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
	}

	@Test
	public void testSuppressMultipleMethods() throws Exception {
		suppressMethod(SuppressMethod.class, "getObject", "getShort");

		SuppressMethod tested = new SuppressMethod();
		assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
		assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
	}

	@Test
	public void testGetObjectStatic() throws Exception {
		suppressMethod(SuppressMethod.class, "getObjectStatic");

		assertNull("A method returning Object should return null after suppressing method code.", SuppressMethod.getObjectStatic());
	}

	@Test
	public void testGetByte() throws Exception {
		suppressMethod(SuppressMethod.class, "getByte");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a byte should return 0 after suppressing method code.", 0, tested.getByte());
	}

	@Test
	public void testGetShort() throws Exception {
		suppressMethod(SuppressMethod.class, "getShort");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
	}

	@Test
	public void testGetInt() throws Exception {
		suppressMethod(SuppressMethod.class, "getInt");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning an int should return 0 after suppressing method code.", 0, tested.getInt());
	}

	@Test
	public void testGetLong() throws Exception {
		suppressMethod(SuppressMethod.class, "getLong");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a long should return 0 after suppressing method code.", 0, tested.getLong());
	}

	@Test
	public void testGetBoolean() throws Exception {
		suppressMethod(SuppressMethod.class, "getBoolean");

		SuppressMethod tested = new SuppressMethod();
		assertFalse("A method returning a boolean should return false after suppressing method code.", tested.getBoolean());
	}

	@Test
	public void testGetFloat() throws Exception {
		suppressMethod(SuppressMethod.class, "getFloat");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a float should return 0.0f after suppressing method code.", 0.0f, tested.getFloat(), 0);
	}

	@Test
	public void testGetDouble() throws Exception {
		suppressMethod(SuppressMethod.class, "getDouble");

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a double should return 0.0d after suppressing method code.", 0.0d, tested.getDouble(), 0);
	}

	@Test
	public void testGetDouble_parameter() throws Exception {
		suppressMethod(SuppressMethod.class, "getDouble", new Class<?>[] { double.class });

		SuppressMethod tested = new SuppressMethod();
		assertEquals("A method returning a double should return 0.0d after suppressing method code.", 0.0d, tested.getDouble(8.7d), 0);
	}

	@Test
	public void testInvokeVoid() throws Exception {
		suppressMethod(SuppressMethod.class, "invokeVoid", new Class<?>[] { StringBuilder.class });

		SuppressMethod tested = new SuppressMethod();
		// Should not cause an NPE when suppressing code.
		tested.invokeVoid(null);
	}

	@Test
	public void testInvokeVoid_noParameterTypeSupplied() throws Exception {
		suppressMethod(SuppressMethod.class, "invokeVoid");

		SuppressMethod tested = new SuppressMethod();
		// Should not cause an NPE when suppressing code.
		tested.invokeVoid(null);
	}
	
	@Test
	@Ignore("Doesn't work atm")
	public void testSuppressMethodInParentOnly() throws Exception {
		suppressMethod(SuppressMethodParent.class, "myMethod");

		SuppressMethod tested = new SuppressMethod();
		// Should not cause an NPE when suppressing code.
		assertEquals(20, tested.myMethod());
	}
	
}
{'fraction_non_alphanumeric': 0.09474491752972766, 'fraction_numerical': 0.00728807057920982, 'mean_word_length': 5.2977053140096615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7326741', 'n_tokens_mistral': 2900, 'n_tokens_neox': 2751, 'n_words': 960}