### Question:
Messages extends MessagesBase { public static Messages getInstance() { return instance; } private  Messages(); static Messages getInstance();  }### Answer:
@Test public void testErrorMessages() { assertEquals( "Wrong message returned", "test.ERROR_0001 - test error 1", Messages.getInstance().getErrorString( "test.ERROR_0001_TEST_ERROR1" ) ); assertEquals( "Wrong message returned", "test.ERROR_0002 - test error 2: A", Messages.getInstance().getErrorString( "test.ERROR_0002_TEST_ERROR2", "A" ) ); assertEquals( "Wrong message returned", "test.ERROR_0003 - test error 3: A B", Messages.getInstance() .getErrorString( "test.ERROR_0003_TEST_ERROR3", "A", "B" ) ); assertEquals( "Wrong message returned", "test.ERROR_0004 - test error 4: A B C", Messages.getInstance() .getErrorString( "test.ERROR_0004_TEST_ERROR4", "A", "B", "C" ) ); }
@Test public void testBadKey() { assertEquals( "Wrong message returned", "!bogus key!", Messages.getInstance().getString( "bogus key" ) ); assertEquals( "Wrong message returned", "test.ERROR_0001 - !test.ERROR_0001_BOGUS!", Messages.getInstance().getErrorString( "test.ERROR_0001_BOGUS" ) ); }
@Test public void testEncoding() { assertEquals( "Wrong message returned", "", Messages.getInstance().getEncodedString( null ) ); assertEquals( "Wrong message returned", "test: &#x81; &#x99;", Messages.getInstance().getXslString( "test.encode1" ) ); }
@Test public void test() { try { Constructor<Messages> constructor = Messages.class.getDeclaredConstructor(); assertTrue( Modifier.isPrivate( constructor.getModifiers() ) ); } catch ( Exception e ) { fail( Messages.class.getSimpleName() + " Does not have a private constructor " ); } assertNotNull( Messages.getInstance() ); }
@Test public void testGetInstance() { Messages instance = Messages.getInstance(); assertNotNull( instance ); }
@Test public void testGetInstance() throws Exception { assertNotNull( Messages.getInstance() ); }