diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2016-12-13 11:05:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 11:05:04 +0200 |
commit | 6d1abeb9fc1103af0a04dfd79d56b0f883de6f72 (patch) | |
tree | 81a6a3d6494dea296f39efbc7df40a9393a03a8e /uitest | |
parent | 2a52bce41799dd1b766a17acc1aaacd45ea9bfdd (diff) | |
download | vaadin-framework-6d1abeb9fc1103af0a04dfd79d56b0f883de6f72.tar.gz vaadin-framework-6d1abeb9fc1103af0a04dfd79d56b0f883de6f72.zip |
No inherited threadlocal
Fixes vaadin/framework8-issues#514
Diffstat (limited to 'uitest')
6 files changed, 6 insertions, 135 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/CurrentUiRetained.java b/uitest/src/main/java/com/vaadin/tests/components/ui/CurrentUiRetained.java deleted file mode 100644 index dcb1dcf577..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/CurrentUiRetained.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * 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 com.vaadin.tests.components.ui; - -import java.util.ArrayList; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.UI; -import com.vaadin.util.CurrentInstance; - -public class CurrentUiRetained extends AbstractTestUIWithLog { - public static class GcProbe { - - } - - @Override - protected void setup(VaadinRequest request) { - final ArrayList<UI> uiLog = new ArrayList<>(); - final ArrayList<Boolean> probeLog = new ArrayList<>(); - - final Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - uiLog.add(UI.getCurrent()); - - GcProbe gcProbe = new GcProbe(); - CurrentInstance.set(GcProbe.class, gcProbe); - probeLog.add(CurrentInstance.get(GcProbe.class) != null); - gcProbe = null; - - Thread.sleep(500l); - System.gc(); - Thread.sleep(500l); - - probeLog.add(CurrentInstance.get(GcProbe.class) != null); - uiLog.add(UI.getCurrent()); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - thread.start(); - - addComponent(new Button("Show result", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - try { - thread.join(); - - log("Correct UI.getCurrent before GC: " - + (uiLog.get(0) == CurrentUiRetained.this)); - log("Correct UI.getCurrent after GC: " - + (uiLog.get(1) == CurrentUiRetained.this)); - - log("GC probe available before GC: " + probeLog.get(0)); - log("GC probe available after GC: " + probeLog.get(1)); - - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - })); - } - - @Override - protected String getTestDescription() { - return "Tests that garbage collection removes stale CurrentInstance values while retaining values not collected."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(12509); - } - -} diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java index cdedb6235a..7cf6325e73 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccess.java @@ -257,7 +257,7 @@ public class UIAccess extends AbstractTestUIWithLog { public void buttonClick(ClickEvent event) { log.clear(); // accessSynchronously should maintain values - CurrentInstance.setInheritable( + CurrentInstance.set( CurrentInstanceTestType.class, new CurrentInstanceTestType( "Set before access")); @@ -269,13 +269,13 @@ public class UIAccess extends AbstractTestUIWithLog { log.log("Test value in access: " + CurrentInstance.get( CurrentInstanceTestType.class)); - CurrentInstance.setInheritable( + CurrentInstance.set( CurrentInstanceTestType.class, new CurrentInstanceTestType( "Set in access")); } }); - CurrentInstance.setInheritable( + CurrentInstance.set( CurrentInstanceTestType.class, new CurrentInstanceTestType( "Set before run pending")); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java index 2874074e67..5321827ed3 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java @@ -96,7 +96,7 @@ public class UIAccessExceptionHandling extends AbstractTestUIWithLog .getCurrent() == UIAccessExceptionHandling.this; Map<Class<?>, CurrentInstance> instances = CurrentInstance - .getInstances(false); + .getInstances(); CurrentInstance.clearAll(); assert UI.getCurrent() == null; diff --git a/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java b/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java index 9498413f9b..4600e89862 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java @@ -21,8 +21,8 @@ public class ThreadLocalInstancesTest extends MultiBrowserTest { assertLogText("8. this root in root init", 8); assertLogText("9. some app in root paint", 7); assertLogText("10. this root in root paint", 6); - assertLogText("11. some app in background thread", 5); - assertLogText("12. this root in background thread", 4); + assertLogText("11. null app in background thread", 5); + assertLogText("12. null root in background thread", 4); assertLogText("13. some app in resource handler", 3); assertLogText("14. this root in resource handler", 2); assertLogText("15. some app in button listener", 1); diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/CurrentUiRetainedTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/CurrentUiRetainedTest.java deleted file mode 100644 index d4e1ecb5ce..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/CurrentUiRetainedTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.vaadin.tests.components.ui; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class CurrentUiRetainedTest extends MultiBrowserTest { - @Test - public void testCurrentUiRetained() throws Exception { - openTestURL(); - $(ButtonElement.class).first().click(); - assertLogText(3, "1. Correct UI.getCurrent before GC: true"); - assertLogText(2, "2. Correct UI.getCurrent after GC: true"); - assertLogText(1, "3. GC probe available before GC: true"); - assertLogText(0, "4. GC probe available after GC: false"); - } - - private void assertLogText(int index, String expected) { - Assert.assertEquals("Unexpected log contents,", expected, - getLogRow(index)); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java index a421ab721b..d73696144d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java @@ -117,16 +117,4 @@ public class UIAccessTest extends MultiBrowserTest { "3. Test value after accessSynchornously: Set in accessSynchronosly")); } - @Test - public void currentInstanceCanAccessValue() { - $(ButtonElement.class).get(6).click(); - - assertTrue(logContainsText("0. access has request? false")); - assertTrue( - logContainsText("1. Test value in access: Set before access")); - assertTrue(logContainsText("2. has request after access? true")); - assertTrue(logContainsText( - "3. Test value after access: Set before run pending")); - } - } |