-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CXF-9023] Increase unit test coverage on org.apache.cxf.bus (#1901)
* [CXF-9023] Increase unit test coverage on org.apache.cxf.bus * Remove the tests for classes that already have enough coverage --------- Co-authored-by: Andriy Redko <drreta@gmail.com>
- Loading branch information
Showing
3 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
core/src/test/java/org/apache/cxf/bus/resource/ResourceManagerImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* 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.cxf.bus.resource; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.cxf.Bus; | ||
import org.apache.cxf.BusFactory; | ||
import org.apache.cxf.resource.ResourceManager; | ||
import org.apache.cxf.resource.ResourceResolver; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ResourceManagerImplTest { | ||
|
||
private Bus bus; | ||
|
||
private ResourceManagerImpl resourceManager; | ||
|
||
|
||
@Before | ||
public void setup() { | ||
BusFactory.setDefaultBus(null); | ||
BusFactory.setThreadDefaultBus(null); | ||
bus = BusFactory.newInstance().createBus(); | ||
resourceManager = new ResourceManagerImpl(bus); | ||
} | ||
|
||
@Test | ||
public void testOnFirstResolve() { | ||
List<ResourceResolver> beforeFirstResolve = resourceManager.getResourceResolvers(); | ||
resourceManager.onFirstResolve(); | ||
List<ResourceResolver> afterFirstResolve = resourceManager.getResourceResolvers(); | ||
assertEquals("No additional resolvers added.", beforeFirstResolve.size(), | ||
afterFirstResolve.size()); | ||
} | ||
|
||
@Test | ||
public void testSetResolvers() { | ||
List<ResourceResolver> initialResolvers = resourceManager.getResourceResolvers(); | ||
ResourceResolver mockResourceResolver = Mockito.mock(ResourceResolver.class); | ||
List<ResourceResolver> mockResolvers = List.of(mockResourceResolver); | ||
resourceManager.setResolvers(mockResolvers); | ||
|
||
List<ResourceResolver> actual = resourceManager.getResourceResolvers(); | ||
assertEquals("Contains our Mock ResourceResolver", 1, actual.size()); | ||
|
||
resourceManager.setResolvers(initialResolvers); | ||
actual = resourceManager.getResourceResolvers(); | ||
assertEquals("Initial resolvers should have been cleared by set call.", | ||
0, actual.size()); | ||
} | ||
|
||
@Test | ||
public void testGetRegistrationType() { | ||
ResourceManagerImpl impl = new ResourceManagerImpl(); | ||
assertEquals("ResourceManagerImpl is of type ResourceManager.class", | ||
ResourceManager.class, impl.getRegistrationType()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters