-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
326 additions
and
23 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
151 changes: 151 additions & 0 deletions
151
.../test/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerConfigurationTest.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,151 @@ | ||
/* | ||
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.arquillian.managed; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* The JUnit tests for the ManagedPiranhaContainerConfiguration class. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
class ManagedPiranhaContainerConfigurationTest { | ||
|
||
@Test | ||
void testGetHttpPortDefault() { | ||
System.clearProperty("piranha.httpPort"); | ||
ManagedPiranhaContainerConfiguration configuration = new ManagedPiranhaContainerConfiguration(); | ||
int port = configuration.getHttpPort(); | ||
assertTrue(port > 0, "The port should be a positive integer"); | ||
System.clearProperty("piranha.httpPort"); | ||
} | ||
|
||
@Test | ||
void testGetHttpPortSet() { | ||
System.setProperty("piranha.httpPort", "8080"); | ||
ManagedPiranhaContainerConfiguration configuration = new ManagedPiranhaContainerConfiguration(); | ||
int port = configuration.getHttpPort(); | ||
assertEquals(8080, port, "The port should be 8080"); | ||
System.clearProperty("piranha.httpPort"); | ||
} | ||
|
||
@Test | ||
void testGetHttpPortInvalid() { | ||
System.setProperty("piranha.httpPort", "invalid"); | ||
assertThrows(NumberFormatException.class, () -> { | ||
ManagedPiranhaContainerConfiguration configuration = new ManagedPiranhaContainerConfiguration(); | ||
configuration.getHttpPort(); | ||
}, "A NumberFormatException should be thrown for invalid port"); | ||
System.clearProperty("piranha.httpPort"); | ||
} | ||
|
||
@Test | ||
void testGetDistribution() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertEquals("coreprofile", config.getDistribution()); | ||
} | ||
|
||
@Test | ||
void testSetDistribution() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setDistribution("webprofile"); | ||
assertEquals("webprofile", config.getDistribution()); | ||
} | ||
|
||
@Test | ||
void testGetHttpPort() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertTrue(config.getHttpPort() > 0); | ||
} | ||
|
||
@Test | ||
void testSetHttpPort() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setHttpPort(8080); | ||
assertEquals(8080, config.getHttpPort()); | ||
} | ||
|
||
@Test | ||
void testGetJvmArguments() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertEquals("", config.getJvmArguments()); | ||
} | ||
|
||
@Test | ||
void testSetJvmArguments() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setJvmArguments("-Xmx512m"); | ||
assertEquals("-Xmx512m", config.getJvmArguments()); | ||
} | ||
|
||
@Test | ||
void testGetProtocol() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertEquals("Servlet 6.0", config.getProtocol()); | ||
} | ||
|
||
@Test | ||
void testSetProtocol() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setProtocol("Servlet 5.0"); | ||
assertEquals("Servlet 5.0", config.getProtocol()); | ||
} | ||
|
||
@Test | ||
void testIsDebug() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertFalse(config.isDebug()); | ||
} | ||
|
||
@Test | ||
void testSetDebug() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setDebug(true); | ||
assertTrue(config.isDebug()); | ||
} | ||
|
||
@Test | ||
void testIsSuspend() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertFalse(config.isSuspend()); | ||
} | ||
|
||
@Test | ||
void testSetSuspend() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
config.setSuspend(true); | ||
assertTrue(config.isSuspend()); | ||
} | ||
|
||
@Test | ||
void testValidate() { | ||
ManagedPiranhaContainerConfiguration config = new ManagedPiranhaContainerConfiguration(); | ||
assertDoesNotThrow(config::validate); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
.../src/test/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerExtensionTest.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,69 @@ | ||
/* | ||
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.arquillian.managed; | ||
|
||
import org.jboss.arquillian.core.spi.LoadableExtension.ExtensionBuilder; | ||
import org.jboss.arquillian.core.spi.context.Context; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* The JUnit tests for the ManagedPiranhaContainerExtension class. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
class ManagedPiranhaContainerExtensionTest { | ||
|
||
@Test | ||
void testRegister() { | ||
ExtensionBuilder extensionBuilder = new ExtensionBuilder() { | ||
|
||
@Override | ||
public <T> ExtensionBuilder service(Class<T> service, Class<? extends T> impl) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public <T> ExtensionBuilder override(Class<T> service, Class<? extends T> oldServiceImpl, | ||
Class<? extends T> newServiceImpl) { | ||
throw new UnsupportedOperationException("Unimplemented method 'override'"); | ||
} | ||
|
||
@Override | ||
public ExtensionBuilder observer(Class<?> handler) { | ||
throw new UnsupportedOperationException("Unimplemented method 'observer'"); | ||
} | ||
|
||
@Override | ||
public ExtensionBuilder context(Class<? extends Context> context) { | ||
throw new UnsupportedOperationException("Unimplemented method 'context'"); | ||
} | ||
}; | ||
ManagedPiranhaContainerExtension extension = new ManagedPiranhaContainerExtension(); | ||
extension.register(extensionBuilder); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...n/managed/src/test/java/cloud/piranha/arquillian/managed/ManagedPiranhaContainerTest.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,40 @@ | ||
package cloud.piranha.arquillian.managed; | ||
|
||
import java.io.File; | ||
import org.jboss.arquillian.container.spi.client.container.DeploymentException; | ||
import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* The JUnit tests for the ManagedPiranhaContainer class. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
class ManagedPiranhaContainerTest { | ||
|
||
/** | ||
* Test getContainerConfiguration method. | ||
*/ | ||
@Test | ||
void testGetConfigurationClass() { | ||
ManagedPiranhaContainer container = new ManagedPiranhaContainer(); | ||
assertEquals(ManagedPiranhaContainerConfiguration.class, container.getConfigurationClass()); | ||
} | ||
|
||
/** | ||
* TEst getDefaulProtocol method. | ||
*/ | ||
@Test | ||
void testGetDefaultProtocol() { | ||
ManagedPiranhaContainer container = new ManagedPiranhaContainer(); | ||
container.setup(new ManagedPiranhaContainerConfiguration()); | ||
ProtocolDescription protocolDescription = container.getDefaultProtocol(); | ||
assertEquals("Servlet 6.0", protocolDescription.getName()); | ||
} | ||
} |
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" | ||
version="6.0"> | ||
</web-app> |
Oops, something went wrong.