2013-06-28 2 views
0

내가 Gradle을을 사용하여 부두에 셀레늄 테스트를 실행하려고에 출시되지 않고 내 Gradle을 구성은 다음과 같다 :WebApplicationInitializer는 부두 + 셀레늄

gradle.build :

apply plugin: 'java' 
apply plugin: 'eclipse-wtp' 
apply plugin: 'war' 
apply plugin: 'findbugs' 
//apply from:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle' 
apply from: 'emma.gradle' 
apply plugin: 'jetty' 

sourceCompatibility = 1.7 
version = '' 

sourceSets { 
    selenium 
} 

buildscript { 
    repositories { 
     mavenCentral() 
    } 

    dependencies { 
     classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6' 
    } 
} 

repositories { 
    mavenCentral() 
    mavenRepo url: 'http://repository.primefaces.org' 
    mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public' 
    mavenRepo url: 'http://repository.jboss.org/maven2' 
    mavenRepo url: 'http://maven.springframework.org/release' 
    mavenRepo url: 'http://repo1.maven.org/maven2' 
    mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty' 
} 

dependencies { 
    //JSF 
    compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22' 
    compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22' 
    compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final' 
    compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final' 
    compile 'javax.el:el-api:2.2' 
    runtime 'org.glassfish.web:el-impl:2.2' 


    //Servlet 
    compile group: 'javax.servlet', name: 'jstl', version: '1.2' 
    providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final' 
    compile 'taglibs:standard:1.1.2' 
    compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE' 

    //Omnifaces 
    compile 'org.omnifaces:omnifaces:1.5' 

    //Prime Faces 
    compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT' 
    compile 'org.primefaces.themes:bootstrap:1.0.10' 

    // DB 
    compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE' 
    compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE' 
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9' 

    compile group: 'javax.inject', name: 'javax.inject', version: '1' 
    compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4' 
    compile 'cglib:cglib-nodep:2.2.2' 

    //Hibernate/JPA 
    compile 'org.hibernate:hibernate-core:4.1.0.Final' 
    compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final' 
    compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final' 
    //JSR-303 
    compile 'org.hibernate:hibernate-validator:4.3.1.Final' 

    // Spring Security 
    compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE' 
    compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE' 
    compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE' 

    //Utility 
    compile 'com.google.guava:guava:14.0.1' 
    compile 'commons-lang:commons-lang:2.6' 
    compile 'org.apache.commons:commons-email:1.3.1' 
    compile 'com.typesafe:config:1.0.0' 
    compile 'joda-time:joda-time:2.2' 
    compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3' 
    compile 'org.slf4j:slf4j-api:1.7.2' 
    compile 'org.slf4j:jcl-over-slf4j:1.7.2' 
    compile 'org.slf4j:slf4j-log4j12:1.7.2' 


    //Mustache Templates 
    compile 'com.github.jknack:handlebars:1.0.0' 

    //Projects 
    //compile project(":ExtraValidators") 

    ////TESTING DEPENDENCIES 
    testCompile 'com.googlecode.jmockit:jmockit:1.2' 
    testCompile group: 'junit', name: 'junit', version: '4.11' 
    testCompile 'com.h2database:h2:1.3.172' 

    //Spring Testing 
    testCompile 'org.springframework:spring-test:3.2.3.RELEASE' 

    /* Selenium */ 
    seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0' 
    seleniumCompile 'junit:junit:4.11' 
} 

task wrapper(type: Wrapper){ 
    gradleVersion = '1.5' 
} 

eclipse { 
    classpath { 
     downloadSources=true 
     plusConfigurations += configurations.seleniumCompile 
    } 
} 


task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) { 
    daemon = true 
} 

task selenium(type: Test, dependsOn: jettyDaemon) { 
    testClassesDir = sourceSets.selenium.output.classesDir 
    classpath = sourceSets.selenium.runtimeClasspath 
} 

WebApplicationInitializer :

package com.myapp.web.config; 

import javax.faces.application.ProjectStage; 
import javax.servlet.FilterRegistration; 
import javax.servlet.ServletContext; 
import javax.servlet.ServletException; 

import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import org.springframework.core.env.ConfigurableEnvironment; 
import org.springframework.web.WebApplicationInitializer; 
import org.springframework.web.context.ContextLoader; 
import org.springframework.web.context.request.RequestContextListener; 
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; 
import org.springframework.web.filter.DelegatingFilterProxy; 

import com.myapp.data.config.SpringConfig; 
import com.myapp.data.config.SpringJNDIDataConfig; 
import com.myapp.data.config.SpringJNDIJPAConfig; 
import com.myapp.data.config.SpringSecurityConfig; 
import com.myapp.data.config.SpringWebConfig; 
import com.myapp.utils.configuration.ConfigurationUtil; 

public class WebappConfig implements WebApplicationInitializer { 

    protected final Logger logger = LoggerFactory.getLogger(getClass()); 

    @Override 
    public void onStartup(final ServletContext servletContext) throws ServletException { 



     if(logger.isDebugEnabled()) { 
     logger.debug("Starting web context configuration"); 
     } 

     AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); 
     // rootContext.getEnvironment().setActiveProfiles("production"); 
     rootContext.register(SpringConfig.class, SpringSecurityConfig.class, SpringWebConfig.class, SpringJNDIDataConfig.class, SpringJNDIJPAConfig.class); 

     servletContext.addListener(RequestContextListener.class); 

     new ContextLoader(rootContext).initWebApplicationContext(servletContext); 

     addFilters(servletContext, rootContext.getEnvironment()); 

     servletContext.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ConfigurationUtil.config().getString("jsf.stage")); 
     servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", ConfigurationUtil.config().getString("jsf.refreshPeriod")); 
    } 

    private void addFilters(final ServletContext servletContext, final ConfigurableEnvironment configurableEnvironment) { 
     FilterRegistration.Dynamic securityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")); 
     securityFilter.addMappingForUrlPatterns(null, false, "/*"); 
    } 

} 

WebApplicationInitializer를 실행하는 방법을 알려주세요. wh 부두에서 셀레늄 테스트를하고 있니?

+0

부두는 'No WebApplicationInitializer was found'를 기록합니까? –

+0

@Sotirios Delimanolis 그것에 대해 전혀 아무 것도 기록하지 않습니다. WebApplicationInitializer를 수동으로로드하는 구성이 누락되었다고 생각합니다. –

+0

@Peter Niederwieser,이 문제가 부두 버전과 관련된 경우 아이디어가 있습니까? –

답변

1

WebApplicationInitializer에는 Servlet 3 컨테이너가 필요합니다. 그러나 Gradle의 Jetty 플러그인은 Servlet 2.5 만 지원하는 Jetty 6을 기반으로합니다.

  • 가 Gradle을 가진 새로운 부두 버전을 사용하는 대신 WebApplicationInitializer
  • web.xml 파일을 사용하여 응용 프로그램을 구성합니다

    당신은 몇 가지 옵션이 있습니다. GRADLE-1956
  • 의 코멘트에 몇 가지 해결 방법은 톰캣 (gradle-tomcat-plugin)
  • 사용과 같은 다른 컨테이너 gradle-cargo-plugin 또는 arquillian-gradle-plugin 같은 다른 플러그인을 사용하여 있습니다. AFAIK에는 Arquillian에 기반해야하는 새로운 gradle 배포 플러그인이 있습니다.
+0

나는 리모트 jboss와 함께 gradle을 사용했고, 여기에 해결책을 올렸다 : http : //stackoverflow.com/questions/17389293/how-to-configure-selenium-tests-with-gradle –