Fixing build, adding unit tests

This commit is contained in:
briancaruso 2011-11-16 14:56:11 +00:00
parent 1446b9c039
commit 107c64dbf8
10 changed files with 145 additions and 61 deletions

View file

@ -0,0 +1,47 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
import java.util.Collections;
import junit.framework.Assert;
import org.junit.Test;
public class BasicValidationVTwoTest {
@SuppressWarnings("unchecked")
@Test
public void testHttpUrlValidate() {
BasicValidationVTwo bv = new BasicValidationVTwo(Collections.EMPTY_MAP);
String res;
res = bv.validate("httpUrl", "http://example.com/index");
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
res = bv.validate("httpUrl", "http://example.com/index?bogus=skjd%20skljd&something=sdkf");
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
res = bv.validate("httpUrl", "http://example.com/index#2.23?bogus=skjd%20skljd&something=sdkf");
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
}
@SuppressWarnings("unchecked")
@Test
public void testEmptyValidate(){
BasicValidationVTwo bv = new BasicValidationVTwo(Collections.EMPTY_MAP);
Assert.assertEquals(
bv.validate("nonempty", null)
, BasicValidationVTwo.REQUIRED_FIELD_EMPTY_MSG);
Assert.assertEquals(
bv.validate("nonempty", "")
, BasicValidationVTwo.REQUIRED_FIELD_EMPTY_MSG);
Assert.assertEquals(
bv.validate("nonempty", "some value")
, BasicValidationVTwo.SUCCESS);
}
}

View file

@ -0,0 +1,36 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import stubs.javax.servlet.http.HttpServletRequestStub;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
public class EditConfigurationUtilsTest {
@Before
public void setUp() throws Exception {
}
@Test
public void testGetEditKey() {
HttpServletRequestStub req = new HttpServletRequestStub();
req.addParameter("datapropKey", "2343");
Integer hash = EditConfigurationUtils.getDataHash(new VitroRequest(req));
Assert.assertNotNull(hash);
Assert.assertEquals(new Integer(2343), hash);
req = new HttpServletRequestStub();
hash = EditConfigurationUtils.getDataHash(new VitroRequest(req));
Assert.assertNull( hash);
}
}