1 /* 2 * Copyright The Apache Software Foundation. All rights reserved. 3 * 4 * This software is published under the terms of the Apache Software License 5 * version 1.1, a copy of which has been included with this distribution in 6 * the LICENSE.txt file. 7 */ 8 package org.codehaus.spice.configkit; 9 10 import junit.framework.TestCase; 11 12 /*** 13 * Basic unit tests for the info objects. 14 * 15 * @author Peter Donald 16 */ 17 public final class EntityInfoTestCase 18 extends TestCase 19 { 20 public void testFullySpecified() 21 { 22 doInfoTest( TestData.PUBLIC_ID, 23 TestData.SYSTEM_ID, 24 TestData.RESOURCE ); 25 } 26 27 public void testNullSystemId() 28 { 29 doInfoTest( TestData.PUBLIC_ID, null, TestData.RESOURCE ); 30 } 31 32 public void testNullPublicId() 33 { 34 doInfoTest( null, TestData.SYSTEM_ID, TestData.RESOURCE ); 35 } 36 37 public void testNullResource() 38 { 39 try 40 { 41 doInfoTest( TestData.PUBLIC_ID, TestData.SYSTEM_ID, null ); 42 } 43 catch( final NullPointerException npe ) 44 { 45 assertEquals( npe.getMessage(), "resource" ); 46 return; 47 } 48 fail( "Expected Null pointer due to null resource" ); 49 } 50 51 public void testNullIDs() 52 { 53 try 54 { 55 doInfoTest( null, null, TestData.RESOURCE ); 56 } 57 catch( final NullPointerException npe ) 58 { 59 assertEquals( npe.getMessage(), "systemId" ); 60 return; 61 } 62 fail( "Expected Null pointer due to null publicId/systemId" ); 63 } 64 65 private void doInfoTest( final String publicId, 66 final String systemId, 67 final String resource ) 68 { 69 final EntityInfo info = new EntityInfo( publicId, systemId, resource ); 70 assertEquals( "PUBLIC_ID", publicId, info.getPublicId() ); 71 assertEquals( "SYSTEM_ID", systemId, info.getSystemId() ); 72 assertEquals( "RESOURCE", resource, info.getResource() ); 73 } 74 } 75

This page was automatically generated by Maven