Merge branch 'develop' of github.com:vivo-project/Vitro into develop

This commit is contained in:
Brian Caruso 2013-07-08 13:52:05 -04:00
commit 467256e3ba
406 changed files with 8250 additions and 4587 deletions

View file

@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionRegistry;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* Can we tell whether a user is logged in as root?
@ -79,7 +80,7 @@ public class HasPermissionFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsRootUser;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* Can we tell whether a user is logged in as root?
@ -56,7 +57,7 @@ public class IsRootUserFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsUser;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* The simplest of the IdentifierBundleFactory classes.
@ -46,7 +47,7 @@ public class IsUserFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -73,7 +73,7 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
bean = new PropertyRestrictionPolicyHelper(
Arrays.asList(PROHIBITED_NAMESPACES),
Arrays.asList(PERMITTED_EXCEPTIONS), displayLevels,
modifyLevels);
modifyLevels, ModelFactory.createDefaultModel());
}
@Before

View file

@ -26,6 +26,7 @@ import stubs.edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesStub
import stubs.edu.cornell.mannlib.vitro.webapp.dao.IndividualDaoStub;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDaoStub;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub;
import stubs.edu.cornell.mannlib.vitro.webapp.i18n.I18nStub;
import stubs.javax.servlet.ServletConfigStub;
import stubs.javax.servlet.ServletContextStub;
import stubs.javax.servlet.http.HttpServletRequestStub;
@ -47,6 +48,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.AuthenticatorStub;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
*/
@ -119,6 +121,11 @@ public class AuthenticateTest extends AbstractTestClass {
@Before
public void setup() throws Exception {
// Create an I18n module that has a value for any key, but the value is
// the key itself.
@SuppressWarnings("unused")
I18nStub i18n = new I18nStub();
authenticatorFactory = new AuthenticatorStub.Factory();
authenticator = authenticatorFactory.getInstance(request);
authenticator.addUser(createUserFromUserInfo(NEW_DBA));
@ -147,7 +154,7 @@ public class AuthenticateTest extends AbstractTestClass {
webappDaoFactory.setIndividualDao(individualDao);
servletContext = new ServletContextStub();
servletContext.setAttribute("webappDaoFactory", webappDaoFactory);
ModelAccess.on(servletContext).setWebappDaoFactory(webappDaoFactory);
servletContext.setAttribute(AuthenticatorStub.FACTORY_ATTRIBUTE_NAME,
authenticatorFactory);
@ -313,7 +320,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(LOGGING_IN, NO_USER, NO_MSG,
"Please enter your email address.", URL_LOGIN, URL_WITH_LINK);
"error_no_email_address", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -325,8 +332,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(LOGGING_IN, "unknownBozo", NO_MSG,
"The email or password you entered is incorrect.", URL_LOGIN,
URL_WITH_LINK);
"error_incorrect_credentials", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -338,7 +344,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(LOGGING_IN, NEW_DBA_NAME, NO_MSG,
"Please enter your password.", URL_LOGIN, URL_WITH_LINK);
"error_no_password", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -350,8 +356,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(LOGGING_IN, NEW_DBA_NAME, NO_MSG,
"The email or password you entered is incorrect.", URL_LOGIN,
URL_WITH_LINK);
"error_incorrect_credentials", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -402,8 +407,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(FORCED_PASSWORD_CHANGE, NEW_DBA_NAME, NO_MSG,
"Please enter a password between 6 and 12 "
+ "characters in length.", URL_LOGIN, URL_WITH_LINK);
"error_password_length", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -416,7 +420,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(FORCED_PASSWORD_CHANGE, NEW_DBA_NAME, NO_MSG,
"The passwords entered do not match.", URL_LOGIN, URL_WITH_LINK);
"error_passwords_dont_match", URL_LOGIN, URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}
@ -429,7 +433,7 @@ public class AuthenticateTest extends AbstractTestClass {
doTheRequest();
assertProcessBean(FORCED_PASSWORD_CHANGE, NEW_DBA_NAME, NO_MSG,
"Your new password cannot match the current one.", URL_LOGIN,
"error_previous_password", URL_LOGIN,
URL_WITH_LINK);
assertRedirectToLoginProcessPage();
}

View file

@ -28,6 +28,7 @@ import stubs.javax.servlet.http.HttpSessionStub;
import stubs.org.apache.solr.client.solrj.SolrServerStub;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
/**
@ -106,8 +107,7 @@ public class JsonServletTest extends AbstractTestClass {
resp = new HttpServletResponseStub();
wadf = new WebappDaoFactoryStub();
req.setAttribute("webappDaoFactory", wadf);
ctx.setAttribute("webappDaoFactory", wadf);
ModelAccess.on(ctx).setWebappDaoFactory(wadf);
vcDao = new VClassDaoStub();
wadf.setVClassDao(vcDao);

View file

@ -18,6 +18,7 @@ import com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.SimpleOntModelSelector;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
@ -48,7 +49,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
@Test
public void testGetPageDataGetterObjects() throws Exception{
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
vreq.setWebappDaoFactory(wdf);
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI);
Assert.assertNotNull(pdgList);
@ -58,7 +59,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
@Test
public void testGetNonPageDataGetterObjects() throws Exception{
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
vreq.setWebappDaoFactory(wdf);
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI_2);
Assert.assertNotNull(pdgList);

View file

@ -25,6 +25,10 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDaoStub;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub;
import stubs.freemarker.cache.TemplateLoaderStub;
@ -36,6 +40,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.InvalidConfigurationException;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.PropertyListConfig;
@ -123,7 +129,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
hreq.setSession(session);
vreq = new VitroRequest(hreq);
vreq.setWebappDaoFactory(wadf);
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
subject = new IndividualImpl();
@ -273,6 +279,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
@Test
public void constructQueryNodeMissing()
throws InvalidConfigurationException {
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
op = buildOperation("constructQueryMissing");
optm = new NonCollatingOPTM(op, subject, vreq, true);
// Not an error.
@ -281,6 +288,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
@Test
public void constructQueryMultipleValues()
throws InvalidConfigurationException {
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
op = buildOperation("constructQueryMultiple");
optm = new NonCollatingOPTM(op, subject, vreq, true);
assertConstructQueries("multiple construct queries", "ONE", "TWO",
@ -367,6 +375,10 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
// Helper methods
// ----------------------------------------------------------------------
private OntModel emptyOntModel() {
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
}
/**
* Sets up an operation with name "foobar" and adds it to the
* ObjectPropertyDaoStub.