Repository: incubator-streams Updated Branches: refs/heads/master 09ebd2e8c -> 80207a0db
switch the mojo ITs back to Tests, and add more scala plugin testing Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/80207a0d Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/80207a0d Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/80207a0d Branch: refs/heads/master Commit: 80207a0dbd6ed57053734171dce6d1fc17a825c6 Parents: 09ebd2e Author: Steve Blackmon @steveblackmon <[email protected]> Authored: Wed Oct 19 19:43:06 2016 -0500 Committer: Steve Blackmon @steveblackmon <[email protected]> Committed: Wed Oct 19 19:43:06 2016 -0500 ---------------------------------------------------------------------- ...StreamsCassandraResourceGeneratorMojoIT.java | 96 -------------------- ...reamsCassandraResourceGeneratorMojoTest.java | 96 ++++++++++++++++++++ ...amsElasticsearchResourceGeneratorMojoIT.java | 68 -------------- ...sElasticsearchResourceGeneratorMojoTest.java | 68 ++++++++++++++ .../StreamsHbaseResourceGeneratorMojoIT.java | 83 ----------------- .../StreamsHbaseResourceGeneratorMojoTest.java | 83 +++++++++++++++++ .../StreamsHiveResourceGeneratorMojoIT.java | 83 ----------------- .../StreamsHiveResourceGeneratorMojoTest.java | 83 +++++++++++++++++ .../test/StreamsPigResourceGeneratorMojoIT.java | 83 ----------------- .../StreamsPigResourceGeneratorMojoTest.java | 83 +++++++++++++++++ .../test/StreamsPojoSourceGeneratorMojoIT.java | 86 ------------------ .../StreamsPojoSourceGeneratorMojoTest.java | 86 ++++++++++++++++++ streams-plugins/streams-plugin-scala/pom.xml | 6 ++ .../plugins/StreamsScalaGenerationConfig.java | 65 +++++++++++++ .../plugins/StreamsScalaSourceGenerator.java | 63 +++++++------ .../StreamsScalaSourceGeneratorMojo.java | 9 +- .../StreamsScalaSourceGeneratorCLITest.java | 63 +++++++++++++ .../StreamsScalaSourceGeneratorMojoTest.java | 83 +++++++++++++++++ .../test/StreamsScalaSourceGeneratorTest.java | 26 +++++- .../test/resources/streams-plugin-scala/pom.xml | 3 +- 20 files changed, 784 insertions(+), 532 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java deleted file mode 100644 index fc7765e..0000000 --- a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.cassandra.test; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import junit.framework.TestCase; -import org.apache.commons.lang3.StringUtils; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.apache.streams.plugins.cassandra.test.StreamsCassandraResourceGeneratorTest.cqlFilter; - -/** - * Tests that streams-plugin-hive running via maven generates hql resources - */ -public class StreamsCassandraResourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsCassandraResourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - @Test - public void testStreamsCassandraResourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-cassandra" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-resources")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - Path testOutputPath = Paths.get(testDir.getAbsolutePath()).resolve("target/generated-resources/test-mojo"); - - File testOutput = testOutputPath.toFile(); - - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); - - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) - .filter(cqlFilter); - Collection<File> outputCollection = Lists.newArrayList(outputIterator); - assert( outputCollection.size() == 1 ); - - Path path = testOutputPath.resolve("types.cql"); - - assert( path.toFile().exists() ); - - String typesCqlBytes = new String( - java.nio.file.Files.readAllBytes(path)); - - assert( StringUtils.countMatches(typesCqlBytes, "CREATE TYPE") == 133 ); - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoTest.java new file mode 100644 index 0000000..7f5aa39 --- /dev/null +++ b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoTest.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.cassandra.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.commons.lang3.StringUtils; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.cassandra.test.StreamsCassandraResourceGeneratorTest.cqlFilter; + +/** + * Tests that streams-plugin-hive running via maven generates hql resources + */ +public class StreamsCassandraResourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsCassandraResourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + @Test + public void testStreamsCassandraResourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-cassandra" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-resources")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + Path testOutputPath = Paths.get(testDir.getAbsolutePath()).resolve("target/generated-resources/test-mojo"); + + File testOutput = testOutputPath.toFile(); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(cqlFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() == 1 ); + + Path path = testOutputPath.resolve("types.cql"); + + assert( path.toFile().exists() ); + + String typesCqlBytes = new String( + java.nio.file.Files.readAllBytes(path)); + + assert( StringUtils.countMatches(typesCqlBytes, "CREATE TYPE") == 133 ); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java deleted file mode 100644 index 2a24846..0000000 --- a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.elasticsearch.test; - -import com.google.common.collect.Lists; -import junit.framework.TestCase; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * Tests that streams-plugin-hive running via maven generates hql resources - */ -public class StreamsElasticsearchResourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsElasticsearchResourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - - @Test - public void testStreamsElasticsearchResourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-elasticsearch" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-resources")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoTest.java new file mode 100644 index 0000000..60f3002 --- /dev/null +++ b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.elasticsearch.test; + +import com.google.common.collect.Lists; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Tests that streams-plugin-hive running via maven generates hql resources + */ +public class StreamsElasticsearchResourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsElasticsearchResourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsElasticsearchResourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-elasticsearch" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-resources")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java deleted file mode 100644 index 1495bc1..0000000 --- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.test; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import junit.framework.TestCase; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.apache.streams.plugins.test.StreamsHbaseResourceGeneratorTest.txtFilter; - -/** - * Tests that streams-plugin-hive running via maven generates hql resources - */ -public class StreamsHbaseResourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsHbaseResourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - - @Test - public void testStreamsHbaseResourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-hbase" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-resources")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hbase-mojo"); - - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); - - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) - .filter(txtFilter); - Collection<File> outputCollection = Lists.newArrayList(outputIterator); - assert( outputCollection.size() == 133 ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java new file mode 100644 index 0000000..f14a1b4 --- /dev/null +++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoTest.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.test.StreamsHbaseResourceGeneratorTest.txtFilter; + +/** + * Tests that streams-plugin-hive running via maven generates hql resources + */ +public class StreamsHbaseResourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsHbaseResourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsHbaseResourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-hbase" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-resources")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hbase-mojo"); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(txtFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() == 133 ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java deleted file mode 100644 index e78a175..0000000 --- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.test; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import junit.framework.TestCase; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.apache.streams.plugins.test.StreamsHiveResourceGeneratorTest.hqlFilter; - -/** - * Tests that streams-plugin-hive running via maven generates hql resources - */ -public class StreamsHiveResourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsHiveResourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - - @Test - public void testStreamsHiveResourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-hive" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-resources")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hive-mojo"); - - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); - - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) - .filter(hqlFilter); - Collection<File> outputCollection = Lists.newArrayList(outputIterator); - assert( outputCollection.size() == 133 ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java new file mode 100644 index 0000000..8594e11 --- /dev/null +++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoTest.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.test.StreamsHiveResourceGeneratorTest.hqlFilter; + +/** + * Tests that streams-plugin-hive running via maven generates hql resources + */ +public class StreamsHiveResourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsHiveResourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsHiveResourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-hive" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-resources")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/hive-mojo"); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(hqlFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() == 133 ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java deleted file mode 100644 index a584774..0000000 --- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.pig.test; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import junit.framework.TestCase; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.apache.streams.plugins.pig.test.StreamsPigResourceGeneratorTest.pigFilter; - -/** - * Tests that streams-plugin-hive running via maven generates hql resources - */ -public class StreamsPigResourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsPigResourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - - @Test - public void testStreamsPigResourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-pig" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-resources")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/pig-mojo"); - - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); - - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) - .filter(pigFilter); - Collection<File> outputCollection = Lists.newArrayList(outputIterator); - assert( outputCollection.size() == 133 ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java new file mode 100644 index 0000000..686f6e2 --- /dev/null +++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoTest.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.pig.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.pig.test.StreamsPigResourceGeneratorTest.pigFilter; + +/** + * Tests that streams-plugin-hive running via maven generates hql resources + */ +public class StreamsPigResourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsPigResourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsPigResourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-pig" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-resources")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-resources/pig-mojo"); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(pigFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() == 133 ); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoIT.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoIT.java deleted file mode 100644 index f2ccd2a..0000000 --- a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoIT.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.streams.plugins.test; - -import com.google.common.collect.Lists; -import com.google.common.io.Files; -import junit.framework.TestCase; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.apache.streams.plugins.test.StreamsPojoSourceGeneratorTest.javaFilter; - -/** - * Tests that streams-plugin-pojo running via maven can convert activity schemas into pojos - * which then compile. - */ -public class StreamsPojoSourceGeneratorMojoIT extends TestCase { - - private final static Logger LOGGER = LoggerFactory.getLogger(StreamsPojoSourceGeneratorMojoIT.class); - - protected void setUp() throws Exception - { - // required for mojo lookups to work - super.setUp(); - } - - - @Test - public void testStreamsPojoSourceGeneratorMojo() throws Exception { - - File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-pojo" ); - - Verifier verifier; - - verifier = new Verifier( testDir.getAbsolutePath() ); - - List cliOptions = new ArrayList(); - cliOptions.add( "-N" ); - verifier.executeGoals( Lists.<String>newArrayList( - "clean", - "dependency:unpack-dependencies", - "generate-sources", - "compile")); - - verifier.verifyErrorFreeLog(); - - verifier.resetStreams(); - - File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-sources/pojo-mojo"); - - assert( testOutput != null ); - assert( testOutput.exists() == true ); - assert( testOutput.isDirectory() == true ); - - Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) - .filter(javaFilter); - Collection<File> outputCollection = Lists.newArrayList(outputIterator); - assert( outputCollection.size() > 133 ); - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java new file mode 100644 index 0000000..94db69f --- /dev/null +++ b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorMojoTest.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.test.StreamsPojoSourceGeneratorTest.javaFilter; + +/** + * Tests that streams-plugin-pojo running via maven can convert activity schemas into pojos + * which then compile. + */ +public class StreamsPojoSourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsPojoSourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsPojoSourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-pojo" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "clean", + "dependency:unpack-dependencies", + "generate-sources", + "compile")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-sources/pojo-mojo"); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(javaFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() > 133 ); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/pom.xml b/streams-plugins/streams-plugin-scala/pom.xml index 6b471a8..e0a6d97 100644 --- a/streams-plugins/streams-plugin-scala/pom.xml +++ b/streams-plugins/streams-plugin-scala/pom.xml @@ -88,6 +88,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-verifier</artifactId> + <version>1.6</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-core</artifactId> <version>3.3.3</version> http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaGenerationConfig.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaGenerationConfig.java b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaGenerationConfig.java new file mode 100644 index 0000000..18ae551 --- /dev/null +++ b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaGenerationConfig.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins; + +import org.jsonschema2pojo.DefaultGenerationConfig; +import org.jsonschema2pojo.util.URLUtil; + +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +/** + * Created by sblackmon on 3/27/16. + */ +public class StreamsScalaGenerationConfig { + + private List<String> sourcePackages; + private String targetPackage; + private String targetDirectory; + + public void setSourcePackages(List<String> sourcePackages) { + this.sourcePackages = sourcePackages; + } + + public List<String> getSourcePackages() { + return sourcePackages; + } + + public void setTargetPackage(String targetPackage) { + this.targetPackage = targetPackage; + } + + public void setTargetDirectory(String targetDirectory) { + this.targetDirectory = targetDirectory; + } + + public String getTargetPackage() { + return targetPackage; + } + + public File getTargetDirectory() { + return new File(targetDirectory); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGenerator.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGenerator.java b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGenerator.java index 73d2f5d..4891c0d 100644 --- a/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGenerator.java +++ b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGenerator.java @@ -19,6 +19,7 @@ package org.apache.streams.plugins; +import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -50,40 +51,48 @@ public class StreamsScalaSourceGenerator implements Runnable { private final static String LS = System.getProperty("line.separator"); - private StreamsScalaSourceGeneratorMojo mojo; + private StreamsScalaGenerationConfig config; - String outDir = "./target/generated-sources/scala"; - String packages = "org.apache.streams.pojo.json"; + private Reflections reflections; - private final Reflections reflections = new Reflections( - new ConfigurationBuilder() - // TODO - .forPackages(packages) - .setScanners( - new SubTypesScanner(), - new TypeAnnotationsScanner())); + private String outDir; - public void main(String[] args) { - StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(); + public static void main(String[] args) { + StreamsScalaGenerationConfig config = new StreamsScalaGenerationConfig(); + + List<String> sourcePackages = Lists.newArrayList(); + String targetDirectory = "target/generated-sources/pojo"; + String targetPackage = ""; + + if( args.length > 0 ) + sourcePackages = Splitter.on(',').splitToList(args[0]); + if( args.length > 1 ) + targetDirectory = args[1]; + if( args.length > 2 ) + targetPackage = args[2]; + + config.setSourcePackages(sourcePackages); + config.setTargetPackage(targetPackage); + config.setTargetDirectory(targetDirectory); + + StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(config); streamsScalaSourceGenerator.run(); } - public StreamsScalaSourceGenerator(StreamsScalaSourceGeneratorMojo mojo) { - this.mojo = mojo; - if ( mojo != null && - mojo.getTarget() != null && - !Strings.isNullOrEmpty(mojo.getTarget().getAbsolutePath()) - ) - outDir = mojo.getTarget().getAbsolutePath(); - - if ( mojo != null && - mojo.getPackages() != null && - !Strings.isNullOrEmpty(mojo.getPackages()) - ) - packages = mojo.getPackages(); - } + public StreamsScalaSourceGenerator(StreamsScalaGenerationConfig config) { + this.config = config; + this.outDir = config.getTargetDirectory().getAbsolutePath(); + reflections = new Reflections( + new ConfigurationBuilder() + // TODO + .forPackages( + config.getSourcePackages() + .toArray(new String[config.getSourcePackages().size()]) + ) + .setScanners( + new SubTypesScanner(), + new TypeAnnotationsScanner())); - public StreamsScalaSourceGenerator() { } public void run() { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGeneratorMojo.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGeneratorMojo.java b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGeneratorMojo.java index c88ce41..ae91b36 100644 --- a/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGeneratorMojo.java +++ b/streams-plugins/streams-plugin-scala/src/main/java/org/apache/streams/plugins/StreamsScalaSourceGeneratorMojo.java @@ -19,6 +19,8 @@ package org.apache.streams.plugins; +import com.google.common.base.Splitter; +import com.google.common.base.Strings; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; @@ -64,7 +66,12 @@ public class StreamsScalaSourceGeneratorMojo extends AbstractMojo { private String packages; public void execute() throws MojoExecutionException { - StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(this); + StreamsScalaGenerationConfig config = new StreamsScalaGenerationConfig(); + config.setSourcePackages(Splitter.on(',').splitToList(packages)); + config.setTargetDirectory(target.toString()); + + StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(config); + streamsScalaSourceGenerator.run(); } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorCLITest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorCLITest.java b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorCLITest.java new file mode 100644 index 0000000..6394193 --- /dev/null +++ b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorCLITest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import org.apache.streams.plugins.StreamsScalaSourceGenerator; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.test.StreamsScalaSourceGeneratorTest.scalaFilter; + +/** + * Created by sblackmon on 5/5/16. + */ +public class StreamsScalaSourceGeneratorCLITest { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsScalaSourceGeneratorCLITest.class); + + @Test + public void testStreamsScalaSourceGeneratorCLI() throws Exception { + + String sourcePackages = "org.apache.streams.pojo.json"; + String targetPackage = "org.apache.streams.scala"; + String targetDirectory = "./target/generated-sources/scala-cli"; + + List<String> argsList = Lists.newArrayList(sourcePackages, targetDirectory, targetPackage); + StreamsScalaSourceGenerator.main(argsList.toArray(new String[argsList.size()])); + + File testOutput = new File(targetDirectory); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(scalaFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() > 133 ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorMojoTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorMojoTest.java b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorMojoTest.java new file mode 100644 index 0000000..5393889 --- /dev/null +++ b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorMojoTest.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.streams.plugins.test; + +import com.google.common.collect.Lists; +import com.google.common.io.Files; +import junit.framework.TestCase; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.streams.plugins.test.StreamsScalaSourceGeneratorTest.scalaFilter; + +/** + * Tests that streams-plugin-pojo running via maven can convert activity schemas into pojos + * which then compile. + */ +public class StreamsScalaSourceGeneratorMojoTest extends TestCase { + + private final static Logger LOGGER = LoggerFactory.getLogger(StreamsScalaSourceGeneratorMojoTest.class); + + protected void setUp() throws Exception + { + // required for mojo lookups to work + super.setUp(); + } + + + @Test + public void testStreamsScalaSourceGeneratorMojo() throws Exception { + + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/streams-plugin-scala" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + + List cliOptions = new ArrayList(); + cliOptions.add( "-N" ); + verifier.executeGoals( Lists.<String>newArrayList( + "compile")); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + + File testOutput = new File(testDir.getAbsolutePath() + "/target/generated-sources/scala-mojo"); + + assert( testOutput != null ); + assert( testOutput.exists() == true ); + assert( testOutput.isDirectory() == true ); + + Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput) + .filter(scalaFilter); + Collection<File> outputCollection = Lists.newArrayList(outputIterator); + assert( outputCollection.size() > 133 ); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorTest.java ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorTest.java b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorTest.java index bd1c5ff..b4df332 100644 --- a/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorTest.java +++ b/streams-plugins/streams-plugin-scala/src/test/java/org/apache/streams/plugins/test/StreamsScalaSourceGeneratorTest.java @@ -19,11 +19,15 @@ package org.apache.streams.plugins.test; +import com.google.common.base.Predicate; +import com.google.common.collect.Lists; +import org.apache.streams.plugins.StreamsScalaGenerationConfig; import org.apache.streams.plugins.StreamsScalaSourceGenerator; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.File; import java.io.FileFilter; @@ -34,17 +38,31 @@ public class StreamsScalaSourceGeneratorTest { private final static Logger LOGGER = LoggerFactory.getLogger(StreamsScalaSourceGeneratorTest.class); + public static final Predicate<File> scalaFilter = new Predicate<File>() { + @Override + public boolean apply(@Nullable File file) { + if( file.getName().endsWith(".scala") ) + return true; + else return false; + } + }; /** * Tests that all example activities can be loaded into Activity beans * * @throws Exception */ @Test - public void testDetectPojoScala() throws Exception { - StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(); - streamsScalaSourceGenerator.main(new String[0]); + public void testStreamsScalaSourceGenerator() throws Exception { - File testOutput = new File( "./target/generated-sources/scala/org/apache/streams/scala"); + StreamsScalaGenerationConfig streamsScalaGenerationConfig = new StreamsScalaGenerationConfig(); + streamsScalaGenerationConfig.setSourcePackages(Lists.newArrayList("org.apache.streams.pojo.json")); + streamsScalaGenerationConfig.setTargetPackage("org.apache.streams.scala"); + streamsScalaGenerationConfig.setTargetDirectory("target/generated-sources/scala-test"); + + StreamsScalaSourceGenerator streamsScalaSourceGenerator = new StreamsScalaSourceGenerator(streamsScalaGenerationConfig); + streamsScalaSourceGenerator.run(); + + File testOutput = new File( "./target/generated-sources/scala-test/org/apache/streams/scala"); FileFilter scalaFilter = new FileFilter() { @Override public boolean accept(File pathname) { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/80207a0d/streams-plugins/streams-plugin-scala/src/test/resources/streams-plugin-scala/pom.xml ---------------------------------------------------------------------- diff --git a/streams-plugins/streams-plugin-scala/src/test/resources/streams-plugin-scala/pom.xml b/streams-plugins/streams-plugin-scala/src/test/resources/streams-plugin-scala/pom.xml index 708ae26..88b3648 100644 --- a/streams-plugins/streams-plugin-scala/src/test/resources/streams-plugin-scala/pom.xml +++ b/streams-plugins/streams-plugin-scala/src/test/resources/streams-plugin-scala/pom.xml @@ -32,6 +32,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> + <version>4.11</version> <scope>test</scope> </dependency> </dependencies> @@ -58,7 +59,7 @@ <version>0.4-incubating-SNAPSHOT</version> <configuration> <packages>org.apache.streams.pojo.json</packages> - <target>target/test-classes/streams-scala-plugin/</target> + <target>target/generated-sources/scala-mojo</target> </configuration> <executions> <execution>
