1 37 package net.sourceforge.cruisecontrol; 38 39 import junit.framework.TestCase; 40 import net.sourceforge.cruisecontrol.bootstrappers.CVSBootstrapper; 41 import net.sourceforge.cruisecontrol.builders.AntBuilder; 42 import net.sourceforge.cruisecontrol.buildloggers.MergeLogger; 43 import net.sourceforge.cruisecontrol.labelincrementers.DefaultLabelIncrementer; 44 import net.sourceforge.cruisecontrol.listeners.CurrentBuildStatusListener; 45 import net.sourceforge.cruisecontrol.publishers.FTPPublisher; 46 import net.sourceforge.cruisecontrol.publishers.email.EmailMapping; 47 import net.sourceforge.cruisecontrol.publishers.email.PropertiesMapper; 48 import net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem; 49 50 public class PluginTypeTest extends TestCase { 51 52 public void testGettingTypeForPlugin() { 53 PluginType type = PluginType.find(CVSBootstrapper.class); 54 assertSame(PluginType.BOOTSTRAPPER, type); 55 type = PluginType.find(ProjectConfig.Bootstrappers.class); 56 assertSame(PluginType.BOOTSTRAPPERS, type); 57 58 type = PluginType.find(AntBuilder.class); 59 assertSame(PluginType.BUILDER, type); 60 61 type = PluginType.find(CCDateFormat.class); 62 assertSame(PluginType.DATE_FORMAT, type); 63 64 type = PluginType.find(DefaultLabelIncrementer.class); 65 assertSame(PluginType.LABEL_INCREMENTER, type); 66 67 type = PluginType.find(CurrentBuildStatusListener.class); 68 assertSame(PluginType.LISTENER, type); 69 type = PluginType.find(ProjectConfig.Listeners.class); 70 assertSame(PluginType.LISTENERS, type); 71 72 type = PluginType.find(Log.class); 73 assertSame(PluginType.LOG, type); 74 75 type = PluginType.find(EmailMapping.class); 76 assertSame(PluginType.MAP, type); 77 78 type = PluginType.find(MergeLogger.class); 79 assertSame(PluginType.MERGE_LOGGER, type); 80 81 type = PluginType.find(ModificationSet.class); 82 assertSame(PluginType.MODIFICATION_SET, type); 83 84 type = PluginType.find(ProjectConfig.class); 85 assertSame(PluginType.PROJECT, type); 86 87 type = PluginType.find(PropertiesMapper.class); 88 assertSame(PluginType.EMAIL_MAPPER, type); 89 90 type = PluginType.find(FTPPublisher.class); 91 assertSame(PluginType.PUBLISHER, type); 92 type = PluginType.find(ProjectConfig.Publishers.class); 93 assertSame(PluginType.PUBLISHERS, type); 94 95 type = PluginType.find(Schedule.class); 96 assertSame(PluginType.SCHEDULE, type); 97 98 type = PluginType.find(ConcurrentVersionsSystem.class); 99 assertSame(PluginType.SOURCE_CONTROL, type); 100 } 101 102 public void testExceptions() { 103 try { 104 PluginType.find(Object .class); 105 fail("Should not be able to find plugin type for Object."); 106 } catch (IllegalArgumentException expected) { 107 assertEquals("class java.lang.Object is not a CruiseControl plugin.", expected.getMessage()); 108 } 109 110 try { 111 PluginType.find((Class ) null); 112 fail("Should not be able to find plugin type for null."); 113 } catch (IllegalArgumentException expected) { 114 assertEquals("null is not a CruiseControl plugin.", expected.getMessage()); 115 } 116 117 try { 118 PluginType.find((String ) null); 119 fail("Should not be able to find plugin type for null."); 120 } catch (IllegalArgumentException expected) { 121 assertEquals("null is not a CruiseControl plugin.", expected.getMessage()); 122 } 123 } 124 125 public void testGettingTypes() { 126 PluginType[] types = PluginType.getTypes(); 127 128 assertNotNull(types); 129 assertTrue(0 < types.length); 130 } 131 132 public void testGettingNameForPlugin() { 133 PluginType type = PluginType.find(CVSBootstrapper.class); 134 assertEquals("bootstrapper", type.getName()); 135 136 type = PluginType.find(FTPPublisher.class); 137 assertEquals("publisher", type.getName()); 138 139 type = PluginType.find(ConcurrentVersionsSystem.class); 140 assertEquals("sourcecontrol", type.getName()); 141 } 142 143 public void testEquals() { 144 assertFalse(PluginType.BOOTSTRAPPER.equals(null)); 145 assertFalse(PluginType.BOOTSTRAPPER.equals(new Object ())); 146 assertFalse(PluginType.BOOTSTRAPPER.equals(PluginType.SOURCE_CONTROL)); 147 assertTrue(PluginType.BOOTSTRAPPER.equals(PluginType.BOOTSTRAPPER)); 148 } 149 150 public void testToString() { 151 assertEquals("bootstrapper", PluginType.BOOTSTRAPPER.toString()); 152 assertEquals("publisher", PluginType.PUBLISHER.toString()); 153 assertEquals("sourcecontrol", PluginType.SOURCE_CONTROL.toString()); 154 } 155 } 156 | Popular Tags |