本文整理汇总了Java中com.helger.commons.mock.CommonsTestHelper类的典型用法代码示例。如果您正苦于以下问题:Java CommonsTestHelper类的具体用法?Java CommonsTestHelper怎么用?Java CommonsTestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonsTestHelper类属于com.helger.commons.mock包,在下文中一共展示了CommonsTestHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testAll ()
{
final SingleElementEnumeration <String> eit = new SingleElementEnumeration <> ("any");
assertTrue (eit.hasMoreElements ());
assertEquals ("any", eit.nextElement ());
try
{
eit.nextElement ();
fail ();
}
catch (final NoSuchElementException ex)
{}
assertFalse (eit.hasMoreElements ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new SingleElementEnumeration <> ("any"),
new SingleElementEnumeration <> ("any"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new SingleElementEnumeration <> ("any"),
new SingleElementEnumeration <> ("any2"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new SingleElementEnumeration <> ("any"),
new SingleElementEnumeration <> (Integer.valueOf (1)));
}
示例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: testGet
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testGet ()
{
final DirectedGraphNode nf = new DirectedGraphNode ();
final DirectedGraphNode nt = new DirectedGraphNode ();
final DirectedGraphRelation gr = new DirectedGraphRelation (nf, nt);
assertSame (gr.getFrom (), nf);
assertSame (gr.getTo (), nt);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new DirectedGraphRelation ("id1", nf, nt),
new DirectedGraphRelation ("id1", nf, nt));
// different IDs
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new DirectedGraphRelation (nf, nt),
new DirectedGraphRelation (nf, nt));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new DirectedGraphRelation ("id1", nf, nt),
new DirectedGraphRelation ("id1",
nf,
new DirectedGraphNode ()));
}
示例4: testBasicWithScopeCtor
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testBasicWithScopeCtor () throws Exception
{
assertTrue (AbstractSessionSingleton.getAllSessionSingletons ().isEmpty ());
assertFalse (AbstractSessionSingleton.isSessionSingletonInstantiated (MockSessionSingletonWithScopeCtor.class));
assertNull (AbstractSessionSingleton.getSessionSingletonIfInstantiated (MockSessionSingletonWithScopeCtor.class));
final MockSessionSingletonWithScopeCtor a = MockSessionSingletonWithScopeCtor.getInstance ();
assertNotNull (a);
assertTrue (AbstractSessionSingleton.isSessionSingletonInstantiated (MockSessionSingletonWithScopeCtor.class));
assertSame (a,
AbstractSessionSingleton.getSessionSingletonIfInstantiated (MockSessionSingletonWithScopeCtor.class));
assertNotNull (a.getScope ());
assertEquals (0, a.get ());
a.inc ();
assertEquals (1, a.get ());
assertSame (a, MockSessionSingletonWithScopeCtor.getInstance ());
CommonsTestHelper.testDefaultSerialization (a);
}
示例5: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testAll ()
{
final LoggingTransformErrorListener el = new LoggingTransformErrorListener (L_EN);
final TransformerFactory fac = XMLTransformerFactory.createTransformerFactory (el,
new LoggingTransformURIResolver ());
assertNotNull (fac);
// Read valid XSLT
Templates t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test1.xslt"));
assertNotNull (t1);
// Read valid XSLT (with import)
t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test2.xslt"));
assertNotNull (t1);
// Read invalid XSLT
assertNull (XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("test1.txt")));
CommonsTestHelper.testToStringImplementation (el);
}
示例6: testRead1
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testRead1 ()
{
CSSStyleRule aSR;
aSR = _parse ("div { color: red; }");
assertEquals (1, aSR.getSelectorCount ());
assertEquals (1, aSR.getSelectorAtIndex (0).getMemberCount ());
assertTrue (aSR.getSelectorAtIndex (0).getMemberAtIndex (0) instanceof CSSSelectorSimpleMember);
assertEquals ("div", ((CSSSelectorSimpleMember) aSR.getSelectorAtIndex (0).getMemberAtIndex (0)).getValue ());
assertEquals (1, aSR.getDeclarationCount ());
assertEquals ("color", aSR.getDeclarationAtIndex (0).getProperty ());
assertEquals (1, aSR.getDeclarationAtIndex (0).getExpression ().getMemberCount ());
assertTrue (aSR.getDeclarationAtIndex (0)
.getExpression ()
.getMemberAtIndex (0) instanceof CSSExpressionMemberTermSimple);
assertEquals ("red",
((CSSExpressionMemberTermSimple) aSR.getDeclarationAtIndex (0)
.getExpression ()
.getMemberAtIndex (0)).getValue ());
// Create the same rule by application
final CSSStyleRule aCreated = new CSSStyleRule ();
aCreated.addSelector (new CSSSelectorSimpleMember ("div"));
aCreated.addDeclaration ("color", CSSExpression.createSimple ("red"), false);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aSR, aCreated);
}
示例7: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testAll ()
{
final FileSystemByteStreamProvider aFSSR = new FileSystemByteStreamProvider (new File ("."));
final InputStream aIS = aFSSR.getInputStream ("pom.xml");
assertNotNull (aIS);
StreamHelper.close (aIS);
final OutputStream aOS = aFSSR.getOutputStream ("$deleteme.txt", EAppend.DEFAULT);
assertNotNull (aOS);
StreamHelper.close (aOS);
assertTrue (FileOperations.deleteFile (new File ("$deleteme.txt")).isSuccess ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new FileSystemByteStreamProvider (new File (".")),
new FileSystemByteStreamProvider (new File (".")));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new FileSystemByteStreamProvider (new File (".")),
new FileSystemByteStreamProvider ("."));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new FileSystemByteStreamProvider (new File (".")),
new FileSystemByteStreamProvider (new File ("..")));
}
示例8: testReadonlyMultiLingualText
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testReadonlyMultiLingualText ()
{
final ReadOnlyMultilingualText aMLT = new ReadOnlyMultilingualText (CollectionHelper.newMap (new Locale [] { Locale.GERMAN,
Locale.CHINA },
new String [] { "Cumberlandstraße",
"Whatspever" }));
final IMicroElement aElement = MicroTypeConverter.convertToMicroElement (aMLT, "mtext");
assertNotNull (aElement);
final ReadOnlyMultilingualText aMLT2 = MicroTypeConverter.convertToNative (aElement,
ReadOnlyMultilingualText.class);
assertEquals (aMLT, aMLT2);
assertNull (MicroTypeConverter.convertToNative (null, ReadOnlyMultilingualText.class));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aMLT, aMLT2);
}
示例9: testStdMethods
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testStdMethods ()
{
final IMutablePriceGraduation pg1 = new PriceGraduation (ECurrency.DEFAULT_CURRENCY);
final IMutablePriceGraduation pg2 = new PriceGraduation (ECurrency.DEFAULT_CURRENCY);
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (pg1, pg2);
final BigDecimal aNetAmount1 = new BigDecimal ("19.9");
pg1.addItem (new PriceGraduationItem (1, aNetAmount1));
pg2.addItem (new PriceGraduationItem (1, aNetAmount1));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (pg1, pg2);
for (int i = 2; i <= 100; ++i)
{
final BigDecimal aNetAmount = new BigDecimal ("19.9").add (MathHelper.toBigDecimal (i));
pg1.addItem (new PriceGraduationItem (i, aNetAmount));
pg2.addItem (new PriceGraduationItem (i, aNetAmount));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (pg1, pg2);
}
}
示例10: testBasic
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testBasic ()
{
final IMicroElement e1 = new MicroElement ("a1");
final IMicroElement e2 = new MicroElement ("a1");
MicroEvent e = new MicroEvent (EMicroEvent.NODE_INSERTED, e1, e2);
assertEquals (EMicroEvent.NODE_INSERTED, e.getEventType ());
assertSame (e1, e.getSourceNode ());
assertSame (e2, e.getTargetNode ());
CommonsTestHelper.testToStringImplementation (e);
e = new MicroEvent (EMicroEvent.NODE_INSERTED, null, null);
assertEquals (EMicroEvent.NODE_INSERTED, e.getEventType ());
assertNull (e.getSourceNode ());
assertNull (e.getTargetNode ());
CommonsTestHelper.testToStringImplementation (e);
try
{
new MicroEvent (null, e1, e2);
fail ();
}
catch (final NullPointerException ex)
{}
}
示例11: testSerialize
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testSerialize ()
{
final JsonArray aArray = new JsonArray ();
CommonsTestHelper.testDefaultSerialization (aArray);
aArray.add (5);
CommonsTestHelper.testDefaultSerialization (aArray);
aArray.add (3.1234);
CommonsTestHelper.testDefaultSerialization (aArray);
aArray.add ("This is a string");
CommonsTestHelper.testDefaultSerialization (aArray);
aArray.add (new JsonArray ().add ("nested").add (0).add (Double.valueOf (12.34)));
CommonsTestHelper.testDefaultSerialization (aArray);
aArray.add (new JsonObject ().add ("n1", "nested").add ("n2", 0).add ("n3", Double.valueOf (12.34)));
CommonsTestHelper.testDefaultSerialization (aArray);
}
示例12: testCtor
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testCtor ()
{
final DefaultTreeItemFactory <String> tif = new DefaultTreeItemFactory <> ();
final DefaultTreeItem <String> t = tif.createRoot ();
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (t, tif.createRoot ());
final DefaultTreeItem <String> c = t.createChildItem ("any");
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (t, tif.createRoot ());
assertTrue (t.isRootItem ());
assertFalse (c.isRootItem ());
assertTrue (t.isSameOrChildOf (t));
assertFalse (t.isSameOrChildOf (c));
assertTrue (c.isSameOrChildOf (t));
assertTrue (c.isSameOrChildOf (c));
}
示例13: testSerialize
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testSerialize ()
{
final ErrorList aList = new ErrorList ();
CommonsTestHelper.testDefaultSerialization (aList);
aList.add (SingleError.builderInfo ()
.setErrorID ("test-1")
.setErrorFieldName ("field1")
.setErrorText ("TestInfo")
.setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
.build ());
CommonsTestHelper.testDefaultSerialization (aList);
aList.add (SingleError.builderInfo ()
.setErrorID ("test-2")
.setErrorFieldName ("field1")
.setErrorText ("TestInfo")
.setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
.setLinkedException (new MockIOException ("Mock"))
.build ());
CommonsTestHelper.testDefaultSerialization (aList);
}
示例14: 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));
}
示例15: testBasic
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testBasic ()
{
final ICommonsMap <String, String> aTest = new CommonsHashMap <> ();
aTest.put ("aaa", "bla");
aTest.put ("bbb", "blb");
aTest.put ("ccc", "blc");
final ICommonsOrderedSet <String> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet ();
assertEquals ("aaa", aSortedKeys.getAtIndex (0));
assertEquals ("bbb", aSortedKeys.getAtIndex (1));
assertEquals ("ccc", aSortedKeys.getAtIndex (2));
CommonsTestHelper.testDefaultSerialization (aTest);
CommonsTestHelper.testGetClone (aTest);
assertEquals (3, aTest.size ());
aTest.removeIf (e -> !e.getKey ().startsWith ("c"));
assertEquals (1, aTest.size ());
}