Package org.jostraca.util

Examples of org.jostraca.util.StandardException



  public void testExceptions() {
    RecordingUserMessageHandler umh = new RecordingUserMessageHandler();
    umh.setThreshold( UserMessageHandler.INFO );
    umh.error( new StandardException( StandardException.CODE_user, "se01") );

    System.out.println( umh.toString() );

    StandardException se02s = new StandardException( StandardException.CODE_user, "se02s" );
    StandardException se02  = new StandardException( StandardException.CODE_user, "se02", se02s );
    umh.error( se02 );

    System.out.println( umh.toString() );

  }
View Full Code Here



  // test methods

  public void testNoArgConstructor() throws Exception {
    StandardException se01 = new StandardException();
    assertEquals( StandardException.CODE_system, se01.getCode() );
    assertEquals( "org.jostraca.util.StandardException: [system/standard] (org.jostraca.util.test.StandardExceptionTest.testNoArgConstructor:64)", se01.toString() );
    assertEquals( "[system/standard]", se01.getMessage() );
    assertEquals( 2, ((PropertySet)se01.getContextValues()).size() );
    assertEquals( "standard", se01.getKey() );
    assertEquals( StandardException.Code.CAT_system, se01.getCat() );
  }
View Full Code Here

    assertEquals( StandardException.Code.CAT_system, se01.getCat() );
  }


  public void testCodeConstructor() throws Exception {
    StandardException se01 = new StandardException( StandardException.CODE_system );
    assertEquals( StandardException.CODE_system, se01.getCode() );
    assertEquals( 2, ((PropertySet)se01.getContextValues()).size() );

    StandardException se02 = new StandardException( StandardException.CODE_user );
    assertEquals( StandardException.CODE_user, se02.getCode() );
    assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
  }
View Full Code Here

    assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
  }


  public void testMsgConstructor() throws Exception {
    StandardException se01 = new StandardException( "msg01" );
    assertEquals( StandardException.CODE_system, se01.getCode() );
    assertEquals( "[system/standard]: msg01", se01.getMessage() );
    assertEquals( 2, ((PropertySet)se01.getContextValues()).size() );

    StandardException se02 = new StandardException( "msg02" );
    assertEquals( StandardException.CODE_system, se02.getCode() );
    assertEquals( "[system/standard]: msg02", se02.getMessage() );
    assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
  }
View Full Code Here

    assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
  }


  public void testCodeMsgConstructor() throws Exception {
    StandardException se01 = new StandardException( StandardException.CODE_system, "msg01" );
    assertEquals( StandardException.CODE_system, se01.getCode() );
    assertEquals( "[system/standard]: msg01", se01.getMessage() );
    assertEquals( 2, ((PropertySet)se01.getContextValues()).size() );

    StandardException se02 = new StandardException( StandardException.CODE_user, "msg02" );
    assertEquals( StandardException.CODE_user, se02.getCode() );
    assertEquals( "[user/standard]: msg02", se02.getMessage() );
    assertEquals( 2, ((PropertySet)se02.getContextValues()).size() );
  }
View Full Code Here


  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" ) );

  }
View Full Code Here

TOP

Related Classes of org.jostraca.util.StandardException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.