You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/07/02 10:40:42 UTC

git commit: WICKET-5625 Setting custom IResourceSettings is not possible in WebApplication#init()

Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x 8b6b2ca6e -> 35f2003a4


WICKET-5625 Setting custom IResourceSettings is not possible in WebApplication#init()

Add a unit test verifying that it is possible to set custom IResourceSettings in MyApp#init() method


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/35f2003a
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/35f2003a
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/35f2003a

Branch: refs/heads/wicket-6.x
Commit: 35f2003a456fb0fcd6f62b586565efafa4f3e111
Parents: 8b6b2ca
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Jul 2 11:39:46 2014 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Jul 2 11:39:46 2014 +0300

----------------------------------------------------------------------
 .../def/SetCustomResourceSettingsTest.java      | 67 ++++++++++++++++++++
 1 file changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/35f2003a/wicket-core/src/test/java/org/apache/wicket/settings/def/SetCustomResourceSettingsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/settings/def/SetCustomResourceSettingsTest.java b/wicket-core/src/test/java/org/apache/wicket/settings/def/SetCustomResourceSettingsTest.java
new file mode 100644
index 0000000..f9b6fa2
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/settings/def/SetCustomResourceSettingsTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.settings.def;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.settings.IResourceSettings;
+import org.apache.wicket.util.time.Duration;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for https://issues.apache.org/jira/browse/WICKET-5625
+ */
+public class SetCustomResourceSettingsTest extends WicketTestCase
+{
+	final Duration expected = Duration.days(3);
+	IResourceSettings resSettings;
+
+	@Override
+	@Before
+	public void commonBefore() {
+		resSettings = mock(IResourceSettings.class);
+		when(resSettings.getDefaultCacheDuration()).thenReturn(expected);
+
+		super.commonBefore();
+	}
+
+	@Test
+	public void check() {
+		IResourceSettings settings = tester.getApplication().getResourceSettings();
+		assertThat(settings.getDefaultCacheDuration(), is(equalTo(expected)));
+	}
+
+	@Override
+	protected WebApplication newApplication()
+	{
+		return new MockApplication() {
+			@Override
+			protected void init()
+			{
+				super.init();
+				setResourceSettings(resSettings);
+			}
+		};
+	}
+}