use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPageModelTest method should_set_server_route_when_updating_server.
@Test
public void should_set_server_route_when_updating_server() throws CoreException {
// given
model.setSelectDefaultRoute(true);
IRoute route = model.getRoute();
assertThat(route).isNotNull();
String routeURL = route.getURL();
// when
model.updateServer();
// then
verify(server, atLeastOnce()).setAttribute(eq(OpenShiftServerUtils.ATTR_ROUTE), eq(routeURL));
verify(model, atLeastOnce()).updateServer(anyString(), any(IService.class), anyString(), eq(routeURL), anyString(), anyString(), anyString(), anyString(), any(org.eclipse.core.resources.IProject.class));
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class OpenShiftServerExtendedProperties method getRoute.
/**
* Opens a dialog for user to select a route from the list.
* @param routes
* @return
*/
private IRoute getRoute(List<IRoute> routes) {
IRouteChooser chooser = OpenShiftCoreUIIntegration.getInstance().getRouteChooser();
IRoute route = null;
if (routes == null || routes.isEmpty()) {
chooser.noRouteErrorDialog();
return null;
}
if (routes.size() > 1) {
route = chooser.chooseRoute(routes);
if (route != null && chooser.isRememberChoice()) {
fireUpdateRoute(server, route.getURL());
}
} else {
route = routes.get(0);
}
return route;
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class OpenShiftServerExtendedProperties method getWelcomePageUrl.
@Override
public String getWelcomePageUrl() throws GetWelcomePageURLException {
String welcomePageUrl = null;
try {
// Get connection explicitly to report failure. Try and connect right now to know if it fails.
// Do not catch OpenShiftException, let it be reported. We are more concerned of NPE.
Connection connection = OpenShiftServerUtils.getConnection(server);
if (connection == null || !connection.connect()) {
throw new GetWelcomePageURLException("Connection is not established.");
}
IResource resource = OpenShiftServerUtils.getResource(server, connection, new NullProgressMonitor());
if (resource == null) {
throw new GetWelcomePageURLException("Resource is missing.");
}
IProject project = resource.getProject();
if ((project != null) && (resource instanceof IService)) {
List<IRoute> routes = ResourceUtils.getRoutesFor((IService) resource, project.getResources(ResourceKind.ROUTE));
IRoute route = getRoute(OpenShiftServerUtils.getRouteURL(server), routes);
if (route == null) {
route = getRoute(routes);
}
// Reporting route == null is implemented in getRoute.
if (route != null) {
welcomePageUrl = route.getURL();
}
}
} catch (OpenShiftException e) {
throw new GetWelcomePageURLException(e.getMessage(), e);
}
return welcomePageUrl;
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class NewApplicationWizardModelTest method setWrongJsonAsTemplateFile.
@Test
public void setWrongJsonAsTemplateFile() throws Exception {
IRoute route = Mockito.mock(IRoute.class);
when(route.getKind()).thenReturn(ResourceKind.ROUTE);
when(factory.create(any(InputStream.class))).thenReturn(route);
model.setLocalAppSourceFileName("resources/jboss_infinispan-server_ImageStreamImport.json");
model.loadAppSource(null);
assertFalse(model.getAppSourceStatus().isOK());
assertNull(model.getAppSourceStatus().getException());
}
use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.
the class RouteTimeout method set.
/**
* Sets the given timeout to the route that's found for the given resource.
* Returns the route that was modified or {@code null} otherwise.
*
* @param timeout
* @param monitor
* @return the route if it was modified or {@code null}
* @throws CoreException
*/
public IRoute set(DebugContext context, IProgressMonitor monitor) throws CoreException {
IRoute route = getRoute(resource, connection, monitor);
if (route == null) {
OpenShiftCoreActivator.pluginLog().logInfo(NLS.bind("Could not increase timeout for debugging: could not find any route for resource {0}", resource.getName()));
return null;
}
monitor.subTask(NLS.bind("Setting haproxy timeout for route {0}...", route.getName()));
String currentTimeout = getAnnotation(route);
if (!StringUtils.isBlank(currentTimeout)) {
// store for latter restore
OpenShiftServerUtils.setRouteTimeout(currentTimeout, context.getServer());
if (StringUtils.equals(ROUTE_DEBUG_TIMEOUT, currentTimeout)) {
return null;
}
}
setAnnotation(ROUTE_DEBUG_TIMEOUT, route);
return route;
}
Aggregations