use of org.minijax.rs.MinijaxRequestContext in project minijax by minijax.
the class RequestScopedProvider method get.
@Override
public T get(final Object obj) {
final MinijaxRequestContext context = (MinijaxRequestContext) obj;
final ResourceCache resourceCache = context.getResourceCache();
T instance = resourceCache.get(key);
if (instance == null) {
instance = sourceProvider.get(context);
resourceCache.put(key, instance);
}
return instance;
}
use of org.minijax.rs.MinijaxRequestContext in project minijax by minijax.
the class AdapterTest method testOnMessage.
@Test
void testOnMessage() throws IOException {
try (final MinijaxRequestContext ctx = createRequestContext()) {
final MinijaxUndertowWebSocketAdapter adapter = new MinijaxUndertowWebSocketAdapter(ctx, TestSocket2.class);
adapter.onOpen(emptyMap());
adapter.onMessage(singletonMap(String.class, "test"));
adapter.onClose(emptyMap());
adapter.onError(emptyMap());
}
}
use of org.minijax.rs.MinijaxRequestContext in project minijax by minijax.
the class AdapterTest method testOnClose.
@Test
void testOnClose() throws IOException {
try (final MinijaxRequestContext ctx = createRequestContext()) {
final MinijaxUndertowWebSocketAdapter adapter = new MinijaxUndertowWebSocketAdapter(ctx, TestSocket3.class);
adapter.onOpen(emptyMap());
adapter.onMessage(emptyMap());
adapter.onClose(emptyMap());
adapter.onError(emptyMap());
}
}
use of org.minijax.rs.MinijaxRequestContext in project minijax by minijax.
the class ExceptionMapperTest method testNotFound.
@Test
void testNotFound() throws IOException {
try (final MinijaxRequestContext ctx = createRequestContext()) {
final MinijaxJsonExceptionMapper mapper = new MinijaxJsonExceptionMapper();
final Response response = mapper.toResponse(new NotFoundException());
assertNotNull(response);
assertEquals(404, response.getStatus());
assertEquals(404, ((MinijaxJsonExceptionWrapper) response.getEntity()).getCode());
assertEquals("HTTP 404 Not Found", ((MinijaxJsonExceptionWrapper) response.getEntity()).getMessage());
}
}
use of org.minijax.rs.MinijaxRequestContext in project minijax by minijax.
the class ExceptionMapperTest method testNotFound.
@Test
void testNotFound() throws IOException {
try (final MinijaxRequestContext ctx = createRequestContext()) {
final MinijaxMustacheExceptionMapper mapper = new MinijaxMustacheExceptionMapper();
final Response response = mapper.toResponse(new NotFoundException());
assertNotNull(response);
assertEquals(404, response.getStatus());
assertEquals("error", ((View) response.getEntity()).getTemplateName());
}
}
Aggregations