2014-02-17 23:58:40 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright the original author or authors
|
|
|
|
*
|
|
|
|
* Licensed 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.
|
|
|
|
*/
|
2014-02-18 10:24:59 +01:00
|
|
|
package org.jivesoftware.smack.provider;
|
2014-02-17 23:58:40 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2019-02-15 23:21:30 +01:00
|
|
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
2014-02-17 23:58:40 +01:00
|
|
|
import org.jivesoftware.smack.util.FileUtils;
|
2019-05-06 22:06:13 +02:00
|
|
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
|
|
|
import org.junit.Assert;
|
2014-02-17 23:58:40 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
public class ProviderConfigTest {
|
2014-02-18 10:24:59 +01:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
@Test
|
|
|
|
public void addGenericLoaderProvider() {
|
2014-05-11 09:27:41 +02:00
|
|
|
ProviderManager.addLoader(new ProviderLoader() {
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
@Override
|
|
|
|
public Collection<IQProviderInfo> getIQProviderInfo() {
|
|
|
|
ArrayList<IQProviderInfo> l = new ArrayList<IQProviderInfo>(1);
|
|
|
|
l.add(new IQProviderInfo("provider", "test:provider", new TestIQProvider()));
|
|
|
|
return l;
|
|
|
|
}
|
2014-02-18 10:24:59 +01:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
@Override
|
|
|
|
public Collection<ExtensionProviderInfo> getExtensionProviderInfo() {
|
|
|
|
return null;
|
|
|
|
}
|
2014-09-11 23:58:07 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Collection<StreamFeatureProviderInfo> getStreamFeatureProviderInfo() {
|
|
|
|
return null;
|
|
|
|
}
|
2014-02-17 23:58:40 +01:00
|
|
|
});
|
2014-02-18 10:24:59 +01:00
|
|
|
|
2014-05-11 09:27:41 +02:00
|
|
|
Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:provider"));
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|
2014-02-18 10:24:59 +01:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
@Test
|
2017-05-23 16:45:04 +02:00
|
|
|
public void addClasspathFileLoaderProvider() throws Exception {
|
2018-04-04 16:41:24 +02:00
|
|
|
ProviderManager.addLoader(new ProviderFileLoader(FileUtils.getStreamForClasspathFile("test.providers", null)));
|
2014-05-11 09:27:41 +02:00
|
|
|
Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:file_provider"));
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
public static class TestIQProvider extends IQProvider<IQ> {
|
2014-02-17 23:58:40 +01:00
|
|
|
|
|
|
|
@Override
|
2019-02-15 23:21:30 +01:00
|
|
|
public IQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
|
2014-02-17 23:58:40 +01:00
|
|
|
return null;
|
|
|
|
}
|
2014-02-18 10:24:59 +01:00
|
|
|
|
2014-02-17 23:58:40 +01:00
|
|
|
}
|
|
|
|
}
|