├── .gitignore ├── .travis.yml ├── README.md ├── example ├── pom.xml └── src │ └── test │ └── java │ └── ru │ └── trylogic │ └── maven │ └── plugins │ └── redis │ └── example │ └── tests │ └── ConnectionTest.java ├── pom.xml └── src ├── main └── java │ └── ru │ └── trylogic │ └── maven │ └── plugins │ └── redis │ ├── RunRedisMojo.java │ ├── ShutdownRedisMojo.java │ └── StartRedisMojo.java └── test ├── java └── ru │ └── trylogic │ └── maven │ └── plugins │ └── redis │ └── tests │ ├── AbstractRedisMojoTest.java │ ├── RunForkedRedisMojoTest.java │ ├── RunRedisMojoTest.java │ └── StartRedisMojoTest.java └── resources └── unit └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | .idea 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | target/ 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | redis-maven-plugin [![Build Status](https://travis-ci.org/bsideup/redis-maven-plugin.png)](https://travis-ci.org/bsideup/redis-maven-plugin) 2 | ================== 3 | 4 | Embedded pure Java redis server for Maven 3. Based on great https://github.com/spullara/redis-protocol. 5 | 6 | 7 | Basic example 8 | ----------------- 9 | 10 | add plugin to your pom: 11 | ```xml 12 | 13 | ru.trylogic.maven.plugins 14 | redis-maven-plugin 15 | 1.4.6 16 | 17 | ``` 18 | 19 | run ```mvn redis:run``` 20 | 21 | Is you see this message you are ready to go: ```[INFO] Starting Redis(forked=false) server...``` 22 | 23 | 24 | Integration tests example 25 | ----------------- 26 | 27 | (This example also available here: https://github.com/bsideup/redis-maven-plugin/tree/master/example ) 28 | 29 | Configure plugin as follow: 30 | ```xml 31 | 32 | ru.trylogic.maven.plugins 33 | redis-maven-plugin 34 | 1.4.6 35 | 36 | true 37 | 38 | 39 | 40 | start-redis 41 | pre-integration-test 42 | 43 | run 44 | 45 | 46 | 47 | stop-redis 48 | post-integration-test 49 | 50 | shutdown 51 | 52 | 53 | 54 | 55 | ``` 56 | 57 | Now you will be able to run your integration Redis-backed tests with ```mvn clean verify``` 58 | 59 | License 60 | ----------------- 61 | 62 | Copyright (c) 2013 Sergei bsideup Egorov 63 | 64 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 65 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 66 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 67 | to permit persons to whom the Software is furnished to do so, subject to the following conditions: 68 | 69 | The above copyright notice and this permission notice shall be included in all copies or substantial 70 | portions of the Software. 71 | 72 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 73 | THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 74 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 75 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 76 | -------------------------------------------------------------------------------- /example/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | ru.trylogic.maven.plugins.redis.example 8 | redis-maven-plugin-example 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | 13 | 14 | 15 | org.apache.maven.plugins 16 | maven-surefire-plugin 17 | 18 | 19 | **/*.java 20 | 21 | 22 | 23 | 24 | maven-failsafe-plugin 25 | 2.6 26 | 27 | 28 | **/*.java 29 | 30 | 31 | 32 | 33 | 34 | integration-test 35 | verify 36 | 37 | 38 | 39 | 40 | 41 | ru.trylogic.maven.plugins 42 | redis-maven-plugin 43 | 1.0-SNAPSHOT 44 | 45 | true 46 | 47 | 48 | 49 | start-redis 50 | pre-integration-test 51 | 52 | run 53 | 54 | 55 | 56 | stop-redis 57 | post-integration-test 58 | 59 | shutdown 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | junit 70 | junit 71 | 4.11 72 | 73 | 74 | 75 | redis.clients 76 | jedis 77 | 2.2.1 78 | test 79 | 80 | 81 | -------------------------------------------------------------------------------- /example/src/test/java/ru/trylogic/maven/plugins/redis/example/tests/ConnectionTest.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis.example.tests; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | import redis.clients.jedis.Jedis; 6 | 7 | public class ConnectionTest { 8 | 9 | @Test 10 | public void testConnection() { 11 | Jedis jedis = new Jedis("localhost"); 12 | 13 | System.out.println(jedis.ping()); 14 | 15 | jedis.set("test", "123"); 16 | 17 | Assert.assertEquals("123", jedis.get("test")); 18 | 19 | try { 20 | jedis.quit(); 21 | } catch (Exception e) { 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | ru.trylogic.maven.plugins 5 | redis-maven-plugin 6 | 1.4.7-SNAPSHOT 7 | maven-plugin 8 | 9 | Redis Maven Plugin in pure Java 10 | 11 | https://github.com/bsideup/redis-maven-plugin 12 | 13 | Embedded pure Java redis server for Maven 3. Based on great https://github.com/spullara/redis-protocol 14 | 15 | 16 | https://github.com/bsideup/redis-maven-plugin 17 | scm:git:https://github.com/bsideup/redis-maven-plugin.git 18 | scm:git:https://github.com/bsideup/redis-maven-plugin.git 19 | HEAD 20 | 21 | 22 | 23 | 24 | Sergei Egorov 25 | 26 | 27 | 28 | 29 | 30 | The MIT License 31 | http://www.opensource.org/licenses/mit-license.php 32 | repo 33 | 34 | 35 | 36 | 37 | UTF-8 38 | 39 | 40 | 41 | 42 | release-sign-artifacts 43 | 44 | 45 | performRelease 46 | true 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-gpg-plugin 54 | 1.1 55 | 56 | 57 | sign-artifacts 58 | verify 59 | 60 | sign 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | org.codehaus.plexus 74 | plexus-component-metadata 75 | 1.5.5 76 | 77 | 78 | 79 | generate-metadata 80 | generate-test-metadata 81 | 82 | 83 | 84 | 85 | 86 | org.apache.maven.plugins 87 | maven-source-plugin 88 | 2.1.2 89 | 90 | 91 | attach-sources 92 | 93 | jar-no-fork 94 | 95 | 96 | 97 | 98 | 99 | org.apache.maven.plugins 100 | maven-javadoc-plugin 101 | 2.7 102 | 103 | 104 | attach-javadocs 105 | 106 | jar 107 | 108 | 109 | 110 | 111 | 112 | maven-plugin-plugin 113 | 3.2 114 | 115 | true 116 | 117 | 118 | 119 | mojo-descriptor 120 | 121 | addPluginArtifactMetadata 122 | descriptor 123 | 124 | 125 | 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-compiler-plugin 130 | 3.0 131 | 132 | 1.6 133 | 1.6 134 | 135 | 136 | 137 | maven-surefire-plugin 138 | 139 | false 140 | always 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | org.apache.maven 150 | maven 151 | 3.0.3 152 | pom 153 | import 154 | 155 | 156 | org.codehaus.plexus 157 | plexus-archiver 158 | 2.1.2 159 | 160 | 161 | org.apache.maven.plugin-tools 162 | maven-plugin-annotations 163 | 3.2 164 | provided 165 | 166 | 167 | 168 | com.github.spullara.redis 169 | netty4-server 170 | 0.7 171 | 172 | 173 | 174 | org.apache.maven.plugin-testing 175 | maven-plugin-testing-harness 176 | 2.0 177 | test 178 | 179 | 180 | redis.clients 181 | jedis 182 | 2.2.1 183 | test 184 | 185 | 186 | 187 | 188 | 189 | 190 | org.apache.maven 191 | maven-plugin-api 192 | 193 | 194 | org.apache.maven 195 | maven-artifact 196 | 197 | 198 | org.apache.maven 199 | maven-core 200 | 201 | 202 | org.codehaus.plexus 203 | plexus-utils 204 | 205 | 206 | 207 | org.apache.maven.plugin-testing 208 | maven-plugin-testing-harness 209 | test 210 | 211 | 212 | 213 | org.codehaus.plexus 214 | plexus-archiver 215 | 216 | 217 | org.apache.maven.plugin-tools 218 | maven-plugin-annotations 219 | provided 220 | 221 | 222 | 223 | com.github.spullara.redis 224 | netty4-server 225 | 226 | 227 | 228 | redis.clients 229 | jedis 230 | test 231 | 232 | 233 | 234 | 235 | 236 | bintray-bsideup-repo-redis-maven-plugin 237 | https://api.bintray.com/maven/bsideup/repo/${project.artifactId} 238 | 239 | 240 | 241 | 242 | -------------------------------------------------------------------------------- /src/main/java/ru/trylogic/maven/plugins/redis/RunRedisMojo.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis; 2 | 3 | import io.netty.bootstrap.ServerBootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.ChannelInitializer; 6 | import io.netty.channel.ChannelOption; 7 | import io.netty.channel.ChannelPipeline; 8 | import io.netty.channel.nio.NioEventLoopGroup; 9 | import io.netty.channel.socket.SocketChannel; 10 | import io.netty.channel.socket.nio.NioServerSocketChannel; 11 | import io.netty.util.concurrent.DefaultEventExecutorGroup; 12 | import org.apache.maven.plugin.AbstractMojo; 13 | import org.apache.maven.plugin.MojoExecutionException; 14 | import org.apache.maven.plugins.annotations.LifecyclePhase; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import redis.server.netty.RedisCommandDecoder; 18 | import redis.server.netty.RedisCommandHandler; 19 | import redis.server.netty.RedisReplyEncoder; 20 | import redis.server.netty.SimpleRedisServer; 21 | 22 | @Mojo(name = "run", defaultPhase = LifecyclePhase.NONE) 23 | public class RunRedisMojo extends AbstractMojo { 24 | 25 | public static final String REDIS_GROUP_CONTEXT_PROPERTY_NAME = RunRedisMojo.class.getName() + ":redisGroup"; 26 | public static final String REDIS_CHANNEL_CONTEXT_PROPERTY_NAME = RunRedisMojo.class.getName() + ":redisChannel"; 27 | 28 | @Parameter(property = "redis.server.port", defaultValue = "6379") 29 | public Integer port; 30 | 31 | @Parameter(property = "redis.server.forked", defaultValue = "false") 32 | public boolean forked; 33 | 34 | @Parameter(property = "redis.server.skip", defaultValue = "false") 35 | public boolean skip; 36 | 37 | @Override 38 | public void execute() throws MojoExecutionException { 39 | if (skip) { 40 | getLog().info("Skipping Redis server..."); 41 | return; 42 | } 43 | doExecute(forked); 44 | } 45 | 46 | public void doExecute(boolean forked) { 47 | final RedisCommandHandler commandHandler = new RedisCommandHandler(new SimpleRedisServer()); 48 | 49 | final DefaultEventExecutorGroup redisGroup = new DefaultEventExecutorGroup(1); 50 | 51 | getPluginContext().put(REDIS_GROUP_CONTEXT_PROPERTY_NAME, redisGroup); 52 | 53 | ServerBootstrap redisServerBootstrap = new ServerBootstrap(); 54 | 55 | try { 56 | redisServerBootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup()) 57 | .channel(NioServerSocketChannel.class) 58 | .option(ChannelOption.SO_BACKLOG, 100) 59 | .localAddress(port) 60 | .childOption(ChannelOption.TCP_NODELAY, true) 61 | .childHandler(new ChannelInitializer() { 62 | @Override 63 | public void initChannel(SocketChannel ch) throws Exception { 64 | ChannelPipeline p = ch.pipeline(); 65 | p.addLast(new RedisCommandDecoder()); 66 | p.addLast(new RedisReplyEncoder()); 67 | p.addLast(redisGroup, commandHandler); 68 | } 69 | }); 70 | 71 | getLog().info("Starting Redis(forked=" + forked + ", port=" + port + ") server..."); 72 | ChannelFuture future = redisServerBootstrap.bind(); 73 | ChannelFuture syncFuture = future.sync(); 74 | getPluginContext().put(REDIS_CHANNEL_CONTEXT_PROPERTY_NAME, syncFuture.channel()); 75 | 76 | if (!forked) { 77 | getLog().info("Press Ctrl-C to stop Redis..."); 78 | syncFuture.channel().closeFuture().sync(); 79 | } 80 | } catch (InterruptedException e) { 81 | getLog().info(e); 82 | redisGroup.shutdownGracefully(); 83 | } finally { 84 | if (!forked && !redisGroup.isShutdown()) { 85 | redisGroup.shutdownGracefully(); 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/ru/trylogic/maven/plugins/redis/ShutdownRedisMojo.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis; 2 | 3 | 4 | import io.netty.channel.Channel; 5 | import io.netty.channel.ChannelFuture; 6 | import io.netty.util.concurrent.DefaultEventExecutorGroup; 7 | import org.apache.maven.plugin.AbstractMojo; 8 | import org.apache.maven.plugin.MojoExecutionException; 9 | import org.apache.maven.plugin.MojoFailureException; 10 | import org.apache.maven.plugins.annotations.LifecyclePhase; 11 | import org.apache.maven.plugins.annotations.Mojo; 12 | import org.apache.maven.plugins.annotations.Parameter; 13 | 14 | @Mojo( name = "shutdown", defaultPhase = LifecyclePhase.NONE ) 15 | public class ShutdownRedisMojo extends AbstractMojo { 16 | 17 | @Parameter(property = "redis.server.skip", defaultValue = "false") 18 | public boolean skip; 19 | 20 | @Override 21 | @SuppressWarnings("unchecked") 22 | public void execute() throws MojoExecutionException, MojoFailureException { 23 | if (skip) { 24 | getLog().info("Redis server had been skipped..."); 25 | return; 26 | } 27 | 28 | DefaultEventExecutorGroup redisGroup = (DefaultEventExecutorGroup) getPluginContext().get(RunRedisMojo.REDIS_GROUP_CONTEXT_PROPERTY_NAME); 29 | Channel redisChannel = (Channel) getPluginContext().get(RunRedisMojo.REDIS_CHANNEL_CONTEXT_PROPERTY_NAME); 30 | 31 | if(redisGroup == null || redisChannel == null) { 32 | throw new MojoExecutionException("Redis server is not running"); 33 | } 34 | 35 | getLog().info("Shutting down Redis server..."); 36 | ChannelFuture closeFuture = redisChannel.close(); 37 | try { 38 | closeFuture.sync(); 39 | 40 | // The Netty version required by the embedded Redis implementation does not 41 | // return a Future, so wait until terminated in a loop 42 | redisGroup.shutdownGracefully(); 43 | while (!redisGroup.isTerminated()) { 44 | Thread.sleep(50); 45 | } 46 | getLog().info("Redis server shutdown completed"); 47 | } catch (InterruptedException e) { 48 | getLog().info(e); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/ru/trylogic/maven/plugins/redis/StartRedisMojo.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis; 2 | 3 | import org.apache.maven.plugins.annotations.LifecyclePhase; 4 | import org.apache.maven.plugins.annotations.Mojo; 5 | 6 | @Mojo(name = "start", defaultPhase = LifecyclePhase.NONE) 7 | public class StartRedisMojo extends RunRedisMojo { 8 | 9 | @Override 10 | public void doExecute(final boolean forked) { 11 | super.doExecute(true); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/ru/trylogic/maven/plugins/redis/tests/AbstractRedisMojoTest.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis.tests; 2 | 3 | import org.apache.maven.execution.DefaultMavenExecutionRequest; 4 | import org.apache.maven.execution.MavenExecutionRequest; 5 | import org.apache.maven.plugin.AbstractMojo; 6 | import org.apache.maven.plugin.testing.AbstractMojoTestCase; 7 | import org.apache.maven.project.MavenProject; 8 | import org.apache.maven.project.ProjectBuilder; 9 | import org.apache.maven.project.ProjectBuildingRequest; 10 | import redis.clients.jedis.Jedis; 11 | 12 | import java.io.File; 13 | import java.util.Map; 14 | import java.util.concurrent.ConcurrentHashMap; 15 | 16 | abstract public class AbstractRedisMojoTest extends AbstractMojoTestCase { 17 | 18 | public static final String TEST_KEY = "testKey"; 19 | public static final String TEST_VALUE = "testValue"; 20 | 21 | protected final Map pluginContext = new ConcurrentHashMap(); 22 | 23 | protected T lookupRedisMojo(String file, String mojo) throws Exception { 24 | File pomFile = getTestFile(file); 25 | assertNotNull(pomFile); 26 | assertTrue(pomFile.exists()); 27 | 28 | MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); 29 | ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest(); 30 | ProjectBuilder projectBuilder = lookup(ProjectBuilder.class); 31 | MavenProject project = projectBuilder.build(pomFile, buildingRequest).getProject(); 32 | 33 | T result = (T) lookupConfiguredMojo(project, mojo); 34 | result.setPluginContext(pluginContext); 35 | return result; 36 | } 37 | 38 | protected void testConnectionDown(Jedis jedis) { 39 | try { 40 | jedis.ping(); 41 | fail(); 42 | } catch (Throwable ignored) {} 43 | } 44 | 45 | protected void waitUntilConnect(Jedis jedis) throws InterruptedException { 46 | int attempts = 200; 47 | while(true) { 48 | if(--attempts <= 0) { 49 | fail(); 50 | } 51 | 52 | try { 53 | jedis.ping(); 54 | break; 55 | } catch (Throwable ignored) { 56 | Thread.sleep(50); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/ru/trylogic/maven/plugins/redis/tests/RunForkedRedisMojoTest.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis.tests; 2 | 3 | import redis.clients.jedis.Jedis; 4 | import ru.trylogic.maven.plugins.redis.RunRedisMojo; 5 | import ru.trylogic.maven.plugins.redis.ShutdownRedisMojo; 6 | 7 | public class RunForkedRedisMojoTest extends AbstractRedisMojoTest { 8 | 9 | public static final String FORKED_POM_FILE = "src/test/resources/unit/pom.xml"; 10 | 11 | public void testRunForked() throws Exception { 12 | final RunRedisMojo runRedisMojo = lookupRedisMojo(FORKED_POM_FILE, "run"); 13 | assertNotNull(runRedisMojo); 14 | 15 | runRedisMojo.forked = true; 16 | 17 | runRedisMojo.execute(); 18 | 19 | final Jedis jedis = new Jedis("localhost", runRedisMojo.port); 20 | waitUntilConnect(jedis); 21 | 22 | assertEquals("OK", jedis.set(TEST_KEY, TEST_VALUE)); 23 | assertEquals(TEST_VALUE, jedis.get(TEST_KEY)); 24 | 25 | try { 26 | jedis.quit(); 27 | } catch(Exception ignored) { 28 | 29 | } 30 | 31 | final ShutdownRedisMojo shutdownRedisMojo = lookupRedisMojo(FORKED_POM_FILE, "shutdown"); 32 | shutdownRedisMojo.execute(); 33 | 34 | testConnectionDown(jedis); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/ru/trylogic/maven/plugins/redis/tests/RunRedisMojoTest.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis.tests; 2 | 3 | import org.apache.maven.plugin.MojoExecutionException; 4 | import redis.clients.jedis.Jedis; 5 | import ru.trylogic.maven.plugins.redis.RunRedisMojo; 6 | import ru.trylogic.maven.plugins.redis.ShutdownRedisMojo; 7 | 8 | public class RunRedisMojoTest extends AbstractRedisMojoTest { 9 | 10 | public static final String SIMPLE_POM_FILE = "src/test/resources/unit/pom.xml"; 11 | 12 | public void testRun() throws Exception { 13 | final RunRedisMojo runRedisMojo = lookupRedisMojo(SIMPLE_POM_FILE, "run"); 14 | assertNotNull(runRedisMojo); 15 | 16 | Thread redisThread = new Thread(new Runnable() { 17 | @Override 18 | public void run() { 19 | try { 20 | runRedisMojo.execute(); 21 | } catch (MojoExecutionException e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | }); 26 | 27 | redisThread.start(); 28 | 29 | final Jedis jedis = new Jedis("localhost", runRedisMojo.port); 30 | waitUntilConnect(jedis); 31 | 32 | assertEquals("OK", jedis.set(TEST_KEY, TEST_VALUE)); 33 | assertEquals(TEST_VALUE, jedis.get(TEST_KEY)); 34 | 35 | try { 36 | jedis.quit(); 37 | } catch(Exception ignored) { 38 | 39 | } 40 | 41 | final ShutdownRedisMojo shutdownRedisMojo = lookupRedisMojo(SIMPLE_POM_FILE, "shutdown"); 42 | shutdownRedisMojo.execute(); 43 | 44 | testConnectionDown(jedis); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/ru/trylogic/maven/plugins/redis/tests/StartRedisMojoTest.java: -------------------------------------------------------------------------------- 1 | package ru.trylogic.maven.plugins.redis.tests; 2 | 3 | import redis.clients.jedis.Jedis; 4 | import ru.trylogic.maven.plugins.redis.ShutdownRedisMojo; 5 | import ru.trylogic.maven.plugins.redis.StartRedisMojo; 6 | 7 | public class StartRedisMojoTest extends AbstractRedisMojoTest { 8 | 9 | public static final String FORKED_POM_FILE = "src/test/resources/unit/pom.xml"; 10 | 11 | public void testRunForked() throws Exception { 12 | final StartRedisMojo startRedisMojo = lookupRedisMojo(FORKED_POM_FILE, "start"); 13 | assertNotNull(startRedisMojo); 14 | 15 | startRedisMojo.execute(); 16 | 17 | final Jedis jedis = new Jedis("localhost", startRedisMojo.port); 18 | waitUntilConnect(jedis); 19 | 20 | assertEquals("OK", jedis.set(TEST_KEY, TEST_VALUE)); 21 | assertEquals(TEST_VALUE, jedis.get(TEST_KEY)); 22 | 23 | try { 24 | jedis.quit(); 25 | } catch(Exception ignored) { 26 | 27 | } 28 | 29 | final ShutdownRedisMojo shutdownRedisMojo = lookupRedisMojo(FORKED_POM_FILE, "shutdown"); 30 | shutdownRedisMojo.execute(); 31 | 32 | testConnectionDown(jedis); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/resources/unit/pom.xml: -------------------------------------------------------------------------------- 1 | 5 | 4.0.0 6 | 7 | ru.trylogic.maven.plugins.redis.tests 8 | redis-maven-plugin-test 9 | 1.0-SNAPSHOT 10 | jar 11 | 12 | 13 | 14 | 15 | ru.trylogic.maven.plugins.redis 16 | redis-maven-plugin 17 | 18 | 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------