Author: rjung Date: Mon Jan 16 08:17:31 2012 New Revision: 1231856 URL: http://svn.apache.org/viewvc?rev=1231856&view=rev Log: Fix svn:eol-style for three recent source files.
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java (contents, props changed) tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java (contents, props changed) tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java (contents, props changed) Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java?rev=1231856&r1=1231855&r2=1231856&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java Mon Jan 16 08:17:31 2012 @@ -1,56 +1,56 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.tomcat.jdbc.pool.interceptor; - -import java.lang.reflect.Method; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Map; - -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; -import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty; - -public class QueryTimeoutInterceptor extends AbstractCreateStatementInterceptor { - private static Log log = LogFactory.getLog(QueryTimeoutInterceptor.class); - int timeout; - - @Override - public void setProperties(Map<String,InterceptorProperty> properties) { - super.setProperties(properties); - timeout = properties.get("queryTimeout").getValueAsInt(-1); - } - - @Override - public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) { - if (statement instanceof Statement && timeout > 0) { - Statement s = (Statement)statement; - try { - s.setQueryTimeout(timeout); - }catch (SQLException x) { - log.warn("[QueryTimeoutInterceptor] Unable to set query timeout:"+x.getMessage(),x); - } - } - return statement; - } - - @Override - public void closeInvoked() { - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.tomcat.jdbc.pool.interceptor; + +import java.lang.reflect.Method; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Map; + +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty; + +public class QueryTimeoutInterceptor extends AbstractCreateStatementInterceptor { + private static Log log = LogFactory.getLog(QueryTimeoutInterceptor.class); + int timeout; + + @Override + public void setProperties(Map<String,InterceptorProperty> properties) { + super.setProperties(properties); + timeout = properties.get("queryTimeout").getValueAsInt(-1); + } + + @Override + public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) { + if (statement instanceof Statement && timeout > 0) { + Statement s = (Statement)statement; + try { + s.setQueryTimeout(timeout); + }catch (SQLException x) { + log.warn("[QueryTimeoutInterceptor] Unable to set query timeout:"+x.getMessage(),x); + } + } + return statement; + } + + @Override + public void closeInvoked() { + } + +} Propchange: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java?rev=1231856&r1=1231855&r2=1231856&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java Mon Jan 16 08:17:31 2012 @@ -1,54 +1,54 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.tomcat.jdbc.test; - -import java.sql.Connection; -import java.sql.Statement; - -import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor; -import org.apache.tomcat.jdbc.test.driver.Driver; - - -public class TestQueryTimeoutInterceptor extends DefaultTestCase { - - public TestQueryTimeoutInterceptor(String name) { - super(name); - } - - public void testTimeout() throws Exception { - int timeout = 10; - int withoutuser =10; - int withuser = withoutuser; - this.init(); - this.datasource.setMaxActive(withuser+withoutuser); - this.datasource.setJdbcInterceptors(QueryTimeoutInterceptor.class.getName()+"(queryTimeout="+timeout+")"); - this.datasource.setDriverClassName(Driver.class.getName()); - this.datasource.setUrl("jdbc:tomcat:test"); - Connection con = this.datasource.getConnection(); - Statement st = con.createStatement(); - assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); - st.close(); - st = con.prepareStatement(""); - assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); - st.close(); - st = con.prepareCall(""); - assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); - st.close(); - con.close(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.tomcat.jdbc.test; + +import java.sql.Connection; +import java.sql.Statement; + +import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor; +import org.apache.tomcat.jdbc.test.driver.Driver; + + +public class TestQueryTimeoutInterceptor extends DefaultTestCase { + + public TestQueryTimeoutInterceptor(String name) { + super(name); + } + + public void testTimeout() throws Exception { + int timeout = 10; + int withoutuser =10; + int withuser = withoutuser; + this.init(); + this.datasource.setMaxActive(withuser+withoutuser); + this.datasource.setJdbcInterceptors(QueryTimeoutInterceptor.class.getName()+"(queryTimeout="+timeout+")"); + this.datasource.setDriverClassName(Driver.class.getName()); + this.datasource.setUrl("jdbc:tomcat:test"); + Connection con = this.datasource.getConnection(); + Statement st = con.createStatement(); + assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); + st.close(); + st = con.prepareStatement(""); + assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); + st.close(); + st = con.prepareCall(""); + assertEquals(st.getClass().getName(),timeout,st.getQueryTimeout()); + st.close(); + con.close(); + } +} Propchange: tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java?rev=1231856&r1=1231855&r2=1231856&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java (original) +++ tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java Mon Jan 16 08:17:31 2012 @@ -1,120 +1,120 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.catalina.connector; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.Writer; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -import org.apache.catalina.Context; -import org.apache.catalina.startup.Tomcat; -import org.apache.catalina.startup.TomcatBaseTest; -import org.apache.tomcat.util.buf.ByteChunk; - -public class TestOutputBuffer extends TomcatBaseTest{ - - @Test - public void testWriteSpeed() throws Exception { - Tomcat tomcat = getTomcatInstance(); - - Context root = tomcat.addContext("", TEMP_DIR); - - for (int i = 1; i <= WritingServlet.EXPECTED_CONTENT_LENGTH; i*=10) { - WritingServlet servlet = new WritingServlet(i); - Tomcat.addServlet(root, "servlet" + i, servlet); - root.addServletMapping("/servlet" + i, "servlet" + i); - } - - tomcat.start(); - - ByteChunk bc = new ByteChunk(); - - for (int i = 1; i <= WritingServlet.EXPECTED_CONTENT_LENGTH; i*=10) { - int rc = getUrl("http://localhost:" + getPort() + - "/servlet" + i, bc, null, null); - assertEquals(HttpServletResponse.SC_OK, rc); - assertEquals( - WritingServlet.EXPECTED_CONTENT_LENGTH, bc.getLength()); - - bc.recycle(); - - rc = getUrl("http://localhost:" + getPort() + - "/servlet" + i + "?useBuffer=y", bc, null, null); - assertEquals(HttpServletResponse.SC_OK, rc); - assertEquals( - WritingServlet.EXPECTED_CONTENT_LENGTH, bc.getLength()); - - bc.recycle(); - } - } - - private static class WritingServlet extends HttpServlet { - - private static final long serialVersionUID = 1L; - - protected static final int EXPECTED_CONTENT_LENGTH = 100000; - - private final String writeString; - private final int writeCount; - - public WritingServlet(int writeLength) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < writeLength; i++) { - sb.append('x'); - } - writeString = sb.toString(); - writeCount = EXPECTED_CONTENT_LENGTH / writeLength; - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - resp.setContentType("text/plain"); - resp.setCharacterEncoding("ISO-8859-1"); - - Writer w = resp.getWriter(); - - // Wrap with a buffer if necessary - String useBufferStr = req.getParameter("useBuffer"); - if (useBufferStr != null) { - w = new BufferedWriter(w); - } - - long start = System.nanoTime(); - for (int i = 0; i < writeCount; i++) { - w.write(writeString); - } - if (useBufferStr != null) { - w.flush(); - } - long lastRunNano = System.nanoTime() - start; - - System.out.println("Write length: " + writeString.length() + - ", Buffered: " + (useBufferStr == null ? "n" : "y") + - ", Time: " + lastRunNano + "ns"); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.catalina.connector; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.tomcat.util.buf.ByteChunk; + +public class TestOutputBuffer extends TomcatBaseTest{ + + @Test + public void testWriteSpeed() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + Context root = tomcat.addContext("", TEMP_DIR); + + for (int i = 1; i <= WritingServlet.EXPECTED_CONTENT_LENGTH; i*=10) { + WritingServlet servlet = new WritingServlet(i); + Tomcat.addServlet(root, "servlet" + i, servlet); + root.addServletMapping("/servlet" + i, "servlet" + i); + } + + tomcat.start(); + + ByteChunk bc = new ByteChunk(); + + for (int i = 1; i <= WritingServlet.EXPECTED_CONTENT_LENGTH; i*=10) { + int rc = getUrl("http://localhost:" + getPort() + + "/servlet" + i, bc, null, null); + assertEquals(HttpServletResponse.SC_OK, rc); + assertEquals( + WritingServlet.EXPECTED_CONTENT_LENGTH, bc.getLength()); + + bc.recycle(); + + rc = getUrl("http://localhost:" + getPort() + + "/servlet" + i + "?useBuffer=y", bc, null, null); + assertEquals(HttpServletResponse.SC_OK, rc); + assertEquals( + WritingServlet.EXPECTED_CONTENT_LENGTH, bc.getLength()); + + bc.recycle(); + } + } + + private static class WritingServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + protected static final int EXPECTED_CONTENT_LENGTH = 100000; + + private final String writeString; + private final int writeCount; + + public WritingServlet(int writeLength) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < writeLength; i++) { + sb.append('x'); + } + writeString = sb.toString(); + writeCount = EXPECTED_CONTENT_LENGTH / writeLength; + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + resp.setContentType("text/plain"); + resp.setCharacterEncoding("ISO-8859-1"); + + Writer w = resp.getWriter(); + + // Wrap with a buffer if necessary + String useBufferStr = req.getParameter("useBuffer"); + if (useBufferStr != null) { + w = new BufferedWriter(w); + } + + long start = System.nanoTime(); + for (int i = 0; i < writeCount; i++) { + w.write(writeString); + } + if (useBufferStr != null) { + w.flush(); + } + long lastRunNano = System.nanoTime() - start; + + System.out.println("Write length: " + writeString.length() + + ", Buffered: " + (useBufferStr == null ? "n" : "y") + + ", Time: " + lastRunNano + "ns"); + } + } +} Propchange: tomcat/trunk/test/org/apache/catalina/connector/TestOutputBuffer.java ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org