use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class VcrServerTest method setup.
@BeforeClass
public static void setup() throws Exception {
mockClusterAgentsFactory = new MockClusterAgentsFactory(false, true, 1, 1, 2);
mockClusterMap = mockClusterAgentsFactory.getClusterMap();
notificationSystem = mock(NotificationSystem.class);
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class RestServerTest method badArgumentsTest.
// serverCreationWithBadInputTest() helpers
/**
* Tests {@link RestServer} instantiation attempts with bad input.
* @throws Exception
* @throws IOException
*/
private void badArgumentsTest() throws Exception {
// dud properties. server should pick up defaults
Properties properties = new Properties();
VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
try {
// no props.
new RestServer(null, clusterMap, notificationSystem, SSL_FACTORY);
fail("Properties missing, yet no exception was thrown");
} catch (IllegalArgumentException e) {
// nothing to do. expected.
}
try {
// no ClusterMap.
new RestServer(verifiableProperties, null, notificationSystem, SSL_FACTORY);
fail("ClusterMap missing, yet no exception was thrown");
} catch (IllegalArgumentException e) {
// nothing to do. expected.
}
try {
// no NotificationSystem.
new RestServer(verifiableProperties, clusterMap, null, SSL_FACTORY);
fail("NotificationSystem missing, yet no exception was thrown");
} catch (IllegalArgumentException e) {
// nothing to do. expected.
}
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class RestServerTest method startShutdownTestWithBadComponent.
/**
* Tests for correct exceptions thrown on {@link RestServer#start()}/{@link RestServer#shutdown()} with bad
* components.
* @throws Exception
*/
@Test
public void startShutdownTestWithBadComponent() throws Exception {
Properties properties = new Properties();
properties.setProperty("rest.server.nio.server.factory", MockNioServerFactory.class.getCanonicalName());
// makes MockNioServer throw exceptions.
properties.setProperty(MockNioServerFactory.IS_FAULTY_KEY, "true");
VerifiableProperties verifiableProperties = getVProps(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
RestServer server = new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY);
try {
server.start();
fail("start() should not be successful. MockNioServer::start() would have thrown InstantiationException");
} catch (InstantiationException e) {
// nothing to do. expected.
} finally {
try {
server.shutdown();
fail("RestServer shutdown should have failed.");
} catch (RuntimeException e) {
// nothing to do. expected.
}
}
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class VcrServerTest method testVCRServerWithReporterFactory.
/**
* Bring up the VCR server and then shut it down with {@link StaticVcrClusterParticipant} and a custom {@link JmxReporter}
* factory.
* @throws Exception
*/
@Test
public void testVCRServerWithReporterFactory() throws Exception {
VerifiableProperties verifiableProperties = getStaticClusterVcrProps();
ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
Function<MetricRegistry, JmxReporter> reporterFactory = reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
VcrServer vcrServer = new VcrServer(verifiableProperties, mockClusterAgentsFactory, notificationSystem, reporterFactory);
vcrServer.startup();
// check that the custom ObjectNameFactory specified in reporterFactory was used.
verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
vcrServer.shutdown();
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class RestServerTest method shutdownWithoutStartTest.
/**
* Tests for {@link RestServer#shutdown()} when {@link RestServer#start()} had not been called previously. This test
* is for cases where {@link RestServer#start()} has failed and {@link RestServer#shutdown()} needs to be run.
* @throws Exception
*/
@Test
public void shutdownWithoutStartTest() throws Exception {
Properties properties = new Properties();
VerifiableProperties verifiableProperties = getVProps(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
RestServer server = new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY);
server.shutdown();
server.awaitShutdown();
}
Aggregations