use of org.mule.test.petstore.extension.PetStoreClient in project mule by mulesoft.
the class PetStoreCachedConnectionWithDynamicParameterTestCase method getDynamicConnectionParametersOnCachedConnection.
@Test
public void getDynamicConnectionParametersOnCachedConnection() throws Exception {
PetStoreClient client = (PetStoreClient) flowRunner(FLOW_NAME).withVariable(USERNAME, "john").withVariable(PASSWORD, "doe").withVariable(DATE, parseDateTime("2008-09-15T15:53:23+05:00").getTime()).run().getMessage().getPayload().getValue();
assertThat(client.getUsername(), is("john"));
assertThat(client.getPassword(), is("doe"));
Calendar calendar = Calendar.getInstance();
calendar.setTime(client.getOpeningDate());
assertEquals(calendar.get(Calendar.YEAR), 2008);
assertEquals(calendar.get(Calendar.MONTH) + 1, 9);
assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 15);
client = (PetStoreClient) flowRunner(FLOW_NAME).withVariable(USERNAME, "john").withVariable(PASSWORD, "doe").withVariable(DATE, parseDateTime("2017-02-10").getTime()).run().getMessage().getPayload().getValue();
assertThat(client.getUsername(), is("john"));
assertThat(client.getPassword(), is("doe"));
calendar.setTime(client.getOpeningDate());
assertEquals(calendar.get(Calendar.YEAR), 2017);
assertEquals(calendar.get(Calendar.MONTH) + 1, 2);
assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 10);
}
use of org.mule.test.petstore.extension.PetStoreClient in project mule by mulesoft.
the class PetStoreTlsConnectionTestCase method tls.
@Test
public void tls() throws Exception {
PetStoreClient client = (PetStoreClient) runFlow("getClient").getMessage().getPayload().getValue();
assertThat(client.getTlsContext(), is(notNullValue()));
}
use of org.mule.test.petstore.extension.PetStoreClient in project mule by mulesoft.
the class PetStoreConnectionPoolingTestCase method exhaustion.
@Test
public void exhaustion() throws Exception {
if (NO_POOLING.equals(name)) {
// test does not apply
return;
}
executorService = Executors.newFixedThreadPool(poolSize);
List<Future<PetStoreClient>> clients = new ArrayList<>(poolSize);
for (int i = 0; i < poolSize; i++) {
clients.add(getClientOnLatch());
}
testLatch.await();
try {
getClient();
fail("was expecting pool to be exhausted when using config: " + name);
} catch (Exception e) {
assertThat(e.getCause(), is(instanceOf(ConnectionException.class)));
}
connectionLatch.release();
for (Future<PetStoreClient> future : clients) {
PollingProber prober = new PollingProber(1000, 100);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
PetStoreClient client = future.get(100, MILLISECONDS);
assertValidClient(client);
return true;
}
@Override
public String describeFailure() {
return "Could not obtain valid client";
}
});
}
// now test that the pool is usable again
assertValidClient(getClient());
}
Aggregations