public void testContextConstructor() throws Exception {
Hashtable ct01 = new Hashtable();
ct01.put( "ct01", "ct01" );
StandardException se01 = new StandardException( ct01 );
assertEquals( StandardException.CODE_system, se01.getCode() );
assertEquals( "[system/standard]: [Context: \nct01=ct01\nmsg=\n]", se01.getMessage() );
assertEquals( 2, ((PropertySet)se01.getContextValues()).size() );
assertEquals( "ct01", ((PropertySet)se01.getContextValues()).get( "ct01" ) );
Hashtable ct02 = new Hashtable();
ct02.put( "ct02", "ct02" );
StandardException se02 = new StandardException( ct02 );
assertEquals( StandardException.CODE_system, se02.getCode() );
assertEquals( "[system/standard]: [Context: \nmsg=\nct02=ct02\n]", se02.getMessage() );
assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
assertEquals( "ct02", ((PropertySet)se02.getContextValues()).get( "ct02" ) );
StandardException se03 = new StandardException( new String[] {} );
assertEquals( StandardException.CODE_system, se03.getCode() );
assertEquals( "[system/standard]: [Context: \nmsg=\n]", se03.getMessage() );
assertEquals( 0, ((String[])se03.getContext()).length );
assertEquals( 1, ((PropertySet)se03.getContextValues()).size() );
StandardException se04 = new StandardException( new String[] { "n1", "v1" } );
assertEquals( StandardException.CODE_system, se04.getCode() );
assertEquals( "[system/standard]: [Context: \nn1=v1\nmsg=\n]", se04.getMessage() );
assertEquals( 2, ((String[])se04.getContext()).length );
assertEquals( 2, ((PropertySet)se04.getContextValues()).size() );
assertEquals( "v1", ((PropertySet)se04.getContextValues()).get( "n1" ) );
StandardException se05 = new StandardException( new String[] { "n1", "v1", "n2", "v2", "n3" } );
assertEquals( StandardException.CODE_system, se05.getCode() );
assertEquals( "[system/standard]: [Context: \nn3=\nn2=v2\nn1=v1\nmsg=\n]", se05.getMessage() );
assertEquals( 5, ((String[])se05.getContext()).length );
assertEquals( 4, ((PropertySet)se05.getContextValues()).size() );
assertEquals( "v1", ((PropertySet)se05.getContextValues()).get( "n1" ) );
assertEquals( "v2", ((PropertySet)se05.getContextValues()).get( "n2" ) );
assertEquals( "", ((PropertySet)se05.getContextValues()).get( "n3" ) );
HashMap hm = new HashMap();
hm.put("n1","v1");
hm.put("n2","v2");
ArrayList al = new ArrayList();
al.add("a1");
al.add("a2");
StandardException se06 = new StandardException( new Object[] { "hm", hm, "al", al, "s", "string" } );
assertEquals( StandardException.CODE_system, se06.getCode() );
assertEquals( "[system/standard]: [Context: "
+"\ns=string"
+"\nal=[a1, a2]"
+"\nmsg="
+"\nhm={n1=v1, n2=v2}\n]", se06.getMessage() );
assertEquals( 6, ((Object[])se06.getContext()).length );
assertEquals( 4, ((PropertySet)se06.getContextValues()).size() );
assertEquals( "string", ((PropertySet)se06.getContextValues()).get( "s" ) );
assertEquals( "[a1, a2]", ((PropertySet)se06.getContextValues()).get( "al" ) );
assertEquals( "{n1=v1, n2=v2}", ((PropertySet)se06.getContextValues()).get( "hm" ) );
}