-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from mendix/feature/global-request-settings-6
Added action to set max concurrency and timeouts to latest version
- Loading branch information
Showing
8 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
javasource/restservices/actions/setGlobalRequestSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// This file was generated by Mendix Modeler. | ||
// | ||
// WARNING: Only the following code will be retained when actions are regenerated: | ||
// - the import list | ||
// - the code between BEGIN USER CODE and END USER CODE | ||
// - the code between BEGIN EXTRA CODE and END EXTRA CODE | ||
// Other code you write will be lost the next time you deploy the project. | ||
// Special characters, e.g., é, ö, à, etc. are supported in comments. | ||
|
||
package restservices.actions; | ||
|
||
import com.mendix.systemwideinterfaces.core.IContext; | ||
import com.mendix.webui.CustomJavaAction; | ||
import restservices.consume.RestConsumer; | ||
|
||
/** | ||
* | ||
*/ | ||
public class setGlobalRequestSettings extends CustomJavaAction<Boolean> | ||
{ | ||
private Long maxConcurrentRequests; | ||
private Long timeout; | ||
|
||
public setGlobalRequestSettings(IContext context, Long maxConcurrentRequests, Long timeout) | ||
{ | ||
super(context); | ||
this.maxConcurrentRequests = maxConcurrentRequests; | ||
this.timeout = timeout; | ||
} | ||
|
||
@Override | ||
public Boolean executeAction() throws Exception | ||
{ | ||
// BEGIN USER CODE | ||
RestConsumer.setGlobalRequestSettings(maxConcurrentRequests, timeout); | ||
return true; | ||
// END USER CODE | ||
} | ||
|
||
/** | ||
* Returns a string representation of this action | ||
*/ | ||
@Override | ||
public String toString() | ||
{ | ||
return "setGlobalRequestSettings"; | ||
} | ||
|
||
// BEGIN EXTRA CODE | ||
// END EXTRA CODE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tests; | ||
|
||
import com.mendix.core.Core; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import restservices.RestServices; | ||
import restservices.consume.RestConsumeException; | ||
import restservices.consume.RestConsumer; | ||
import restservices.proxies.HttpMethod; | ||
import restservices.publish.MicroflowService; | ||
|
||
public class TimeoutTests extends TestBase { | ||
|
||
@Test | ||
public void testIdleTimeout() throws Exception { | ||
RestConsumer.setGlobalRequestSettings(null, 1000L); | ||
String url = RestServices.getAbsoluteUrl("ServiceWithLongOperation"); | ||
|
||
new MicroflowService("Tests.ServiceWithLongOperation", "*", HttpMethod.GET, "Service with 1 minute operation"); | ||
|
||
try { | ||
RestConsumer.request(Core.createSystemContext(), HttpMethod.GET, url, null, null, false); | ||
} catch (RestConsumeException rce) { | ||
Assert.assertTrue(rce.getResponseData().getBody().startsWith("java.net.SocketTimeoutException")); | ||
} finally { | ||
RestConsumer.setGlobalRequestSettings(null, 0L); | ||
} | ||
} | ||
} |