本文整理汇总了Java中com.helger.commons.mock.CommonsTestHelper.testDefaultImplementationWithEqualContentObject方法的典型用法代码示例。如果您正苦于以下问题:Java CommonsTestHelper.testDefaultImplementationWithEqualContentObject方法的具体用法?Java CommonsTestHelper.testDefaultImplementationWithEqualContentObject怎么用?Java CommonsTestHelper.testDefaultImplementationWithEqualContentObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.mock.CommonsTestHelper
的用法示例。
在下文中一共展示了CommonsTestHelper.testDefaultImplementationWithEqualContentObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMutableBoolean
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testMutableBoolean ()
{
final MutableBoolean x = new MutableBoolean (false);
assertFalse (x.booleanValue ());
assertSame (Boolean.FALSE, x.getAsBoolean ());
assertTrue (x.set (true).isChanged ());
assertTrue (x.booleanValue ());
assertSame (Boolean.TRUE, x.getAsBoolean ());
assertFalse (x.set (true).isChanged ());
assertTrue (x.booleanValue ());
assertSame (Boolean.TRUE, x.getAsBoolean ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new MutableBoolean (true),
new MutableBoolean (true));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new MutableBoolean (true),
new MutableBoolean (false));
CommonsTestHelper.testGetClone (new MutableBoolean (true));
}
示例2: testCycles
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testCycles ()
{
SimpleGraph sg = _buildGraph ();
assertTrue (sg.isSelfContained ());
sg = new SimpleGraph ();
final IMutableGraphNode n1 = sg.createNode (null);
final IMutableGraphNode n2 = sg.createNode (null);
sg.createRelation (n1, n2);
sg.createRelation (n2, n1);
assertTrue (n1.hasRelations ());
assertTrue (n1.isConnectedWith (n2));
assertTrue (n2.hasRelations ());
assertTrue (n2.isConnectedWith (n1));
assertTrue (sg.isSelfContained ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (_buildGraph (), _buildGraph ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new SimpleGraph (), new SimpleGraph ());
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (_buildGraph (), new SimpleGraph ());
}
示例3: testDefault
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testDefault () throws Exception
{
final ClassPathResource aCPISP1a = new ClassPathResource ("folder/test2.txt");
final ClassPathResource aCPISP1b = new ClassPathResource ("folder/test2.txt");
final ClassPathResource aCPISP2 = new ClassPathResource ("folder/test1.txt");
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aCPISP1a, aCPISP1b);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aCPISP1a,
new ClassPathResource ("cp:folder/test2.txt"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aCPISP1a,
new ClassPathResource ("classpath:folder/test2.txt"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aCPISP1a, aCPISP2);
CommonsTestHelper.testDefaultSerialization (aCPISP1a);
CommonsTestHelper.testDefaultSerialization (new ClassPathResource ("folder/test2.txt"));
try
{
// Can't serialize with class loader
CommonsTestHelper.testDefaultSerialization (new ClassPathResource ("folder/test2.txt",
ClassLoaderHelper.getDefaultClassLoader ()));
fail ();
}
catch (final IllegalArgumentException ex)
{}
}
示例4: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll ()
{
GlobalIDFactory.setPersistentIntIDFactory (new MemoryStaticIntIDFactory ());
final StringIDFromGlobalPersistentIntIDFactory x = new StringIDFromGlobalPersistentIntIDFactory ("idd");
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (x,
new StringIDFromGlobalPersistentIntIDFactory ("idd"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (x,
new StringIDFromGlobalPersistentIntIDFactory ("prefix"));
assertTrue (x.getNewID ().startsWith ("idd"));
try
{
new StringIDFromGlobalPersistentIntIDFactory (null);
fail ();
}
catch (final NullPointerException ex)
{}
}
示例5: testISO8859
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testISO8859 ()
{
final ResourceBundleKey key = new ResourceBundleKey ("properties/test-iso8859", "key1");
assertEquals ("properties/test-iso8859", key.getBundleName ());
assertEquals ("key1", key.getKey ());
assertEquals ("äöü", key.getString (L_DE));
final ResourceBundleTextProvider aRBT = new ResourceBundleTextProvider (key);
assertEquals ("äöü", aRBT.getText (L_DE));
assertEquals ("äöü", aRBT.getTextWithArgs (L_DE, "egal"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new ResourceBundleTextProvider (key),
new ResourceBundleTextProvider (key));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new ResourceBundleTextProvider (key),
new ResourceBundleTextProvider ("properties/test-iso8859",
"key1"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new ResourceBundleTextProvider (key),
new ResourceBundleTextProvider ("properties/test-iso8859",
"key2"));
try
{
new ResourceBundleTextProvider (null);
fail ();
}
catch (final NullPointerException ex)
{}
}
示例6: testEqualsAndHashcode
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testEqualsAndHashcode ()
{
final SafeVector <String> sl = new SafeVector <> ();
sl.set (10, "any");
assertNull (sl.get (9));
final SafeVector <String> sl2 = new SafeVector <> ();
sl2.set (10, "any");
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (sl, sl2);
sl2.set (9, "x");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (sl, sl2);
}
示例7: testStdMethods
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testStdMethods ()
{
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new DirectedGraphNode ("id0"),
new DirectedGraphNode ("id0"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new DirectedGraphNode ("id0"),
new DirectedGraphNode ("id1"));
final DirectedGraphNode n1 = new DirectedGraphNode ("id0");
n1.attrs ().putIn ("a", "b");
final DirectedGraphNode n2 = new DirectedGraphNode ("id0");
n2.attrs ().putIn ("a", "c");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (n1, n2);
}
示例8: testDefaultImpl
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testDefaultImpl ()
{
ExtendedEmailAddress a = new ExtendedEmailAddress ();
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (a, new ExtendedEmailAddress ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (a, new ExtendedEmailAddress (a));
CommonsTestHelper.testGetClone (a);
a = new ExtendedEmailAddress ();
a.setType (EEmailAddressType.PERSONAL);
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (a, new ExtendedEmailAddress ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (a, new ExtendedEmailAddress (a));
CommonsTestHelper.testGetClone (a);
a = new ExtendedEmailAddress ();
a.setAddress ("[email protected]");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (a, new ExtendedEmailAddress ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (a, new ExtendedEmailAddress (a));
CommonsTestHelper.testGetClone (a);
a = new ExtendedEmailAddress ();
a.setPersonal ("Ich & Du");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (a, new ExtendedEmailAddress ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (a, new ExtendedEmailAddress (a));
CommonsTestHelper.testGetClone (a);
CommonsTestHelper.testDefaultSerialization (a);
}
示例9: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll ()
{
final TimeValue t = new TimeValue (TimeUnit.SECONDS, 5);
assertEquals (TimeUnit.SECONDS, t.getTimeUnit ());
assertEquals (5, t.getDuration ());
assertEquals (0, t.getAsDays ());
assertEquals (0, t.getAsHours ());
assertEquals (0, t.getAsMinutes ());
assertEquals (5, t.getAsSeconds ());
assertEquals (5000, t.getAsMillis ());
assertEquals (5000000, t.getAsMicros ());
assertEquals (5000000000L, t.getAsNanos ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new TimeValue (TimeUnit.SECONDS, 5),
new TimeValue (TimeUnit.SECONDS, 5));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new TimeValue (TimeUnit.SECONDS, 5),
new TimeValue (TimeUnit.SECONDS, 4));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new TimeValue (TimeUnit.SECONDS, 5),
new TimeValue (TimeUnit.NANOSECONDS, 5));
try
{
new TimeValue (null, 5);
fail ();
}
catch (final NullPointerException ex)
{}
}
示例10: testBasic
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testBasic ()
{
final CSSURI aURI = new CSSURI ("a.gif");
assertEquals ("a.gif", aURI.getURI ());
final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
assertEquals ("url(a.gif)", aURI.getAsCSSString (aSettings));
aSettings.setQuoteURLs (true);
assertEquals ("url('a.gif')", aURI.getAsCSSString (aSettings));
assertFalse (aURI.isDataURL ());
assertNull (aURI.getAsDataURL ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aURI, new CSSURI ("a.gif"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aURI, new CSSURI ("b.gif"));
}
示例11: testEquals
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testEquals ()
{
final IAggregator <String, String> aAggregator = x -> StringHelper.getImploded ('/', x);
final DefaultFolderTreeItemFactory <String, String, List <String>> ftif = new DefaultFolderTreeItemFactory <> (aAggregator);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (ftif,
new DefaultFolderTreeItemFactory <> (aAggregator));
// New aggregator - different object!
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (ftif,
new DefaultFolderTreeItemFactory <> (x -> StringHelper.getImploded ('/',
x)));
}
示例12: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll ()
{
final MemoryStaticIntIDFactory x = new MemoryStaticIntIDFactory ();
assertTrue (x.getNewID () >= MemoryStaticIntIDFactory.INITIAL_ID);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (x, new MemoryStaticIntIDFactory ());
}
示例13: _testEqualsHashcode
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
private void _testEqualsHashcode (@Nullable final Object aValue)
{
final IJson aJson = JsonConverter.convertToJson (aValue);
assertNotNull ("Failed: " + aValue, aJson);
final String sJson = aJson.getAsJsonString ();
assertNotNull (sJson);
final IJson aJsonRead = JsonReader.readFromString (sJson);
assertNotNull ("Failed to read: " + sJson, aJsonRead);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aJson, aJsonRead);
}
示例14: testEqualsHashCode
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testEqualsHashCode ()
{
final DefaultTree <String> t = new DefaultTree <> ();
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (t, new DefaultTree <String> ());
t.getRootItem ().createChildItem ("data");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (t, new DefaultTree <String> ());
}
示例15: testLRUCache
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testLRUCache ()
{
final LRUSet <Integer> aCache = new LRUSet<> (MAX_SIZE);
assertTrue (aCache.isEmpty ());
assertEquals (0, aCache.size ());
assertEquals (MAX_SIZE, aCache.getMaxSize ());
assertNotNull (aCache.iterator ());
assertFalse (aCache.iterator ().hasNext ());
for (int i = 0; i < MAX_SIZE * 2; ++i)
{
assertEquals (i < MAX_SIZE ? i : MAX_SIZE, aCache.size ());
assertTrue (aCache.add (Integer.valueOf (i)));
}
assertEquals (MAX_SIZE, aCache.size ());
// add the same again
assertTrue (aCache.add (Integer.valueOf (-3)));
assertFalse (aCache.add (Integer.valueOf (-3)));
assertEquals (MAX_SIZE, aCache.size ());
// addAll
assertTrue (aCache.addAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -5)));
assertTrue (aCache.addAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -6)));
assertEquals (MAX_SIZE, aCache.size ());
// containsAll
assertTrue (aCache.containsAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -5)));
assertFalse (aCache.containsAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -7)));
assertEquals (MAX_SIZE, aCache.size ());
// removeAll
assertTrue (aCache.removeAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -5, -6)));
assertFalse (aCache.removeAll (PrimitiveCollectionHelper.newPrimitiveList (-4, -5, -6)));
assertEquals (MAX_SIZE - 3, aCache.size ());
try
{
aCache.retainAll (null);
fail ();
}
catch (final NullPointerException ex)
{}
assertEquals (2, aCache.toArray ().length);
assertEquals (2, aCache.toArray (new Integer [aCache.size ()]).length);
aCache.clear ();
assertEquals (0, aCache.size ());
final LRUSet <String> ret = new LRUSet<> (4);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (ret, new LRUSet<> (4));
ret.add ("a");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (ret, new LRUSet<> (4));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new LRUSet<> (3), new LRUSet<> (4));
}