// This method will read synapse.xml files public String readSynapseFile() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); Properties properties = new Properties(); String conCatLines = "exact:"; try { // Open the file FileInputStream fstream = new FileInputStream(esbCommon.getCarbonHome() + "/conf/synapse.xml"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; // Read File Line By Line while ((strLine = br.readLine()) != null) { strLine = strLine.trim(); conCatLines = conCatLines + strLine + " "; } // Close the input stream in.close(); // return conCatLines; } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); } return conCatLines; }
/* This method will add an XSLT mediator and it's mandatory properties */ public void addXSLTMediator(String level, String resource) throws Exception { selenium.click("//a[@id='mediator-" + level + "']"); Thread.sleep(2000); selenium.click("//a[@onclick=\"showInLinedRegistryBrowser('mediator.xslt.key')\"]"); ESBCommon esbCommon = new ESBCommon(selenium); esbCommon.selectResource("Entry", resource); }
/* Method to set Proxy Service General settings */ public void testSetGeneralSettings() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); ESBAddProxyServiceTest esbAddProxyServiceTest = new ESBAddProxyServiceTest(selenium); // Options which could be used are Specify in-line, Specify source URL, Pick from registry, None esbAddProxyServiceTest.addProxyName("StockQuoteProxy251", "Custom Proxy"); esbAddProxyServiceTest.addSourceUrlWsdl( "file:" + esbCommon.getCarbonHome() + "/repository/samples/resources/proxy/sample_proxy_1.wsdl"); esbAddProxyServiceTest.specifyStartOnload("true"); System.out.println("Setting general settings"); }
/* This method will test setting up of the Out Sequence of the Proxy Service wizard */ public void testSetOutSequence() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); ESBSendMediatorTest esbSendMediatorTest = new ESBSendMediatorTest(selenium); ESBAddProxyServiceTest esbAddProxyServiceTest = new ESBAddProxyServiceTest(selenium); // Available options are outSeqOpAnon, outSeqOpReg, outSeqOpImp, inSeqOpNone esbAddProxyServiceTest.selectOutSequence("outSeqOpAnon", null); esbCommon.addRootLevelChildren("Add Child", "Core", "Send"); esbSendMediatorTest.addNormalSendMediator("0"); esbCommon.mediatorUpdate(); esbCommon.sequenceSave(); System.out.println("The Out sequence was created successfully"); }
/* This method will test setting up of the Endpoint of the Proxy Service wizard */ public void testSetEndpoint() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); ESBAddProxyServiceTest esbAddProxyServiceTest = new ESBAddProxyServiceTest(selenium); ESBAddAddressEndpointTest esbAddAddressEndpointTest = new ESBAddAddressEndpointTest(selenium); // Available options are epOpImp, epOpAnon, epOpReg, epOpNone esbAddProxyServiceTest.selectEndpoint("epOpAnon", null); esbAddAddressEndpointTest.addAnonAddressEndpoint(); esbAddAddressEndpointTest.addAddressEprMandatoryInfo( null, esbCommon.getServiceAddUrl("JmsSimpleStockQuoteService")); esbAddAddressEndpointTest.saveAddressEndpoint(); esbAddProxyServiceTest.clickNext(); System.out.println("The endpoints was created successfully"); }
/* This method will test setting up of the In Sequence of the Proxy Service wizard */ public void testSetInSequence() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); ESBAddAddressEndpointTest esbAddAddressEndpointTest = new ESBAddAddressEndpointTest(selenium); ESBPropertyMediatorTest esbPropertyMediatorTest = new ESBPropertyMediatorTest(selenium); ESBAddProxyServiceTest esbAddProxyServiceTest = new ESBAddProxyServiceTest(selenium); // Available options are inSeqOpAnon, inSeqOpReg, inSeqOpImp, inSeqOpNone esbAddProxyServiceTest.selectInSequence("inSeqOpAnon", null); esbCommon.addRootLevelChildren("Add Child", "Core", "Property"); esbPropertyMediatorTest.addBasicPropInfo("0", "OUT_ONLY", "set"); esbPropertyMediatorTest.addPropertyMediator("value", "true", "Synapse"); esbCommon.mediatorUpdate(); esbCommon.sequenceSave(); System.out.println("The In sequence was created successfully"); }
/* * This method will verify the properties of the Command mediator */ public void addCommandMediator( String level, String className, String param1, String param2, String param3, String param4, String param5) throws Exception { selenium.click("//a[@id='mediator-" + level + "']"); Thread.sleep(2000); selenium.type("mediatorInputId", className); selenium.click("actionID"); ESBCommon esbCommon = new ESBCommon(selenium); esbCommon.mediatorUpdate(); }
/* This method will invoke the client */ public void testInvokeClient() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); OMElement stockQuoteResponse = null; ESBSampleClient sampleClient = new ESBSampleClient(); if (esbCommon.getContextRoot().equals(null)) { stockQuoteResponse = sampleClient.stockQuoteClientforProxy( "http://" + esbCommon.getHostName() + ":" + esbCommon.getNioHttpPort() + "/services/StockQuoteProxy251", null, "MSFT"); } else { stockQuoteResponse = sampleClient.stockQuoteClientforProxy( "http://" + esbCommon.getHostName() + ":" + esbCommon.getNioHttpPort() + "/" + esbCommon.getContextRoot() + "/services/StockQuoteProxy251", null, "MSFT"); } Iterator iterator = stockQuoteResponse .getFirstElement() .getChildrenWithName(new QName("http://services.samples/xsd", "name")); while (iterator.hasNext()) { OMElement element = (OMElement) iterator.next(); System.out.println("The response is received : " + element.getText()); assertEquals("MSFT Company", element.getText()); } Thread.sleep(5000); esbCommon.closeFiles(); }
/* Set Transport Listener */ public void testSetJmsTransportListner() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); esbCommon.configureTransportListner("JMS"); esbCommon.configureTransportSender("JMS"); }
/* * This method will verify the ESB Login page */ public void testVerifyHomePage() throws Exception { ESBCommon esbCommon = new ESBCommon(selenium); SeleniumTestBase seleniumTestBase = new SeleniumTestBase(selenium); boolean login = selenium.isTextPresent("Sign-out"); if (login) { seleniumTestBase.logOutUI(); } // Signing in seleniumTestBase.loginToUI("admin", "admin"); // Verify whether the ESB logo is available assertEquals("", selenium.getText("//div[@id='header-div']/div[2]/a/img")); assertTrue(selenium.isElementPresent("//div[@id='header-div']/div[2]/a/img")); // Verify whether the Management Console text assertEquals("Management Console", selenium.getText("//div[@id='header-div']/div[1]")); assertTrue(selenium.isElementPresent("//div[@id='header-div']/div[1]")); // Verify whether the About link is available and whether it is valid esbCommon.docLinks("About", "About WSO2 ESB", "//h2[1]"); // Verify whether the Docs link is available and whether it is valid esbCommon.docLinks("Docs", null, null); // Verify whether the Sign-in text is valid assertEquals("admin@localhost:9443", selenium.getText("logged-user")); // Verify whether the Sign-out link is available and whether it is valid assertEquals("Sign-out", selenium.getText("link=Sign-out")); assertTrue(selenium.isElementPresent("link=Sign-out")); seleniumTestBase.logOutUI(); // Signing in seleniumTestBase.loginToUI("admin", "admin"); // Verify whether the Help link is available and whether it is valid esbCommon.docLinks("Help", "WSO2 Carbon Server Home Page", "//h1"); // Verifying the home page content assertEquals("WSO2 ESB Home", selenium.getText("//div[@id='middle']/h2")); assertEquals( "Welcome to the WSO2 ESB Management Console", selenium.getText("//div[@id='middle']/p[1]")); assertEquals("Server", selenium.getText("//table[@id='systemInfoTable']/thead/tr/th")); assertEquals("Host", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[1]/td[1]")); assertEquals( "Server URL", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[2]/td[1]")); assertEquals( "Server Start Time", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[3]/td[1]")); assertEquals( "System Up Time", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[4]/td[1]")); assertEquals("Version", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[5]/td[1]")); assertEquals( "Repository Location", selenium.getText("//table[@id='systemInfoTable']/tbody/tr[6]/td[1]")); assertEquals("Operating System", selenium.getText("//table[@id='serverTable']/thead/tr/th")); assertEquals("OS Name", selenium.getText("//table[@id='serverTable']/tbody/tr[1]/td[1]")); assertEquals("OS Version", selenium.getText("//table[@id='serverTable']/tbody/tr[2]/td[1]")); assertEquals("Operating System User", selenium.getText("//table[@id='userTable']/thead/tr/th")); assertEquals("Country", selenium.getText("//table[@id='userTable']/tbody/tr[1]/td[1]")); assertEquals("Home", selenium.getText("//table[@id='userTable']/tbody/tr[2]/td[1]")); assertEquals("Name", selenium.getText("//table[@id='userTable']/tbody/tr[3]/td[1]")); assertEquals("Timezone", selenium.getText("//table[@id='userTable']/tbody/tr[4]/td[1]")); assertEquals("Java VM", selenium.getText("//table[@id='vmTable']/thead/tr/th")); assertEquals("Java Home", selenium.getText("//table[@id='vmTable']/tbody/tr[1]/td[1]")); assertEquals("Java Runtime Name", selenium.getText("//table[@id='vmTable']/tbody/tr[2]/td[1]")); assertEquals("Java Version", selenium.getText("//table[@id='vmTable']/tbody/tr[3]/td[1]")); assertEquals("Java Vendor", selenium.getText("//table[@id='vmTable']/tbody/tr[4]/td[1]")); assertEquals("Java VM Version", selenium.getText("//table[@id='vmTable']/tbody/tr[5]/td[1]")); assertEquals( "© 2008 - 2009 WSO2 Inc. All Rights Reserved.", selenium.getText("//div[@id='footer-div']/div/div")); // Verifying the Home link of the left menu assertEquals("Home", selenium.getText("link=Home")); assertTrue(selenium.isElementPresent("link=Home")); selenium.click("link=Home"); selenium.waitForPageToLoad("30000"); assertEquals("WSO2 ESB Home", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure link of the left menu assertEquals("Configure", selenium.getText("//div[@id='menu']/ul/li[2]")); // Verifying the Configure > User Management link of the left menu assertEquals("User Management", selenium.getText("link=User Management")); selenium.click("link=User Management"); selenium.waitForPageToLoad("30000"); assertEquals( "> User Management", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("User Management", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure > Key Stores link of the left menu assertEquals("Key Stores", selenium.getText("link=Key Stores")); selenium.click("link=Key Stores"); selenium.waitForPageToLoad("30000"); assertEquals( "> Key Stores", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Key store Management", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure > Logging link of the left menu assertEquals("Logging", selenium.getText("link=Logging")); selenium.click("link=Logging"); selenium.waitForPageToLoad("30000"); assertEquals("Home", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[1]/a")); assertEquals("Logging Configuration", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure > Data sources link of the left menu assertEquals("Data Sources", selenium.getText("link=Data Sources")); selenium.click("link=Data Sources"); selenium.waitForPageToLoad("30000"); assertEquals( "> Configure", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Data Sources", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure > Event Stores link of the left menu assertEquals("Event Sources", selenium.getText("link=Event Sources")); selenium.click("link=Event Sources"); selenium.waitForPageToLoad("30000"); assertEquals( "> Configure", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Event Sources", selenium.getText("eventsources")); // Verifying the Configure > Scheduled Tasks link of the left menu assertEquals("Scheduled Tasks", selenium.getText("link=Scheduled Tasks")); selenium.click("link=Scheduled Tasks"); selenium.waitForPageToLoad("30000"); assertEquals( "> Configure", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Scheduled Tasks", selenium.getText("//div[@id='middle']/h2")); // Verifying the Configure > Synapse link of the left menu assertEquals("Synapse", selenium.getText("link=Synapse")); selenium.click("link=Synapse"); selenium.waitForPageToLoad("30000"); assertEquals( "> Configure", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Manage Synapse Configuration", selenium.getText("//div[@id='middle']/h2")); assertTrue(selenium.isTextPresent("Manage")); // Verifying the Manage > Service link of the left menu assertEquals("Service", selenium.getText("//div[@id='menu']/ul/li[5]/ul/li[1]")); assertEquals("List", selenium.getText("link=List")); selenium.click("link=List"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Deployed Services", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Service > Add link of the left menu assertEquals("Add", selenium.getText("//div[@id='menu']/ul/li[5]/ul/li[2]/ul/li[2]")); // Verifying the Manage > Proxy Service link of the left menu assertEquals("Proxy Service", selenium.getText("link=Proxy Service")); selenium.click("link=Proxy Service"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Add Proxy Service", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Mediation link of the left menu assertEquals("Mediation", selenium.getText("//div[@id='menu']/ul/li[5]/ul/li[3]")); // Verifying the Manage > Mediation > Sequences link of the left menu assertEquals("Sequences", selenium.getText("link=Sequences")); selenium.click("link=Sequences"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Mediation Sequences", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Mediation > Endpoints link of the left menu assertEquals("Endpoints", selenium.getText("link=Endpoints")); selenium.click("link=Endpoints"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Manage Endpoints", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Mediation > Local Entries link of the left menu assertEquals("Local Entries", selenium.getText("link=Local Entries")); selenium.click("link=Local Entries"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Manage Local Registry Entries", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Modules link of the left menu assertEquals("Modules", selenium.getText("//div[@id='menu']/ul/li[5]/ul/li[5]")); assertEquals("List", selenium.getText("//div[@id='menu']/ul/li[5]/ul/li[6]/ul/li[1]/a")); selenium.click("//div[@id='menu']/ul/li[5]/ul/li[6]/ul/li[1]/a"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Deployed Modules", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Module > Add link of the left menu assertEquals("Add", selenium.getText("link=Add")); selenium.click("link=Add"); selenium.waitForPageToLoad("30000"); assertEquals("> Modules", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Add a module", selenium.getText("//div[@id='middle']/h2")); // Verifying the Manage > Transports link of the left menu assertEquals("Transports", selenium.getText("link=Transports")); selenium.click("link=Transports"); selenium.waitForPageToLoad("30000"); assertEquals("> Manage", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Transport Management", selenium.getText("listTransport")); // Verifying the Manage > Shutdown/Restart link of the left menu assertEquals("Shutdown/Restart", selenium.getText("link=Shutdown/Restart")); selenium.click("link=Shutdown/Restart"); selenium.waitForPageToLoad("30000"); assertEquals( "> Shutdown/Restart", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Shutdown/Restart Server", selenium.getText("//div[@id='middle']/h2")); // Verifying the Registry > Resources link of the left menu assertEquals("Registry", selenium.getText("//tr[3]/td/div/ul/li[1]")); assertEquals("Resources", selenium.getText("link=Resources")); selenium.click("link=Resources"); Thread.sleep(20000); assertEquals( "> Registry", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); // Verifying the Registry > Search link of the left menu assertEquals("Resources", selenium.getText("//div[@id='middle']/h2")); assertEquals("Search", selenium.getText("link=Search")); selenium.click("link=Search"); selenium.waitForPageToLoad("30000"); assertEquals( "> Registry", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); // Verifying the Search link of the left menu assertEquals("Search", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor link of the left menu assertEquals("Monitor", selenium.getText("//tr[4]/td/div/ul/li[1]")); // Verifying the Monitor > System Statistics link of the left menu assertEquals("System Statistics", selenium.getText("link=System Statistics")); selenium.click("link=System Statistics"); selenium.waitForPageToLoad("30000"); assertEquals( "> System Statistics", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("System Statistics", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > Mediation Statistics link of the left menu assertEquals("Mediation Statistics", selenium.getText("link=Mediation Statistics")); selenium.click("link=Mediation Statistics"); selenium.waitForPageToLoad("30000"); assertEquals( "> Mediation Statistics", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Mediation Statistics", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > System Logs link of the left menu assertEquals("System Logs", selenium.getText("link=System Logs")); selenium.click("link=System Logs"); selenium.waitForPageToLoad("30000"); // Verifying the Monitor > Monitor link of the left menu assertEquals("> Monitor", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); // Verifying the Monitor > System Logs link of the left menu assertEquals("System Logs", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > SOAP Tracer link of the left menu assertEquals("SOAP Tracer", selenium.getText("link=SOAP Tracer")); selenium.click("link=SOAP Tracer"); selenium.waitForPageToLoad("30000"); assertEquals("> Monitor", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); // Verifying the Monitor > SOAP Message Tracer link of the left menu assertEquals("SOAP Message Tracer", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > Mediation Tracer link of the left menu assertEquals("Mediation Tracer", selenium.getText("link=Mediation Tracer")); selenium.click("link=Mediation Tracer"); selenium.waitForPageToLoad("30000"); assertEquals("> Monitor", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[2]")); assertEquals("Mediation Message Tracer", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > Message Flows link of the left menu assertEquals("Message Flows", selenium.getText("link=Message Flows")); selenium.click("link=Message Flows"); selenium.waitForPageToLoad("30000"); assertEquals( "> Message Flows", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Message Flows (Graphical View)", selenium.getText("//div[@id='middle']/h2")); // Verifying the Monitor > Tools link of the left menu assertEquals("Tools", selenium.getText("//tr[5]/td/div/ul/li[1]")); // Verifying the Monitor > Try It link of the left menu assertEquals("Try It", selenium.getText("link=Try It")); selenium.click("link=Try It"); selenium.waitForPageToLoad("30000"); assertEquals("> Try It", selenium.getText("//div[@id='breadcrumb-div']/table/tbody/tr/td[3]")); assertEquals("Try It", selenium.getText("//div[@id='middle']/h2")); // Signing out seleniumTestBase.logOutUI(); }