CCM NG/ccm-cms: Fixed some tests
CCM NG/ccm-core: Vaadin prototype (UI) git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4678 8810af33-2d31-482b-a856-94f89814c4df
parent
991f7e85d8
commit
4d27baca2a
|
|
@ -30,6 +30,7 @@
|
|||
<!-- JAX-RS -->
|
||||
<!--<servlet>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
|
|
@ -63,11 +64,11 @@
|
|||
|
||||
<servlet-mapping>
|
||||
<servlet-name>vaadin-servlet</servlet-name>
|
||||
<url-pattern>/vaadin/</url-pattern>
|
||||
<url-pattern>/vaadin/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>vaadin-servlet</servlet-name>
|
||||
<url-pattern>/VAADIN/</url-pattern>
|
||||
<url-pattern>/VAADIN/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
||||
|
|
|
|||
|
|
@ -235,7 +235,9 @@ public class ContentItemManagerTest {
|
|||
})
|
||||
public void createContentItem() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final Article article = itemManager.createContentItem("new-article",
|
||||
|
|
@ -274,7 +276,9 @@ public class ContentItemManagerTest {
|
|||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemTypeNotInSection() {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
itemManager.createContentItem("Test", section, folder, Event.class);
|
||||
|
|
@ -294,7 +298,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemNameIsNull() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
itemManager.createContentItem(null, section, folder, Article.class);
|
||||
|
|
@ -315,7 +321,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemNameIsEmpty() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
itemManager.createContentItem(" ", section, folder, Article.class);
|
||||
|
|
@ -337,7 +345,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemFolderIsNull() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
itemManager.createContentItem("Test", section, null, Article.class);
|
||||
});
|
||||
|
|
@ -370,7 +380,9 @@ public class ContentItemManagerTest {
|
|||
})
|
||||
public void createContentItemWithWorkflow() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
|
|
@ -415,7 +427,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemTypeNotInSectionWithWorkflow() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
|
|
@ -444,7 +458,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemNameIsNullWithWorkflow() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
|
|
@ -473,7 +489,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemNameIsNullWorkflowIsNull() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Folder folder = section.getRootDocumentsFolder();
|
||||
|
||||
itemManager.createContentItem(null,
|
||||
|
|
@ -499,7 +517,9 @@ public class ContentItemManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void createItemFolderIsNullWithWorkflow() {
|
||||
shiro.getSystemUser().execute(() -> {
|
||||
final ContentSection section = sectionRepo.findByLabel("info");
|
||||
final ContentSection section = sectionRepo
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
|
||||
.findById(-110L).get();
|
||||
|
|
@ -573,7 +593,8 @@ public class ContentItemManagerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verifies that null null null null null null null null null null null null {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)
|
||||
* Verifies that null null null null null null null null null null null null
|
||||
* null null null null null null null null null {@link ContentItemManager#move(org.librecms.contentsection.ContentItem, org.librecms.contentsection.Folder)
|
||||
* throws an {@link IllegalArgumentException} if the type of the item to
|
||||
* copy has not been registered in content section to which the target
|
||||
* folder belongs.
|
||||
|
|
|
|||
|
|
@ -242,7 +242,9 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"object_id"})
|
||||
@InSequence(200)
|
||||
public void renameSection() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
manager.renameContentSection(section, "content");
|
||||
|
||||
|
|
@ -284,7 +286,9 @@ public class ContentSectionManagerTest {
|
|||
"grantee_id"})
|
||||
@InSequence(300)
|
||||
public void addRole() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
manager.addRoleToContentSection(section,
|
||||
"reviewer",
|
||||
|
|
@ -330,7 +334,9 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(302)
|
||||
public void addRoleNameIsNull() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
manager.addRoleToContentSection(section,
|
||||
null,
|
||||
|
|
@ -354,7 +360,9 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(302)
|
||||
public void addRoleNameIsEmpty() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
manager.addRoleToContentSection(section,
|
||||
" ",
|
||||
|
|
@ -375,7 +383,9 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"object_id"})
|
||||
@InSequence(350)
|
||||
public void removeRole() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
final Role role = roleRepository.findByName("info_publisher").get();
|
||||
|
||||
manager.removeRoleFromContentSection(section, role);
|
||||
|
|
@ -395,7 +405,9 @@ public class ContentSectionManagerTest {
|
|||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
@InSequence(351)
|
||||
public void removeRoleNull() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final ContentSection section = repository
|
||||
.findByLabel("info")
|
||||
.get();
|
||||
|
||||
manager.removeRoleFromContentSection(section, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.admin.ui;
|
||||
|
||||
import com.vaadin.cdi.CDIUI;
|
||||
import com.vaadin.cdi.CDIViewProvider;
|
||||
import com.vaadin.cdi.URLMapping;
|
||||
import com.vaadin.navigator.Navigator;
|
||||
import com.vaadin.server.VaadinRequest;
|
||||
import com.vaadin.ui.UI;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@URLMapping("vaadin")
|
||||
@CDIUI("admin")
|
||||
public class AdminUIVaadin extends UI {
|
||||
|
||||
private static final long serialVersionUID = -1352590567964037112L;
|
||||
|
||||
// private TabSheet tabSheet;
|
||||
|
||||
// @Inject
|
||||
// private UserRepository userRepo;
|
||||
|
||||
@Inject
|
||||
private CDIViewProvider viewProvider;
|
||||
|
||||
@Inject
|
||||
private Subject subject;
|
||||
|
||||
@Override
|
||||
protected void init(VaadinRequest request) {
|
||||
|
||||
final Navigator navigator = new Navigator(this, this);
|
||||
navigator.addProvider(viewProvider);
|
||||
|
||||
if (subject.isAuthenticated()) {
|
||||
navigator.navigateTo(AdminView.VIEWNAME);
|
||||
} else {
|
||||
navigator.navigateTo(LoginView.VIEWNAME);
|
||||
}
|
||||
|
||||
|
||||
// tabSheet = new TabSheet();
|
||||
//
|
||||
// final TabSheet userGroupsRoles = new TabSheet();
|
||||
// final Grid<User> usersTable = new Grid<>();
|
||||
// usersTable.setItems(userRepo.findAll());
|
||||
// usersTable.addColumn(User::getName).setCaption("User name");
|
||||
// usersTable.addColumn(User::getGivenName).setCaption("Given name");
|
||||
// usersTable.addColumn(User::getFamilyName).setCaption("Family name");
|
||||
// usersTable
|
||||
// .addColumn(user -> user.getPrimaryEmailAddress().getAddress())
|
||||
// .setCaption("E-Mail");
|
||||
// usersTable.addColumn(User::isBanned).setCaption("Banned?");
|
||||
// userGroupsRoles.addTab(usersTable, "Users");
|
||||
//
|
||||
// tabSheet.addTab(userGroupsRoles, "Users/Groups/Roles");
|
||||
// setContent(tabSheet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.admin.ui;
|
||||
|
||||
import com.vaadin.cdi.CDIView;
|
||||
import com.vaadin.navigator.View;
|
||||
import com.vaadin.navigator.ViewChangeListener;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.Grid;
|
||||
import com.vaadin.ui.TabSheet;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.security.UserRepository;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@CDIView(value = AdminView.VIEWNAME,
|
||||
uis = {AdminUIVaadin.class})
|
||||
public class AdminView extends CustomComponent implements View {
|
||||
|
||||
private static final long serialVersionUID = -2959302663954819489L;
|
||||
|
||||
public static final String VIEWNAME = "admin";
|
||||
|
||||
@Inject
|
||||
private UserRepository userRepo;
|
||||
|
||||
private final TabSheet tabSheet;
|
||||
private final Grid<User> usersTable;
|
||||
|
||||
public AdminView() {
|
||||
tabSheet = new TabSheet();
|
||||
|
||||
final TabSheet userGroupsRoles = new TabSheet();
|
||||
usersTable = new Grid<>();
|
||||
// usersTable.setItems(userRepo.findAll());
|
||||
usersTable.addColumn(User::getName).setCaption("User name");
|
||||
usersTable.addColumn(User::getGivenName).setCaption("Given name");
|
||||
usersTable.addColumn(User::getFamilyName).setCaption("Family name");
|
||||
usersTable
|
||||
.addColumn(user -> user.getPrimaryEmailAddress().getAddress())
|
||||
.setCaption("E-Mail");
|
||||
usersTable.addColumn(User::isBanned).setCaption("Banned?");
|
||||
userGroupsRoles.addTab(usersTable, "Users");
|
||||
|
||||
tabSheet.addTab(userGroupsRoles, "Users/Groups/Roles");
|
||||
setCompositionRoot(tabSheet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter(final ViewChangeListener.ViewChangeEvent event) {
|
||||
|
||||
usersTable.setItems(userRepo.findAll());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.admin.ui;
|
||||
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||
|
||||
import com.vaadin.cdi.CDIView;
|
||||
import com.vaadin.navigator.View;
|
||||
import com.vaadin.navigator.ViewChangeListener;
|
||||
import com.vaadin.server.UserError;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.CustomComponent;
|
||||
import com.vaadin.ui.FormLayout;
|
||||
import com.vaadin.ui.PasswordField;
|
||||
import com.vaadin.ui.TextField;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@CDIView(LoginView.VIEWNAME)
|
||||
public class LoginView extends CustomComponent implements View {
|
||||
|
||||
private static final long serialVersionUID = 997966222985596011L;
|
||||
|
||||
public static final String VIEWNAME = "login";
|
||||
|
||||
@Inject
|
||||
private ConfigurationManager confManager;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
@Inject
|
||||
private Subject subject;
|
||||
|
||||
private ResourceBundle bundle;
|
||||
|
||||
private final FormLayout layout;
|
||||
private final TextField userName;
|
||||
private final TextField password;
|
||||
private final Button submitButton;
|
||||
|
||||
public LoginView() {
|
||||
|
||||
layout = new FormLayout();
|
||||
layout.setSizeFull();
|
||||
|
||||
userName = new TextField();
|
||||
userName.setCaption("User name");
|
||||
layout.addComponent(userName);
|
||||
|
||||
password = new PasswordField("Password");
|
||||
layout.addComponent(password);
|
||||
|
||||
submitButton = new Button("Login");
|
||||
submitButton.addClickListener(event -> login(event));
|
||||
layout.addComponent(submitButton);
|
||||
|
||||
setCompositionRoot(layout);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void postConstruct() {
|
||||
bundle = ResourceBundle.getBundle(
|
||||
"com.arsdigita.ui.login.LoginResources",
|
||||
globalizationHelper.getNegotiatedLocale());
|
||||
|
||||
}
|
||||
|
||||
private void login(final Button.ClickEvent event) {
|
||||
final UsernamePasswordToken token = new UsernamePasswordToken(
|
||||
userName.getValue(),
|
||||
password.getValue());
|
||||
token.setRememberMe(true);
|
||||
|
||||
try {
|
||||
subject.login(token);
|
||||
} catch (AuthenticationException ex) {
|
||||
layout.setComponentError(
|
||||
new UserError(bundle.getString("login.error.loginFail")));
|
||||
return;
|
||||
}
|
||||
|
||||
getUI().getNavigator().navigateTo(AdminView.VIEWNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enter(final ViewChangeListener.ViewChangeEvent event) {
|
||||
|
||||
final KernelConfig kernelConfig = confManager
|
||||
.findConfiguration(KernelConfig.class);
|
||||
if (kernelConfig.emailIsPrimaryIdentifier()) {
|
||||
userName.setCaption(bundle
|
||||
.getString("login.userRegistrationForm.email"));
|
||||
} else {
|
||||
userName.setCaption(bundle
|
||||
.getString("login.userRegistrationForm.screenName"));
|
||||
}
|
||||
password.setCaption(
|
||||
bundle.getString("login.userRegistrationForm.password"));
|
||||
|
||||
submitButton.setCaption(bundle
|
||||
.getString("login.userRegistrationForm.title"));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue