Changeset 5745 for DASISH


Ignore:
Timestamp:
10/24/14 18:33:24 (10 years ago)
Author:
olhsha@mpi.nl
Message:

bug in AnnotationTest?: httpSevletRequest = null;

Location:
DASISH/t5.6/backend/annotator-backend/branches/Jersey-2.12-adaptation/annotator-backend
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/branches/Jersey-2.12-adaptation/annotator-backend/pom.xml

    r5739 r5745  
    2323            <groupId>javax.servlet</groupId>
    2424            <artifactId>javax.servlet-api</artifactId>
    25             <version>3.0.1</version>
    26             <scope>provided</scope>           
     25            <version>3.0.1</version>         
    2726        </dependency> 
    28         <dependency>
    29             <groupId>javax.servlet</groupId>
    30             <artifactId>servlet-api</artifactId>
    31             <version>2.5</version>
    32             <scope>provided</scope>
    33         </dependency> 
     27       
    3428 <!--      <dependency>
    3529            <groupId>javax.ws.rs</groupId>
     
    5751            <version>${jersey.version}</version>
    5852        </dependency>
    59          <dependency>
     53        <dependency>
     54            <groupId>org.glassfish.jersey.containers</groupId>
     55            <artifactId>jersey-container-grizzly2-servlet</artifactId>
     56            <version>${jersey.version}</version>
     57        </dependency>
     58 <!--       <dependency>
     59            <groupId>org.glassfish.jersey.containers</groupId>
     60            <artifactId>jersey-container-simple-http</artifactId>
     61            <version>${jersey.version}</version>
     62        </dependency>-->
     63<!--        <dependency>
    6064            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
    61             <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
    62             <version>${jersey.version}</version>
    63         </dependency>
     65            <artifactId>jersey-test-framework-provider-jdk-http</artifactId>
     66            <version>${jersey.version}</version>
     67        </dependency>-->
    6468        <dependency>
    6569            <groupId>org.glassfish.jersey.core</groupId>
     
    433437           
    434438    <properties>
    435         <jersey.version>2.12</jersey.version>
     439        <jersey.version>2.13</jersey.version>
    436440        <spring.version>3.2.0.RELEASE</spring.version>
    437441        <slf4j.version>1.7.5</slf4j.version>
  • DASISH/t5.6/backend/annotator-backend/branches/Jersey-2.12-adaptation/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java

    r5739 r5745  
    4141    @Autowired
    4242    protected DBDispatcher dbDispatcher;
     43   
    4344    @Context
    4445    protected HttpServletRequest httpServletRequest;
     
    5657
    5758    public Number getPrincipalID() throws IOException {
    58         dbDispatcher.setResourcesPaths(this.getRelativeServiceURI());
     59        String relativeServiceURI = this.getRelativeServiceURI();
     60        dbDispatcher.setResourcesPaths(relativeServiceURI);
    5961        String remotePrincipal = httpServletRequest.getRemoteUser();
    6062        if (remotePrincipal != null) {
  • DASISH/t5.6/backend/annotator-backend/branches/Jersey-2.12-adaptation/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r5739 r5745  
    2626import java.io.IOException;
    2727import java.net.URISyntaxException;
     28import java.util.Set;
     29import javax.ws.rs.client.Invocation;
    2830import javax.ws.rs.core.Application;
    2931import javax.ws.rs.core.HttpHeaders;
     
    3335import org.glassfish.jersey.server.spring.SpringLifecycleListener;
    3436import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
    35 import org.glassfish.jersey.test.TestProperties;
     37import org.glassfish.jersey.test.DeploymentContext;
     38import org.glassfish.jersey.test.ServletDeploymentContext;
    3639import org.junit.Test;
    3740import static org.junit.Assert.*;
     
    4548import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    4649import org.springframework.context.support.ClassPathXmlApplicationContext;
    47 
    4850/**
    4951 *
     
    5759    private JdbcTemplate jdbcTemplate;
    5860   
     61   
    5962    //String _relativePath = "/backend/api";
    6063   
    61    
     64    public AnnotationsTest() {
     65        super(new DasishTestContainerFactory());
     66    }
     67
    6268    @Override
    63     protected Application configure() {
    64        
    65       enable(TestProperties.LOG_TRAFFIC);
    66       enable(TestProperties.DUMP_ENTITY);
    67      
    68      
    69      
     69    protected DeploymentContext configureDeployment() {
    7070      ApplicationContext ctx = new ClassPathXmlApplicationContext(
    7171              "/spring-test-config/dataSource.xml",
    7272              "/spring-config/componentscan.xml",
    73               "/spring-config/dbDispatcher.xml",
     73              "/spring-config/dbDispatcher.xml", // passed; commenting it out gives compilation error
    7474              "/spring-config/principalDao.xml",
    7575              "/spring-config/annotationDao.xml",
     
    8080              "/spring-config/jaxbUnmarshallerFactory.xml");
    8181     
    82       return (new ResourceConfig())
    83                .register(AutheticationResource.class)
     82       //HttpServletRequest  mockHttpServletRequest = new MockHttpServletRequest();
     83       
     84     
     85       ResourceConfig rc = (new ResourceConfig())
     86               .register(AutheticationResource.class) // passed non-null (otherwise calling test will fends with 404
    8487               .register(AnnotationResource.class)
    8588               .register(DummySecurityFilter.class)
    8689               .register(SpringLifecycleListener.class)
    87                .register(RequestContextFilter.class)           
     90               .register(RequestContextFilter.class)
    8891               .property("contextConfig", ctx);
    89               // .property("contextPath", "/backend") //??
    90               // .property("servletPath", "/api"); //
    9192     
    9293                //.servletClass(SpringServlet.class)
     
    9798                //.contextPath("/backend").servletPath("/api")
    9899                //.build();
    99        
     100       
     101       
     102       Application app = rc.getApplication();
     103       org.glassfish.jersey.test.ServletDeploymentContext.Builder deploymentContextBuilder =
     104               ServletDeploymentContext.builder(app);
     105     
     106       return deploymentContextBuilder.build();
    100107    }
    101108   
     
    128135    public void testGetAnnotation() throws NotInDataBaseException, IOException {
    129136       
    130         //Response resTest = this.target("authentication/logintest").request().accept(MediaType.TEXT_HTML).get();
    131         //assertEquals(200, resTest.getStatus());
     137       
     138        // Authentication
     139        // httpServletRequest == null!!
    132140       
    133         // Authentication 
    134         Response response = getAuthenticatedResource().accept(MediaType.TEXT_HTML).get(); 
     141        Invocation request = this.target("authentication/login").request().accept(MediaType.TEXT_HTML).buildGet();
     142        Response response = request.invoke(); 
    135143        assertEquals(200, response.getStatus());
    136144//       
Note: See TracChangeset for help on using the changeset viewer.