-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[312] Add ParameterResolver which allows Arquillian to provide parame…
…ters. The parameters are resolved from TestEnrichers. Signed-off-by: James R. Perkins <[email protected]>
- Loading branch information
Showing
12 changed files
with
418 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,29 @@ | |
|
||
package org.jboss.arquillian.integration.test.resource.injection; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Path; | ||
|
||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.integration.test.common.TestEnvironment; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
@RunAsClient | ||
public class ClientArquillianResourceTest extends AbstractArquillianResourceTest { | ||
|
||
@Test | ||
public void checkMultipleParameters(@ArquillianResource final URL url, @TempDir final Path tempDir) { | ||
Assertions.assertNotNull(url, "The URL should have been injected"); | ||
Assertions.assertEquals(TestEnvironment.protocol(), url.getProtocol()); | ||
checkHost(url.getHost()); | ||
Assertions.assertEquals(TestEnvironment.port(), url.getPort()); | ||
Assertions.assertEquals("/" + DEPLOYMENT_NAME + "/", url.getPath()); | ||
Assertions.assertNotNull(tempDir, "The temp dir should have been injected"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,13 +19,17 @@ | |
|
||
package org.jboss.arquillian.integration.test.resource.injection; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import javax.naming.Context; | ||
import javax.naming.InitialContext; | ||
|
||
import org.jboss.arquillian.integration.test.common.TestEnvironment; | ||
import org.jboss.arquillian.junit5.annotations.Vetoed; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
|
@@ -46,7 +50,6 @@ public void checkContext() throws Exception { | |
} | ||
|
||
@Test | ||
@Disabled("https://github.com/arquillian/arquillian-core/issues/312") | ||
public void checkContextParameter(@ArquillianResource final Context context) throws Exception { | ||
Assertions.assertNotNull(context, "The Context should have been injected"); | ||
final Object bm = context.lookup("java:comp/BeanManager"); | ||
|
@@ -61,10 +64,19 @@ public void checkInitialContext() throws Exception { | |
} | ||
|
||
@Test | ||
@Disabled("https://github.com/arquillian/arquillian-core/issues/312") | ||
public void checkInitialContextParameter(@ArquillianResource final InitialContext initialContext) throws Exception { | ||
Assertions.assertNotNull(initialContext, "The InitialContext should have been injected"); | ||
final Object bm = initialContext.lookup("java:comp/BeanManager"); | ||
Assertions.assertNotNull(bm); | ||
} | ||
|
||
@Test | ||
public void checkMultipleParameters(@ArquillianResource final URL url, @Vetoed @TempDir final Path tempDir) { | ||
Assertions.assertNotNull(url, "The URL should have been injected"); | ||
Assertions.assertEquals(TestEnvironment.protocol(), url.getProtocol()); | ||
checkHost(url.getHost()); | ||
Assertions.assertEquals(TestEnvironment.port(), url.getPort()); | ||
Assertions.assertEquals("/" + DEPLOYMENT_NAME + "/", url.getPath()); | ||
Assertions.assertNotNull(tempDir, "The temp dir should have been injected"); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...iner/src/main/java/org/jboss/arquillian/junit5/container/JUnitJupiterRemoteExtension.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 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* | ||
* Copyright 2024 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.arquillian.junit5.container; | ||
|
||
import org.jboss.arquillian.container.test.spi.RemoteLoadableExtension; | ||
import org.jboss.arquillian.core.spi.LoadableExtension; | ||
import org.jboss.arquillian.junit5.MethodParameterObserver; | ||
|
||
/** | ||
* The remote extension for JUnit 5 in-container tests. | ||
* | ||
* @author <a href="mailto:[email protected]">James R. Perkins</a> | ||
*/ | ||
public class JUnitJupiterRemoteExtension implements RemoteLoadableExtension { | ||
|
||
@Override | ||
public void register(LoadableExtension.ExtensionBuilder builder) { | ||
builder.observer(MethodParameterObserver.class); | ||
} | ||
} |
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
Oops, something went wrong.