Diff for revision 1227
=== modified file 'src/com/pugh/sockso/web/ServerThread.java'
--- src/com/pugh/sockso/web/ServerThread.java 2010-02-18 08:21:19 +0000
+++ src/com/pugh/sockso/web/ServerThread.java 2010-02-18 08:48:35 +0000
@@ -139,9 +139,8 @@
protected void process( final User user, final Request req, final Locale locale, final Response res ) throws Exception {
- //
- // are we set up to log requests?
- //
+ if ( req.getResource().equals("/favicon.ico") ) { return; }
+
if ( p.get(Constants.WWW_LOG_REQUESTS_ENABLED).equals(p.YES) ) {
final RequestLogger logger = new DbRequestLogger( db );
logger.log( user, client.getInetAddress().getHostAddress(),
@@ -149,10 +148,6 @@
req.getHeader("Referer"), req.getHeader("Cookie") );
}
- //
- // dispatch the action...
- //
-
final WebAction action = dispatcher.getAction( req );
if ( action == null ) {
=== added file 'test/com/pugh/sockso/tests/TestRequest.java'
--- test/com/pugh/sockso/tests/TestRequest.java 1970-01-01 00:00:00 +0000
+++ test/com/pugh/sockso/tests/TestRequest.java 2010-02-18 08:48:35 +0000
@@ -0,0 +1,74 @@
+
+package com.pugh.sockso.tests;
+
+import com.pugh.sockso.web.HttpRequest;
+import com.pugh.sockso.web.Request;
+import com.pugh.sockso.web.UploadFile;
+
+import java.io.InputStream;
+
+public class TestRequest extends HttpRequest implements Request {
+
+ private String resource;
+
+ public TestRequest( final String resource ) {
+ super( null );
+ this.resource = resource;
+ }
+
+ public void process( InputStream in ) {
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getHeader( String name ) {
+ return "";
+ }
+
+ public String getCookie( String name ) {
+ return "";
+ }
+
+ public String getHost() {
+ return "";
+ }
+
+ public String getUrlParam( int index ) {
+ return "";
+ }
+
+ public int getParamCount() {
+ return 0;
+ }
+
+ public String[] getPlayParams( boolean skipOne ) {
+ return new String[] {};
+ }
+
+ public String[] getPlayParams( int skip ) {
+ return new String[] {};
+ }
+
+ public String[] getPlayParams() {
+ return new String[] {};
+ }
+
+ public String getArgument( String name ) {
+ return "";
+ }
+
+ public boolean hasArgument( String name ) {
+ return false;
+ }
+
+ public UploadFile getFile( String file ) {
+ return null;
+ }
+
+ public String getPreferredLangCode() {
+ return "en";
+ }
+
+}
=== modified file 'test/com/pugh/sockso/web/ServerThreadTest.java'
--- test/com/pugh/sockso/web/ServerThreadTest.java 2010-02-18 08:21:19 +0000
+++ test/com/pugh/sockso/web/ServerThreadTest.java 2010-02-18 08:48:35 +0000
@@ -9,12 +9,14 @@
package com.pugh.sockso.web;
+import com.pugh.sockso.StringProperties;
import com.pugh.sockso.tests.TestUtils;
import com.pugh.sockso.Properties;
import com.pugh.sockso.db.Database;
import com.pugh.sockso.music.CollectionManager;
import com.pugh.sockso.resources.Resources;
import com.pugh.sockso.tests.SocksoTestCase;
+import com.pugh.sockso.tests.TestRequest;
import java.io.InputStream;
import java.io.OutputStream;
@@ -34,7 +36,7 @@
public void setUp() {
server = createMock( Server.class );
db = createMock( Database.class );
- p = createNiceMock( Properties.class );
+ p = new StringProperties();
r = createMock( Resources.class );
cm = createNiceMock( CollectionManager.class );
}
@@ -62,8 +64,17 @@
}
- public void testSlashFaviconRequestsIgnored() {
- // @TODO
+ public void testSlashFaviconRequestsIgnored() throws Exception {
+ TestRequest req = new TestRequest( "/favicon.ico" );
+ boolean gotException = false;
+ try {
+ ServerThread s = new ServerThread( server, getSocket(""), db, p, r, null );
+ s.process( null, req, null, null );
+ }
+ catch ( BadRequestException e ) {
+ gotException = true;
+ }
+ assertFalse( gotException );
}
/**