1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-11 03:09:46 +02:00

Move EntityCaps and Bookmarks API in correct package

Also move ProviderConfigTest into core, since it tests core
functionality, nothing provided by extensions. Found the reason the test
was failing since the gradle migration (provider entry test.providers),
and activated it again. \o/

New API design as of SMACK-545
This commit is contained in:
Florian Schmaus 2014-02-18 10:24:59 +01:00
parent 1f63ac31a5
commit 312f2f7508
17 changed files with 32 additions and 35 deletions

View file

@ -0,0 +1,71 @@
/**
*
* 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.
*/
package org.jivesoftware.smack.provider;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.Assert;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.ExtensionProviderInfo;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.IQProviderInfo;
import org.jivesoftware.smack.provider.ProviderFileLoader;
import org.jivesoftware.smack.provider.ProviderLoader;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.util.FileUtils;
import org.junit.Test;
import org.xmlpull.v1.XmlPullParser;
public class ProviderConfigTest {
@Test
public void addGenericLoaderProvider() {
ProviderManager.getInstance().addLoader(new ProviderLoader() {
@Override
public Collection<IQProviderInfo> getIQProviderInfo() {
ArrayList<IQProviderInfo> l = new ArrayList<IQProviderInfo>(1);
l.add(new IQProviderInfo("provider", "test:provider", new TestIQProvider()));
return l;
}
@Override
public Collection<ExtensionProviderInfo> getExtensionProviderInfo() {
return null;
}
});
Assert.assertNotNull(ProviderManager.getInstance().getIQProvider("provider", "test:provider"));
}
@Test
public void addClasspathFileLoaderProvider() throws Exception{
ProviderManager.getInstance().addLoader(new ProviderFileLoader(FileUtils.getStreamForUrl("classpath:test.providers", null)));
Assert.assertNotNull(ProviderManager.getInstance().getIQProvider("provider", "test:file_provider"));
}
public static class TestIQProvider implements IQProvider {
@Override
public IQ parseIQ(XmlPullParser parser) throws Exception {
return null;
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!-- Providers file for default Smack extensions -->
<smackProviders>
<iqProvider>
<elementName>provider</elementName>
<namespace>test:file_provider</namespace>
<className>org.jivesoftware.smack.provider.ProviderConfigTest$TestIQProvider</className>
</iqProvider>
</smackProviders>