comparison gwt-client/src/test/java/test/AbstractModuleRunner.java @ 9424:da19f1f58d72

jUnit test uinfo salix regional
author gernotbelger
date Fri, 17 Aug 2018 14:29:05 +0200
parents e567fac95e3d
children ce0a48b93f4b
comparison
equal deleted inserted replaced
9423:a299f32e4a71 9424:da19f1f58d72
77 private static final String IGNORE_ERSTELLDATUM = "# Datum der Erstellung"; 77 private static final String IGNORE_ERSTELLDATUM = "# Datum der Erstellung";
78 private static final String IGNORE_FLYS_VERSION = "# FLYS-Version:"; 78 private static final String IGNORE_FLYS_VERSION = "# FLYS-Version:";
79 private static final String IGNORE_BEARBEITER = "NEIN_DOCH_NICHT";// "# Bearbeiter:"; 79 private static final String IGNORE_BEARBEITER = "NEIN_DOCH_NICHT";// "# Bearbeiter:";
80 80
81 private final Infotype infotype; 81 private final Infotype infotype;
82 private final String userUuid; 82 private static String userUuid;
83 private Collection collection; 83 private Collection collection;
84 private Artifact artifact; 84 private Artifact artifact;
85 private final IFilenameMapper fileName; 85 private final IFilenameMapper fileName;
86 86
87 // common attributes 87 // common attributes
102 this.infotype = infotype; 102 this.infotype = infotype;
103 this.fileName = helloWorldFile; 103 this.fileName = helloWorldFile;
104 104
105 // init 105 // init
106 this.client = new HttpClientImpl(this.serverUrl, this.locale); 106 this.client = new HttpClientImpl(this.serverUrl, this.locale);
107 this.userUuid = makeUserUuid(); 107 if (AbstractModuleRunner.userUuid == null)
108 AbstractModuleRunner.userUuid = makeUserUuid(this.serverUrl);
108 this.collection = getCollection(); 109 this.collection = getCollection();
109 this.artifact = getArtifact(); 110 this.artifact = getArtifact();
110 } 111 }
111 112
112 private String makeUserUuid() throws ConnectionException { 113 private static String makeUserUuid(final String serverUrl) throws ConnectionException {
113 final User user = new DefaultUser(this.USERNAME, this.PASSWORD, null, false, new ArrayList<String>(), new ArrayList<String>()); 114 final User user = new DefaultUser(USERNAME, PASSWORD, null, false, new ArrayList<String>(), new ArrayList<String>());
114 final UserClient userClient = new UserClient(this.serverUrl); 115 final UserClient userClient = new UserClient(serverUrl);
115 Element userElement; 116 Element userElement;
116 117
117 userElement = userClient.findUser(user); 118 userElement = userClient.findUser(user);
118 return userElement.getAttributeNS(ArtifactNamespaceContext.NAMESPACE_URI, "uuid"); 119 return userElement.getAttributeNS(ArtifactNamespaceContext.NAMESPACE_URI, "uuid");
119 120
130 protected Collection getCollection() throws ConnectionException { 131 protected Collection getCollection() throws ConnectionException {
131 132
132 if (this.collection == null) { 133 if (this.collection == null) {
133 // lazy-Loading 134 // lazy-Loading
134 final Document create = ClientProtocolUtils.newCreateCollectionDocument(null); 135 final Document create = ClientProtocolUtils.newCreateCollectionDocument(null);
135 final Document doc = (Document) this.client.createCollection(create, this.userUuid, new DocumentResponseHandler()); 136 final Document doc = (Document) this.client.createCollection(create, userUuid, new DocumentResponseHandler());
136 final String uuid = XMLUtils.xpathString(doc, CreateCollectionServiceImpl.XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE); 137 final String uuid = XMLUtils.xpathString(doc, CreateCollectionServiceImpl.XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE);
137 final String ttlStr = XMLUtils.xpathString(doc, CreateCollectionServiceImpl.XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE); 138 final String ttlStr = XMLUtils.xpathString(doc, CreateCollectionServiceImpl.XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE);
138 this.collection = new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid); 139 this.collection = new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid);
139 } 140 }
140 return this.collection; 141 return this.collection;
162 } 163 }
163 164
164 protected final void feedAndGo(final Data[] data, final int reachableStateIndex) throws ConnectionException, ServerException { 165 protected final void feedAndGo(final Data[] data, final int reachableStateIndex) throws ConnectionException, ServerException {
165 feed(data); 166 feed(data);
166 advance(getReachableStateByIndex(getArtifact(), reachableStateIndex)); // reachablestate könnte auch String sein. 167 advance(getReachableStateByIndex(getArtifact(), reachableStateIndex)); // reachablestate könnte auch String sein.
167
168 } 168 }
169 169
170 private final String getReachableStateByIndex(final Artifact artifact, final int index) { 170 private final String getReachableStateByIndex(final Artifact artifact, final int index) {
171 171
172 final String[] states = artifact.getArtifactDescription().getReachableStates(); 172 final String[] states = artifact.getArtifactDescription().getReachableStates();
310 new DataItem[] { new DefaultDataItem(calcmodeStr, calcmodeStr, calcmodeStr) }); 310 new DataItem[] { new DefaultDataItem(calcmodeStr, calcmodeStr, calcmodeStr) });
311 feedAndGo(new Data[] { dataCalcMode }, 0); 311 feedAndGo(new Data[] { dataCalcMode }, 0);
312 } 312 }
313 313
314 protected final void selectRange() throws ConnectionException, ServerException { 314 protected final void selectRange() throws ConnectionException, ServerException {
315 final String fromStr = String.valueOf(this.from); 315 makeKmRange(this.from, this.to, "ld_from", "ld_to");
316 final String toStr = String.valueOf(this.to); 316
317 final Data dataFrom = new StringOptionsData("ld_from", "ld_from", new DataItem[] { new DefaultDataItem(fromStr, fromStr, fromStr) }); 317 }
318 final Data dataTo = new StringOptionsData("ld_to", "ld_to", new DataItem[] { new DefaultDataItem(toStr, toStr, toStr) }); 318
319 protected final void makeKmRange(final double from, final double to, final String from_key, final String to_key)
320 throws ConnectionException, ServerException {
321 final String fromStr = String.valueOf(from);
322 final String toStr = String.valueOf(to);
323 final Data dataFrom = new StringOptionsData(from_key, from_key, new DataItem[] { new DefaultDataItem(fromStr, fromStr, fromStr) });
324 final Data dataTo = new StringOptionsData(to_key, to_key, new DataItem[] { new DefaultDataItem(toStr, toStr, toStr) });
319 final Data[] rangeFromToDetermined = new Data[] { dataFrom, dataTo }; 325 final Data[] rangeFromToDetermined = new Data[] { dataFrom, dataTo };
320 326
321 feedAndGo(rangeFromToDetermined, 0); 327 feedAndGo(rangeFromToDetermined, 0);
322 } 328 }
323 329
345 protected final String getRecommendationPairString(final SimpleRecommendation rec1, final SimpleRecommendation rec2) 351 protected final String getRecommendationPairString(final SimpleRecommendation rec1, final SimpleRecommendation rec2)
346 throws ConnectionException, ServerException { 352 throws ConnectionException, ServerException {
347 353
348 return rec1.getRecommendationPairString(rec2, getCollection(), this.serverUrl, this.locale); 354 return rec1.getRecommendationPairString(rec2, getCollection(), this.serverUrl, this.locale);
349 } 355 }
356
357 protected final void feedSimpleTextInput(final String key, final String value) throws ConnectionException, ServerException {
358 final Data data = new StringOptionsData(key, key, new DataItem[] { new DefaultDataItem(value, value, value) });
359 feedAndGo(new Data[] { data }, 0);
360 }
361
350 } 362 }

http://dive4elements.wald.intevation.org