package modTransf.model.extension;
import junit.framework.TestCase;
import java.io.IOException;
import modTransf.model.java.JavaObjectModelHelper;
import modTransf.model.ModelHelper;
import modTransf.model.ModelException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
/**
* Test case for SimpleMultiModelHelper.
*/
public class SimpleExtensibleModelHelperTest extends ExtensionTestCase
{
protected ExtensibleModelHelper helper;
protected SimpleExtensibleModelHelper helperImpl;
protected ModelHelper model1;
public SimpleExtensibleModelHelperTest(String name)
{
super(name);
}
/**
* Initialize the context for a new test.
* This method is called befor each test
* @throws IOException
*/
public void setUp()
throws IOException
{
super.setUp();
// create models
try
{
model1 = new JavaObjectModelHelper();
model1.createInstance("java.lang.Object");
}
catch(InstantiationException ex)
{
throw new Error(ex);
}
// create context.
helperImpl = new SimpleExtensibleModelHelper(model1);
helper = helperImpl;
}
/**
* Tear down the test.
* This method is called after each test.
*/
public void tearDown()
{
super.tearDown();
model1 = null;
helper = null;
}
/**
* Check the getProperty on regular property and on registered property.
*/
public void testGet()
throws ModelException
{
// Define a property on a String
ConceptPropertyExtension p1 = createPropertyExtension("size2", "java.lang.Integer",
"java.lang.String", new Integer(5) );
helper.registerProperty(p1);
// Internal check
assertNotNull( "internal registration", helperImpl.extensionMngr );
assertNotNull( "internal registration: properties hash creation", helperImpl.extensionMngr.propertyExtensions );
assertNotNull( "internal registration: pool creation", helperImpl.extensionMngr.propertyExtensions.get("size2") );
// Test registration
String bean = new String("abc");
Object res = helper.getProperty(bean, "class");
assertEquals("Returned value", bean.getClass(), res);
res = helper.getProperty(bean, "size2");
assertEquals("Returned value", new Integer(5), res);
}
}