|
| 1 | +/* |
| 2 | + * Copyright (c) 2010-2011 Sonatype, Inc. All rights reserved. |
| 3 | + * |
| 4 | + * This program is licensed to you under the Apache License Version 2.0, |
| 5 | + * and you may not use this file except in compliance with the Apache License Version 2.0. |
| 6 | + * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. |
| 7 | + * |
| 8 | + * Unless required by applicable law or agreed to in writing, |
| 9 | + * software distributed under the Apache License Version 2.0 is distributed on an |
| 10 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. |
| 12 | + */ |
| 13 | +package com.ning.http.client; |
| 14 | + |
| 15 | +import com.ning.http.client.Realm.AuthScheme; |
| 16 | +import com.ning.http.client.Realm.RealmBuilder; |
| 17 | +import org.testng.Assert; |
| 18 | +import org.testng.annotations.Test; |
| 19 | + |
| 20 | +public class RealmTest { |
| 21 | + @Test(groups = "fast") |
| 22 | + public void testClone() { |
| 23 | + RealmBuilder builder = new RealmBuilder(); |
| 24 | + builder.setPrincipal( "user" ).setPassword( "pass" ); |
| 25 | + builder.setEnconding( "enc" ).setUsePreemptiveAuth( true ); |
| 26 | + builder.setRealmName( "realm" ).setAlgorithm( "algo" ); |
| 27 | + builder.setScheme( AuthScheme.BASIC ); |
| 28 | + Realm orig = builder.build(); |
| 29 | + |
| 30 | + Realm clone = new RealmBuilder().clone( orig ).build(); |
| 31 | + Assert.assertEquals( clone.getPrincipal(), orig.getPrincipal() ); |
| 32 | + Assert.assertEquals( clone.getPassword(), orig.getPassword() ); |
| 33 | + Assert.assertEquals( clone.getEncoding(), orig.getEncoding() ); |
| 34 | + Assert.assertEquals( clone.getUsePreemptiveAuth(), orig.getUsePreemptiveAuth() ); |
| 35 | + Assert.assertEquals( clone.getRealmName(), orig.getRealmName() ); |
| 36 | + Assert.assertEquals( clone.getAlgorithm(), orig.getAlgorithm() ); |
| 37 | + Assert.assertEquals( clone.getAuthScheme(), orig.getAuthScheme() ); |
| 38 | + } |
| 39 | +} |
0 commit comments