tests work in eclipse

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1067 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-07-02 09:30:45 +00:00
parent 27203844b0
commit 689d743d0b
4 changed files with 81 additions and 3 deletions

2
.gitignore vendored
View File

@ -13,3 +13,5 @@ extensions/jython/module/MOD-INF/lib/cachedir/
broker/appengine/module/MOD-INF/classes/
broker/core/module/MOD-INF/classes/
broker/core/WEB-INF/lib/
broker/core/data/
broker/core/test-output/

View File

@ -12,5 +12,12 @@
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/slf4j-api-1.5.6.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/slf4j-api-1.5.6-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/tests/server/lib/mockito-all-1.8.4.jar" sourcepath="/gridworks/tests/server/lib-src/mockito-all-1.8.4-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/tests/server/lib/testng-5.12.1.jar" sourcepath="/gridworks/tests/server/lib-src/testng-5.12.1-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/log4j-1.2.15.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/log4j-1.2.15-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/slf4j-log4j12-1.5.6-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/velocity-1.5.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/rhino-1.7R2.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/lessen-trunk-r8.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/jcl-over-slf4j-1.5.6.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/jcl-over-slf4j-1.5.6-sources.jar"/>
<classpathentry kind="output" path="module/MOD-INF/classes"/>
</classpath>

View File

@ -5,7 +5,7 @@
<listEntry value="/gridworks-broker/module/MOD-INF/classes"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.testng.remote.RemoteTestNG"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gridworks"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gridworks-broker"/>
<mapAttribute key="org.testng.eclipse.ALL_CLASS_METHODS"/>
<listAttribute key="org.testng.eclipse.CLASS_TEST_LIST"/>
<stringAttribute key="org.testng.eclipse.COMPLIANCE_LEVEL" value="JDK"/>

View File

@ -1,15 +1,84 @@
package com.metaweb.gridworks.broker.tests;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.metaweb.gridworks.broker.GridworksBroker;
import com.metaweb.gridworks.broker.GridworksBrokerImpl;
public class GridworksBrokerTests {
protected Logger logger;
protected File data;
@BeforeSuite
public void init() {
public void suite_init() {
//System.setProperty("log4j.configuration", "tests.log4j.properties");
data = new File("data");
if (!data.exists()) data.mkdirs();
}
@AfterSuite
public void suite_destroy() {
}
@BeforeTest
public void test_init() {
logger = LoggerFactory.getLogger(this.getClass());
}
// System under test
GridworksBroker SUT = null;
// mocks
HttpServletRequest request = null;
HttpServletResponse response = null;
ServletConfig config = null;
@BeforeMethod
public void setup() throws Exception {
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
config = mock(ServletConfig.class);
when(config.getInitParameter("gridworks.data")).thenReturn(data.getAbsolutePath());
SUT = new GridworksBrokerImpl();
SUT.init(config);
}
@AfterMethod
public void teardown() {
SUT = null;
request = null;
response = null;
config = null;
}
// ------------------------------------------------------------------------------------
@Test
public void testLifeCycle() {
Assert.assertTrue(true);
}
}