本文整理汇总了Java中com.helger.commons.mock.CommonsTestHelper.testToStringImplementation方法的典型用法代码示例。如果您正苦于以下问题:Java CommonsTestHelper.testToStringImplementation方法的具体用法?Java CommonsTestHelper.testToStringImplementation怎么用?Java CommonsTestHelper.testToStringImplementation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.mock.CommonsTestHelper
的用法示例。
在下文中一共展示了CommonsTestHelper.testToStringImplementation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll ()
{
for (int i = 0; i < 2; ++i)
{
final DefaultTransformURIResolver res = new DefaultTransformURIResolver (i == 0 ? null
: new LoggingTransformURIResolver ());
final TransformerFactory fac = XMLTransformerFactory.createTransformerFactory (null, res);
assertNotNull (fac);
// Read valid XSLT
Templates t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test1.xslt"));
assertNotNull (t1);
// Read valid XSLT with valid include
t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test2.xslt"));
assertNotNull (t1);
// Read valid XSLT with invalid include
t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test3.xslt"));
assertNull (t1);
CommonsTestHelper.testToStringImplementation (res);
}
}
示例2: 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);
}
示例3: testIteration5
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testIteration5 ()
{
// filtered elements at the beginning
final List <String> aList = CollectionHelper.newList (null, null, "s1", "s2", "s3");
final FilterIterator <String> it = new FilterIterator <> (aList, Objects::nonNull);
assertNotNull (it);
assertEquals ("s1", it.next ());
assertEquals ("s2", it.next ());
assertEquals ("s3", it.next ());
CommonsTestHelper.testToStringImplementation (it);
try
{
// can't call next if hasNext failed
it.next ();
fail ();
}
catch (final NoSuchElementException ex)
{}
}
示例4: 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)
{}
}
示例5: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll () throws IOException
{
final NonBlockingStringWriter aSW = new NonBlockingStringWriter ();
try (final WrappedWriter ws = new WrappedWriter (aSW))
{
ws.write ('a');
ws.write ("bc".toCharArray ());
ws.write ("de".toCharArray (), 0, 1);
ws.write ("ef");
ws.write ("fgh", 1, 1);
assertEquals ("abcdefg", aSW.getAsString ());
ws.append ('0').append ("12").append ("234", 1, 2);
assertEquals ("abcdefg0123", aSW.getAsString ());
ws.flush ();
CommonsTestHelper.testToStringImplementation (ws);
}
try (final WrappedWriter ws = new WrappedWriter (null))
{
fail ();
}
catch (final NullPointerException ex)
{}
}
示例6: testBindAllValidSchematrons
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testBindAllValidSchematrons () throws SchematronException
{
for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ())
{
// Parse the schema
final PSSchema aSchema = new PSReader (aRes).readSchema ();
assertNotNull (aSchema);
CommonsTestHelper.testToStringImplementation (aSchema);
final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler ();
assertTrue (aRes.getPath (), aSchema.isValid (aLogger));
assertTrue (aLogger.isEmpty ());
// Create a compiled schema
final String sPhaseID = null;
final IPSErrorHandler aErrorHandler = null;
final IPSBoundSchema aBoundSchema = PSXPathQueryBinding.getInstance ().bind (aSchema, sPhaseID, aErrorHandler);
assertNotNull (aBoundSchema);
}
}
示例7: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
@SuppressFBWarnings (value = "DLS_DEAD_LOCAL_STORE")
public void testAll ()
{
final BasicThreadFactory x = new BasicThreadFactory.Builder ().setDaemon (false)
.setPriority (Thread.NORM_PRIORITY)
.setNamingPattern ("pool %d")
.build ();
for (int i = 0; i < 2; ++i)
{
final Thread t = x.newThread ( () -> {
// nada
if (false)
s_aLogger.info ("In thread '" + Thread.currentThread ().getName () + "'");
});
assertNotNull (t);
t.start ();
}
CommonsTestHelper.testToStringImplementation (x);
}
示例8: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll () throws TransformerConfigurationException, TransformerException
{
final CollectingTransformErrorListener el = new CollectingTransformErrorListener ();
final TransformerFactory fac = XMLTransformerFactory.createTransformerFactory (el.andThen (new LoggingTransformErrorListener (L_EN)),
new LoggingTransformURIResolver ());
assertNotNull (fac);
// Read valid XSLT
Templates t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test1.xslt"));
assertNotNull (t1);
// May contain warning in JDK 1.7
// (http://javax.xml.XMLConstants/property/accessExternalDTD is unknown)
assertTrue (el.getErrorList ().containsNoError ());
// Try a real transformation
{
final Document aDoc = XMLFactory.newDocument ();
t1.newTransformer ().transform (TransformSourceFactory.create (new ClassPathResource ("xml/xslt1.xml")),
new DOMResult (aDoc));
assertNotNull (aDoc);
assertNotNull (aDoc.getDocumentElement ());
assertEquals ("html", aDoc.getDocumentElement ().getTagName ());
}
// Read valid XSLT (with import)
t1 = XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("xml/test2.xslt"));
assertNotNull (t1);
// May contain warning in JDK 1.7
// (http://javax.xml.XMLConstants/property/accessExternalDTD is unknown)
assertTrue (el.getErrorList ().containsNoError ());
// Read invalid XSLT
assertNull (XMLTransformerFactory.newTemplates (fac, new ClassPathResource ("test1.txt")));
assertTrue (el.getErrorList ().containsAtLeastOneError ());
CommonsTestHelper.testToStringImplementation (el);
}
示例9: testMisc
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testMisc ()
{
assertEquals ("<!DOCTYPE qname PUBLIC \"pubid\" \"sysid\">",
XMLEmitter.getDocTypeHTMLRepresentation (EXMLSerializeVersion.XML_10,
EXMLIncorrectCharacterHandling.DEFAULT,
new MicroDocumentType ("qname", "pubid", "sysid")));
assertEquals ("<!DOCTYPE qname PUBLIC \"pubid\" \"sysid\">",
XMLEmitter.getDocTypeHTMLRepresentation (EXMLSerializeVersion.XML_11,
EXMLIncorrectCharacterHandling.DEFAULT,
new MicroDocumentType ("qname", "pubid", "sysid")));
CommonsTestHelper.testToStringImplementation (new XMLEmitter (new ByteArrayOutputStreamProvider ().getWriter (StandardCharsets.ISO_8859_1,
EAppend.DEFAULT),
XMLWriterSettings.DEFAULT_XML_SETTINGS));
}
示例10: testDefault
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testDefault ()
{
LoggingLSResourceResolver lrr = new LoggingLSResourceResolver ();
lrr.resolveResource ("xsd", "nsuri", null, "sysid", "baseURI");
CommonsTestHelper.testToStringImplementation (lrr);
lrr = new LoggingLSResourceResolver ();
lrr.setWrappedResourceResolver (new LoggingLSResourceResolver ());
lrr.resolveResource ("xsd", "nsuri", null, "sysid", "baseURI");
}
示例11: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@SuppressWarnings ("resource")
@Test
public void testAll () throws IOException
{
final NonBlockingByteArrayInputStream baos = new NonBlockingByteArrayInputStream (new byte [100]);
final WrappedInputStream ws = new WrappedInputStream (baos);
assertTrue (ws.markSupported ());
assertEquals (100, ws.available ());
ws.mark (0);
ws.read ();
ws.read (new byte [4]);
ws.read (new byte [5], 1, 1);
ws.skip (4);
assertEquals (90, ws.available ());
ws.reset ();
assertEquals (100, ws.available ());
ws.close ();
CommonsTestHelper.testToStringImplementation (ws);
try
{
new WrappedInputStream (null).close ();
fail ();
}
catch (final NullPointerException ex)
{}
}
示例12: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll () throws IOException
{
CountingFileInputStream aCIS = new CountingFileInputStream ("pom.xml");
try
{
aCIS.read ();
assertEquals (1, aCIS.read (new byte [5], 1, 1));
StreamHelper.copyInputStreamToOutputStream (aCIS, new NonBlockingByteArrayOutputStream ());
CommonsTestHelper.testToStringImplementation (aCIS);
}
finally
{
StreamHelper.close (aCIS);
}
aCIS = new CountingFileInputStream (new File ("pom.xml"));
try
{
aCIS.read ();
assertEquals (1, aCIS.read (new byte [5], 1, 1));
StreamHelper.copyInputStreamToOutputStream (aCIS, new NonBlockingByteArrayOutputStream ());
CommonsTestHelper.testToStringImplementation (aCIS);
}
finally
{
StreamHelper.close (aCIS);
}
}
示例13: testCtor
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testCtor ()
{
final IFileOperationManager aFOM = new FileOperationManager ();
assertNull (aFOM.getLastError ());
assertNull (aFOM.getLastOperation ());
CommonsTestHelper.testToStringImplementation (aFOM);
}
示例14: testAll
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testAll ()
{
final FormatterStringSkipPrefixAndSuffix fp = new FormatterStringSkipPrefixAndSuffix ("a", "o");
assertEquals ("bc", fp.apply ("abco"));
assertEquals ("bc", fp.apply ("abc"));
assertEquals ("bc", fp.apply ("bco"));
assertEquals ("bc", fp.apply ("bc"));
CommonsTestHelper.testToStringImplementation (fp);
}
示例15: testSuffix
import com.helger.commons.mock.CommonsTestHelper; //导入方法依赖的package包/类
@Test
public void testSuffix ()
{
final FormatterStringSkipPrefixAndSuffix fp = FormatterStringSkipPrefixAndSuffix.createSuffixOnly ("o");
assertEquals ("abc", fp.apply ("abco"));
assertEquals ("abc", fp.apply ("abc"));
assertEquals ("bc", fp.apply ("bco"));
assertEquals ("bc", fp.apply ("bc"));
CommonsTestHelper.testToStringImplementation (fp);
}