/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project 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 io.netty.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import org.junit.Before;
import org.junit.Test;

public class DefaultAttributeMapTest {
    
    private DefaultAttributeMap map;
    
    @Before
    public void setup() {
        this.map = new DefaultAttributeMap();
    }
    
    @Test
    public void testMapExists() {
        assertNotNull(this.map);
    }
    
    @Test
    public void testGetSetString() {
        AttributeKey<String> key = new AttributeKey<String>("Nothing");
        Attribute one = this.map.attr(key);
        
        assertSame(one, this.map.attr(key));
        
        one.setIfAbsent("Whoohoo");
        
        assertSame(one.get(), "Whoohoo");
        
        one.setIfAbsent("What");
        
        assertNotSame(one.get(), "What");
        
        one.remove();
        
        assertNull(one.get());
    }
    
    @Test
    public void testGetSetInt() {
        AttributeKey<Integer> key = new AttributeKey<Integer>("Nada");
        Attribute one = this.map.attr(key);
        
        assertSame(one, this.map.attr(key));
        
        one.setIfAbsent(3653);
        
        assertEquals(one.get(), 3653);
        
        one.setIfAbsent(1);
        
        assertNotSame(one.get(), 1);
        
        one.remove();
        
        assertNull(one.get());
    }
    
}

@@ -687,199 +687,11 @@
 ert.
-assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertNotSame;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert.assertSame;
+*;%0A
 %0Aimp
@@ -775,20 +775,16 @@
 pTest %7B%0A
-    
 %0A    pri
@@ -813,20 +813,16 @@
 ap map;%0A
-    
 %0A    @Be
@@ -860,21 +860,16 @@
         
-this.
 map = ne
@@ -891,36 +891,32 @@
 uteMap();%0A    %7D%0A
-    
 %0A    @Test%0A    p
@@ -966,21 +966,16 @@
 NotNull(
-this.
 map);%0A  
@@ -970,36 +970,32 @@
 ull(map);%0A    %7D%0A
-    
 %0A    @Test%0A    p
@@ -1111,36 +1111,39 @@
    Attribute
+%3CString%3E
  one = 
-this.
 map.attr(key
@@ -1141,32 +1141,24 @@
 .attr(key);%0A
-        
 %0A        ass
@@ -1162,37 +1162,32 @@
 assertSame(one, 
-this.
 map.attr(key));%0A
@@ -1182,32 +1182,24 @@
 attr(key));%0A
-        
 %0A        one
@@ -1219,33 +1219,24 @@
 %22Whoohoo%22);%0A
-        %0A
         asse
@@ -1261,32 +1261,24 @@
 %22Whoohoo%22);%0A
-        
 %0A        one
@@ -1295,33 +1295,24 @@
 nt(%22What%22);%0A
-        %0A
         asse
@@ -1341,24 +1341,16 @@
 What%22);%0A
-        
 %0A       
@@ -1360,33 +1360,24 @@
 e.remove();%0A
-        %0A
         asse
@@ -1401,20 +1401,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Te
@@ -1538,20 +1538,24 @@
 bute
+%3CInteger%3E
  one = 
-this.
 map.
@@ -1565,24 +1565,16 @@
 r(key);%0A
-        
 %0A       
@@ -1594,13 +1594,8 @@
 ne, 
-this.
 map.
@@ -1606,24 +1606,16 @@
 (key));%0A
-        
 %0A       
@@ -1634,33 +1634,24 @@
 sent(3653);%0A
-        %0A
         asse
@@ -1670,31 +1670,40 @@
 .get(), 
+Integer.valueOf(
 3653)
+)
 ;%0A
-        
 %0A       
@@ -1719,33 +1719,24 @@
 fAbsent(1);%0A
-        %0A
         asse
@@ -1760,24 +1760,16 @@
 (), 1);%0A
-        
 %0A       
@@ -1787,17 +1787,8 @@
 ();%0A
-        %0A
     
@@ -1824,11 +1824,6 @@
   %7D%0A
-    %0A
 %7D%0A

Fix compiler warnings