You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by sc...@apache.org on 2014/10/14 22:06:26 UTC
svn commit: r1631867 -
/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java
Author: sclassen
Date: Tue Oct 14 20:06:26 2014
New Revision: 1631867
URL: http://svn.apache.org/r1631867
Log:
ONAMI-115: unit test to ensure PersistenceFilter is bound as singleton
Added:
onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java (with props)
Added: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java?rev=1631867&view=auto
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java (added)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java Tue Oct 14 20:06:26 2014
@@ -0,0 +1,70 @@
+package org.apache.onami.persist.test;
+
+/*
+ * 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.
+ */
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Scopes;
+import org.apache.onami.persist.PersistenceFilter;
+import org.apache.onami.persist.PersistenceModule;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test which ensures that the @{link PersistenceFilter} fulfills the requirements of a guice servlet filter.
+ */
+public class PersistenceServletFilterTest
+{
+ private Injector injector;
+
+ @Before
+ public void setUp()
+ {
+ final PersistenceModule pm = createPersistenceModuleForTest();
+ injector = Guice.createInjector( pm );
+ }
+
+ private PersistenceModule createPersistenceModuleForTest()
+ {
+ return new PersistenceModule()
+ {
+
+ @Override
+ protected void configurePersistence()
+ {
+ bindApplicationManagedPersistenceUnit( "firstUnit" );
+ }
+ };
+ }
+
+ @Test
+ public void persistenceFilterShouldBeSingleton()
+ {
+ assertThat( isSingleton( PersistenceFilter.class ), is( true ) );
+ }
+
+ private boolean isSingleton( Class<?> type )
+ {
+ return Scopes.isSingleton( injector.getBinding( type ) );
+ }
+}
Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/PersistenceServletFilterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain