[hibernate-commits] Hibernate SVN: r10729 - trunk/Hibernate3/test/org/hibernate/test/mappingexception

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Nov 6 12:43:54 EST 2006


Author: steve.ebersole at jboss.com
Date: 2006-11-06 12:43:53 -0500 (Mon, 06 Nov 2006)
New Revision: 10729

Modified:
   trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
Log:
Configuration : javadocs and general code cleanup

Modified: trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java	2006-11-06 17:43:39 UTC (rev 10728)
+++ trunk/Hibernate3/test/org/hibernate/test/mappingexception/MappingExceptionTest.java	2006-11-06 17:43:53 UTC (rev 10729)
@@ -29,208 +29,224 @@
 public class MappingExceptionTest extends TestCase {
 
 	public MappingExceptionTest(String name) {
-		super(name);
+		super( name );
 	}
 
 	protected String[] getMappings() {
-		return new String[] {"mappingexception/User.hbm.xml"};
+		return new String[] { "mappingexception/User.hbm.xml" };
 	}
 
 	public void testNotFound() throws MappingException, MalformedURLException {
-		
+
 		try {
 			getCfg().addCacheableFile( "completelybogus.hbm.xml" );
 			fail();
-		} catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), "completelybogus.hbm.xml");
-			assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
 		}
-		
+		catch ( MappingNotFoundException e ) {
+			assertEquals( e.getType(), "file" );
+			assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+		}
+
 		try {
-			getCfg().addCacheableFile( new File("completelybogus.hbm.xml") );
+			getCfg().addCacheableFile( new File( "completelybogus.hbm.xml" ) );
 			fail();
-		} catch(InvalidMappingException inv) { // TODO: should be MappingNotFound
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), "completelybogus.hbm.xml");
-			assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
 		}
+		catch ( MappingNotFoundException e ) {
+			assertEquals( e.getType(), "file" );
+			assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+		}
 
 		try {
 			getCfg().addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
 			fail();
-		} catch(MappingNotFoundException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), "org/hibernate/Hibernate.hbm.xml");
 		}
-		
+		catch ( MappingNotFoundException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), "org/hibernate/Hibernate.hbm.xml" );
+		}
+
 		try {
-			getCfg().addFile( "completelybogus.hbm.xml" ); 
+			getCfg().addFile( "completelybogus.hbm.xml" );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), "completelybogus.hbm.xml");
-			assertClassAssignability( inv.getCause().getClass(), MappingNotFoundException.class);
 		}
-		
+		catch ( MappingNotFoundException e ) {
+			assertEquals( e.getType(), "file" );
+			assertEquals( e.getPath(), "completelybogus.hbm.xml" );
+		}
+
 		try {
-			getCfg().addFile( new File("completelybogus.hbm.xml")); 
+			getCfg().addFile( new File( "completelybogus.hbm.xml" ) );
 			fail();
-		} catch(InvalidMappingException inv) { // TODO: could be a MappingNotFoundException
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), "completelybogus.hbm.xml");
 		}
-		
+		catch ( MappingNotFoundException inv ) {
+			assertEquals( inv.getType(), "file" );
+			assertEquals( inv.getPath(), "completelybogus.hbm.xml" );
+		}
+
 		try {
-			getCfg().addInputStream( new ByteArrayInputStream(new byte[0])); 
+			getCfg().addInputStream( new ByteArrayInputStream( new byte[0] ) );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "input stream");
-			assertEquals(inv.getPath(), null);
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "input stream" );
+			assertEquals( inv.getPath(), null );
+		}
+
 		try {
 			getCfg().addResource( "nothere" );
 			fail();
-		} catch(MappingNotFoundException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), "nothere");
 		}
-		
+		catch ( MappingNotFoundException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), "nothere" );
+		}
+
 		try {
 			getCfg().addResource( "nothere", getClass().getClassLoader() );
 			fail();
-		} catch(MappingNotFoundException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), "nothere");
 		}
-		
+		catch ( MappingNotFoundException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), "nothere" );
+		}
+
 		try {
-			getCfg().addURL( new URL("file://nothere") );
+			getCfg().addURL( new URL( "file://nothere" ) );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "URL");
-			assertEquals(inv.getPath(), "file://nothere");
-		}				
+		}
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "URL" );
+			assertEquals( inv.getPath(), "file://nothere" );
+		}
 	}
-	
+
 	public void testDuplicateMapping() {
 		try {
 			getCfg().addResource( getBaseForMappings() + "mappingexception/User.hbm.xml" );
 			fail();
-		} catch(InvalidMappingException inv) {
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml");
-			assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class);
 		}
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), getBaseForMappings() + "mappingexception/User.hbm.xml" );
+			assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class );
+		}
 	}
-	
-	 void copy(InputStream in, File dst) throws IOException {
-	        OutputStream out = new FileOutputStream(dst);
-	    
-	        // Transfer bytes from in to out
-	        byte[] buf = new byte[1024];
-	        int len;
-	        while ((len = in.read(buf)) > 0) {
-	            out.write(buf, 0, len);
-	        }
-	        in.close();
-	        out.close();
-	 }
-	 
+
+	void copy(InputStream in, File dst) throws IOException {
+		OutputStream out = new FileOutputStream( dst );
+
+		// Transfer bytes from in to out
+		byte[] buf = new byte[1024];
+		int len;
+		while ( ( len = in.read( buf ) ) > 0 ) {
+			out.write( buf, 0, len );
+		}
+		in.close();
+		out.close();
+	}
+
 	public void testInvalidMapping() throws MappingException, IOException {
 		String resourceName = getBaseForMappings() + "mappingexception/InvalidMapping.hbm.xml";
-		
+
 		File file = File.createTempFile( "TempInvalidMapping", ".hbm.xml" );
 		file.deleteOnExit();
 		copy( ConfigHelper.getConfigStream( resourceName ), file );
-		
+
 		try {
 			getCfg().addCacheableFile( file.getAbsolutePath() );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "file");
-			assertNotNull(inv.getPath()); 
-			assertTrue(inv.getPath().endsWith(".hbm.xml"));
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));			
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "file" );
+			assertNotNull( inv.getPath() );
+			assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
 			getCfg().addCacheableFile( file );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "file");
-			assertNotNull(inv.getPath()); 
-			assertTrue(inv.getPath().endsWith(".hbm.xml"));
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "file" );
+			assertNotNull( inv.getPath() );
+			assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
 
 		try {
-			getCfg().addClass( InvalidMapping.class ); 
+			getCfg().addClass( InvalidMapping.class );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml");
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml" );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
-			getCfg().addFile( file.getAbsolutePath() ); 
+			getCfg().addFile( file.getAbsolutePath() );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), file.getPath());
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "file" );
+			assertEquals( inv.getPath(), file.getPath() );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
-			getCfg().addFile( file ); 
+			getCfg().addFile( file );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "file");
-			assertEquals(inv.getPath(), file.getPath());
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "file" );
+			assertEquals( inv.getPath(), file.getPath() );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
+
 		try {
-			getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) ); 
+			getCfg().addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "input stream");
-			assertEquals(inv.getPath(), null);
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "input stream" );
+			assertEquals( inv.getPath(), null );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
 			getCfg().addResource( resourceName );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), resourceName);
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), resourceName );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
 			getCfg().addResource( resourceName, getClass().getClassLoader() );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "resource");
-			assertEquals(inv.getPath(), resourceName);
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
 		}
-		
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "resource" );
+			assertEquals( inv.getPath(), resourceName );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
+
 		try {
 			getCfg().addURL( ConfigHelper.findAsResource( resourceName ) );
 			fail();
-		} catch(InvalidMappingException inv) { 
-			assertEquals(inv.getType(), "URL");
-			assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml"));
-			assertTrue(!(inv.getCause() instanceof MappingNotFoundException ));
-		}		
+		}
+		catch ( InvalidMappingException inv ) {
+			assertEquals( inv.getType(), "URL" );
+			assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );
+			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
+		}
 	}
-	
+
 	public static Test suite() {
-		return new TestSuite(MappingExceptionTest.class);
+		return new TestSuite( MappingExceptionTest.class );
 	}
 }




More information about the hibernate-commits mailing list