Project

General

Profile

« Previous | Next » 

Revision 1bfb3aa7

Added by Andreas Kohlbecker over 2 years ago

fixing potential NPE

View differences:

src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
122 122
		DataPortalContexts dataPortalContextsAnotation = getTestClass().getJavaClass().getAnnotation(DataPortalContexts.class);
123 123
		DataPortalContextProvider contextProvider = null;
124 124

  
125
		if(dataPortalContextsAnotation.siteListUrl()){
126
            String siteListUrlString = System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL);
127
            if(System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL) == null) {
128
                throw new RuntimeException("The system property " + SYSTEM_PROPERTY_SITE_LIST_URL + " must be set if 'siteListUrl' is enabled");
129
            }
130
            try {
131
                contextProvider = new DataPortalsListContextProvider(new URL(siteListUrlString));
132
            } catch (MalformedURLException e) {
133
                throw new RuntimeException("Error parsing the provided URL", e);
134
            }
135
		} else {
136
		    contextProvider = new DataPortalSiteContextProvider(dataPortalContextsAnotation.value());
137
		}
138

  
139
		assert contextProvider != null;
140
		for (DataPortalContext dataPortalContext : contextProvider.contexts()) {
141
		    runners.add(new TestClassRunnerWithDataPortalContext(klass, dataPortalContext));
125
		if(dataPortalContextsAnotation != null) {
126
    		if(dataPortalContextsAnotation.siteListUrl()){
127
                String siteListUrlString = System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL);
128
                if(System.getProperty(SYSTEM_PROPERTY_SITE_LIST_URL) == null) {
129
                    throw new RuntimeException("The system property " + SYSTEM_PROPERTY_SITE_LIST_URL + " must be set if 'siteListUrl' is enabled");
130
                }
131
                try {
132
                    contextProvider = new DataPortalsListContextProvider(new URL(siteListUrlString));
133
                } catch (MalformedURLException e) {
134
                    throw new RuntimeException("Error parsing the provided URL", e);
135
                }
136
    		} else {
137
    		    contextProvider = new DataPortalSiteContextProvider(dataPortalContextsAnotation.value());
138
    		}
139

  
140
    		assert contextProvider != null;
141
    		for (DataPortalContext dataPortalContext : contextProvider.contexts()) {
142
    		    runners.add(new TestClassRunnerWithDataPortalContext(klass, dataPortalContext));
143
    		}
142 144
		}
143 145
	}
144 146

  

Also available in: Unified diff