-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add runtime config info, fix arquillian injection
- Loading branch information
1 parent
aed298b
commit 841a2cc
Showing
12 changed files
with
153 additions
and
38 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
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
22 changes: 0 additions & 22 deletions
22
testing/src/main/java/org/seedstack/seed/it/internal/arquillian/SeedRemoteExtension.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
testing/src/main/java/org/seedstack/seed/it/internal/arquillian/WebITModule.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,17 @@ | ||
/* | ||
* Copyright © 2013-2017, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.seed.it.internal.arquillian; | ||
|
||
import com.google.inject.AbstractModule; | ||
|
||
class WebITModule extends AbstractModule { | ||
@Override | ||
protected void configure() { | ||
requestStaticInjection(InjectionTestEnricher.class); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
testing/src/main/java/org/seedstack/seed/it/internal/arquillian/WebITPlugin.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,22 @@ | ||
/* | ||
* Copyright © 2013-2017, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.seed.it.internal.arquillian; | ||
|
||
import org.seedstack.seed.core.internal.AbstractSeedPlugin; | ||
|
||
public class WebITPlugin extends AbstractSeedPlugin { | ||
@Override | ||
public String name() { | ||
return "web-testing"; | ||
} | ||
|
||
@Override | ||
public Object nativeUnitModule() { | ||
return new WebITModule(); | ||
} | ||
} |
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,52 @@ | ||
/* | ||
* Copyright © 2013-2017, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package org.seedstack.seed.web; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URL; | ||
import javax.inject.Inject; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.seedstack.seed.Configuration; | ||
import org.seedstack.seed.diagnostic.DiagnosticManager; | ||
import org.seedstack.seed.it.AbstractSeedWebIT; | ||
|
||
public class WebIT extends AbstractSeedWebIT { | ||
@Inject | ||
private DiagnosticManager diagnosticManager; | ||
@Configuration("web.runtime.servlet.contextPath") | ||
private String contextPath; | ||
@ArquillianResource | ||
private URL baseUrl; | ||
|
||
@Deployment | ||
public static WebArchive createDeployment() { | ||
return ShrinkWrap.create(WebArchive.class); | ||
} | ||
|
||
@Test | ||
@Ignore("remote injection not working, please fix if possible") | ||
public void testIsInjected() throws Exception { | ||
assertThat(diagnosticManager).isNotNull(); | ||
assertThat(diagnosticManager).isNotNull(); | ||
} | ||
|
||
@Test | ||
@RunAsClient | ||
public void testAsClientIsInjected() throws Exception { | ||
assertThat(diagnosticManager).isNotNull(); | ||
assertThat(baseUrl.toString()).endsWith(contextPath + "/"); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
web/core/src/main/java/org/seedstack/seed/web/internal/WebRuntimeConfigurationProvider.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,34 @@ | ||
/* | ||
* Copyright © 2013-2017, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.seed.web.internal; | ||
|
||
import javax.servlet.ServletContext; | ||
import org.seedstack.coffig.node.MapNode; | ||
import org.seedstack.coffig.node.NamedNode; | ||
import org.seedstack.coffig.spi.ConfigurationProvider; | ||
|
||
class WebRuntimeConfigurationProvider implements ConfigurationProvider { | ||
private final ServletContext servletContext; | ||
|
||
WebRuntimeConfigurationProvider(ServletContext servletContext) { | ||
this.servletContext = servletContext; | ||
} | ||
|
||
@Override | ||
public MapNode provide() { | ||
return new MapNode(new NamedNode("web", new MapNode( | ||
new NamedNode("runtime", new MapNode( | ||
new NamedNode("servlet", new MapNode( | ||
new NamedNode("contextPath", servletContext.getContextPath()), | ||
new NamedNode("serverInfo", servletContext.getServerInfo()), | ||
new NamedNode("virtualServerName", servletContext.getVirtualServerName()) | ||
)) | ||
)) | ||
))); | ||
} | ||
} |