/** * Returns wso2 https server port based on automation.xml configurations * @throws Exception */ protected Integer getHttpsServerPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("https")); }
/** * Returns AMQP port based on automation.xml configurations * @throws Exception */ protected Integer getAMQPPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("amqp")); }
/** * Returns JMX RMI Server port based on automation.xml configurations * @throws Exception */ protected Integer getJMXServerPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("jmxserver")); }
/** * Returns JMX RMI Registry port based on automation.xml configurations * @throws Exception */ protected Integer getRMIRegistryPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("rmiregistry")); }
/** * Returns MQTT port based on automation.xml configurations * @throws XPathExpressionException */ protected Integer getAMQPPort() throws XPathExpressionException { return Integer.parseInt(mbServer.getInstance().getPorts().get("amqp")); } }
/** * Returns AMQP port based on automation.xml configurations * @throws Exception */ protected Integer getSecureAMQPPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("sslamqp")); }
/** * Returns MQTT port based on automation.xml configurations * @throws XPathExpressionException */ protected Integer getMQTTPort() throws XPathExpressionException { return Integer.parseInt(mbServer.getInstance().getPorts().get("mqtt")); }
/** * Returns MQTT port based on automation.xml configurations * @throws Exception */ protected Integer getMQTTPort() throws XPathExpressionException { return Integer.parseInt(automationContext.getInstance().getPorts().get("mqtt")); }
protected String getLoginURL() throws XPathExpressionException { return UrlGenerationUtil.getLoginURL(esContext.getInstance()); }
protected String getLoginURL() throws XPathExpressionException { return UrlGenerationUtil.getLoginURL(automationContext.getInstance()); }
protected String getStorePublisherUrl() throws XPathExpressionException { return UrlGenerationUtil.getWebAppURL(esContext.getContextTenant(), esContext.getInstance()).split("\\/t\\/") [0]; } }
/** * Give a random AMQP broker URL. * * @return Broker URL in host:port format (E.g "127.0.0.1:5672") * @throws XPathExpressionException */ protected HostAndPort getRandomAMQPBrokerAddress() throws XPathExpressionException { String randomInstanceKey = getRandomMBInstance(); AutomationContext tempContext = getAutomationContextWithKey(randomInstanceKey); return HostAndPort.fromString(tempContext.getInstance().getHosts().get ("default") + ":" + tempContext.getInstance().getPorts().get("amqp")); }
/** * Give a random AMQP broker URL. * * @return Broker URL in host:port format (E.g "127.0.0.1:5672") * @throws XPathExpressionException */ protected HostAndPort getRandomMQTTBrokerAddress() throws XPathExpressionException { String randomInstanceKey = getRandomMBInstance(); AutomationContext tempContext = getAutomationContextWithKey(randomInstanceKey); return HostAndPort.fromString(tempContext.getInstance().getHosts().get ("default") + ":" + tempContext.getInstance().getPorts().get("mqtt")); }
/** * Retrieve default MQTT client configurations and change if there are configuration changes in * automation xml. * * @return Default MQTTClientConnectionConfigurations */ public MQTTClientConnectionConfiguration getConfigurations(AutomationContext automationContext) throws XPathExpressionException { MQTTClientConnectionConfiguration configuration = getDefaultConfigurations(); String brokerHost = automationContext.getInstance().getHosts().get("default"); if (!brokerHost.isEmpty()) { configuration.setBrokerHost(brokerHost); } if(!automationContext.getInstance().getPorts().get("mqtt").isEmpty()) { configuration.setBrokerPort(automationContext.getInstance().getPorts().get("mqtt")); } return configuration; }
protected String getWebAppURL() throws XPathExpressionException { return UrlGenerationUtil.getWebAppURL(esContext.getContextTenant(), esContext.getInstance()); }
try { login(getPropertyValue(AFConstants.URLS_PROD_SC), tenantAdminUsername, adminPassword, context.getInstance().getHosts().get("default")); isTenantLoggedIn = true; break;
/** * This method to check whether server is up or not * This method wait for some time to check login status by checking the port and login * This will throw an exception if port is not open or couldn't login * * @param automationContext - AutomationContext * @return true: If server is up else false * @throws CarbonToolsIntegrationTestException - Error while waiting for login */ public static boolean isServerStartedUp(AutomationContext automationContext, int portOffset) throws CarbonToolsIntegrationTestException { try { //Waiting util a port is open, If couldn't open within given time this will throw an Exception ClientConnectionUtil.waitForPort( Integer.parseInt(FrameworkConstants.SERVER_DEFAULT_HTTPS_PORT) + portOffset, CarbonIntegrationConstants.DEFAULT_WAIT_MS, false, automationContext.getInstance().getHosts().get("default")); //Waiting util login to the the server this will throw LoginAuthenticationExceptionException if fails ClientConnectionUtil.waitForLogin(automationContext); log.info("Server started successfully."); return true; } catch (Exception e) { log.error("Error while waiting for login ", e); throw new CarbonToolsIntegrationTestException("Error while waiting for login ", e); } }
public synchronized void restartGracefully() throws AutomationFrameworkException { try { int httpsPort = defaultHttpsPort + portOffset; //considering the port offset String backendURL = automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort); User superUser = automationContext.getSuperTenant().getTenantAdmin(); ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, superUser.getUserName() , superUser.getPassword()); } catch (XPathExpressionException e) { throw new AutomationFrameworkException("restart failed", e); } long time = System.currentTimeMillis() + DEFAULT_START_STOP_WAIT_MS; while (!inputStreamHandler.getOutput().contains(SERVER_SHUTDOWN_MESSAGE) && System.currentTimeMillis() < time) { // wait until server shutdown is completed } time = System.currentTimeMillis(); while (System.currentTimeMillis() < time + 5000) { //wait for port to close } try { ClientConnectionUtil.waitForPort( Integer.parseInt(automationContext.getInstance().getPorts().get("https")), automationContext.getInstance().getHosts().get("default")); ClientConnectionUtil.waitForLogin(automationContext); } catch (XPathExpressionException e) { throw new AutomationFrameworkException("Connection attempt to carbon server failed", e); } }
/** * Provides login to carbon server */ public String login() throws AutomationUtilException { String userName = null; try { userName = automationContext.getContextTenant().getContextUser().getUserName(); if (log.isDebugEnabled()) { log.debug("Login with user name " + userName); log.debug("Login with password " + automationContext.getContextTenant().getContextUser().getPassword()); log.debug("Login with host name " + automationContext.getInstance().getHosts().get("default")); } return loginClient.login( userName, automationContext.getContextTenant().getContextUser().getPassword(), automationContext.getInstance().getHosts().get("default")); } catch (LoginAuthenticationExceptionException e) { throw new AutomationUtilException("Error while login as " + userName, e); } catch (IOException e) { throw new AutomationUtilException("Error while login as " + userName, e); } catch (XPathExpressionException e) { throw new AutomationUtilException("Error while login as " + userName, e); } }
/** * Log in to a Carbon server * * @return The session cookie on successful login * @throws LoginAuthenticationExceptionException, IOException, XMLStreamException, * URISyntaxException, SAXException, XPathExpressionException */ public String login() throws LoginAuthenticationExceptionException, IOException, XMLStreamException, URISyntaxException, SAXException, XPathExpressionException { String userName; userName = automationContext.getContextTenant().getContextUser().getUserName(); return loginClient.login(userName, automationContext.getContextTenant().getContextUser().getPassword() , automationContext.getInstance().getHosts().get("default")); }