-
Notifications
You must be signed in to change notification settings - Fork 9
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
376 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Wildfly | ||
|
||
- homepage: https://www.redhat.com/it/technologies/jboss-middleware/data-grid | ||
|
||
## Usage | ||
```java | ||
final JdgConfiguration conf = JdgConfiguration.builder().httpPort(11222).build(); | ||
|
||
try (Container cont = new JdgContainer<>(conf)) { | ||
cont.start() | ||
} | ||
``` | ||
|
||
## Compatibility | ||
- Jdg 8+ |
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,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>containers-parent</artifactId> | ||
<groupId>org.jboss.qa.jcontainer.containers</groupId> | ||
<version>1.3.2-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>jdg</artifactId> | ||
<name>JContainer Manager :: Containers :: JDG</name> | ||
<properties> | ||
<version.wildfly>2.0.5.Final</version.wildfly> | ||
<version.creaper>1.1.0</version.creaper> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-bom</artifactId> | ||
<version>12.1.0.CR2</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>${version.slf4j}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-client-hotrod</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
54 changes: 54 additions & 0 deletions
54
containers/jdg/src/main/java/org/jboss/qa/jcontainer/jdg/JdgClient.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,54 @@ | ||
/* | ||
* Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* 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.qa.jcontainer.jdg; | ||
|
||
import org.jboss.qa.jcontainer.Client; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class JdgClient<T extends JdgConfiguration> extends Client<T> { | ||
private static final String ERROR_MSG = "JDG container does not support client"; | ||
|
||
public JdgClient(T configuration) { | ||
super(configuration); | ||
} | ||
|
||
@Override | ||
public boolean isConnected() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void connectInternal() throws Exception { | ||
throw new UnsupportedOperationException(ERROR_MSG); | ||
} | ||
|
||
@Override | ||
protected void executeInternal(String command) throws Exception { | ||
throw new UnsupportedOperationException(ERROR_MSG); | ||
} | ||
|
||
@Override | ||
protected void executeInternal(List<String> commands) throws Exception { | ||
throw new UnsupportedOperationException(ERROR_MSG); | ||
} | ||
|
||
@Override | ||
protected void closeInternal() throws IOException { | ||
throw new UnsupportedOperationException(ERROR_MSG); | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
containers/jdg/src/main/java/org/jboss/qa/jcontainer/jdg/JdgConfiguration.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,95 @@ | ||
/* | ||
* Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* 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.qa.jcontainer.jdg; | ||
|
||
import org.apache.commons.lang3.SystemUtils; | ||
|
||
import org.jboss.qa.jcontainer.JavaConfiguration; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
|
||
public class JdgConfiguration extends JavaConfiguration { | ||
|
||
public static final int DEFAULT_HTTP_PORT = 11222; | ||
private static final String START_COMMAND = "server"; | ||
|
||
@Getter | ||
protected final int httpPort; | ||
|
||
public JdgConfiguration(Builder<?> builder) { | ||
super(builder); | ||
httpPort = builder.httpPort; | ||
} | ||
|
||
public static Builder<?> builder() { | ||
return new Builder2(); | ||
} | ||
|
||
@Override | ||
public int getBusyPort() { | ||
return httpPort; | ||
} | ||
|
||
@Override | ||
public List<String> generateCommand() { | ||
final List<String> cmd = new ArrayList<>(); | ||
if (SystemUtils.IS_OS_WINDOWS) { | ||
cmd.add("cmd"); | ||
cmd.add("/c"); | ||
cmd.add(new File(directory, "bin" + File.separator + START_COMMAND + ".bat").getAbsolutePath()); | ||
} else { | ||
cmd.add("bash"); | ||
cmd.add(new File(directory, "bin" + File.separator + START_COMMAND + ".sh").getAbsolutePath()); | ||
} | ||
return cmd; | ||
} | ||
|
||
public File getConfigurationFolder() { | ||
return new File(directory, "server" + File.separator + "conf"); | ||
} | ||
|
||
public abstract static class Builder<T extends Builder<T>> extends JavaConfiguration.Builder<T> { | ||
|
||
protected int httpPort; | ||
|
||
public Builder() { | ||
super(); | ||
httpPort(DEFAULT_HTTP_PORT); | ||
password(""); | ||
logFileName("server.log"); | ||
} | ||
|
||
public T httpPort(int httpPort) { | ||
this.httpPort = httpPort; | ||
return self(); | ||
} | ||
|
||
public JdgConfiguration build() { | ||
return new JdgConfiguration(this); | ||
} | ||
} | ||
|
||
private static class Builder2 extends Builder<Builder2> { | ||
@Override | ||
protected Builder2 self() { | ||
return this; | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
containers/jdg/src/main/java/org/jboss/qa/jcontainer/jdg/JdgContainer.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,53 @@ | ||
/* | ||
* Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* 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.qa.jcontainer.jdg; | ||
|
||
import org.apache.commons.configuration.PropertiesConfiguration; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import org.jboss.qa.jcontainer.AbstractContainer; | ||
|
||
import java.io.File; | ||
|
||
public class JdgContainer<T extends JdgConfiguration, U extends JdgClient<T>, V extends JdgUser> | ||
extends AbstractContainer<T, U, V> { | ||
public JdgContainer(T configuration) { | ||
super(configuration); | ||
} | ||
|
||
@Override | ||
protected String getBasicCommand() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected File getLogDirInternal() { | ||
return new File(configuration.getDirectory(), "server" + File.separator + "log"); | ||
} | ||
|
||
@Override | ||
public void addUser(V user) throws Exception { | ||
final File usersFile = new File(configuration.getConfigurationFolder(), "users.properties"); | ||
final File rolesFile = new File(configuration.getConfigurationFolder(), "groups.properties"); | ||
final PropertiesConfiguration propConfUsers = new PropertiesConfiguration(usersFile); | ||
propConfUsers.setProperty(user.getUsername(), user.getPassword()); | ||
propConfUsers.save(); | ||
|
||
final PropertiesConfiguration propConfRoles = new PropertiesConfiguration(rolesFile); | ||
propConfRoles.setProperty(user.getUsername(), StringUtils.join(user.getRoles(), ",")); | ||
propConfRoles.save(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
containers/jdg/src/main/java/org/jboss/qa/jcontainer/jdg/JdgUser.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,21 @@ | ||
/* | ||
* Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* 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.qa.jcontainer.jdg; | ||
|
||
import org.jboss.qa.jcontainer.User; | ||
|
||
public class JdgUser extends User { | ||
} |
79 changes: 79 additions & 0 deletions
79
containers/jdg/src/test/java/org/jboss/qa/jcontainer/jdg/test/JdgContainerTest.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,79 @@ | ||
/* | ||
* Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* 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.qa.jcontainer.jdg.test; | ||
|
||
import org.jboss.qa.jcontainer.AbstractContainer; | ||
import org.jboss.qa.jcontainer.jdg.JdgConfiguration; | ||
import org.jboss.qa.jcontainer.jdg.JdgContainer; | ||
import org.jboss.qa.jcontainer.jdg.JdgUser; | ||
import org.jboss.qa.jcontainer.test.ContainerTest; | ||
import org.jboss.qa.jcontainer.util.FileUtils; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RunWith(JUnit4.class) | ||
public class JdgContainerTest extends ContainerTest { | ||
public static final String JDG_HOME = "/home/federico/Downloads/redhat-datagrid-8.2.0-server"; //getProperty("jdg.home"); | ||
protected static AbstractContainer container; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
final JdgConfiguration conf = JdgConfiguration.builder().directory(JDG_HOME).build(); | ||
container = new JdgContainer(conf); | ||
final JdgUser user = new JdgUser(); | ||
user.setUsername("infinispanUsername"); | ||
user.setPassword("infinispanPassword"); | ||
user.addRoles("admin", "dev"); | ||
container.addUser(user); | ||
container.start(); | ||
|
||
System.out.println(container.isClientSupported()); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() throws Exception { | ||
if (container != null) { | ||
container.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void baseTest() throws Exception { | ||
Assert.assertTrue(container.isRunning()); | ||
} | ||
|
||
@Test | ||
public void defaultLogFileTest() throws Exception { | ||
Assert.assertTrue(container.getDefaultLogFile().exists()); | ||
log.debug("File '{}' - length = {}", container.getDefaultLogFile().getName(), container.getDefaultLogFile().length()); | ||
Assert.assertFalse(FileUtils.isEmpty(container.getDefaultLogFile())); | ||
} | ||
|
||
@Test | ||
public void stdoutLogFileTest() throws Exception { | ||
Assert.assertTrue(container.getStdoutLogFile().exists()); | ||
log.debug("File '{}' - length = {}", container.getStdoutLogFile().getName(), container.getStdoutLogFile().length()); | ||
Assert.assertFalse(FileUtils.isEmpty(container.getStdoutLogFile())); | ||
} | ||
} |
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