Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/MountedRequestMapper.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/MountedRequestMapper.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/MountedRequestMapper.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/MountedRequestMapper.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.request.mapper.mount; import org.apache.wicket.ng.request.Request; @@ -11,43 +27,43 @@ */ public interface MountedRequestMapper { - /** - * Returns {...@link RequestHandler} for the request or <code>null</code> if the encoder does not - * recognize the URL. - * - * @param request - * provides access to request data (i.e. Url and Parameters) - * @param mountParams - * parameters resolved from the mount - * @return RequestHandler instance or <code>null</code> - */ - RequestHandler mapRequest(Request request, MountParameters mountParams); + /** + * Returns {...@link RequestHandler} for the request or <code>null</code> if the encoder does not + * recognize the URL. + * + * @param request + * provides access to request data (i.e. Url and Parameters) + * @param mountParams + * parameters resolved from the mount + * @return RequestHandler instance or <code>null</code> + */ + RequestHandler mapRequest(Request request, MountParameters mountParams); - /** - * Returns the score representing how compatible this request mapper is to processing the given - * request. When a request comes in all mappers are scored and are tried in order from highest - * score to lowest. - * <p> - * A good criteria for calculating the score is the number of matched url segments. For example - * when there are two encoders for mounted page, one mapped to <code>/foo</code> another to - * <code>/foo/bar</code> and the incomming reqest URL is </code>/foo/bar/baz</code>, the encoder - * mapped to <code>/foo/bar</code> will handle the request first as it has matching segments - * count of 2 while the first one has only matching segments count of 1. - * <p> - * Note that the method can return value greater then zero even if the encoder can not decode - * the request. - * - * @param request - * @return count of matching segments - */ - int getCompatibilityScore(Request request); + /** + * Returns the score representing how compatible this request mapper is to processing the given + * request. When a request comes in all mappers are scored and are tried in order from highest + * score to lowest. + * <p> + * A good criteria for calculating the score is the number of matched url segments. For example + * when there are two encoders for mounted page, one mapped to <code>/foo</code> another to + * <code>/foo/bar</code> and the incomming reqest URL is </code>/foo/bar/baz</code>, the encoder + * mapped to <code>/foo/bar</code> will handle the request first as it has matching segments + * count of 2 while the first one has only matching segments count of 1. + * <p> + * Note that the method can return value greater then zero even if the encoder can not decode + * the request. + * + * @param request + * @return count of matching segments + */ + int getCompatibilityScore(Request request); - /** - * Returns the {...@link Mount} for given {...@link RequestHandler} or <code>null</code> if the - * encoder does not recognize the request handler. - * - * @param requestHandler - * @return Url instance or <code>null</code>. - */ - Mount mapHandler(RequestHandler requestHandler); + /** + * Returns the {...@link Mount} for given {...@link RequestHandler} or <code>null</code> if the + * encoder does not recognize the request handler. + * + * @param requestHandler + * @return Url instance or <code>null</code>. + */ + Mount mapHandler(RequestHandler requestHandler); }
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedMapperAdapter.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedMapperAdapter.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedMapperAdapter.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedMapperAdapter.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.request.mapper.mount; import org.apache.wicket.ng.request.Request; @@ -15,31 +31,31 @@ */ class UnmountedMapperAdapter implements MountedRequestMapper { - private final RequestMapper mapper; + private final RequestMapper mapper; - public UnmountedMapperAdapter(RequestMapper mapper) - { - super(); - this.mapper = mapper; - } - - public int getCompatibilityScore(Request request) - { - return mapper.getCompatibilityScore(request); - } - - public Mount mapHandler(RequestHandler requestHandler) - { - Url url = mapper.mapHandler(requestHandler); - if (url != null) - { - return new Mount(url); - } - return null; - } - - public RequestHandler mapRequest(Request request, MountParameters mountParams) - { - return mapper.mapRequest(request); - } + public UnmountedMapperAdapter(RequestMapper mapper) + { + super(); + this.mapper = mapper; + } + + public int getCompatibilityScore(Request request) + { + return mapper.getCompatibilityScore(request); + } + + public Mount mapHandler(RequestHandler requestHandler) + { + Url url = mapper.mapHandler(requestHandler); + if (url != null) + { + return new Mount(url); + } + return null; + } + + public RequestHandler mapRequest(Request request, MountParameters mountParams) + { + return mapper.mapRequest(request); + } } Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedRequestHandlerAdapter.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedRequestHandlerAdapter.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedRequestHandlerAdapter.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/mapper/mount/UnmountedRequestHandlerAdapter.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.request.mapper.mount; import org.apache.wicket.ng.request.Request; @@ -14,30 +30,30 @@ */ class UnmountedRequestHandlerAdapter implements MountedRequestMapper { - private final RequestHandler handler; + private final RequestHandler handler; - public UnmountedRequestHandlerAdapter(RequestHandler handler) - { - this.handler = handler; - } - - public int getCompatibilityScore(Request request) - { - return 0; - } - - public Mount mapHandler(RequestHandler requestHandler) - { - if (requestHandler.equals(handler)) - { - return new Mount(new Url()); - } - return null; - } - - public RequestHandler mapRequest(Request request, MountParameters mountParams) - { - return handler; - } + public UnmountedRequestHandlerAdapter(RequestHandler handler) + { + this.handler = handler; + } + + public int getCompatibilityScore(Request request) + { + return 0; + } + + public Mount mapHandler(RequestHandler requestHandler) + { + if (requestHandler.equals(handler)) + { + return new Mount(new Url()); + } + return null; + } + + public RequestHandler mapRequest(Request request, MountParameters mountParams) + { + return handler; + } } Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/CombinedRequestParametersAdapter.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/CombinedRequestParametersAdapter.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/CombinedRequestParametersAdapter.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/CombinedRequestParametersAdapter.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.request.parameter; import java.util.ArrayList; @@ -13,7 +29,7 @@ { private final RequestParameters parameters[]; - public CombinedRequestParametersAdapter(RequestParameters ... parameters) + public CombinedRequestParametersAdapter(RequestParameters... parameters) { if (parameters == null) { @@ -62,7 +78,7 @@ } } } - + if (result.isEmpty()) { return null; Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/EmptyRequestParameters.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/EmptyRequestParameters.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/EmptyRequestParameters.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/parameter/EmptyRequestParameters.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.request.parameter; import java.util.Collections; @@ -13,7 +29,7 @@ private EmptyRequestParameters() { } - + public static EmptyRequestParameters INSTANCE = new EmptyRequestParameters(); public Set<String> getParameterNames() Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/response/StringResponse.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/response/StringResponse.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/response/StringResponse.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/request/response/StringResponse.java Sun Oct 11 13:52:09 2009 @@ -1,10 +1,26 @@ +/* + * 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.wicket.ng.request.response; public class StringResponse extends Response { private final StringBuilder builder = new StringBuilder(); - + public StringResponse() { } @@ -26,7 +42,7 @@ { throw new UnsupportedOperationException(); } - + @Override public String toString() { Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/ApplicationSettings.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/ApplicationSettings.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/ApplicationSettings.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/ApplicationSettings.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.settings; import org.apache.wicket.ng.application.ClassResolver; @@ -10,7 +26,7 @@ * @return Default class resolver */ ClassResolver getClassResolver(); - + /** * Sets the default class resolver to use when finding classes and resources * Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/RequestCycleSettings.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/RequestCycleSettings.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/RequestCycleSettings.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ng/settings/RequestCycleSettings.java Sun Oct 11 13:52:09 2009 @@ -1,19 +1,32 @@ +/* + * 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.wicket.ng.settings; public interface RequestCycleSettings { - public enum RenderStrategy - { - ONE_PASS_RENDER, - REDIRECT_TO_BUFFER, - REDIRECT_TO_RENDER + public enum RenderStrategy { + ONE_PASS_RENDER, REDIRECT_TO_BUFFER, REDIRECT_TO_RENDER }; - + void setRenderStrategy(RenderStrategy renderStrategy); - + RenderStrategy getRenderStrategy(); - + String getResponseRequestEncoding(); - + void setResponseRequestEncoding(final String responseRequestEncoding); } Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/page/persistent/disk/DiskDataStoreTest.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/page/persistent/disk/DiskDataStoreTest.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/page/persistent/disk/DiskDataStoreTest.java (original) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/page/persistent/disk/DiskDataStoreTest.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.page.persistent.disk; import java.util.ArrayList; @@ -21,7 +37,7 @@ public DiskDataStoreTest() { - + } private static final Random random = new Random(); @@ -34,32 +50,32 @@ private static final int SLEEP_MAX = 10; private static final int THREAD_COUNT = 20; private static final int READ_MODULO = 100; - + private static class File { private final String sessionId; private final int id; - + private byte first; private byte last; private int length; - + public File(String sessionId, int id) { this.sessionId = sessionId; this.id = id; } - + public String getSessionId() { return sessionId; } - + public int getId() { return id; } - + public byte[] generateData() { length = FILE_SIZE_MIN + random.nextInt(FILE_SIZE_MAX - FILE_SIZE_MIN); @@ -69,7 +85,7 @@ last = data[data.length - 1]; return data; } - + public boolean checkData(byte data[]) { Checks.argumentNotNull(data, "data"); @@ -88,39 +104,39 @@ return true; } } - - private Map<String, AtomicInteger> sessionCounter = new ConcurrentHashMap<String, AtomicInteger>(); - private ConcurrentLinkedQueue<File> filesToSave = new ConcurrentLinkedQueue<File>(); - private ConcurrentLinkedQueue<File> filesToRead1 = new ConcurrentLinkedQueue<File>(); - private ConcurrentLinkedQueue<File> filesToRead2 = new ConcurrentLinkedQueue<File>(); - - private AtomicInteger read1Count = new AtomicInteger(0); - private AtomicInteger read2Count = new AtomicInteger(0); - private AtomicInteger saveCount = new AtomicInteger(0); - - private AtomicBoolean saveDone = new AtomicBoolean(false); - private AtomicBoolean read1Done = new AtomicBoolean(false); - private AtomicBoolean read2Done = new AtomicBoolean(false); - - private AtomicInteger failures = new AtomicInteger(); - - private AtomicInteger bytesWritten = new AtomicInteger(0); - private AtomicInteger bytesRead = new AtomicInteger(0); - - private AtomicInteger saveTime = new AtomicInteger(0); - + + private final Map<String, AtomicInteger> sessionCounter = new ConcurrentHashMap<String, AtomicInteger>(); + private final ConcurrentLinkedQueue<File> filesToSave = new ConcurrentLinkedQueue<File>(); + private final ConcurrentLinkedQueue<File> filesToRead1 = new ConcurrentLinkedQueue<File>(); + private final ConcurrentLinkedQueue<File> filesToRead2 = new ConcurrentLinkedQueue<File>(); + + private final AtomicInteger read1Count = new AtomicInteger(0); + private final AtomicInteger read2Count = new AtomicInteger(0); + private final AtomicInteger saveCount = new AtomicInteger(0); + + private final AtomicBoolean saveDone = new AtomicBoolean(false); + private final AtomicBoolean read1Done = new AtomicBoolean(false); + private final AtomicBoolean read2Done = new AtomicBoolean(false); + + private final AtomicInteger failures = new AtomicInteger(); + + private final AtomicInteger bytesWritten = new AtomicInteger(0); + private final AtomicInteger bytesRead = new AtomicInteger(0); + + private final AtomicInteger saveTime = new AtomicInteger(0); + private String randomSessionId() { List<String> s = new ArrayList<String>(sessionCounter.keySet()); return s.get(random.nextInt(s.size())); } - + private int nextSessionId(String sessionId) { AtomicInteger i = sessionCounter.get(sessionId); return i.incrementAndGet(); } - + private void generateFiles() { for (int i = 0; i < SESSION_COUNT; ++i) @@ -134,26 +150,26 @@ long now = System.nanoTime(); filesToSave.add(file); long duration = System.nanoTime() - now; - saveTime.addAndGet((int) duration); + saveTime.addAndGet((int)duration); } - + } - + private DataStore dataStore; - + private class SaveRunnable implements Runnable { public void run() { File file; - + while ((file = filesToSave.poll()) != null || saveCount.get() < FILES_COUNT) { if (file != null) - { + { byte data[] = file.generateData(); dataStore.storeData(file.getSessionId(), file.getId(), data); - + if (saveCount.get() % READ_MODULO == 0) { filesToRead1.add(file); @@ -161,7 +177,7 @@ saveCount.incrementAndGet(); bytesWritten.addAndGet(data.length); } - + try { Thread.sleep(random.nextInt(SLEEP_MAX)); @@ -170,12 +186,12 @@ { e.printStackTrace(); } - } - - saveDone.set(true); - } + } + + saveDone.set(true); + } }; - + private class Read1Runnable implements Runnable { public void run() @@ -190,11 +206,11 @@ { failures.incrementAndGet(); } - filesToRead2.add(file); + filesToRead2.add(file); read1Count.incrementAndGet(); bytesRead.addAndGet(bytes.length); } - + try { Thread.sleep(random.nextInt(SLEEP_MAX)); @@ -203,13 +219,13 @@ { e.printStackTrace(); } - } - + } + read1Done.set(true); - } + } }; - - + + private class Read2Runnable implements Runnable { public void run() @@ -223,11 +239,11 @@ if (file.checkData(bytes) == false) { failures.incrementAndGet(); - } + } read2Count.incrementAndGet(); bytesRead.addAndGet(bytes.length); } - + try { Thread.sleep(random.nextInt(SLEEP_MAX)); @@ -235,34 +251,34 @@ catch (InterruptedException e) { e.printStackTrace(); - } + } } - - read2Done.set(true); + + read2Done.set(true); } }; - + private void doTestDataStore() { System.out.println("Starting..."); long start = System.currentTimeMillis(); - + for (int i = 0; i < THREAD_COUNT; ++i) { new Thread(new SaveRunnable()).start(); } - + for (int i = 0; i < THREAD_COUNT; ++i) { new Thread(new Read1Runnable()).start(); } - + for (int i = 0; i < THREAD_COUNT; ++i) { new Thread(new Read2Runnable()).start(); } - - while(!(read1Done.get() && read2Done.get() && saveDone.get())) + + while (!(read1Done.get() && read2Done.get() && saveDone.get())) { try { @@ -275,30 +291,33 @@ } long duration = System.currentTimeMillis() - start; - + System.out.println("Took: " + duration + " ms"); - System.out.println("Save: " + saveCount.intValue() + " files, " + bytesWritten.get() +" bytes"); - System.out.println("Read: " + (read1Count.get() + read2Count.get()) + " files, " + bytesRead.get() + " bytes"); + System.out.println("Save: " + saveCount.intValue() + " files, " + bytesWritten.get() + + " bytes"); + System.out.println("Read: " + (read1Count.get() + read2Count.get()) + " files, " + + bytesRead.get() + " bytes"); + + System.out.println("Average save time (ns): " + (double)saveTime.get() / + (double)saveCount.get()); - System.out.println("Average save time (ns): " + (double) saveTime.get() / (double) saveCount.get()); - assertEquals(0, failures.get()); - + for (String s : sessionCounter.keySet()) { dataStore.removeData(s); - } + } } - + public void test1() { - generateFiles(); - + generateFiles(); + dataStore = new DiskDataStore("app1", MAX_SIZE_PER_SESSION, FILE_CHANNEL_POOL_CAPACITY); dataStore = new AsynchronousDataStore(dataStore); - + doTestDataStore(); - + dataStore.destroy(); } Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/test/TestPageRender.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/test/TestPageRender.java?rev=824074&r1=824073&r2=824074&view=diff ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/test/TestPageRender.java (original) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ng/test/TestPageRender.java Sun Oct 11 13:52:09 2009 @@ -1,3 +1,19 @@ +/* + * 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.wicket.ng.test; import junit.framework.TestCase; @@ -49,7 +65,7 @@ { // Store current ThreadContext ThreadContext context = ThreadContext.getAndClean(); - + // Create MockApplication MockApplication app = new MockApplication(); app.setName("TestApplication1"); @@ -64,23 +80,24 @@ Response response = new StringResponse(); // create and execute request cycle - MockRequestCycle cycle = (MockRequestCycle) app.createRequestCycle(request, response); + MockRequestCycle cycle = (MockRequestCycle)app.createRequestCycle(request, response); cycle.processRequestAndDetach(); - + System.out.println("Rendered:"); System.out.println(response); - - // invoke listener on the page + + // invoke listener on the page request = new MockRequest(Url.parse("wicket/page?0-1.ILinkListener-link")); response = new StringResponse(); - cycle = (MockRequestCycle) app.createRequestCycle(request, response); + cycle = (MockRequestCycle)app.createRequestCycle(request, response); cycle.processRequestAndDetach(); - + // invoke the listener again - without parsing the URL - cycle = (MockRequestCycle) app.createRequestCycle(request, response); - cycle.forceRequestHandler(new ListenerInterfaceRequestHandler(new PageAndComponentProvider(0, null, "link"), ILinkListener.INTERFACE)); + cycle = (MockRequestCycle)app.createRequestCycle(request, response); + cycle.forceRequestHandler(new ListenerInterfaceRequestHandler(new PageAndComponentProvider( + 0, null, "link"), ILinkListener.INTERFACE)); cycle.processRequestAndDetach(); - + // cleanup app.destroy(); ThreadContext.restore(context);
