本文整理汇总了Java中com.helger.commons.mock.CommonsTestHelper类的典型用法代码示例。如果您正苦于以下问题:Java CommonsTestHelper类的具体用法?Java CommonsTestHelper怎么用?Java CommonsTestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonsTestHelper类属于com.helger.commons.mock包,在下文中一共展示了CommonsTestHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)));
}
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:SingleElementEnumerationTest.java
示例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 ());
}
开发者ID:phax,项目名称:ph-commons,代码行数:25,代码来源:SimpleGraphTest.java
示例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 ()));
}
开发者ID:phax,项目名称:ph-commons,代码行数:20,代码来源:DirectedGraphRelationTest.java
示例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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:SessionSingletonFuncTest.java
示例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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:LoggingTransformErrorListenerTest.java
示例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);
}
开发者ID:phax,项目名称:ph-css,代码行数:27,代码来源:CSSStyleRuleTest.java
示例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 ("..")));
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:FileSystemByteStreamProviderTest.java
示例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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:MultilingualTextMicroTypeConverterRegistrarTest.java
示例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);
}
}
开发者ID:phax,项目名称:ph-masterdata,代码行数:21,代码来源:PriceGraduationTest.java
示例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)
{}
}
开发者ID:phax,项目名称:ph-commons,代码行数:26,代码来源:MicroEventTest.java
示例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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:17,代码来源:JsonArrayTest.java
示例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));
}
开发者ID:phax,项目名称:ph-commons,代码行数:17,代码来源:DefaultTreeItemTest.java
示例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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:ErrorListTest.java
示例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));
}
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:MutableBooleanTest.java
示例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 ());
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:CommonsHashMapTest.java
示例16: testHashCode
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testHashCode ()
{
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new Version (1, 2, 3, "4"),
new Version (1, 2, 3, "4"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new Version (1, 2, 3, "4"),
Version.parse ("1.2.3.4"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new Version (1), Version.parse ("1"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (Version.parse ("1"), Version.parse (" 1"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new Version (1, 2, 3, "4"),
new Version (1, 2, 3));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new Version (1, 2, 3, "4"),
new Version (1, 2, 3, "5"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new Version (1, 2, 3, "4"),
Version.parse ("1.3.3.4"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new Version (2), Version.parse ("1"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (Version.parse ("1"),
Version.parse (" 11"));
}
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:VersionTest.java
示例17: testAccess
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testAccess ()
{
FileSystemResource fr = new FileSystemResource ("pom.xml");
assertTrue (fr.exists ());
assertTrue (fr.getResourceID ().endsWith ("pom.xml"));
assertTrue (fr.getPath ().endsWith ("pom.xml"));
StreamHelper.close (fr.getReader (StandardCharsets.ISO_8859_1));
final byte [] aBytes = StreamHelper.getAllBytes (fr);
assertTrue (aBytes.length > 0);
assertNotNull (fr.getAsURL ());
assertNotNull (fr.getAsFile ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (fr, new FileSystemResource ("pom.xml"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (fr, fr.getReadableCloneForPath ("pom.xml"));
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (fr, fr.getWritableCloneForPath ("pom.xml"));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (fr, new FileSystemResource ("pom.xml2"));
fr = new FileSystemResource ("this file does not exist");
assertFalse (fr.exists ());
assertNull (fr.getInputStream ());
assertNull (fr.getReader (StandardCharsets.ISO_8859_1));
}
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:FileSystemResourceTest.java
示例18: testBasic
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
public void testBasic ()
{
final ICommonsMap <String, String> aTest = new CommonsConcurrentHashMap<> ();
aTest.put ("aaa", "bla");
aTest.put ("bbb", "blb");
aTest.put ("ccc", "blc");
final ICommonsSet <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);
}
开发者ID:phax,项目名称:ph-commons,代码行数:17,代码来源:CommonsConcurrentHashMapTest.java
示例19: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@SuppressWarnings ("resource")
@Test
public void testAll () throws IOException
{
final NonBlockingByteArrayOutputStream baos = new NonBlockingByteArrayOutputStream ();
try (final WrappedOutputStream ws = new WrappedOutputStream (baos))
{
ws.write ('a');
ws.write ("bc".getBytes (StandardCharsets.ISO_8859_1));
ws.write ("cde".getBytes (StandardCharsets.ISO_8859_1), 1, 1);
ws.flush ();
assertEquals ("abcd", baos.getAsString (StandardCharsets.ISO_8859_1));
CommonsTestHelper.testToStringImplementation (ws);
}
try
{
new WrappedOutputStream (null).close ();
fail ();
}
catch (final NullPointerException ex)
{}
}
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:WrappedOutputStreamTest.java
示例20: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入依赖的package包/类
@Test
@SuppressFBWarnings ("TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED")
public void testAll ()
{
final MemoryIntIDFactory x = new MemoryIntIDFactory (9);
assertEquals (9, x.getNewID ());
CommonsTestHelper.testDefaultImplementationWithEqualContentObject (x, new MemoryIntIDFactory (10));
CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (x, new MemoryIntIDFactory (11));
try
{
new MemoryIntIDFactory (-1);
fail ();
}
catch (final IllegalArgumentException ex)
{}
}
开发者ID:phax,项目名称:ph-commons,代码行数:18,代码来源:MemoryIntIDFactoryTest.java
注:本文中的com.helger.commons.mock.CommonsTestHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论