Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start trying to get Weld to work with ContainerWrapper
- Loading branch information
Showing
13 changed files
with
147 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
fcrepo-http-commons/src/test/java/org/fcrepo/http/commons/IntegrationTestConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.fcrepo.http.commons; | ||
|
||
import javax.annotation.ManagedBean; | ||
|
||
@ManagedBean | ||
public class IntegrationTestConfig { | ||
|
||
private String location = "/web.xml"; | ||
private int port = 8080; | ||
|
||
public void setLocation(String location) { | ||
this.location = location; | ||
} | ||
|
||
public String getLocation() { | ||
return this.location; | ||
} | ||
|
||
public void setPort(int port) { | ||
this.port = port; | ||
} | ||
|
||
public int getPort() { | ||
return this.port; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
fcrepo-http-commons/src/test/java/org/fcrepo/http/commons/IntegrationTestConfigLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.fcrepo.http.commons; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
|
||
@Inherited | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE)public @interface IntegrationTestConfigLocation { | ||
|
||
String value()default "/web.xml"; | ||
} |
15 changes: 15 additions & 0 deletions
15
fcrepo-http-commons/src/test/java/org/fcrepo/http/commons/IntegrationTestPort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.fcrepo.http.commons; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
|
||
@Inherited | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE)public @interface IntegrationTestPort { | ||
|
||
int value() default 8090; | ||
} |
37 changes: 37 additions & 0 deletions
37
fcrepo-http-commons/src/test/java/org/fcrepo/http/commons/WeldJUnit4ClassRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.fcrepo.http.commons; | ||
|
||
import javax.enterprise.inject.spi.CDI; | ||
|
||
import org.fcrepo.http.commons.test.util.ContainerWrapper; | ||
import org.jboss.weld.Weld; | ||
import org.junit.runners.BlockJUnit4ClassRunner; | ||
import org.junit.runners.model.InitializationError; | ||
|
||
|
||
public class WeldJUnit4ClassRunner extends BlockJUnit4ClassRunner { | ||
private Class<?> klass; | ||
private Weld weld; | ||
private CDI<Object> container; | ||
|
||
public WeldJUnit4ClassRunner(Class<?> klass) throws InitializationError { | ||
super(klass); | ||
this.klass = klass; | ||
this.weld = new Weld(); | ||
IntegrationTestConfig config = weld.select(IntegrationTestConfig.class).get(); | ||
|
||
if (klass.isAnnotationPresent(IntegrationTestPort.class)) { | ||
config.setPort(klass.getAnnotation(IntegrationTestPort.class).value()); | ||
} | ||
if (klass.isAnnotationPresent(IntegrationTestConfigLocation.class)) { | ||
config.setLocation(klass.getAnnotation(IntegrationTestConfigLocation.class).value()); | ||
} | ||
ContainerWrapper cw = weld.select(ContainerWrapper.class).get(); | ||
} | ||
|
||
|
||
@Override | ||
protected Object createTest() throws Exception { | ||
return this.weld.select(this.klass).get(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters