Commits

kubek2k committed bf72e92

Reverted multithread support from the tip

Comments (0)

Files changed (10)

 .*\.project
 .*\.classpath
 .*\.settings
-.*\.iml
 fe3799187fe9f59eb3e6de4261b847a5d55b00e5 springockito-parent-1.0.3
 c2374d14a4e3a064e8b762a16e403e25aa0d820a springockito-1.0.4
 62fc12c9d9baa288dcbf4b725ef2e39116a8d0d3 springockito-annotations-1.0.2
-79a02fe5deac5f401cfebf744ed04467bb6690ae Multithread support

springockito-annotations/pom.xml

 
     <dependencies>
         <dependency>
-            <groupId>org.kubek2k</groupId>
-            <artifactId>springockito-commons</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
         </dependency>
-        
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>

springockito-annotations/src/main/java/org/kubek2k/springockito/annotations/MockitoBeansDefiner.java

 package org.kubek2k.springockito.annotations;
 
-import org.kubek2k.mockito.spring.factory.MockFactoryBean;
+import org.kubek2k.springockito.annotations.factory.MockFactoryBean;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 

springockito-annotations/src/main/java/org/kubek2k/springockito/annotations/ReplaceWithMock.java

 package org.kubek2k.springockito.annotations;
 
-import org.mockito.Answers;
-import org.mockito.stubbing.Answer;
-
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.FIELD)
 public @interface ReplaceWithMock {
-    Class [] extraInterfaces();
-
-    Answers defaultAnswer();
 }

springockito-commons/pom.xml

-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <artifactId>springockito-parent</artifactId>
-        <groupId>org.kubek2k</groupId>
-        <version>1.0.4-SNAPSHOT</version>
-    </parent>
-    <groupId>org.kubek2k</groupId>
-    <artifactId>springockito-commons</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
-    <description>Common part of springockito projects</description>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
-    </dependencies>
-</project>

springockito-commons/src/main/java/org/kubek2k/mockito/spring/factory/MockFactoryBean.java

-package org.kubek2k.mockito.spring.factory;
-
-import org.mockito.Answers;
-import org.mockito.MockSettings;
-import org.mockito.Mockito;
-import org.mockito.internal.creation.MockSettingsImpl;
-import org.mockito.internal.creation.jmock.ClassImposterizer;
-import org.springframework.beans.factory.FactoryBean;
-
-
-public class MockFactoryBean<T> implements FactoryBean<T> {
-
-    private Class<T> mockClass;
-    private final Class[] extraInterfaces;
-    private final String mockName;
-    private final Answers defaultAnswer;
-    private T instance;
-
-    public MockFactoryBean(Class<T> mockClass, Class[] extraInterfaces, String mockName, Answers defaultAnswer) {
-        this.mockClass = mockClass;
-        this.extraInterfaces = extraInterfaces;
-        this.mockName = mockName;
-        this.defaultAnswer = defaultAnswer;
-    }
-
-    public Class<? extends T> getObjectType() {
-        return mockClass;
-    }
-
-    public boolean isSingleton() {
-        return true;
-    }
-
-    public T getObject() throws Exception {
-        if (instance == null) {
-            instance = ClassImposterizer.INSTANCE.imposterise(new ThreadLocalMockMethodInterceptor<T>(mockClass),
-                    mockClass, new Class[0]);
-        }
-        return instance;
-    }
-
-    protected T createInstance(Class<T> mockClass) {
-        MockSettings settings = new MockSettingsImpl().extraInterfaces(extraInterfaces).defaultAnswer(
-                defaultAnswer.get()).name(mockName);
-        return Mockito.mock(mockClass, settings);
-    }
-
-}

springockito-commons/src/main/java/org/kubek2k/mockito/spring/factory/ThreadLocalMockMethodInterceptor.java

-package org.kubek2k.mockito.spring.factory;
-
-import java.lang.reflect.Method;
-
-import org.mockito.Mockito;
-import org.mockito.cglib.proxy.MethodInterceptor;
-import org.mockito.cglib.proxy.MethodProxy;
-import org.mockito.internal.MockitoInvocationHandler;
-import org.mockito.internal.creation.MethodInterceptorFilter;
-import org.mockito.internal.util.MockUtil;
-
-public class ThreadLocalMockMethodInterceptor<T> extends MethodInterceptorFilter implements MethodInterceptor {
-
-    private static final long serialVersionUID = -531647342545593891L;
-    private InheritableThreadLocal<T> mockLocalForCurrentThread;
-    private Class<T> mockClass;
-    private static final MockUtil MOCK_UTIL = new MockUtil();
-    
-    public ThreadLocalMockMethodInterceptor(Class<T> mockClass) {
-        super(null, null);
-        this.mockClass = mockClass;
-        mockLocalForCurrentThread = new InheritableThreadLocal<T>();
-    }
-
-    private T getOrCreateMockForCurrentThread() {
-        T threadLocalInstance = mockLocalForCurrentThread.get();
-        if (threadLocalInstance == null) {
-            threadLocalInstance = createMock();
-            mockLocalForCurrentThread.set(threadLocalInstance);
-        }
-        return threadLocalInstance;
-    }
-
-    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
-        return method.invoke(getOrCreateMockForCurrentThread(), args);
-    }
-
-
-    private T createMock() {
-        return Mockito.mock(mockClass);
-    }
-    
-    @Override
-    public MockitoInvocationHandler getHandler() {
-        return (MockitoInvocationHandler) MOCK_UTIL.getMockHandler(getOrCreateMockForCurrentThread());
-    }
-}

springockito-parent/pom.xml

         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>${spring.version}</version>
+        <scope>provided</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-expression</artifactId>
         <version>${spring.version}</version>
+        <scope>provided</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-beans</artifactId>
         <version>${spring.version}</version>
+        <scope>provided</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${spring.version}</version>
+        <scope>provided</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-test</artifactId>
         <version>${spring.version}</version>
+        <scope>provided</scope>
       </dependency>
 
       <dependency>

springockito/pom.xml

 
     <dependencies>
         <dependency>
-            <groupId>org.kubek2k</groupId>
-            <artifactId>springockito-commons</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <groupId>org.springframework</groupId>
             <artifactId>spring-beans</artifactId>
         </dependency>
-        
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.