diff --git a/src/main/java/org/olat/restapi/support/MultipartReader.java b/src/main/java/org/olat/restapi/support/MultipartReader.java index 6a8c0284c61cb1f63cd7f8e1f1fe968562566da2..56b90bf9938d5bff5fecc488fddf609763275560 100644 --- a/src/main/java/org/olat/restapi/support/MultipartReader.java +++ b/src/main/java/org/olat/restapi/support/MultipartReader.java @@ -84,6 +84,7 @@ public class MultipartReader { } catch (Exception e) { log.error("", e); } + System.out.println("************* " + file.length()); } } } catch (Exception e) { diff --git a/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java b/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java index fe343d56926918344d911ae2d66f6600b4d0048b..783decf235e2a200519749c9793a6782701d0c35 100644 --- a/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java +++ b/src/test/java/org/olat/portfolio/FunctionalArtefactTest.java @@ -59,12 +59,18 @@ public class FunctionalArtefactTest { public final static String FORUM_POST_TITLE = "question about multiplexing"; public final static String FORUM_POST_MESSAGE = "What multiplexing exists in operating systems?"; + public final static String FORUM_ARTEFACT_TITLE = "multiplexing forum post"; + public final static String FORUM_ARTEFACT_DESCRIPTION = "Thread about multiplexing."; + public final static String FORUM_TAGS = "networking multiplexing operating systems virtual machine forum post"; public final static String FORUM_BINDER = BINDER_PROGRAMMING_THEORIE; public final static String FORUM_PAGE = "operating systems"; public final static String FORUM_STRUCTURE = "issue 1"; public final static String WIKI_ARTICLE_PAGENAME = "Multiplexing"; public final static String WIKI_ARTICLE_CONTENT = "==Time Multiplexing==\nscheduling a serially-reusable resource among several users\n\n==Space multiplexing==\ndividing a multiple-use resource up among several users"; + public final static String WIKI_ARTEFACT_TITLE = "multiplexing wiki"; + public final static String WIKI_ARTEFACT_DESCRIPTION = "wiki page about multiplexing"; + public final static String WIKI_TAGS = "networking multiplexing operating systems virtual machine wiki"; public final static String WIKI_BINDER = BINDER_PROGRAMMING_THEORIE; public final static String WIKI_PAGE = "operating systems"; public final static String WIKI_STRUCTURE = "issue 2"; @@ -74,6 +80,9 @@ public class FunctionalArtefactTest { public final static String BLOG_POST_TITLE = "Multiplexing articles"; public final static String BLOG_POST_DESCRIPTION = "Where you may find useful information about multiplexing."; public final static String BLOG_POST_CONTENT = "Operating Systems: Design & Implementation (by Andrew S. Tanenbaum)"; + public final static String BLOG_ARTEFACT_TITLE = "blog"; + public final static String BLOG_ARTEFACT_DESCRIPTION = "my personal blog"; + public final static String BLOG_TAGS = "john smith blog"; public final static String BLOG_BINDER = BINDER_PROGRAMMING_THEORIE; public final static String BLOG_PAGE = "operating systems"; public final static String BLOG_STRUCTURE = "issue 3"; @@ -152,7 +161,9 @@ public class FunctionalArtefactTest { Assert.assertTrue(functionalCourseUtil.postForumMessage(browser, course.getRepoEntryKey(), 0, FORUM_POST_TITLE, FORUM_POST_MESSAGE)); /* add artefact */ - Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, FORUM_BINDER, FORUM_PAGE, FORUM_STRUCTURE)); + Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, FORUM_BINDER, FORUM_PAGE, FORUM_STRUCTURE, + FORUM_ARTEFACT_TITLE, FORUM_ARTEFACT_DESCRIPTION, FORUM_TAGS, + functionalEportfolioUtil)); } @Test @@ -168,7 +179,9 @@ public class FunctionalArtefactTest { Assert.assertTrue(functionalCourseUtil.createWikiArticle(browser, vo.getKey(), WIKI_ARTICLE_PAGENAME, WIKI_ARTICLE_CONTENT)); /* add artefact */ - Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, WIKI_BINDER, WIKI_PAGE, WIKI_STRUCTURE)); + Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, WIKI_BINDER, WIKI_PAGE, WIKI_STRUCTURE, + WIKI_ARTEFACT_TITLE, WIKI_ARTEFACT_DESCRIPTION, WIKI_TAGS, + functionalEportfolioUtil)); } @Test @@ -184,7 +197,9 @@ public class FunctionalArtefactTest { Assert.assertTrue(functionalCourseUtil.createBlogEntry(browser, repoKey, BLOG_POST_TITLE, BLOG_POST_DESCRIPTION, BLOG_POST_CONTENT)); /* add artefact */ - Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, BLOG_BINDER, BLOG_PAGE, BLOG_STRUCTURE)); + Assert.assertTrue(functionalCourseUtil.addToEportfolio(browser, BLOG_BINDER, BLOG_PAGE, BLOG_STRUCTURE, + BLOG_ARTEFACT_TITLE, BLOG_ARTEFACT_DESCRIPTION, BLOG_TAGS, + functionalEportfolioUtil)); } @Test diff --git a/src/test/java/org/olat/util/FunctionalCourseUtil.java b/src/test/java/org/olat/util/FunctionalCourseUtil.java index cfe1b80937401044af73ce584f944096963de9e7..4dedf7b1b4ebb0980f2981029b45d9d04e1c7069 100644 --- a/src/test/java/org/olat/util/FunctionalCourseUtil.java +++ b/src/test/java/org/olat/util/FunctionalCourseUtil.java @@ -141,7 +141,13 @@ public class FunctionalCourseUtil { * button. */ public boolean addToEportfolio(Selenium browser, String binder, String page, String structure, + String title, String description, String tags, FunctionalEPortfolioUtil functionalEPortfolioUtil){ + /* create binder, page or structure if necessary */ + if(!functionalEPortfolioUtil.createElements(browser, binder, page, structure)) + return(false); + + /* open wizard */ StringBuffer selectorBuffer = new StringBuffer(); selectorBuffer.append("xpath=//a[contains(@class, '") @@ -151,7 +157,17 @@ public class FunctionalCourseUtil { browser.click(selectorBuffer.toString()); if(binder != null){ - //TODO:JK: implement me + /* fill in wizard - title & description */ + functionalEPortfolioUtil.fillInTitleAndDescription(browser, title, description); + + /* fill in wizard - tags */ + functionalEPortfolioUtil.fillInTags(browser, tags); + + /* fill in wizard - destination */ + browser.click(functionalEPortfolioUtil.createSelector(binder, page, structure)); + + /* click finish */ + functionalUtil.clickWizardFinish(browser); } return(true); diff --git a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java index 5d99d9935c7490bc6f77cfe8fcc160e2e44993fa..7123f1f210ca67e5eef63b53f01de1c2cf64f3a9 100644 --- a/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java +++ b/src/test/java/org/olat/util/FunctionalEPortfolioUtil.java @@ -31,7 +31,7 @@ import com.thoughtworks.selenium.Selenium; * * @author jkraehemann, joel.kraehemann@frentix.com, frentix.com */ -public class FunctionalEportfolioUtil { +public class FunctionalEPortfolioUtil { public final static String EPORTFOLIO_CSS = "b_eportfolio"; public final static String EPORTFOLIO_MAP_CSS = "b_eportfolio_map"; @@ -79,7 +79,7 @@ public class FunctionalEportfolioUtil { private FunctionalUtil functionalUtil; private FunctionalHomeSiteUtil functionalHomeSiteUtil; - public FunctionalEportfolioUtil(FunctionalUtil functionalUtil, FunctionalHomeSiteUtil functionalHomeSiteUtil){ + public FunctionalEPortfolioUtil(FunctionalUtil functionalUtil, FunctionalHomeSiteUtil functionalHomeSiteUtil){ this.functionalUtil = functionalUtil; this.functionalHomeSiteUtil = functionalHomeSiteUtil; @@ -373,6 +373,9 @@ public class FunctionalEportfolioUtil { * Checks if structural element exists. */ public boolean structureExists(Selenium browser, String binder, String page, String title){ + if(!openBinder(browser, binder)) + return(false); + StringBuffer selectorBuffer = new StringBuffer(); //TODO:JK: implement me @@ -460,7 +463,7 @@ public class FunctionalEportfolioUtil { * * Fills in the open wizard's title and description fields. */ - private boolean fillInTitleAndDescription(Selenium browser, String title, String description){ + protected boolean fillInTitleAndDescription(Selenium browser, String title, String description){ StringBuffer locatorBuffer = new StringBuffer(); locatorBuffer.append("xpath=//form//div[contains(@class, '") @@ -483,7 +486,7 @@ public class FunctionalEportfolioUtil { * * Fills in the open wizard's tags. */ - private boolean fillInTags(Selenium browser, String tags){ + protected boolean fillInTags(Selenium browser, String tags){ StringBuffer locatorBuffer = new StringBuffer(); locatorBuffer.append("xpath=//form//div[contains(@class, '") @@ -509,9 +512,11 @@ public class FunctionalEportfolioUtil { */ public boolean addTextArtefact(Selenium browser, String binder, String page, String structure, String content, String title, String description, String tags){ + /* create binder, page or structure if necessary */ + if(!createElements(browser, binder, page, structure)) + return(false); - - /* add text artefact */ + /* navigate to the right place */ if(!functionalUtil.openSite(browser, OlatSite.HOME)) return(false); @@ -542,10 +547,7 @@ public class FunctionalEportfolioUtil { /* fill in wizard - tags */ fillInTags(browser, tags); - /* fill in wizard - select destination and create it if doesn't exist */ - if(!createElements(browser, binder, page, structure)) - return(false); - + /* fill in wizard - select destination */ browser.click(createSelector(binder, page, structure)); /* click finish */ diff --git a/src/test/java/org/olat/util/FunctionalEportfolioUtil.java b/src/test/java/org/olat/util/FunctionalEportfolioUtil.java deleted file mode 100644 index 553b8c8d1314f44c1f5dc7b9432838ebea523e66..0000000000000000000000000000000000000000 --- a/src/test/java/org/olat/util/FunctionalEportfolioUtil.java +++ /dev/null @@ -1,447 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.util; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URI; - -import org.olat.util.FunctionalHomeSiteUtil.EPortfolioAction; -import org.olat.util.FunctionalHomeSiteUtil.HomeSiteAction; -import org.olat.util.FunctionalUtil.OlatSite; - -import com.thoughtworks.selenium.Selenium; - -/** - * - * @author jkraehemann, joel.kraehemann@frentix.com, frentix.com - */ -public class FunctionalEportfolioUtil { - - public final static String HOME_PORTAL_EDIT_LINK_CSS = "o_sel_add_artfeact"; - public final static String ADD_TEXT_ARTEFACT_CSS = "o_sel_add_text_artfeact"; - public final static String UPLOAD_FILE_ARTEFACT_CSS = "o_sel_add_upload_artfeact"; - public final static String CREATE_LEARNING_JOURNAL_CSS = "o_sel_add_liveblog_artfeact"; - - public final static String CREATE_FOLDER_CSS = "b_ep_add_artefact"; - - private String homePortalEditLinkCss; - private String addTextArtefactCss; - private String uploadFileArtefactCss; - private String createLearningJournalCss; - - private String createFolderCss; - - private FunctionalUtil functionalUtil; - private FunctionalHomeSiteUtil functionalHomeSiteUtil; - - public FunctionalEportfolioUtil(FunctionalUtil functionalUtil, FunctionalHomeSiteUtil functionalHomeSiteUtil){ - this.functionalUtil = functionalUtil; - this.functionalHomeSiteUtil = functionalHomeSiteUtil; - - setHomePortalEditLinkCss(HOME_PORTAL_EDIT_LINK_CSS); - setAddTextArtefactCss(ADD_TEXT_ARTEFACT_CSS); - setUploadFileArtefactCss(UPLOAD_FILE_ARTEFACT_CSS); - setCreateLearningJournalCss(CREATE_LEARNING_JOURNAL_CSS); - - setCreateFolderCss(CREATE_FOLDER_CSS); - } - - /** - * @param binderPath - * @return - * - * Creates an xpath expression of a slash separated path to - * select a tree item. - */ - public String createSelectorOfBinderPath(String binderPath){ - if(binderPath == null) - return(null); - - if(!binderPath.startsWith("/")){ - binderPath = "/" + binderPath; - } - - StringBuffer selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath="); - - int prevSeparator = 0; - int currentSeparator = -1; - - while(prevSeparator != binderPath.length() && (currentSeparator = binderPath.indexOf('/', prevSeparator + 1)) != -1){ - selectorBuffer.append("//ul//li//a//span[text()=") - .append(binderPath.substring(prevSeparator + 1, currentSeparator)) - .append("]"); - - - prevSeparator = currentSeparator; - } - - if(prevSeparator > 0){ - selectorBuffer.append("/.."); - - return(selectorBuffer.toString()); - }else{ - return(null); - } - } - - /** - * @param browser - * @param binderPath - * @return the xpath selector - * - * Create a binder of given path. - */ - public String createBinderPath(Selenium browser, String binderPath){ - if(binderPath == null) - return(null); - - if(!binderPath.startsWith("/")){ - binderPath = "/" + binderPath; - } - - StringBuffer selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath="); - - int prevSeparator = 0; - int currentSeparator = -1; - - while(prevSeparator != binderPath.length() && (currentSeparator = binderPath.indexOf('/', prevSeparator + 1)) != -1){ - String current = binderPath.substring(prevSeparator + 1, currentSeparator); - - selectorBuffer.append("//ul//li//a//span[text()=") - .append(current) - .append("]"); - - - - - - - prevSeparator = currentSeparator; - } - - if(prevSeparator > 0){ - selectorBuffer.append("/.."); - - return(selectorBuffer.toString()); - }else{ - return(null); - } - } - - /** - * @param browser - * @return - * - * Clicks the edit link. - */ - private boolean openEditLink(Selenium browser){ - StringBuffer selectorBuffer = new StringBuffer(); - - selectorBuffer.append("xpath=//a[contains(@class, '") - .append(getHomePortalEditLinkCss()) - .append("')]"); - - browser.click(selectorBuffer.toString()); - - browser.waitForPageToLoad(functionalUtil.getWaitLimit()); - - return(true); - } - - /** - * @param browser - * @param title - * @param description - * @return true on success - * - * Fills in the open wizard's title and description fields. - */ - private boolean fillInTitleAndDescription(Selenium browser, String title, String description){ - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//form//div[contains(@class, '") - .append(functionalUtil.getWizardCss()) - .append("')]//input[@type='text']"); - - browser.type(locatorBuffer.toString(), title); - - functionalUtil.typeMCE(browser, description); - - functionalUtil.clickWizardNext(browser); - - return(true); - } - - /** - * @param browser - * @param tags - * @return - * - * Fills in the open wizard's tags. - */ - private boolean fillInTags(Selenium browser, String tags){ - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//form//div[contains(@class, '") - .append(functionalUtil.getWizardCss()) - .append("')]//input[@type='text']"); - - browser.type(locatorBuffer.toString(), tags); - - functionalUtil.clickWizardNext(browser); - - return(true); - } - - /** - * @param browser - * @param content - * @param title - * @param description - * @param tags - * @param binderPath - * @return - * - * Add a text artefact to a e-portfolio. - */ - public boolean addTextArtefact(Selenium browser, String content, String title, String description, String tags, String binderPath){ - if(!functionalUtil.openSite(browser, OlatSite.HOME)) - return(false); - - if(!functionalHomeSiteUtil.openActionByMenuTree(browser, EPortfolioAction.MY_ARTIFACTS)) - return(false); - - /* open wizard */ - openEditLink(browser); - - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//a[contains(@class, '") - .append(getAddTextArtefactCss()) - .append("')]"); - - browser.click(locatorBuffer.toString()); - - /* fill in wizard - content */ - functionalUtil.typeMCE(browser, description); - - functionalUtil.clickWizardNext(browser); - - /* fill in wizard - title & description */ - fillInTitleAndDescription(browser, title, description); - - /* fill in wizard - tags */ - fillInTags(browser, tags); - - /* fill in wizard - select binder path */ - browser.click(createSelectorOfBinderPath(binderPath)); - - /* click finish */ - functionalUtil.clickWizardFinish(browser); - - return(true); - } - - /** - * @param browser - * @param file - * @param title - * @param description - * @param tags - * @param binderPath - * @return - * @throws MalformedURLException - * - * Upload a file artefact to a e-portfolio. - */ - public boolean uploadFileArtefact(Selenium browser, URI file, String title, String description, String tags, String binderPath) throws MalformedURLException{ - if(!functionalUtil.openSite(browser, OlatSite.HOME)) - return(false); - - if(!functionalHomeSiteUtil.openActionByMenuTree(browser, EPortfolioAction.MY_ARTIFACTS)) - return(false); - - /* open wizard */ - openEditLink(browser); - - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//a[contains(@class, '") - .append(getUploadFileArtefactCss()) - .append("')]"); - - browser.click(locatorBuffer.toString()); - - /* fill in wizard - file */ - locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//form//div[contains(@class, '") - .append(functionalUtil.getWizardCss()) - .append("')]//input[@type='file']"); - - browser.attachFile(locatorBuffer.toString(), file.toURL().toString()); - - functionalUtil.clickWizardNext(browser); - - /* fill in wizard - title & description */ - fillInTitleAndDescription(browser, title, description); - - /* fill in wizard - tags */ - fillInTags(browser, tags); - - /* fill in wizard - select binder path */ - browser.click(createSelectorOfBinderPath(binderPath)); - - /* click finish */ - functionalUtil.clickWizardFinish(browser); - - return(true); - } - - /** - * @param browser - * @param title - * @param description - * @param tags - * @param binderPath - * @return - * - * Create a learnig journal for a e-portfolio. - */ - public boolean createLearningJournal(Selenium browser, String title, String description, String tags, String binderPath){ - return(createLearningJournal(browser, title, description, tags, binderPath, true)); - } - - /** - * @param browser - * @param title - * @param description - * @param tags - * @param binderPath - * @param create - * @return - * - * Create a learnig journal for a e-portfolio. - */ - public boolean createLearningJournal(Selenium browser, String title, String description, String tags, String binderPath, boolean create){ - if(!functionalUtil.openSite(browser, OlatSite.HOME)) - return(false); - - if(!functionalHomeSiteUtil.openActionByMenuTree(browser, EPortfolioAction.MY_ARTIFACTS)) - return(false); - - /* open wizard */ - openEditLink(browser); - - StringBuffer locatorBuffer = new StringBuffer(); - - locatorBuffer.append("xpath=//a[contains(@class, '") - .append(getCreateLearningJournalCss()) - .append("')]"); - - browser.click(locatorBuffer.toString()); - - browser.waitForPageToLoad(functionalUtil.getWaitLimit()); - - /* fill in wizard - title & description */ - fillInTitleAndDescription(browser, title, description); - - /* fill in wizard - tags */ - fillInTags(browser, tags); - - /* fill in wizard - select binder path */ - String selector = createSelectorOfBinderPath(binderPath); - - if(selector == null){ - selector = createBinderPath(browser, binderPath); - - browser.click(selector); - }else{ - browser.click(selector); - } - - /* click finish */ - functionalUtil.clickWizardFinish(browser); - - return(true); - } - - public FunctionalUtil getFunctionalUtil() { - return functionalUtil; - } - - public void setFunctionalUtil(FunctionalUtil functionalUtil) { - this.functionalUtil = functionalUtil; - } - - public FunctionalHomeSiteUtil getFunctionalHomeSiteUtil() { - return functionalHomeSiteUtil; - } - - public void setFunctionalHomeSiteUtil( - FunctionalHomeSiteUtil functionalHomeSiteUtil) { - this.functionalHomeSiteUtil = functionalHomeSiteUtil; - } - - public String getHomePortalEditLinkCss() { - return homePortalEditLinkCss; - } - - public void setHomePortalEditLinkCss(String homePortalEditLinkCss) { - this.homePortalEditLinkCss = homePortalEditLinkCss; - } - - public String getAddTextArtefactCss() { - return addTextArtefactCss; - } - - public void setAddTextArtefactCss(String addTextArtefactCss) { - this.addTextArtefactCss = addTextArtefactCss; - } - - public String getUploadFileArtefactCss() { - return uploadFileArtefactCss; - } - - public void setUploadFileArtefactCss(String uploadFileArtefactCss) { - this.uploadFileArtefactCss = uploadFileArtefactCss; - } - - public String getCreateLearningJournalCss() { - return createLearningJournalCss; - } - - public void setCreateLearningJournalCss(String createLearningJournalCss) { - this.createLearningJournalCss = createLearningJournalCss; - } - - public String getCreateFolderCss() { - return createFolderCss; - } - - public void setCreateFolderCss(String createFolderCss) { - this.createFolderCss = createFolderCss; - } -} diff --git a/src/test/resources/arquillian.xml b/src/test/resources/arquillian.xml index 7d0a1aad8f37aaff4353f2b6970169f4209ce9bf..0b2b46fa170bb8b7eb1139535edc15f69f5df122 100644 --- a/src/test/resources/arquillian.xml +++ b/src/test/resources/arquillian.xml @@ -12,7 +12,7 @@ <configuration> <property name="workDir">target/arquillianDeployments</property> <property name="catalinaHome">target/arq-apache-tomcat-7.0.27</property> - <!-- <property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</property> --> + <property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</property> </configuration> </container>