Repository: incubator-streams Updated Branches: refs/heads/master 9861124ae -> 67d5cca51
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/main/resources/moreover.conf ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/main/resources/moreover.conf b/streams-contrib/streams-provider-moreover/src/main/resources/moreover.conf deleted file mode 100644 index 3b683fe..0000000 --- a/streams-contrib/streams-provider-moreover/src/main/resources/moreover.conf +++ /dev/null @@ -1,25 +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. - -moreover { - apiKeys { - key { - key = "" - startingSequence = "" - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerIT.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerIT.java deleted file mode 100644 index ea83777..0000000 --- a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverJsonActivitySerializerIT.java +++ /dev/null @@ -1,79 +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 - * - * 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.data; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.io.IOUtils; -import org.apache.streams.data.util.JsonUtil; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URL; -import java.nio.charset.Charset; - -import static org.apache.streams.data.util.MoreoverTestUtil.test; - -/** - * Tests ability to serialize moreover json Strings - */ -public class MoreoverJsonActivitySerializerIT { - JsonNode json; - ActivitySerializer serializer = new MoreoverJsonActivitySerializer(); - ObjectMapper mapper; - - @Before - public void setup() throws Exception { - - StringWriter writer = new StringWriter(); - InputStream resourceAsStream = this.getClass().getResourceAsStream("/moreover.json"); - IOUtils.copy(resourceAsStream, writer, Charset.forName("UTF-8")); - - mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE); - mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE); - mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE); - - json = mapper.readValue(writer.toString(), JsonNode.class); - } - - @Test - public void loadData() throws Exception { - for (JsonNode item : json) { - test(serializer.deserialize(getString(item))); - } - } - - - private String getString(JsonNode jsonNode) { - try { - return new ObjectMapper().writeValueAsString(jsonNode); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerIT.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerIT.java deleted file mode 100644 index da660cd..0000000 --- a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/MoreoverXmlActivitySerializerIT.java +++ /dev/null @@ -1,65 +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 - * - * 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.data; - - -import com.google.common.collect.Lists; -import org.apache.commons.io.IOUtils; -import org.apache.streams.pojo.json.Activity; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.nio.charset.Charset; -import java.util.List; - -import static org.apache.streams.data.util.MoreoverTestUtil.test; - -/** - * Tests ability to serialize moreover xml Strings - */ -public class MoreoverXmlActivitySerializerIT { - ActivitySerializer serializer; - private String xml; - - @Before - public void setup() throws IOException { - serializer = new MoreoverXmlActivitySerializer(); - xml = loadXml(); - } - - @Test - public void loadData() throws Exception { - List<Activity> activities = serializer.deserializeAll(Lists.newArrayList(xml)); - for (Activity activity : activities) { - test(activity); - } - } - - private String loadXml() throws IOException { - StringWriter writer = new StringWriter(); - InputStream resourceAsStream = this.getClass().getResourceAsStream("/moreover.xml"); - IOUtils.copy(resourceAsStream, writer, Charset.forName("UTF-8")); - return writer.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java deleted file mode 100644 index 14b7652..0000000 --- a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/data/util/MoreoverTestUtil.java +++ /dev/null @@ -1,43 +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 - * - * 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.data.util; - -import org.apache.streams.pojo.json.Activity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static java.util.regex.Pattern.matches; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; - -public class MoreoverTestUtil { - - private final static Logger LOGGER = LoggerFactory.getLogger(MoreoverTestUtil.class); - - public static void test(Activity activity) { - assertThat(activity, is(not(nullValue()))); - assertThat(activity.getActor(), is(not(nullValue()))); - assertThat(activity.getObject(), is(not(nullValue()))); - if(activity.getObject().getId() != null) { - assertThat(matches("id:.*:[a-z]*s:[a-zA-Z0-9]*", activity.getObject().getId()), is(true)); - } - assertThat(activity.getObject().getObjectType(), is(not(nullValue()))); - LOGGER.debug(activity.getPublished().toString()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/MoreoverTestUtil.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/MoreoverTestUtil.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/MoreoverTestUtil.java new file mode 100644 index 0000000..cdd5822 --- /dev/null +++ b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/MoreoverTestUtil.java @@ -0,0 +1,43 @@ +/* + * 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 + * + * 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.moreover; + +import org.apache.streams.pojo.json.Activity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.regex.Pattern.matches; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; + +public class MoreoverTestUtil { + + private final static Logger LOGGER = LoggerFactory.getLogger(MoreoverTestUtil.class); + + public static void test(Activity activity) { + assertThat(activity, is(not(nullValue()))); + assertThat(activity.getActor(), is(not(nullValue()))); + assertThat(activity.getObject(), is(not(nullValue()))); + if(activity.getObject().getId() != null) { + assertThat(matches("id:.*:[a-z]*s:[a-zA-Z0-9]*", activity.getObject().getId()), is(true)); + } + assertThat(activity.getObject().getObjectType(), is(not(nullValue()))); + LOGGER.debug(activity.getPublished().toString()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverJsonActivitySerializerIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverJsonActivitySerializerIT.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverJsonActivitySerializerIT.java new file mode 100644 index 0000000..94ef097 --- /dev/null +++ b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverJsonActivitySerializerIT.java @@ -0,0 +1,76 @@ +/* + * 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 + * + * 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.moreover.test; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; +import org.apache.streams.data.ActivitySerializer; +import org.apache.streams.moreover.MoreoverJsonActivitySerializer; +import org.junit.Before; +import org.junit.Test; + +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.charset.Charset; + +import static org.apache.streams.moreover.MoreoverTestUtil.test; + +/** + * Tests ability to serialize moreover json Strings + */ +public class MoreoverJsonActivitySerializerIT { + JsonNode json; + ActivitySerializer serializer = new MoreoverJsonActivitySerializer(); + ObjectMapper mapper; + + @Before + public void setup() throws Exception { + + StringWriter writer = new StringWriter(); + InputStream resourceAsStream = this.getClass().getResourceAsStream("/moreover.json"); + IOUtils.copy(resourceAsStream, writer, Charset.forName("UTF-8")); + + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE); + mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE); + mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE); + + json = mapper.readValue(writer.toString(), JsonNode.class); + } + + @Test + public void loadData() throws Exception { + for (JsonNode item : json) { + test(serializer.deserialize(getString(item))); + } + } + + + private String getString(JsonNode jsonNode) { + try { + return new ObjectMapper().writeValueAsString(jsonNode); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverXmlActivitySerializerIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverXmlActivitySerializerIT.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverXmlActivitySerializerIT.java new file mode 100644 index 0000000..ad0b384 --- /dev/null +++ b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/MoreoverXmlActivitySerializerIT.java @@ -0,0 +1,66 @@ +/* + * 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 + * + * 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.moreover.test; + +import com.google.common.collect.Lists; +import org.apache.commons.io.IOUtils; +import org.apache.streams.data.ActivitySerializer; +import org.apache.streams.pojo.json.Activity; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.nio.charset.Charset; +import java.util.List; + +import org.apache.streams.moreover.MoreoverXmlActivitySerializer; + +import static org.apache.streams.moreover.MoreoverTestUtil.test; + +/** + * Tests ability to serialize moreover xml Strings + */ +public class MoreoverXmlActivitySerializerIT { + ActivitySerializer serializer; + private String xml; + + @Before + public void setup() throws IOException { + serializer = new MoreoverXmlActivitySerializer(); + xml = loadXml(); + } + + @Test + public void loadData() throws Exception { + List<Activity> activities = serializer.deserializeAll(Lists.newArrayList(xml)); + for (Activity activity : activities) { + test(activity); + } + } + + private String loadXml() throws IOException { + StringWriter writer = new StringWriter(); + InputStream resourceAsStream = this.getClass().getResourceAsStream("/moreover.xml"); + IOUtils.copy(resourceAsStream, writer, Charset.forName("UTF-8")); + return writer.toString(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/provider/MoreoverProviderIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/provider/MoreoverProviderIT.java b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/provider/MoreoverProviderIT.java new file mode 100644 index 0000000..2bc672d --- /dev/null +++ b/streams-contrib/streams-provider-moreover/src/test/java/org/apache/streams/moreover/test/provider/MoreoverProviderIT.java @@ -0,0 +1,67 @@ +/* + * 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 + * + * 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.moreover.test.provider; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Lists; +import org.apache.streams.moreover.MoreoverProvider; +import org.apache.streams.jackson.StreamsJacksonMapper; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileReader; +import java.io.LineNumberReader; + +/** + * Integration test for MoreoverProviderIT + * + * Created by sblackmon on 10/21/16. + */ +@Ignore("this is ignored because the project doesn't have credentials to test it with during CI") +public class MoreoverProviderIT { + + private final static Logger LOGGER = LoggerFactory.getLogger(MoreoverProviderIT.class); + + private ObjectMapper mapper = StreamsJacksonMapper.getInstance(); + + @Test + public void testRssStreamProvider() throws Exception { + + String configfile = "./target/test-classes/RssStreamProviderIT.conf"; + String outfile = "./target/test-classes/RssStreamProviderIT.stdout.txt"; + + MoreoverProvider.main(Lists.newArrayList(configfile, outfile).toArray(new String[2])); + + File out = new File(outfile); + assert (out.exists()); + assert (out.canRead()); + assert (out.isFile()); + + FileReader outReader = new FileReader(out); + LineNumberReader outCounter = new LineNumberReader(outReader); + + while(outCounter.readLine() != null) {} + + assert (outCounter.getLineNumber() >= 1); + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/015f0ae1/streams-contrib/streams-provider-moreover/src/test/resources/moreover.conf ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-moreover/src/test/resources/moreover.conf b/streams-contrib/streams-provider-moreover/src/test/resources/moreover.conf new file mode 100644 index 0000000..3b683fe --- /dev/null +++ b/streams-contrib/streams-provider-moreover/src/test/resources/moreover.conf @@ -0,0 +1,25 @@ +# 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. + +moreover { + apiKeys { + key { + key = "" + startingSequence = "" + } + } +}
