use of org.xwiki.administration.test.po.AdministrationPage in project xwiki-platform by xwiki.
the class NotificationsIT method setUpEmails.
@Before
public void setUpEmails() throws Exception {
if (this.mail != null) {
// Already done
return;
}
getUtil().login(SUPERADMIN_USER_NAME, SUPERADMIN_PASSWORD);
AdministrationPage wikiAdministrationPage = AdministrationPage.gotoPage();
wikiAdministrationPage.clickSection("Mail", "Mail Sending");
SendMailAdministrationSectionPage sendMailPage = new SendMailAdministrationSectionPage();
sendMailPage.setHost("localhost");
sendMailPage.setPort(String.valueOf(ServerSetupTest.SMTP.getPort()));
sendMailPage.setEmailAddressToSendFrom("test@xwiki.org");
// Make sure we don't wait between email sending in order to speed up the test (and not incur timeouts when
// we wait to receive the mails)
sendMailPage.setSendWaitTime("0");
sendMailPage.clickSave();
this.mail = new GreenMail(ServerSetupTest.SMTP);
this.mail.start();
}
use of org.xwiki.administration.test.po.AdministrationPage in project xwiki-platform by xwiki.
the class ExtensionIT method testDependencies.
/**
* Tests how extension dependencies are displayed (both direct and backward dependencies).
*/
@Test
public void testDependencies() throws Exception {
// Setup the extension and its dependencies.
ExtensionId dependencyId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
TestExtension dependency = getRepositoryTestUtils().getTestExtension(dependencyId, "xar");
dependency.setName("Bob Wiki Macro");
dependency.setSummary("Required by Alice");
getRepositoryTestUtils().addExtension(dependency);
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
extension.addDependency(new DefaultExtensionDependency(dependencyId.getId(), new DefaultVersionConstraint(dependencyId.getVersion().getValue())));
extension.addDependency(new DefaultExtensionDependency("missing-dependency", new DefaultVersionConstraint("135")));
extension.addDependency(new DefaultExtensionDependency("org.xwiki.platform:xwiki-platform-sheet-api", new DefaultVersionConstraint("[3.2,)")));
extension.addDependency(new DefaultExtensionDependency("org.xwiki.commons:xwiki-commons-diff-api", new DefaultVersionConstraint("2.7")));
extension.addDependency(new DefaultExtensionDependency("org.xwiki.platform:xwiki-platform-display-api", new DefaultVersionConstraint("100.1")));
getRepositoryTestUtils().addExtension(extension);
// Search the extension and assert the list of dependencies.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
ExtensionDependenciesPane dependenciesPane = extensionPane.openDependenciesSection();
List<DependencyPane> directDependencies = dependenciesPane.getDirectDependencies();
assertEquals(5, directDependencies.size());
assertEquals(dependency.getName(), directDependencies.get(0).getName());
assertEquals(dependencyId.getVersion().getValue(), directDependencies.get(0).getVersion());
assertEquals("remote", directDependencies.get(0).getStatus());
assertNull(directDependencies.get(0).getStatusMessage());
assertNull(directDependencies.get(1).getLink());
assertEquals("missing-dependency", directDependencies.get(1).getName());
assertEquals("135", directDependencies.get(1).getVersion());
assertEquals("unknown", directDependencies.get(1).getStatus());
assertNull(directDependencies.get(1).getStatusMessage());
assertNotNull(directDependencies.get(2).getLink());
assertEquals("XWiki Platform - Sheet - API", directDependencies.get(2).getName());
assertEquals("[3.2,)", directDependencies.get(2).getVersion());
assertEquals("core", directDependencies.get(2).getStatus());
assertEquals("Provided", directDependencies.get(2).getStatusMessage());
assertNotNull(directDependencies.get(3).getLink());
assertEquals("XWiki Commons - Diff API", directDependencies.get(3).getName());
assertEquals("2.7", directDependencies.get(3).getVersion());
assertEquals("remote-core", directDependencies.get(3).getStatus());
assertTrue(directDependencies.get(3).getStatusMessage().matches("Version [^\\s]+ is provided"));
assertEquals("XWiki Platform - Display API", directDependencies.get(4).getName());
assertEquals("100.1", directDependencies.get(4).getVersion());
assertEquals("remote-core-incompatible", directDependencies.get(4).getStatus());
assertTrue(directDependencies.get(4).getStatusMessage().matches("Incompatible with provided version [^\\s]+"));
assertTrue(dependenciesPane.getBackwardDependencies().isEmpty());
// Follow the link to a dependency.
directDependencies.get(0).getLink().click();
adminPage = new ExtensionAdministrationPage();
extensionPane = adminPage.getSearchResults().getExtension(0);
assertEquals(dependency.getName(), extensionPane.getName());
assertEquals(dependencyId.getVersion().getValue(), extensionPane.getVersion());
assertEquals(dependency.getSummary(), extensionPane.getSummary());
// Check that we are still in the administration.
assertTrue(new AdministrationPage().hasSection("XWiki.Extensions"));
}
use of org.xwiki.administration.test.po.AdministrationPage in project xwiki-platform by xwiki.
the class OfficeImporterTest method setUp.
@Before
public void setUp() {
// Connect the wiki to the office server if it is not already done
AdministrationPage administrationPage = AdministrationPage.gotoPage();
administrationPage.clickSection("Content", "Office Server");
OfficeServerAdministrationSectionPage officeServerAdministrationSectionPage = new OfficeServerAdministrationSectionPage();
if (!"Connected".equals(officeServerAdministrationSectionPage.getServerState())) {
officeServerAdministrationSectionPage.startServer();
assertEquals("Connected", officeServerAdministrationSectionPage.getServerState());
}
}
use of org.xwiki.administration.test.po.AdministrationPage in project xwiki-platform by xwiki.
the class PanelWizardTest method verifyPanelWizardPresentInAdministration.
@Test
public void verifyPanelWizardPresentInAdministration() {
AdministrationPage administrationPage = AdministrationPage.gotoPage();
Assert.assertTrue(administrationPage.hasSection("Panels.PanelWizard"));
// Select space administration (XWiki space, since that space exists)
AdministrationPage spaceAdministrationPage = AdministrationPage.gotoSpaceAdministrationPage("XWiki");
// The Panel Wizard should be available in the space administration.
Assert.assertTrue(spaceAdministrationPage.hasSection("Panels.PanelWizard"));
}
use of org.xwiki.administration.test.po.AdministrationPage in project xwiki-platform by xwiki.
the class MailTest method testMail.
@Test
public void testMail() throws Exception {
// Step 0: Delete all pre-existing mails to start clean. This also verifies the deleteAll() script service
// API.
String content = "{{velocity}}$services.mailstorage.deleteAll(){{/velocity}}";
ViewPage deleteAllPage = getUtil().createPage(getTestClassName(), "DeleteAll", content, "");
// Verify that the page doesn't display any content (unless there's an error!)
assertEquals("", deleteAllPage.getContent());
// Step 1: Verify that there are 2 email sections in the Mail category
AdministrationPage wikiAdministrationPage = AdministrationPage.gotoPage();
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Mail Sending"));
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Mail Sending Status"));
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Advanced"));
// Verify we can click on Mail > Advanced
wikiAdministrationPage.clickSection("Mail", "Advanced");
// Step 2: Before validating that we can send email, let's verify that we can report errors when the mail
// setup is not correct
// Make sure there's an invalid mail server set.
wikiAdministrationPage.clickSection("Mail", "Mail Sending");
SendMailAdministrationSectionPage sendMailPage = new SendMailAdministrationSectionPage();
sendMailPage.setHost("invalidmailserver");
sendMailPage.clickSave();
// Send the mail that's supposed to fail and validate that it fails
sendMailWithInvalidMailSetup();
// Step 3: Navigate to each mail section and set the mail sending parameters (SMTP host/port)
wikiAdministrationPage = AdministrationPage.gotoPage();
wikiAdministrationPage.clickSection("Mail", "Mail Sending");
sendMailPage = new SendMailAdministrationSectionPage();
sendMailPage.setHost("localhost");
sendMailPage.setPort("3025");
// Make sure we don't wait between email sending in order to speed up the test (and not incur timeouts when
// we wait to receive the mails)
sendMailPage.setSendWaitTime("0");
// Keep all mail statuses including successful ones (so that we verify this works fine)
sendMailPage.setDiscardSuccessStatuses(false);
sendMailPage.clickSave();
// Step 3: Verify that there are no admin email sections when administering a space
// Select XWiki space administration.
AdministrationPage spaceAdministrationPage = AdministrationPage.gotoSpaceAdministrationPage("XWiki");
// 2018-01-31: Got a failure on CI showing that the first assert below this line was failing because the
// current page was still the one before move to the XWiki space admin. Thus taking extra step to ensure we
// wait. However I don't understand why this happens since getDriver().url() called by
// gotoSpaceAdministrationPage() should wait for the page to be loaded before returning.
getDriver().waitUntilCondition(driver -> spaceAdministrationPage.getMetaDataValue("reference").equals("xwiki:XWiki.WebPreferences"));
// All those sections should not be present
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Mail Sending"));
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Mail Sending Status"));
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Advanced"));
// Step 4: Prepare a Template Mail
getUtil().deletePage(getTestClassName(), "MailTemplate");
// Create a Wiki page containing a Mail Template (ie a XWiki.Mail object)
getUtil().createPage(getTestClassName(), "MailTemplate", "", "");
// Note: We use the following bindings in the Template subject and content so that we ensure that they are
// provided by default:
// - "$xwiki"
// - "$xcontext"
// - "$escapetool"
// - "$services"
// - "$request"
// Note: We also use the $name and $doc bindings to show that the user can add new bindings ($doc is not bound
// by default since there isn't always a notion of current doc in all places where mail sending is done).
// Note: We use $xwiki.getURL() in the content to verify that we generate full external URLs.
String velocityContent = "Hello $name from $escapetool.xml($services.model.resolveDocument(" + "$xcontext.getUser()).getName()) - Served from $request.getRequestURL().toString() - " + "url: $xwiki.getURL('Main.WebHome')";
getUtil().addObject(getTestClassName(), "MailTemplate", "XWiki.Mail", "subject", "#if ($xwiki.exists($doc.documentReference))Status for $name on $doc.fullName#{else}wrong#end", "language", "en", "html", "<strong>" + velocityContent + "</strong>", "text", velocityContent);
// We also add an attachment to the Mail Template page to verify that it is sent in the mail
ByteArrayInputStream bais = new ByteArrayInputStream("Content of attachment".getBytes());
getUtil().attachFile(getTestClassName(), "MailTemplate", "something.txt", bais, true, new UsernamePasswordCredentials("superadmin", "pass"));
// Step 5: Send a template email (with an attachment) to a single email address
sendTemplateMailToEmail();
// Step 6: Send a template email to all the users in the XWikiAllGroup Group (we'll create 2 users) + to
// two other users (however since they're part of the group they'll receive only one mail each, we thus test
// deduplicatio!).
sendTemplateMailToUsersAndGroup();
// Step 7: Navigate to the Mail Sending Status Admin page and assert that the Livetable displays the entry for
// the sent mails
wikiAdministrationPage = AdministrationPage.gotoPage();
wikiAdministrationPage.clickSection("Mail", "Mail Sending Status");
MailStatusAdministrationSectionPage statusPage = new MailStatusAdministrationSectionPage();
LiveTableElement liveTableElement = statusPage.getLiveTable();
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-3", "Test");
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-5", "send_success");
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-6", "xwiki");
// Let's wait till we have at least 3 rows. Note that we wait because we could have received the mails above
// but the last mail's status in the database may not have been updated yet. Note that The first 2 are
// guaranteed to have been updated since we send mail in one thread one after another and we update the
// database after sending each mail.
liveTableElement.waitUntilRowCountGreaterThan(3);
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-4", "john@doe.com");
assertTrue(liveTableElement.getRowCount() > 0);
assertTrue(liveTableElement.hasRow("Error", ""));
}
Aggregations