Java源码示例:org.apache.commons.collections.set.ListOrderedSet
示例1
@Test
public void testAlterTable() throws Exception {
Exception ex= null;
try {
columns.add(new ColumnNameTypeValue("newfield", ColumnType.STRING, "my new value"));
Set<String> oldColumnNamesnew= new ListOrderedSet();
oldColumnNamesnew.add("id");
oldColumnNamesnew.add("name");
oldColumnNamesnew.add("enabled");
oldColumnNamesnew.add("timestamp");
service.alterTable(TABLE, oldColumnNamesnew, columns);
} catch (Exception e) {
ex= e;
}
assertEquals("Expected null but exception found", null, ex);
}
示例2
@Before
public void setUp() throws Exception {
siddhiManager= new StreamingSiddhiConfiguration().siddhiManager();
siddhiManager.defineStream(StreamsHelper.STREAM_DEFINITION);
metadataService= new StreamMetadataService(siddhiManager);
javaToSiddhiSerializer= new JavaToSiddhiSerializer(metadataService);
javaToAvroSerializer = new JavaToAvroSerializer(new SpecificDatumReader(InsertMessage.getClassSchema()));
Set<StreamAction> activeActions= new ListOrderedSet();
activeActions.add(StreamAction.LISTEN);
producer= Mockito.mock(Producer.class);
avroProducer= Mockito.mock(Producer.class);
//List<KeyedMessage<String, String>> km= any();
//doNothing().when(producer).send(km);
doNothing().when(producer).send(Matchers.<List<KeyedMessage<String, String>>>any());
cbk= new StreamToActionBusCallback(activeActions, streamName, avroProducer,
javaToSiddhiSerializer, javaToAvroSerializer);
}
示例3
/**
* Determines the columns that are present in the given result set.
*
* @param resultSet The result set
* @return The columns
*/
private Set getColumnsInResultSet(ResultSet resultSet) throws SQLException
{
ListOrderedSet result = new ListOrderedSet();
ResultSetMetaData metaData = resultSet.getMetaData();
for (int idx = 1; idx <= metaData.getColumnCount(); idx++)
{
result.add(metaData.getColumnName(idx).toUpperCase());
}
return result;
}
示例4
/**
* Determines the columns that are present in the given result set.
*
* @param resultSet The result set
* @return The columns
*/
private Set getColumnsInResultSet(ResultSet resultSet) throws SQLException
{
ListOrderedSet result = new ListOrderedSet();
ResultSetMetaData metaData = resultSet.getMetaData();
for (int idx = 1; idx <= metaData.getColumnCount(); idx++)
{
result.add(metaData.getColumnName(idx).toUpperCase());
}
return result;
}
示例5
public static StratioStreamingMessage getSampleMessage() {
Set<StreamAction> actions= new ListOrderedSet();
actions.add(StreamAction.LISTEN);
StratioStreamingMessage message= new StratioStreamingMessage(STREAM_NAME, Long.parseLong("1234567890"), COLUMNS);
message.setActiveActions(actions);
return message;
}
示例6
protected void initialize() {
conf= ConfigFactory.load();
ZOO_HOST= getHostsStringFromList(conf.getStringList("zookeeper.hosts"));
MONGO_HOST= getHostsStringFromList(conf.getStringList("mongo.hosts"));
siddhiManager= new StreamingSiddhiConfiguration().siddhiManager();
streamStatusDao= new StreamStatusDao();
ServiceConfiguration serviceConfiguration= new ServiceConfiguration();
callbackService= serviceConfiguration.callbackService();
streamOperationsService= new StreamOperationService(siddhiManager, streamStatusDao, callbackService);
streamOperationsService.createStream(StreamsHelper.STREAM_NAME, StreamsHelper.COLUMNS);
String queryId= streamOperationsService.addQuery(StreamsHelper.STREAM_NAME, StreamsHelper.QUERY);
message= StreamsHelper.getSampleMessage();
message.setRequest(StreamsHelper.QUERY);
validators= new ListOrderedSet();
StreamNameNotEmptyValidation validation= new StreamNameNotEmptyValidation();
validators.add(validation);
Properties properties = new Properties();
properties.put("serializer.class", "kafka.serializer.StringEncoder");
properties.put("metadata.broker.list", conf.getStringList("kafka.hosts").get(0));
properties.put("producer.type", "async");
producer = new kafka.javaapi.producer.Producer<String, String>(new ProducerConfig(properties));
ConfigurationContext configurationContext = new ConfigurationContext();
try {
ClusterSyncManager.getClusterSyncManager(configurationContext, null);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7
/**
* Returns a set that maintains the order of elements that are added
* backed by the given set.
* <p>
* If an element is added twice, the order is determined by the first add.
* The order is observed through the iterator or toArray.
*
* @param set the set to order, must not be null
* @return an ordered set backed by the given set
* @throws IllegalArgumentException if the Set is null
*/
public static Set orderedSet(Set set) {
return ListOrderedSet.decorate(set);
}