<commit_before>/*
 * $Id$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 * 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 wicket.markup;

import java.io.Serializable;

import junit.framework.Assert;
import junit.framework.TestCase;
import wicket.AttributeModifier;
import wicket.model.Model;

/**
 * Test case for the component tag attribute modifer test.
 * 
 * @author <NAME>
 */
public class ComponentTagAttributeModifierTest extends TestCase
{

	/**
	 * Create a test case instance.
	 * 
	 * @param name
	 *            The test name
	 */
	public ComponentTagAttributeModifierTest(final String name)
	{
		super(name);
	}

	/**
	 * 
	 */
	public void testSerializable()
	{
		AttributeModifier modifier = new AttributeModifier("test", new Model("model"));
		Assert.assertTrue(modifier instanceof Serializable);
	}

	/**
	 * 
	 */
	public void testBadConstructor()
	{
		try
		{
			new AttributeModifier(null, new Model("model"));
			Assert.fail("IllegalArgumentException should be thrown on null attribute name");
		}
		catch (IllegalArgumentException e)
		{
			// Expected result
		}

		try
		{
			new AttributeModifier("test", null);
			Assert.fail("IllegalArgumentException should be thrown on null replace model");
		}
		catch (IllegalArgumentException e)
		{
			// Expected result
		}
	}

	// TODO Need attribute modifier tests that use the public API. These old
	// tests use replaceAttributeValue, which is package private and should
	// remain so.

	/**
	 * Tests attribute modifier
	 * 
	 * public void testModifyAttributeSuccessfully() { AttributeModifier
	 * modifier = new AttributeModifier("test", new Model("model"));
	 * ComponentTag tag = new ComponentTag(new XmlTag()); ValueMap attributes =
	 * tag.getAttributes(); attributes.put("test", "oldValue");
	 * modifier.replaceAttibuteValue(tag); attributes = tag.getAttributes();
	 * Assert.assertEquals("Tag attribute should have been modified", "model",
	 * attributes .getString("test")); }
	 * 
	 * /**
	 * <commit_msg>null replacement model is now allowed<commit_after>/*
 * $Id$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 * 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 wicket.markup;

import java.io.Serializable;

import junit.framework.Assert;
import junit.framework.TestCase;
import wicket.AttributeModifier;
import wicket.model.Model;

/**
 * Test case for the component tag attribute modifer test.
 * 
 * @author <NAME>
 */
public class ComponentTagAttributeModifierTest extends TestCase
{

	/**
	 * Create a test case instance.
	 * 
	 * @param name
	 *            The test name
	 */
	public ComponentTagAttributeModifierTest(final String name)
	{
		super(name);
	}

	/**
	 * 
	 */
	public void testSerializable()
	{
		AttributeModifier modifier = new AttributeModifier("test", new Model("model"));
		Assert.assertTrue(modifier instanceof Serializable);
	}

	/**
	 * 
	 */
	public void testBadConstructor()
	{
		try
		{
			new AttributeModifier(null, new Model("model"));
			Assert.fail("IllegalArgumentException should be thrown on null attribute name");
		}
		catch (IllegalArgumentException e)
		{
			// Expected result
		}

		try
		{
			new AttributeModifier("test", null);
		}
		catch (IllegalArgumentException e)
		{
			Assert.fail("IllegalArgumentException should not be thrown on null replace model");
		}
	}

	// TODO Need attribute modifier tests that use the public API. These old
	// tests use replaceAttributeValue, which is package private and should
	// remain so.

	/**
	 * Tests attribute modifier
	 * 
	 * public void testModifyAttributeSuccessfully() { AttributeModifier
	 * modifier = new AttributeModifier("test", new Model("model"));
	 * ComponentTag tag = new ComponentTag(new XmlTag()); ValueMap attributes =
	 * tag.getAttributes(); attributes.put("test", "oldValue");
	 * modifier.replaceAttibuteValue(tag); attributes = tag.getAttributes();
	 * Assert.assertEquals("Tag attribute should have been modified", "model",
	 * attributes .getString("test")); }
	 * 
	 * /**
	 * 
{'fraction_non_alphanumeric': 0.12905748924520924, 'fraction_numerical': 0.001564333202972233, 'mean_word_length': 3.932497589199614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '533819', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1333, 'n_words': 468}