DataSourceHelper { public static List<String> validateDataSourceAnnotation( Class<? extends IDataSource> ds) { List<String> validationMessages = new ArrayList<String>(); DataSource annotation = ds.getAnnotation(DataSource.class); if (annotation == null) { validationMessages .add("A class implementing IDataSource must be annotated with @DataSource"); return validationMessages; } if (annotation.name().equals("") ) { validationMessages .add("DataSource.name() must not be null. This name is used in the UI."); } if (annotation.shortName().equals("")) { validationMessages .add("DataSource.shortName() must not be null. This name can be used in the test suite specification instead of a content type."); } for(String contentType : annotation.contentTypes()) { if(contentType.equals("")) { validationMessages.add("DataSource.contentTypes() must not include a null nor an empty (\"\") value."); } } return validationMessages; } private  DataSourceHelper(); static List<DataSourceConfigurationOption> getConfigurationOptionsFor(
			Class<? extends IDataSource> dataSource); static List<DataSourceConfigurationOption> getConfigurationOptionsFor(
			IDataSource dataSource); static boolean isValidConfigurationOption(IDataSource dataSource,
			String propertyName); static void setConfigurationOption(IDataSource dataSource,
			String name, String value); static List<String> validateDataSourceAnnotation(
			Class<? extends IDataSource> ds); static List<String> validateMethodAnnotations(
			Class<? extends IDataSource> ds); static String getName(IDataSource ds); static String getShortName(IDataSource ds);  }
@Test public void testValidateDataSourceAnnotationWithMissingAnnotation() throws Exception { List<String> messages = DataSourceHelper .validateDataSourceAnnotation(DataSourceWithoutAnnotation.class); assertEquals(1, messages.size()); }
@Test public void testValidateDataSourceAnnotationWithMissingNames() throws Exception { List<String> messages = DataSourceHelper .validateDataSourceAnnotation(DataSourceAnnotationWithMissingNames.class); assertEquals(2, messages.size()); }
@Test public void testValidateDataSourceAnnotationWithEmptyContentType() throws Exception { List<String> messages = DataSourceHelper .validateDataSourceAnnotation(DataSourceAnnotationWithEmptyContentType.class); assertEquals(1, messages.size()); }