Project

General

Profile

« Previous | Next » 

Revision 24ee49b9

Added by Andreas Kohlbecker over 12 years ago

switching to selenium 2.3.1 & SearchPage & OriginalSource tests

View differences:

modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java
91 91

  
92 92
	}
93 93

  
94
	public static String getProperty(String key){
95
		return getProperty(key, String.class);
94
	public static String getProperty(String key) throws TestConfigurationException{
95
		return getProperty(key, String.class, false);
96 96
	}
97 97

  
98 98
	@SuppressWarnings("unchecked")
99
	public static <T> T getProperty(String key, Class<T> type){
99
	public static <T> T getProperty(String key, Class<T> type, boolean nonNull) throws TestConfigurationException{
100 100
		if(testConfiguration == null){
101 101
			testConfiguration = new TestConfiguration();
102 102
		}
103 103
		String value = testConfiguration.getProperties().getProperty(key);
104 104

  
105

  
105 106
		if(value != null){
106 107
			if(URI.class.isAssignableFrom(type)){
107 108
				try {
108 109
					return (T) new URI(value);
109 110
				} catch (URISyntaxException e) {
110
					logger.error("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
111
					throw new TestConfigurationException("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString(), e);
111 112
				}
112 113
			} else if(UUID.class.isAssignableFrom(type)){
113 114
				try {
114 115
					return (T) UUID.fromString(value);
115 116
				} catch (IllegalArgumentException e) {
116
					logger.error("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
117
					throw new TestConfigurationException("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString(), e);
117 118
				}
118 119
			} else if(String.class.isAssignableFrom(type)){
119 120
				return (T) value;
120 121
			} else {
121
				throw new RuntimeException("Unsupported type " + type.toString());
122
				throw new TestConfigurationException("Unsupported type " + type.toString());
123
			}
124
		} else {
125
			if( nonNull) {
126
				throw new TestConfigurationException("Property " + key + " of " + testConfiguration.propertySourceUri.toString() + " must not be null");
122 127
			}
123 128
		}
124 129

  

Also available in: Unified diff