TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);
boolean caught = false;
try
{
new TabularDataSupport(null);
}
catch (IllegalArgumentException e)
{
caught = true;
}
if (caught == false)
fail("Expected IllegalArgumentException for null tabular type");
caught = false;
try
{
new TabularDataSupport(null, 10, .5f);
}
catch (IllegalArgumentException e)
{
caught = true;
}
if (caught == false)
fail("Expected IllegalArgumentException for null tabular type");
caught = false;
try
{
new TabularDataSupport(tabularType, -1, .5f);
}
catch (IllegalArgumentException e)
{
caught = true;
}
if (caught == false)
fail("Expected IllegalArgumentException for negative initial capacity");
caught = false;
try
{
new TabularDataSupport(tabularType, 10, 0f);
}
catch (IllegalArgumentException e)
{
caught = true;
}
if (caught == false)
fail("Expected IllegalArgumentException for zero load factor");
caught = false;
try
{
new TabularDataSupport(tabularType, 10, -0.5f);
}
catch (IllegalArgumentException e)
{
caught = true;
}
if (caught == false)
fail("Expected IllegalArgumentException for negative load factor");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.calculateIndex(null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for calculate index on null object");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.calculateIndex(compData2);
}
catch (InvalidOpenTypeException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for calculate index on wrong composite type");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.get((Object) null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for get((Object) null)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.get(new Object());
}
catch (ClassCastException e)
{
caught = true;
}
if (caught == false)
fail("Expected ClassCastException for get(new Object())");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.get((Object) new Object[] { "wrong" });
}
catch (InvalidKeyException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidKeyException for get(Object) wrong");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.get((Object[]) null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for get((Object[]) null)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.get(new Object[] { "wrong" });
}
catch (InvalidKeyException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidKeyException for get(Object[]) wrong");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(new Object(), null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for put(Object, Object) with null value");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(new Object(), new Object());
}
catch (ClassCastException e)
{
caught = true;
}
if (caught == false)
fail("Expected ClassCastException for put(Object, Object) with none CompositeData");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(new Object(), compData2);
}
catch (InvalidOpenTypeException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for put(Object, Object) with wrong CompositeType");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(new Object(), compData);
data.put(new Object(), compData);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected KeyAlreadyExistsException for put(Object, Object)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for put(CompositeData) with null value");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(compData2);
}
catch (InvalidOpenTypeException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for put(CompositeData) with wrong CompositeType");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.put(compData);
data.put(compData);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected KeyAlreadyExistsException for put(CompositeData)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.remove((Object) null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for remove((Object) null)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.remove(new Object());
}
catch (ClassCastException e)
{
caught = true;
}
if (caught == false)
fail("Expected ClassCastException for remove(new Object())");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.remove((Object) new Object[] { "wrong" });
}
catch (InvalidKeyException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidKeyException for remove(Object) wrong");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.remove((Object[]) null);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for remove((Object[]) null)");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
data.remove(new Object[] { "wrong" });
}
catch (InvalidKeyException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidKeyException for remove(Object[]) wrong");
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), null);
data.putAll(toPut);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for putAll(Map) null");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), null);
try
{
data.putAll(toPut);
}
catch (NullPointerException expected)
{
}
assertTrue("Nothing should be added for NullPointerException putAll(Map)", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), new Object());
data.putAll(toPut);
}
catch (ClassCastException e)
{
caught = true;
}
if (caught == false)
fail("Expected ClassCastException for putAll(Map) non composite data");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), new Object());
try
{
data.putAll(toPut);
}
catch (ClassCastException expected)
{
}
assertTrue("Nothing should be added for ClassCastException putAll(Map)", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), compData2);
data.putAll(toPut);
}
catch (InvalidOpenTypeException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(Map) wrong composite type");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), compData2);
try
{
data.putAll(toPut);
}
catch (InvalidOpenTypeException expected)
{
}
assertTrue("Nothing should be added for InvalidOpenTypeException putAll(Map)", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), compData);
data.putAll(toPut);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(Map) with duplicate data");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
toPut.put(new Object(), compData);
try
{
data.putAll(toPut);
}
catch (KeyAlreadyExistsException expected)
{
}
assertTrue("Nothing should be added for KeyAlreadyExistsException duplicates putAll(Map)", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
data.putAll(toPut);
toPut = new HashMap();
toPut.put(new Object(), compData);
data.putAll(toPut);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(Map) adding a duplicate");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
HashMap toPut = new HashMap();
toPut.put(new Object(), compData);
data.putAll(toPut);
toPut = new HashMap();
toPut.put(new Object(), compData);
try
{
data.putAll(toPut);
}
catch (KeyAlreadyExistsException expected)
{
}
assertTrue("Nothing should be added for KeyAlreadyExistsException already put putAll(Map)", data.size() == 1);
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, null };
data.putAll(toPut);
}
catch (NullPointerException e)
{
caught = true;
}
if (caught == false)
fail("Expected NullPointerException for putAll(CompositeData[]) null");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, null };
try
{
data.putAll(toPut);
}
catch (NullPointerException expected)
{
}
assertTrue("Nothing should be added for NullPointerException putAll(CompositeData[])", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, compData2 };
data.putAll(toPut);
}
catch (InvalidOpenTypeException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) wrong composite type");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, compData2 };
try
{
data.putAll(toPut);
}
catch (InvalidOpenTypeException expected)
{
}
assertTrue("Nothing should be added for InvalidOpenTypeException putAll(CompositeData[])", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, compData };
data.putAll(toPut);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) with duplicate data");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData, compData };
try
{
data.putAll(toPut);
}
catch (KeyAlreadyExistsException expected)
{
}
assertTrue("Nothing should be added for KeyAlreadyExistsException duplicates putAll(CompositeData[])", data.isEmpty());
}
caught = false;
try
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData };
data.putAll(toPut);
data.putAll(toPut);
}
catch (KeyAlreadyExistsException e)
{
caught = true;
}
if (caught == false)
fail("Expected InvalidOpenTypeException for putAll(CompositeData[]) adding a duplicate");
{
TabularDataSupport data = new TabularDataSupport(tabularType);
CompositeData[] toPut = new CompositeData[] { compData };
data.putAll(toPut);
try
{
data.putAll(toPut);
}
catch (KeyAlreadyExistsException expected)
{
}
assertTrue("Nothing should be added for KeyAlreadyExistsException already put putAll(CompositeData[])", data.size() == 1);
}
}