Skip to content
Snippets Groups Projects
Commit a2665674 authored by felmer's avatar felmer
Browse files

LMS-401 initial build.xml, checkstyle, first class and test class added

SVN: 5816
parent 647ab05d
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="false">
<local-check-config name="CISD Checks" location="/build_resources/checkstyle/cisd_checkstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="CISD Checks" local="true">
<file-match-pattern match-pattern=".+ch/systemsx/cisd.+" include-pattern="true"/>
</fileset>
</fileset-config>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="source/java"/> <classpathentry kind="src" path="source/java"/>
<classpathentry kind="src" path="sourceTest/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/common"/>
<classpathentry kind="lib" path="/libraries/log4j/log4j.jar" sourcepath="/libraries/log4j/src.zip"/>
<classpathentry kind="lib" path="/libraries/jetty/servlet-api-2.5.jar" sourcepath="/libraries/jetty/src/servlet-api-2.5.zip"/>
<classpathentry kind="lib" path="/libraries/testng/testng-jdk15.jar" sourcepath="/libraries/testng/src.zip"/>
<classpathentry kind="lib" path="/libraries/jmock/third-party-libs/cglib-2.1_3-src.jar"/>
<classpathentry kind="lib" path="/libraries/jmock/third-party-libs/cglib-nodep-2.1_3.jar"/>
<classpathentry kind="lib" path="/libraries/jmock/third-party-libs/hamcrest-api-1.0.jar"/>
<classpathentry kind="lib" path="/libraries/jmock/third-party-libs/hamcrest-library-1.0.jar"/>
<classpathentry kind="lib" path="/libraries/jmock/third-party-libs/objenesis-1.0.jar"/>
<classpathentry kind="lib" path="/libraries/jmock/jmock.jar"/>
<classpathentry kind="output" path="targets/classes"/> <classpathentry kind="output" path="targets/classes"/>
</classpath> </classpath>
#! /bin/bash
ME="$0"
MYDIR=${ME%/*}
cd $MYDIR
ant -lib ../../build_resources/lib/ecj.jar "$@"
<project name="authentication" basedir="..">
<import file="../../build_resources/ant/build-common.xml" />
<project-classpath name="ecp" classes="${classes}" />
<target name="ci" depends="build-common.ci, check-dependencies"/>
</project>
\ No newline at end of file
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.datasetdownload;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory;
import ch.systemsx.cisd.common.logging.LogInitializer;
/**
* @author Franz-Josef Elmer
*/
public class DatasetDownloadServlet extends HttpServlet
{
static final String DATASET_CODE_KEY = "datasetCode";
static final String SESSION_ID_KEY = "sessionID";
private static final long serialVersionUID = 1L;
protected static final Logger operationLog =
LogFactory.getLogger(LogCategory.OPERATION, DatasetDownloadServlet.class);
protected static final Logger notificationLog =
LogFactory.getLogger(LogCategory.NOTIFY, DatasetDownloadServlet.class);
//
// HttpServlet
//
@Override
public final void init(final ServletConfig servletConfig) throws ServletException
{
super.init(servletConfig);
LogInitializer.init();
try
{
} catch (Exception ex)
{
notificationLog.fatal("Failure during '" + servletConfig.getServletName()
+ "' servlet initialization.", ex);
throw new ServletException(ex);
}
}
@Override
protected final void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException
{
final String datasetCode = request.getParameter(DATASET_CODE_KEY);
final String sessionID = request.getParameter(SESSION_ID_KEY);
final PrintWriter writer = response.getWriter();
writer.write("<html><body>Download dataset " + datasetCode + " (sessionID:" + sessionID + ")</body></html>");
writer.flush();
writer.close();
}
}
# The root directory of the data store
storeroot-dir = targets/store
# The URL of the openBIS server
server-url = http://localhost:8080/openbis
# The username to use when contacting the openBIS server
username = etlserver
# The password to use when contacting the openBIS server
password = doesnotmatter
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.datasetdownload;
import static org.testng.AssertJUnit.assertEquals;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Level;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ch.systemsx.cisd.common.logging.BufferedAppender;
/**
*
*
* @author Franz-Josef Elmer
*/
public class DatasetDownloadServletTest
{
private BufferedAppender logRecorder;
private Mockery context;
private HttpServletRequest request;
private HttpServletResponse response;
@BeforeMethod
public void setUp()
{
logRecorder = new BufferedAppender("%-5p %c - %m%n", Level.DEBUG);
context = new Mockery();
request = context.mock(HttpServletRequest.class);
response = context.mock(HttpServletResponse.class);
}
@AfterMethod
public void tearDown()
{
logRecorder.reset();
// To following line of code should also be called at the end of each test method.
// Otherwise one do not known which test failed.
context.assertIsSatisfied();
}
@Test
public void testDoGet() throws Exception
{
final StringWriter writer = new StringWriter();
context.checking(new Expectations()
{
{
one(request).getParameter(DatasetDownloadServlet.DATASET_CODE_KEY);
will(returnValue("1234-1"));
one(request).getParameter(DatasetDownloadServlet.SESSION_ID_KEY);
will(returnValue("AV76CF"));
one(response).getWriter();
will(returnValue(new PrintWriter(writer)));
}
});
DatasetDownloadServlet servlet = new DatasetDownloadServlet();
servlet.init();
servlet.doGet(request, response);
assertEquals("<html><body>Download dataset 1234-1 (sessionID:AV76CF)</body></html>", writer.toString());
}
}
<suite name="All" verbose="1">
<test name="All">
<groups>
<run>
<exclude name="broken" />
</run>
</groups>
<packages>
<package name="ch.systemsx.cisd.openbis.datasetdownload.*" />
</packages>
</test>
</suite>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment