You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2017/04/05 23:19:14 UTC
[11/23] storm git commit: STORM-2453 Move non-connectors into the top
directory
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java
----------------------------------------------------------------------
diff --git a/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java b/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java
deleted file mode 100644
index 0a3bac6..0000000
--- a/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/TestUtils.java
+++ /dev/null
@@ -1,584 +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
- * * <p>
- * * http://www.apache.org/licenses/LICENSE-2.0
- * * <p>
- * * 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.storm.sql;
-
-import org.apache.storm.sql.runtime.ChannelContext;
-import org.apache.storm.sql.runtime.ChannelHandler;
-import org.apache.storm.sql.runtime.DataSource;
-import org.apache.storm.sql.runtime.ISqlTridentDataSource;
-import org.apache.storm.sql.runtime.SimpleSqlTridentConsumer;
-import org.apache.storm.task.IMetricsContext;
-import org.apache.storm.task.TopologyContext;
-import org.apache.storm.trident.operation.TridentCollector;
-import org.apache.storm.trident.operation.TridentOperationContext;
-import org.apache.storm.trident.spout.IBatchSpout;
-import org.apache.storm.trident.state.State;
-import org.apache.storm.trident.state.StateFactory;
-import org.apache.storm.trident.state.StateUpdater;
-import org.apache.storm.trident.tuple.TridentTuple;
-import org.apache.storm.tuple.Fields;
-import org.apache.storm.tuple.Values;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-
-public class TestUtils {
- public static class MyPlus {
- public static Integer evaluate(Integer x, Integer y) {
- return x + y;
- }
- }
-
- public static class MyConcat {
- public static String init() {
- return "";
- }
- public static String add(String accumulator, String val) {
- return accumulator + val;
- }
- public static String result(String accumulator) {
- return accumulator;
- }
- }
-
-
- public static class TopN {
- public static PriorityQueue<Integer> init() {
- return new PriorityQueue<>();
- }
- public static PriorityQueue<Integer> add(PriorityQueue<Integer> accumulator, Integer n, Integer val) {
- if (n <= 0) {
- return accumulator;
- }
- if (accumulator.size() >= n) {
- if (val > accumulator.peek()) {
- accumulator.remove();
- accumulator.add(val);
- }
- } else {
- accumulator.add(val);
- }
- return accumulator;
- }
- public static List<Integer> result(PriorityQueue<Integer> accumulator) {
- List<Integer> res = new ArrayList<>(accumulator);
- Collections.reverse(res);
- return res;
- }
- }
-
-
- public static class MockDataSource implements DataSource {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
-
- public MockDataSource() {
- for (int i = 0; i < 5; ++i) {
- RECORDS.add(new Values(i, "x", null));
- }
- }
-
- @Override
- public void open(ChannelContext ctx) {
- for (Values v : RECORDS) {
- ctx.emit(v);
- }
- ctx.fireChannelInactive();
- }
- }
-
- public static class MockGroupDataSource implements DataSource {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
-
- public MockGroupDataSource() {
- for (int i = 0; i < 10; ++i) {
- RECORDS.add(new Values(i/3, i, (i+1)* 0.5, "x", i/2));
- }
- }
-
- @Override
- public void open(ChannelContext ctx) {
- for (Values v : RECORDS) {
- ctx.emit(v);
- }
- // force evaluation of the aggregate function on the last group
- ctx.flush();
- ctx.fireChannelInactive();
- }
- }
-
- public static class MockEmpDataSource implements DataSource {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
-
- public MockEmpDataSource() {
- RECORDS.add(new Values(1, "emp1", 1));
- RECORDS.add(new Values(2, "emp2", 1));
- RECORDS.add(new Values(3, "emp3", 2));
- }
-
- @Override
- public void open(ChannelContext ctx) {
- for (Values v : RECORDS) {
- ctx.emit(v);
- }
- ctx.flush();
- ctx.fireChannelInactive();
- }
- }
-
- public static class MockDeptDataSource implements DataSource {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
-
- public MockDeptDataSource() {
- RECORDS.add(new Values(1, "dept1"));
- RECORDS.add(new Values(2, "dept2"));
- RECORDS.add(new Values(3, "dept3"));
- }
-
- @Override
- public void open(ChannelContext ctx) {
- for (Values v : RECORDS) {
- ctx.emit(v);
- }
- ctx.flush();
- ctx.fireChannelInactive();
- }
- }
-
- public static class MockNestedDataSource implements DataSource {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
-
- public MockNestedDataSource() {
- List<Integer> ints = Arrays.asList(100, 200, 300);
- for (int i = 0; i < 5; ++i) {
- Map<String, Integer> map = new HashMap<>();
- map.put("b", i);
- map.put("c", i*i);
- Map<String, Map<String, Integer>> mm = new HashMap<>();
- mm.put("a", map);
- RECORDS.add(new Values(i, map, mm, ints));
- }
- }
-
- @Override
- public void open(ChannelContext ctx) {
- for (Values v : RECORDS) {
- ctx.emit(v);
- }
- ctx.fireChannelInactive();
- }
- }
-
- public static class MockState implements State {
- /**
- * Collect all values in a static variable as the instance will go through serialization and deserialization.
- * NOTE: This should be cleared before or after running each test.
- */
- private transient static final List<List<Object> > VALUES = new ArrayList<>();
-
- public static List<List<Object>> getCollectedValues() {
- return VALUES;
- }
-
- @Override
- public void beginCommit(Long txid) {
- // NOOP
- }
-
- @Override
- public void commit(Long txid) {
- // NOOP
- }
-
- public void updateState(List<TridentTuple> tuples, TridentCollector collector) {
- for (TridentTuple tuple : tuples) {
- VALUES.add(tuple.getValues());
- }
- }
- }
-
- public static class MockStateFactory implements StateFactory {
-
- @Override
- public State makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
- return new MockState();
- }
- }
-
- public static class MockStateUpdater implements StateUpdater<MockState> {
-
- @Override
- public void updateState(MockState state, List<TridentTuple> tuples, TridentCollector collector) {
- state.updateState(tuples, collector);
- }
-
- @Override
- public void prepare(Map conf, TridentOperationContext context) {
- // NOOP
- }
-
- @Override
- public void cleanup() {
- // NOOP
- }
- }
-
- public static class MockSqlTridentDataSource implements ISqlTridentDataSource {
- @Override
- public IBatchSpout getProducer() {
- return new MockSpout();
- }
-
- @Override
- public SqlTridentConsumer getConsumer() {
- return new SimpleSqlTridentConsumer(new MockStateFactory(), new MockStateUpdater());
- }
-
- private static class MockSpout implements IBatchSpout {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
- private final Fields OUTPUT_FIELDS = new Fields("ID", "NAME", "ADDR");
-
- public MockSpout() {
- RECORDS.add(new Values(0, "a", "y"));
- RECORDS.add(new Values(1, "ab", "y"));
- RECORDS.add(new Values(2, "abc", "y"));
- RECORDS.add(new Values(3, "abcd", "y"));
- RECORDS.add(new Values(4, "abcde", "y"));
- }
-
- private boolean emitted = false;
-
- @Override
- public void open(Map conf, TopologyContext context) {
- }
-
- @Override
- public void emitBatch(long batchId, TridentCollector collector) {
- if (emitted) {
- return;
- }
-
- for (Values r : RECORDS) {
- collector.emit(r);
- }
- emitted = true;
- }
-
- @Override
- public void ack(long batchId) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Map<String, Object> getComponentConfiguration() {
- return null;
- }
-
- @Override
- public Fields getOutputFields() {
- return OUTPUT_FIELDS;
- }
- }
- }
-
- public static class MockSqlTridentGroupedDataSource implements ISqlTridentDataSource {
- @Override
- public IBatchSpout getProducer() {
- return new MockGroupedSpout();
- }
-
- @Override
- public SqlTridentConsumer getConsumer() {
- return new SimpleSqlTridentConsumer(new MockStateFactory(), new MockStateUpdater());
- }
-
- private static class MockGroupedSpout implements IBatchSpout {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
- private final Fields OUTPUT_FIELDS = new Fields("ID", "GRPID", "NAME", "ADDR", "AGE", "SCORE");
-
- public MockGroupedSpout() {
- for (int i = 0; i < 5; ++i) {
- RECORDS.add(new Values(i, 0, "x", "y", 5 - i, i * 10));
- }
- }
-
- private boolean emitted = false;
-
- @Override
- public void open(Map conf, TopologyContext context) {
- }
-
- @Override
- public void emitBatch(long batchId, TridentCollector collector) {
- if (emitted) {
- return;
- }
-
- for (Values r : RECORDS) {
- collector.emit(r);
- }
- emitted = true;
- }
-
- @Override
- public void ack(long batchId) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Map<String, Object> getComponentConfiguration() {
- return null;
- }
-
- @Override
- public Fields getOutputFields() {
- return OUTPUT_FIELDS;
- }
- }
- }
-
- public static class MockSqlTridentJoinDataSourceEmp implements ISqlTridentDataSource {
- @Override
- public IBatchSpout getProducer() {
- return new MockSpout();
- }
-
- @Override
- public SqlTridentConsumer getConsumer() {
- return new SimpleSqlTridentConsumer(new MockStateFactory(), new MockStateUpdater());
- }
-
- private static class MockSpout implements IBatchSpout {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
- private final Fields OUTPUT_FIELDS = new Fields("EMPID", "EMPNAME", "DEPTID");
-
- public MockSpout() {
- for (int i = 0; i < 5; ++i) {
- RECORDS.add(new Values(i, "emp-" + i, i % 2));
- }
- for (int i = 10; i < 15; ++i) {
- RECORDS.add(new Values(i, "emp-" + i, i));
- }
- }
-
- private boolean emitted = false;
-
- @Override
- public void open(Map conf, TopologyContext context) {
- }
-
- @Override
- public void emitBatch(long batchId, TridentCollector collector) {
- if (emitted) {
- return;
- }
-
- for (Values r : RECORDS) {
- collector.emit(r);
- }
- emitted = true;
- }
-
- @Override
- public void ack(long batchId) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Map<String, Object> getComponentConfiguration() {
- return null;
- }
-
- @Override
- public Fields getOutputFields() {
- return OUTPUT_FIELDS;
- }
- }
- }
-
- public static class MockSqlTridentJoinDataSourceDept implements ISqlTridentDataSource {
- @Override
- public IBatchSpout getProducer() {
- return new MockSpout();
- }
-
- @Override
- public SqlTridentConsumer getConsumer() {
- return new SimpleSqlTridentConsumer(new MockStateFactory(), new MockStateUpdater());
- }
-
- private static class MockSpout implements IBatchSpout {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
- private final Fields OUTPUT_FIELDS = new Fields("DEPTID", "DEPTNAME");
-
- public MockSpout() {
- for (int i = 0; i < 5; ++i) {
- RECORDS.add(new Values(i, "dept-" + i));
- }
- }
-
- private boolean emitted = false;
-
- @Override
- public void open(Map conf, TopologyContext context) {
- }
-
- @Override
- public void emitBatch(long batchId, TridentCollector collector) {
- if (emitted) {
- return;
- }
-
- for (Values r : RECORDS) {
- collector.emit(r);
- }
- emitted = true;
- }
-
- @Override
- public void ack(long batchId) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Map<String, Object> getComponentConfiguration() {
- return null;
- }
-
- @Override
- public Fields getOutputFields() {
- return OUTPUT_FIELDS;
- }
- }
- }
-
- public static class MockSqlTridentNestedDataSource implements ISqlTridentDataSource {
- @Override
- public IBatchSpout getProducer() {
- return new MockSpout();
- }
-
- @Override
- public SqlTridentConsumer getConsumer() {
- return new SimpleSqlTridentConsumer(new MockStateFactory(), new MockStateUpdater());
- }
-
- private static class MockSpout implements IBatchSpout {
- private final ArrayList<Values> RECORDS = new ArrayList<>();
- private final Fields OUTPUT_FIELDS = new Fields("ID", "MAPFIELD", "NESTEDMAPFIELD", "ARRAYFIELD");
-
- public MockSpout() {
- List<Integer> ints = Arrays.asList(100, 200, 300);
- for (int i = 0; i < 5; ++i) {
- Map<String, Integer> map = new HashMap<>();
- map.put("b", i);
- map.put("c", i*i);
- Map<String, Map<String, Integer>> mm = new HashMap<>();
- mm.put("a", map);
- RECORDS.add(new Values(i, map, mm, ints));
- }
- }
-
- private boolean emitted = false;
-
- @Override
- public void open(Map conf, TopologyContext context) {
- }
-
- @Override
- public void emitBatch(long batchId, TridentCollector collector) {
- if (emitted) {
- return;
- }
-
- for (Values r : RECORDS) {
- collector.emit(r);
- }
- emitted = true;
- }
-
- @Override
- public void ack(long batchId) {
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public Map<String, Object> getComponentConfiguration() {
- return null;
- }
-
- @Override
- public Fields getOutputFields() {
- return OUTPUT_FIELDS;
- }
- }
- }
-
- public static class CollectDataChannelHandler implements ChannelHandler {
- private final List<Values> values;
-
- public CollectDataChannelHandler(List<Values> values) {
- this.values = values;
- }
-
- @Override
- public void dataReceived(ChannelContext ctx, Values data) {
- values.add(data);
- }
-
- @Override
- public void channelInactive(ChannelContext ctx) {}
-
- @Override
- public void exceptionCaught(Throwable cause) {
- throw new RuntimeException(cause);
- }
-
- @Override
- public void flush(ChannelContext ctx) {}
-
- @Override
- public void setSource(ChannelContext ctx, Object source) {}
- }
-
- public static long monotonicNow() {
- final long NANOSECONDS_PER_MILLISECOND = 1000000;
- return System.nanoTime() / NANOSECONDS_PER_MILLISECOND;
- }
-}
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/runtime/datasource/socket/TestSocketDataSourceProvider.java
----------------------------------------------------------------------
diff --git a/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/runtime/datasource/socket/TestSocketDataSourceProvider.java b/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/runtime/datasource/socket/TestSocketDataSourceProvider.java
deleted file mode 100644
index 1e8edee..0000000
--- a/external/sql/storm-sql-runtime/src/test/org/apache/storm/sql/runtime/datasource/socket/TestSocketDataSourceProvider.java
+++ /dev/null
@@ -1,94 +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.storm.sql.runtime.datasource.socket;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.apache.storm.sql.runtime.DataSourcesRegistry;
-import org.apache.storm.sql.runtime.FieldInfo;
-import org.apache.storm.sql.runtime.ISqlTridentDataSource;
-import org.apache.storm.sql.runtime.serde.json.JsonSerializer;
-import org.apache.storm.sql.runtime.datasource.socket.trident.SocketState;
-import org.apache.storm.sql.runtime.datasource.socket.trident.SocketStateUpdater;
-import org.apache.storm.trident.state.StateUpdater;
-import org.apache.storm.trident.tuple.TridentTuple;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TestSocketDataSourceProvider {
- private static final List<FieldInfo> FIELDS = ImmutableList.of(
- new FieldInfo("ID", int.class, true),
- new FieldInfo("val", String.class, false));
- private static final List<String> FIELD_NAMES = ImmutableList.of("ID", "val");
- private static final JsonSerializer SERIALIZER = new JsonSerializer(FIELD_NAMES);
-
- @Test
- public void testSocketSink() throws IOException {
- ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(
- URI.create("socket://localhost:8888"), null, null, new Properties(), FIELDS);
- Assert.assertNotNull(ds);
-
- ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
-
- Assert.assertEquals(SocketState.Factory.class, consumer.getStateFactory().getClass());
- Assert.assertEquals(SocketStateUpdater.class, consumer.getStateUpdater().getClass());
-
- // makeState() fails on creating State so we just mock SocketState anyway
- SocketState mockState = mock(SocketState.class);
- StateUpdater stateUpdater = consumer.getStateUpdater();
-
- List<TridentTuple> tupleList = mockTupleList();
-
- stateUpdater.updateState(mockState, tupleList, null);
- for (TridentTuple t : tupleList) {
- String serializedValue = new String(SERIALIZER.write(t.getValues(), null).array());
- verify(mockState).write(serializedValue + "\n");
- }
- }
-
- private static List<TridentTuple> mockTupleList() {
- List<TridentTuple> tupleList = new ArrayList<>();
- TridentTuple t0 = mock(TridentTuple.class);
- TridentTuple t1 = mock(TridentTuple.class);
- when(t0.getValueByField("ID")).thenReturn(1);
- when(t0.getValueByField("val")).thenReturn("2");
- doReturn(Lists.<Object>newArrayList(1, "2")).when(t0).getValues();
- when(t0.size()).thenReturn(2);
-
- when(t1.getValueByField("ID")).thenReturn(2);
- when(t1.getValueByField("val")).thenReturn("3");
- doReturn(Lists.<Object>newArrayList(2, "3")).when(t1).getValues();
- when(t1.size()).thenReturn(2);
-
- tupleList.add(t0);
- tupleList.add(t1);
- return tupleList;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/pom.xml
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/pom.xml b/external/storm-submit-tools/pom.xml
deleted file mode 100644
index 90e6dd8..0000000
--- a/external/storm-submit-tools/pom.xml
+++ /dev/null
@@ -1,216 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>storm</artifactId>
- <groupId>org.apache.storm</groupId>
- <version>2.0.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>storm-submit-tools</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <!-- Aether :: maven dependency resolution -->
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>3.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.sisu</groupId>
- <artifactId>sisu-inject-plexus</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>1.12</version>
- </dependency>
-
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>1.12</version>
- </dependency>
-
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-impl</artifactId>
- <version>1.12</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-aether-provider</artifactId>
- <version>3.0.3</version>
- <exclusions>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-spi</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-util</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-impl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-connector-file</artifactId>
- <version>1.12</version>
- </dependency>
-
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-connector-wagon</artifactId>
- <version>1.12</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http-lightweight</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http-shared</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http</artifactId>
- <version>1.0</version>
- <exclusions>
- </exclusions>
- </dependency>
-
- <!-- storm-core is needed only for test (surefire) -->
- <dependency>
- <groupId>org.apache.storm</groupId>
- <artifactId>storm-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <configuration>
- <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.sf</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.dsa</exclude>
- <exclude>META-INF/*.RSA</exclude>
- <exclude>META-INF/*.rsa</exclude>
- <exclude>META-INF/*.EC</exclude>
- <exclude>META-INF/*.ec</exclude>
- <exclude>META-INF/MSFTSIG.SF</exclude>
- <exclude>META-INF/MSFTSIG.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
deleted file mode 100644
index ac50110..0000000
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/command/DependencyResolverMain.java
+++ /dev/null
@@ -1,158 +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.storm.submit.command;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import org.apache.commons.lang.StringUtils;
-import org.apache.storm.submit.dependency.AetherUtils;
-import org.apache.storm.submit.dependency.DependencyResolver;
-import org.json.simple.JSONValue;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResult;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-public class DependencyResolverMain {
-
- public static void main(String[] args) {
- if (args.length < 1) {
- throw new IllegalArgumentException("artifacts must be presented.");
- }
-
- String artifactsArg = args[0];
-
- // DO NOT CHANGE THIS TO SYSOUT
- System.err.println("DependencyResolver input - artifacts: " + artifactsArg);
- List<Dependency> dependencies = parseArtifactArgs(artifactsArg);
-
- List<RemoteRepository> repositories;
- if (args.length > 1) {
- String remoteRepositoryArg = args[1];
-
- // DO NOT CHANGE THIS TO SYSOUT
- System.err.println("DependencyResolver input - repositories: " + remoteRepositoryArg);
-
- repositories = parseRemoteRepositoryArgs(remoteRepositoryArg);
- } else {
- repositories = Collections.emptyList();
- }
-
- try {
- String localMavenRepoPath = getOrDefaultLocalMavenRepositoryPath("local-repo");
- DependencyResolver resolver = new DependencyResolver(localMavenRepoPath, repositories);
-
- List<ArtifactResult> artifactResults = resolver.resolve(dependencies);
-
- Iterable<ArtifactResult> missingArtifacts = filterMissingArtifacts(artifactResults);
- if (missingArtifacts.iterator().hasNext()) {
- printMissingArtifactsToSysErr(missingArtifacts);
- throw new RuntimeException("Some artifacts are not resolved");
- }
-
- System.out.println(JSONValue.toJSONString(transformArtifactResultToArtifactToPaths(artifactResults)));
- System.out.flush();
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
- }
-
- private static Iterable<ArtifactResult> filterMissingArtifacts(List<ArtifactResult> artifactResults) {
- return Iterables.filter(artifactResults, new Predicate<ArtifactResult>() {
- @Override
- public boolean apply(ArtifactResult artifactResult) {
- return artifactResult.isMissing();
- }
- });
- }
-
- private static void printMissingArtifactsToSysErr(Iterable<ArtifactResult> missingArtifacts) {
- for (ArtifactResult artifactResult : missingArtifacts) {
- System.err.println("ArtifactResult : " + artifactResult + " / Errors : " + artifactResult.getExceptions());
- }
- }
-
- private static List<Dependency> parseArtifactArgs(String artifactArgs) {
- List<String> artifacts = Arrays.asList(artifactArgs.split(","));
- List<Dependency> dependencies = new ArrayList<>(artifacts.size());
- for (String artifactOpt : artifacts) {
- if (artifactOpt.trim().isEmpty()) {
- continue;
- }
-
- dependencies.add(AetherUtils.parseDependency(artifactOpt));
- }
-
- return dependencies;
- }
-
- private static List<RemoteRepository> parseRemoteRepositoryArgs(String remoteRepositoryArg) {
- List<String> repositories = Arrays.asList(remoteRepositoryArg.split(","));
- List<RemoteRepository> remoteRepositories = new ArrayList<>(repositories.size());
- for (String repositoryOpt : repositories) {
- if (repositoryOpt.trim().isEmpty()) {
- continue;
- }
-
- remoteRepositories.add(AetherUtils.parseRemoteRepository(repositoryOpt));
- }
-
- return remoteRepositories;
- }
-
- private static Map<String, String> transformArtifactResultToArtifactToPaths(List<ArtifactResult> artifactResults) {
- Map<String, String> artifactToPath = new LinkedHashMap<>();
- for (ArtifactResult artifactResult : artifactResults) {
- Artifact artifact = artifactResult.getArtifact();
- artifactToPath.put(AetherUtils.artifactToString(artifact), artifact.getFile().getAbsolutePath());
- }
- return artifactToPath;
- }
-
- private static String getOrDefaultLocalMavenRepositoryPath(String defaultPath) {
- String localMavenRepoPathStr = getLocalMavenRepositoryPath();
- if (StringUtils.isNotEmpty(localMavenRepoPathStr)) {
- Path localMavenRepoPath = new File(localMavenRepoPathStr).toPath();
- if (Files.exists(localMavenRepoPath) && Files.isDirectory(localMavenRepoPath)) {
- return localMavenRepoPathStr;
- }
- }
-
- return defaultPath;
- }
-
- private static String getLocalMavenRepositoryPath() {
- String userHome = System.getProperty("user.home");
- if (StringUtils.isNotEmpty(userHome)) {
- return userHome + File.separator + ".m2" + File.separator + "repository";
- }
-
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
deleted file mode 100644
index 086be2b..0000000
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/AetherUtils.java
+++ /dev/null
@@ -1,91 +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.storm.submit.dependency;
-
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class AetherUtils {
- private AetherUtils() {
- }
-
- public static Dependency parseDependency(String dependency) {
- List<String> dependencyAndExclusions = Arrays.asList(dependency.split("\\^"));
- Collection<Exclusion> exclusions = new ArrayList<>();
- for (int idx = 1 ; idx < dependencyAndExclusions.size() ; idx++) {
- exclusions.add(AetherUtils.createExclusion(dependencyAndExclusions.get(idx)));
- }
-
- Artifact artifact = new DefaultArtifact(dependencyAndExclusions.get(0));
- return new Dependency(artifact, JavaScopes.COMPILE, false, exclusions);
- }
-
- public static Exclusion createExclusion(String exclusionString) {
- String[] parts = exclusionString.split(":");
-
- // length of parts should be greater than 0
- String groupId = parts[0];
-
- String artifactId = "*";
- String classifier = "*";
- String extension = "*";
-
- int len = parts.length;
- if (len > 1) {
- artifactId = parts[1];
- }
- if (len > 2) {
- classifier = parts[2];
- }
- if (len > 3) {
- extension = parts[3];
- }
-
- return new Exclusion(groupId, artifactId, classifier, extension);
- }
-
- public static String artifactToString(Artifact artifact) {
- StringBuilder buffer = new StringBuilder(128);
- buffer.append(artifact.getGroupId());
- buffer.append(':').append(artifact.getArtifactId());
- buffer.append(':').append(artifact.getExtension());
- if (artifact.getClassifier().length() > 0) {
- buffer.append(':').append(artifact.getClassifier());
- }
- buffer.append(':').append(artifact.getVersion());
- return buffer.toString();
- }
-
- public static RemoteRepository parseRemoteRepository(String repository) {
- String[] parts = repository.split("\\^");
- if (parts.length < 2) {
- throw new IllegalArgumentException("Bad remote repository form: " + repository);
- }
-
- return new RemoteRepository(parts[0], "default", parts[1]);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
deleted file mode 100644
index 816e3cc..0000000
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/Booter.java
+++ /dev/null
@@ -1,51 +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.storm.submit.dependency;
-
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.repository.LocalRepository;
-import org.sonatype.aether.repository.RemoteRepository;
-
-import java.io.File;
-
-/**
- * Manage mvn repository.
- */
-public class Booter {
- public static RepositorySystem newRepositorySystem() {
- return RepositorySystemFactory.newRepositorySystem();
- }
-
- public static RepositorySystemSession newRepositorySystemSession(
- RepositorySystem system, String localRepoPath) {
- MavenRepositorySystemSession session = new MavenRepositorySystemSession();
-
- LocalRepository localRepo =
- new LocalRepository(new File(localRepoPath).getAbsolutePath());
- session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
-
- return session;
- }
-
- public static RemoteRepository newCentralRepository() {
- return new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
deleted file mode 100644
index 4534344..0000000
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/DependencyResolver.java
+++ /dev/null
@@ -1,98 +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.storm.submit.dependency;
-
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.ArtifactResolutionException;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.resolution.DependencyRequest;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.util.artifact.JavaScopes;
-import org.sonatype.aether.util.filter.DependencyFilterUtils;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class DependencyResolver {
- private final RepositorySystem system = Booter.newRepositorySystem();
- private final RepositorySystemSession session;
-
- private final List<RemoteRepository> remoteRepositories;
-
- public DependencyResolver(String localRepoPath) {
- this(localRepoPath, Collections.emptyList());
- }
-
- public DependencyResolver(String localRepoPath, List<RemoteRepository> repositories) {
- localRepoPath = handleRelativePath(localRepoPath);
-
- session = Booter.newRepositorySystemSession(system, localRepoPath);
-
- remoteRepositories = new ArrayList<>();
- remoteRepositories.add(Booter.newCentralRepository());
- remoteRepositories.addAll(repositories);
- }
-
- private String handleRelativePath(String localRepoPath) {
- File repoDir = new File(localRepoPath);
- if (!repoDir.isAbsolute()) {
- // find homedir
- String home = System.getProperty("storm.home");
- if (home == null) {
- home = ".";
- }
-
- localRepoPath = home + "/" + localRepoPath;
- }
- return localRepoPath;
- }
-
- public List<ArtifactResult> resolve(List<Dependency> dependencies) throws MalformedURLException,
- DependencyResolutionException, ArtifactResolutionException {
-
- DependencyFilter classpathFilter = DependencyFilterUtils
- .classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME);
-
- if (dependencies.size() == 0) {
- return Collections.EMPTY_LIST;
- }
-
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(dependencies.get(0));
- for (int idx = 1; idx < dependencies.size(); idx++) {
- collectRequest.addDependency(dependencies.get(idx));
- }
-
- for (RemoteRepository repository : remoteRepositories) {
- collectRequest.addRepository(repository);
- }
-
- DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
- return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java b/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
deleted file mode 100644
index f1fa2db..0000000
--- a/external/storm-submit-tools/src/main/java/org/apache/storm/submit/dependency/RepositorySystemFactory.java
+++ /dev/null
@@ -1,67 +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.storm.submit.dependency;
-
-import org.apache.maven.repository.internal.DefaultServiceLocator;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.providers.http.HttpWagon;
-import org.apache.maven.wagon.providers.http.LightweightHttpWagon;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.connector.file.FileRepositoryConnectorFactory;
-import org.sonatype.aether.connector.wagon.WagonProvider;
-import org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory;
-import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
-
-/**
- * Get maven repository instance.
- */
-public class RepositorySystemFactory {
- public static RepositorySystem newRepositorySystem() {
- DefaultServiceLocator locator = new DefaultServiceLocator();
- locator.addService(RepositoryConnectorFactory.class, FileRepositoryConnectorFactory.class);
- locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);
- locator.setServices(WagonProvider.class, new ManualWagonProvider());
-
- return locator.getService(RepositorySystem.class);
- }
-
- /**
- * ManualWagonProvider
- */
- public static class ManualWagonProvider implements WagonProvider {
-
- @Override
- public Wagon lookup(String roleHint) throws Exception {
- if ("http".equals(roleHint)) {
- return new LightweightHttpWagon();
- }
-
- if ("https".equals(roleHint)) {
- return new HttpWagon();
- }
-
- return null;
- }
-
- @Override
- public void release(Wagon arg0) {
-
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
deleted file mode 100644
index 9951621..0000000
--- a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/AetherUtilsTest.java
+++ /dev/null
@@ -1,102 +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.storm.submit.dependency;
-
-import com.google.common.collect.Lists;
-import org.junit.Test;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
-
-import java.util.List;
-
-import static org.junit.Assert.*;
-
-public class AetherUtilsTest {
- @Test
- public void parseDependency() throws Exception {
- String testDependency = "testgroup:testartifact:1.0.0^testgroup:testexcartifact^testgroup:*";
-
- Dependency dependency = AetherUtils.parseDependency(testDependency);
-
- assertEquals("testgroup", dependency.getArtifact().getGroupId());
- assertEquals("testartifact", dependency.getArtifact().getArtifactId());
- assertEquals("1.0.0", dependency.getArtifact().getVersion());
- assertEquals(JavaScopes.COMPILE, dependency.getScope());
-
- assertEquals(2, dependency.getExclusions().size());
-
- List<Exclusion> exclusions = Lists.newArrayList(dependency.getExclusions());
-
- Exclusion exclusion = exclusions.get(0);
- assertEquals("testgroup", exclusion.getGroupId());
- assertEquals("testexcartifact", exclusion.getArtifactId());
- assertEquals(JavaScopes.COMPILE, dependency.getScope());
-
- exclusion = exclusions.get(1);
- assertEquals("testgroup", exclusion.getGroupId());
- assertEquals("*", exclusion.getArtifactId());
- assertEquals(JavaScopes.COMPILE, dependency.getScope());
- }
-
- @Test
- public void createExclusion() throws Exception {
- String testExclusion = "group";
- Exclusion exclusion = AetherUtils.createExclusion(testExclusion);
-
- assertEquals("group", exclusion.getGroupId());
- assertEquals("*", exclusion.getArtifactId());
- assertEquals("*", exclusion.getClassifier());
- assertEquals("*", exclusion.getExtension());
-
- testExclusion = "group:artifact";
- exclusion = AetherUtils.createExclusion(testExclusion);
-
- assertEquals("group", exclusion.getGroupId());
- assertEquals("artifact", exclusion.getArtifactId());
- assertEquals("*", exclusion.getClassifier());
- assertEquals("*", exclusion.getExtension());
-
- testExclusion = "group:artifact:site";
- exclusion = AetherUtils.createExclusion(testExclusion);
-
- assertEquals("group", exclusion.getGroupId());
- assertEquals("artifact", exclusion.getArtifactId());
- assertEquals("site", exclusion.getClassifier());
- assertEquals("*", exclusion.getExtension());
-
- testExclusion = "group:artifact:site:jar";
- exclusion = AetherUtils.createExclusion(testExclusion);
-
- assertEquals("group", exclusion.getGroupId());
- assertEquals("artifact", exclusion.getArtifactId());
- assertEquals("site", exclusion.getClassifier());
- assertEquals("jar", exclusion.getExtension());
- }
-
- @Test
- public void artifactToString() throws Exception {
- Artifact testArtifact = new DefaultArtifact("org.apache.storm:storm-core:1.0.0");
-
- String ret = AetherUtils.artifactToString(testArtifact);
- assertEquals("org.apache.storm:storm-core:jar:1.0.0", ret);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/storm/blob/e9d78338/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
----------------------------------------------------------------------
diff --git a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java b/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.java
deleted file mode 100644
index 086abad..0000000
--- a/external/storm-submit-tools/src/test/java/org/apache/storm/submit/dependency/DependencyResolverTest.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.storm.submit.dependency;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.io.FileUtils;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.resolution.ArtifactResult;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.artifact.JavaScopes;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-public class DependencyResolverTest {
- private static Path tempDirForTest;
-
- private DependencyResolver sut;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- tempDirForTest = Files.createTempDirectory("dr-test");
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- FileUtils.deleteQuietly(tempDirForTest.toFile());
- }
-
- @Before
- public void setUp() {
- sut = new DependencyResolver(tempDirForTest.toAbsolutePath().toString());
- }
-
- @Test
- public void resolveValid() throws Exception {
- // please pick small artifact which has small transitive dependency
- // and let's mark as Ignore if we want to run test even without internet or maven central is often not stable
- Dependency dependency = new Dependency(new DefaultArtifact("org.apache.storm:flux-core:1.0.0"), JavaScopes.COMPILE);
- List<ArtifactResult> results = sut.resolve(Lists.newArrayList(dependency));
-
- assertTrue(results.size() > 0);
- // it should be org.apache.storm:flux-core:jar:1.0.0 and commons-cli:commons-cli:jar:1.2
- assertContains(results, "org.apache.storm", "flux-core", "1.0.0");
- assertContains(results, "commons-cli", "commons-cli", "1.2");
- }
-
- private void assertContains(List<ArtifactResult> results, String groupId, String artifactId, String version) {
- for (ArtifactResult result : results) {
- if (result.getArtifact().getGroupId().equals(groupId) &&
- result.getArtifact().getArtifactId().equals(artifactId) &&
- result.getArtifact().getVersion().equals(version) &&
- result.isResolved()) {
- return;
- }
- }
-
- throw new AssertionError("Result doesn't contain expected artifact > " + groupId + ":" + artifactId + ":" + version);
- }
-
-}
\ No newline at end of file