View Javadoc
1   /*
2    * Copyright 2002-2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.beans.factory.parsing;
18  
19  import org.junit.Test;
20  
21  import static org.junit.Assert.*;
22  
23  /**
24   * Unit tests for {@link PassThroughSourceExtractor}.
25   *
26   * @author Rick Evans
27   * @author Chris Beams
28   */
29  public final class PassThroughSourceExtractorTests {
30  
31  	@Test
32  	public void testPassThroughContract() throws Exception {
33  		Object source  = new Object();
34  		Object extractedSource = new PassThroughSourceExtractor().extractSource(source, null);
35  		assertSame("The contract of PassThroughSourceExtractor states that the supplied " +
36  				"source object *must* be returned as-is", source, extractedSource);
37  	}
38  
39  	@Test
40  	public void testPassThroughContractEvenWithNull() throws Exception {
41  		Object extractedSource = new PassThroughSourceExtractor().extractSource(null, null);
42  		assertNull("The contract of PassThroughSourceExtractor states that the supplied " +
43  				"source object *must* be returned as-is (even if null)", extractedSource);
44  	}
45  
46  }