Skip to content
Permalink
Browse files
Replace assert by simpler but equivalent calls.
  • Loading branch information
arturobernalg committed Jun 20, 2021
1 parent bc1091e commit d9d6b1fc28a72bd8610939017802de90ce72f574
Showing 8 changed files with 29 additions and 25 deletions.
@@ -205,7 +205,7 @@ public void test_Setter_Returns()
SetterReturns root = new SetterReturns();

Method m = OgnlRuntime.getWriteMethod( root.getClass(), "value" );
assertTrue( m != null );
assertNotNull(m);

Ognl.setValue( "value", context, root, "12__" );
assertEquals( Ognl.getValue( "value", context, root ), "12__" );
@@ -63,18 +63,18 @@ public void test_Get_Indexed_Property_Type()
context.setCurrentNode( pRef );

assertEquals( root.getClass(), context.getCurrentType() );
assertEquals( null, context.getPreviousType() );
assertNull(context.getPreviousType());
assertEquals( root, context.getCurrentObject() );
assertEquals( null, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getCurrentAccessor());
assertNull(context.getPreviousAccessor());

int type = p.getIndexedPropertyType( context, root );

assertEquals( OgnlRuntime.INDEXED_PROPERTY_NONE, type );
assertEquals( root.getClass(), context.getCurrentType() );
assertEquals( null, context.getPreviousType() );
assertEquals( null, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousType());
assertNull(context.getCurrentAccessor());
assertNull(context.getPreviousAccessor());
}

public void test_Get_Value_Body()
@@ -95,18 +95,18 @@ public void test_Get_Value_Body()
context.setCurrentNode( pRef );

assertEquals( root.getClass(), context.getCurrentType() );
assertEquals( null, context.getPreviousType() );
assertNull(context.getPreviousType());
assertEquals( root, context.getCurrentObject() );
assertEquals( null, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getCurrentAccessor());
assertNull(context.getPreviousAccessor());

Object value = p.getValue( context, root );

assertEquals( root.get( "nested" ), value );
assertEquals( root.getClass(), context.getCurrentType() );
assertEquals( null, context.getPreviousType() );
assertEquals( null, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousType());
assertNull(context.getCurrentAccessor());
assertNull(context.getPreviousAccessor());
}

public void test_Get_Source()
@@ -130,14 +130,14 @@ public void test_Get_Source()
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Map.class, context.getCurrentAccessor() );
assertEquals( root.getClass(), context.getPreviousType() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());

assertEquals( root.get( "nested" ), context.getCurrentObject() );

assert Map.class.isAssignableFrom( context.getCurrentAccessor() );

assertEquals( root.getClass(), context.getPreviousType() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
}

public void test_Set_Source()
@@ -164,7 +164,7 @@ public void test_Set_Source()
assert Map.class.isAssignableFrom( context.getCurrentAccessor() );

assertEquals( root.getClass(), context.getPreviousType() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
}

public void test_Indexed_Object_Type()
@@ -206,7 +206,7 @@ public void test_Indexed_Object_Type()
assertEquals( ".getList()", listp.toGetSourceString( context, root ) );
assertEquals( List.class, context.getCurrentType() );
assertEquals( Root.class, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
assertEquals( root.getClass(), context.getPreviousType() );
assertEquals( root.getList(), context.getCurrentObject() );

@@ -225,7 +225,7 @@ public void test_Indexed_Object_Type()
assertEquals( ".getList()", chain.toGetSourceString( context, root ) );
assertEquals( List.class, context.getCurrentType() );
assertEquals( Root.class, context.getCurrentAccessor() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
assertEquals( Root.class, context.getPreviousType() );
assertEquals( root.getList(), context.getCurrentObject() );

@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;

import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -77,7 +78,7 @@ public static Collection<Object[]> data()
public void runTest()
throws Exception
{
assertTrue( Ognl.isConstant( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
Assert.assertEquals(Ognl.isConstant(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}

/*
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Collection;

import junit.framework.Assert;
import org.apache.commons.ognl.OgnlException;
import org.apache.commons.ognl.OgnlOps;
import org.junit.Test;
@@ -213,7 +214,7 @@ public void runTest()
double scalingFactor = Math.pow( 10, scale ), v1 = ( (Number) value ).doubleValue() * scalingFactor, v2 =
( (Number) expectedValue ).doubleValue() * scalingFactor;

assertTrue( (int) v1 == (int) v2 );
Assert.assertEquals((int) v1, (int) v2);
}
else
{
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;

import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -78,6 +79,6 @@ public SimpleNavigationChainTreeTest( String name, Object root, String expressio
public void runTest()
throws Exception
{
assertTrue( Ognl.isSimpleNavigationChain( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
Assert.assertEquals(Ognl.isSimpleNavigationChain(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}
}
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;

import junit.framework.Assert;
import org.apache.commons.ognl.Ognl;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -78,6 +79,6 @@ public SimplePropertyTreeTest( String name, Object root, String expressionString
public void runTest()
throws Exception
{
assertTrue( Ognl.isSimpleProperty( getExpression(), _context ) == ( (Boolean) getExpectedResult() ).booleanValue() );
Assert.assertEquals(Ognl.isSimpleProperty(getExpression(), _context), ((Boolean) getExpectedResult()).booleanValue());
}
}
@@ -56,7 +56,7 @@ public void test_Get_Source_String_Number_Index()
assertEquals( List.class, context.getCurrentAccessor() );
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Integer.TYPE, context.getPreviousType() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
}

@Test
@@ -76,7 +76,7 @@ public void test_Get_Source_Object_Number_Index()
assertEquals( List.class, context.getCurrentAccessor() );
assertEquals( Object.class, context.getCurrentType() );
assertEquals( Integer.class, context.getPreviousType() );
assertEquals( null, context.getPreviousAccessor() );
assertNull(context.getPreviousAccessor());
}

@Test
@@ -242,7 +242,7 @@ public void test_Set_Generic_Property()
GenericRoot root = new GenericRoot();

Node node = Ognl.compileExpression( _context, root, "cracker.param" );
assertEquals( null, node.getAccessor().get( _context, root ) );
assertNull(node.getAccessor().get(_context, root));

node.getAccessor().set( _context, root, 0 );
assertEquals( 0, node.getAccessor().get( _context, root ) );

0 comments on commit d9d6b1f

Please sign in to comment.