Skip to content

Commit

Permalink
chore: update Flow version and fix unit test (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis committed Mar 17, 2021
1 parent b2c48f6 commit aad397c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>vaadin-cdi-parent</artifactId>
<version>11.2-SNAPSHOT</version>
<version>11.3-SNAPSHOT</version>
<packaging>pom</packaging>

<name>vaadin-cdi-parent</name>
Expand Down Expand Up @@ -45,7 +45,7 @@
<driver.binary.downloader.maven.plugin.version>1.0.14
</driver.binary.downloader.maven.plugin.version>

<vaadin.flow.version>2.2-SNAPSHOT</vaadin.flow.version>
<vaadin.flow.version>2.6-SNAPSHOT</vaadin.flow.version>
<slf4j.version>1.7.25</slf4j.version>
<deltaspike.version>1.8.1</deltaspike.version>
<owb.version>1.7.5</owb.version>
Expand Down
2 changes: 1 addition & 1 deletion vaadin-cdi-itest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-cdi-parent</artifactId>
<version>11.2-SNAPSHOT</version>
<version>11.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion vaadin-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-cdi-parent</artifactId>
<version>11.2-SNAPSHOT</version>
<version>11.3-SNAPSHOT</version>
</parent>

<artifactId>vaadin-cdi</artifactId>
Expand Down
42 changes: 30 additions & 12 deletions vaadin-cdi/src/test/java/com/vaadin/cdi/CdiVaadinServletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

package com.vaadin.cdi;

import com.vaadin.cdi.context.ServiceUnderTestContext;
import com.vaadin.flow.server.VaadinServletService;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import java.io.IOException;
import java.util.Collections;

import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
Expand All @@ -26,12 +33,10 @@
import org.junit.runner.RunWith;
import org.mockito.Mockito;

import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Collections;
import com.vaadin.cdi.context.ServiceUnderTestContext;
import com.vaadin.flow.di.Lookup;
import com.vaadin.flow.di.ResourceProvider;
import com.vaadin.flow.server.VaadinServletService;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
Expand All @@ -45,19 +50,32 @@ public class CdiVaadinServletTest {
private CdiVaadinServlet servlet;

@Before
public void setUp() throws ServletException {
public void setUp() throws ServletException, IOException {
final ServletConfig servletConfig = Mockito.mock(ServletConfig.class);
final ServletContext servletContext = Mockito.mock(ServletContext.class);
final ServletContext servletContext = Mockito
.mock(ServletContext.class);
Mockito.when(servletConfig.getInitParameterNames())
.thenReturn(Collections.emptyEnumeration());
Mockito.when(servletConfig.getServletContext())
.thenReturn(servletContext);
Mockito.when(servletConfig.getServletName())
.thenReturn("test");
Mockito.when(servletConfig.getServletName()).thenReturn("test");
Mockito.when(servletContext.getInitParameterNames())
.thenReturn(Collections.emptyEnumeration());
servlet = new CdiVaadinServlet();
BeanProvider.injectFields(servlet);

Lookup lookup = Mockito.mock(Lookup.class);
Mockito.when(servletContext.getAttribute(Lookup.class.getName()))
.thenReturn(lookup);
ResourceProvider provider = Mockito.mock(ResourceProvider.class);
Mockito.doAnswer(invocation -> {
return Collections.singletonList(
CdiVaadinServletTest.class.getClassLoader().getResource(
invocation.getArgumentAt(1, String.class)));
}).when(provider).getApplicationResources(Mockito.any(), Mockito.any());
Mockito.when(lookup.lookup(ResourceProvider.class))
.thenReturn(provider);

servlet.init(servletConfig);
}

Expand Down

0 comments on commit aad397c

Please sign in to comment.