Java 类java.io.StringBufferInputStream 实例源码

项目:VerveineC-Cpp    文件:IncludeFilterTest.java   
public static void main(String[] args) throws IOException {
        byte[] srcBuf = new byte[SRC.length()];
        InputStream input = new IncludeToLowerInputStream( new StringBufferInputStream(SRC) );
//      InputStream input =  new StringBufferInputStream(SRC) ;

        if ( TGT.length() != input.read(srcBuf)) {
            System.err.println("too few charcaters in converted string");
            System.exit(0);
        };

        if (! TGT.equals(new String(srcBuf))) {
            System.err.println("Converted string not equal to expected string");
            System.exit(0);
        }

        System.out.println("Everything went accroding to plans");

        input.close();  // useless but avoid warnings in Eclipse
    }
项目:openjdk-jdk10    文件:Bug6573786.java   
void runTest(String xmlString) {
    Bug6573786ErrorHandler handler = new Bug6573786ErrorHandler();
    try {
        InputStream is = new StringBufferInputStream(xmlString);
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        parser.parse(is, handler);
    } catch (Exception e) {
        if (handler.fail) {
            Assert.fail("The value of standalone attribute should be merged into the error message.");
        }
    }

}
项目:LewisOmniscientDebugger    文件:CodePane.java   
private static VectorD getDemoList(String sourceFileName) {
    BufferedReader r;
    if (Debugger.clazz == com.lambda.Debugger.QuickSortNonThreaded.class) {
    r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(QuickSortNonThreadedString.programString)));
    return(buildFileLines(r, sourceFileName));
    }
    if (Debugger.clazz == com.lambda.Debugger.Rewrite.class) {
    r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(RewriteString.programString)));
    return(buildFileLines(r, sourceFileName));
    }
    if (Debugger.clazz == com.lambda.Debugger.Demo.class) {
    r = new BufferedReader(new InputStreamReader(new StringBufferInputStream(DemoString.programString)));
    return(buildFileLines(r, sourceFileName));
    }
return null;
}
项目:sonar-tsql-plugin    文件:AntrlFileTest.java   
@Test
public void compareWithAntrl() {
    String s = "select " + "*" + "from dbo.test";
    AntrlResult result = Antlr4Utils.getFull(s);
    SourceLinesProvider p = new SourceLinesProvider();
    SourceLine[] lines = p.getLines(new StringBufferInputStream(s), Charset.defaultCharset());
    FillerRequest file = new FillerRequest(null, null, result.getTree(), lines);
    for (Token t : result.getStream().getTokens()) {
        if (t.getType() == Token.EOF) {
            continue;
        }
        int[] start = file.getLineAndColumn(t.getStartIndex());
        int[] end = file.getLineAndColumn(t.getStopIndex());
        Assert.assertNotNull(start);
        Assert.assertNotNull(end);
        Assert.assertEquals(t.getLine(), start[0]);
        System.out.println(t.getText() + Arrays.toString(start) + " " + t.getCharPositionInLine() + " "
                + t.getLine() + " " + Arrays.toString(end));
        Assert.assertEquals(t.getCharPositionInLine(), start[1]);
    }
}
项目:openxds    文件:MultipartMap.java   
/**
 * Used for testing and demonstration purposes.
 */
static public void main(String args[]) throws Exception, java.io.IOException {
    try {
        //String xx = "------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------=_Part_2_9110923.1073664290010\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------=_Part_2_9110923.1073664290010--\r\n";
        String xx = "------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:d4bfb124-7922-45bc-a03d-823351eed716\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/transform.html\r\n------_Part_\r\nContent-Type: text/plain\r\nContent-ID: urn:uuid:45b90888-49c1-4b64-a8eb-e94f541368f0\r\n\r\nhttp://ratbert.ncsl.nist.gov:8081/hl7services/rawSQL.html\r\n------_Part_--\r\n";
        StringBufferInputStream is = new StringBufferInputStream(xx);
        String contentType = "multipart/related; boundary=----_Part_";
        ByteArrayDataSource ds = new ByteArrayDataSource(is,  contentType);
        //ByteArrayDataSource ds = new ByteArrayDataSource();
        javax.mail.internet.MimeMultipart mp = new javax.mail.internet.MimeMultipart(ds);
        int i = mp.getCount();
    } catch (javax.mail.MessagingException me) {
        throw new Exception("messaging exception in parsing for MultipartMap");
    }
    System.out.println("Done");
}
项目:groovy    文件:DependencyTest.java   
public void testTransitiveDep(){
    cu.addSource("testTransitiveDep.gtest", new StringBufferInputStream(
            "class A1 {}\n" +
            "class A2 extends A1{}\n" +
            "class A3 extends A2{}\n"
    ));
    cu.compile(Phases.CLASS_GENERATION);
    cache.makeTransitiveHull();

    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(),1);

    dep = cache.get("A2");
    assertEquals(dep.size(),2);
    assertTrue(dep.contains("A1"));

    dep = cache.get("A3");
    assertEquals(dep.size(),3);
    assertTrue(dep.contains("A1"));
    assertTrue(dep.contains("A2"));
}
项目:com.obdobion.funnelsort    文件:InputTest.java   
/**
 * <p>
 * sysinFileout.
 * </p>
 *
 * @throws java.lang.Throwable if any.
 */
@Test
public void sysinFileout() throws Throwable
{
    final String testName = Helper.testName();
    Helper.initializeFor(testName);

    final List<String> out = new ArrayList<>();
    out.add("line 1");
    out.add("line 2");

    final StringBuilder sb = new StringBuilder();
    for (final String outline : out)
        sb.append(outline).append(System.getProperty("line.separator"));
    final InputStream inputStream = new StringBufferInputStream(sb.toString());
    System.setIn(inputStream);

    final File file = Helper.outFileWhenInIsSysin();

    final FunnelContext context = Funnel.sort(Helper.config(), "-o" + file.getAbsolutePath()
            + " --row 2 -c original");

    Assert.assertEquals("records", 2L, context.getRecordCount());
    Helper.compare(file, out);
    Assert.assertTrue("delete " + file.getAbsolutePath(), file.delete());
}
项目:openbd-core    文件:TreeApplet.java   
private Vector getData(String a){
    //-- Put them together
    int x = 0;
    StringBuilder appletP   = new StringBuilder(128);
    String line = thisApplet.getParameter("treedata" + x);
    while (line!=null){
        appletP.append( line.substring(1,line.length()-1) );
        x++;
        line    = thisApplet.getParameter("treedata" + x);
    }

    String appletParam  = appletP.toString();

    tags        = new Stack();
    params  = new Stack();
    StringBufferInputStream s = new StringBufferInputStream(appletParam);   

    try{
        parseXML(s);
    }catch(Throwable E){
        E.printStackTrace();
        return null;
    }

    return (Vector)params.peek();
}
项目:In-the-Box-Fork    文件:StreamTokenizerTest.java   
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "StreamTokenizer",
    args = {java.io.InputStream.class}
)
public void test_ConstructorLjava_io_InputStream() throws IOException {
    st = new StreamTokenizer(new StringBufferInputStream(
            "/comments\n d 8 'h'"));

    assertEquals("the next token returned should be the letter d",
             StreamTokenizer.TT_WORD, st.nextToken());
    assertEquals("the next token returned should be the letter d",
             "d", st.sval);

    assertEquals("the next token returned should be the digit 8",
             StreamTokenizer.TT_NUMBER, st.nextToken());
    assertEquals("the next token returned should be the digit 8",
             8.0, st.nval);

    assertEquals("the next token returned should be the quote character",
             39, st.nextToken());
    assertEquals("the next token returned should be the quote character",
             "h", st.sval);
}
项目:lightblue-client    文件:LightblueHttpClientTest.java   
@Test
public void testStreaming() throws Exception {
    when(httpTransport.executeRequestGetStream(any(LightblueRequest.class),anyString())).
        thenReturn(new StringBufferInputStream(streamingResponse.replaceAll("'","\"")));
    LightblueClientConfiguration c = new LightblueClientConfiguration();
    try (LightblueHttpClient httpClient = new LightblueHttpClient(c, httpTransport)) {
        DataFindRequest findRequest = new DataFindRequest("test");
        findRequest.where(Query.withValue("a = b"));
        findRequest.select(Projection.includeField("foo"));
        ResultStream response=httpClient.prepareFind(findRequest);
        final List<JsonNode> docs=new ArrayList<JsonNode>();
        response.run(new ResultStream.ForEachDoc() {
                @Override
                public boolean processDocument(ResultStream.StreamDoc doc) {
                    docs.add(doc.doc);
                    return true;
                }
            });
        Assert.assertEquals(9,docs.size());

    }
}
项目:lightblue-client    文件:LightblueHttpClientTest.java   
@Test
public void testNotStreaming() throws Exception {
    when(httpTransport.executeRequestGetStream(any(LightblueRequest.class),anyString())).
        thenReturn(new StringBufferInputStream(nonStreamingResponse.replaceAll("'","\"")));
    LightblueClientConfiguration c = new LightblueClientConfiguration();
    try (LightblueHttpClient httpClient = new LightblueHttpClient(c, httpTransport)) {
        DataFindRequest findRequest = new DataFindRequest("test");
        findRequest.where(Query.withValue("a = b"));
        findRequest.select(Projection.includeField("foo"));
        ResultStream response=httpClient.prepareFind(findRequest);
        final List<JsonNode> docs=new ArrayList<JsonNode>();
        response.run(new ResultStream.ForEachDoc() {
                @Override
                public boolean processDocument(ResultStream.StreamDoc doc) {
                    docs.add(doc.doc);
                    return true;
                }
            });
        Assert.assertEquals(9,docs.size());

    }
}
项目:cn1    文件:CachedRowSetImpl.java   
@SuppressWarnings("deprecation")
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
    Object obj = getObject(columnIndex);
    if (obj == null) {
        return null;
    }
    if (obj instanceof byte[]) {
        return new StringBufferInputStream(new String((byte[]) obj));
    }

    if (obj instanceof String) {
        return new StringBufferInputStream((String) obj);
    }

    if (obj instanceof char[]) {
        return new StringBufferInputStream(new String((char[]) obj));
    }

    // rowset.10=Data Type Mismatch
    throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
}
项目:cn1    文件:CachedRowSetStreamTest.java   
public void testGetUnicodeStream_Not_Ascii() throws Exception {
    String value = new String("\u548c\u8c10");
    insertRow(100, value, null);
    rs = st.executeQuery("SELECT * FROM STREAM WHERE ID = 100");
    crset = newNoInitialInstance();
    crset.populate(rs);

    crset.next();

    assertTrue(crset.getObject(2) instanceof String);
    assertEquals(value, crset.getString(2));

    InputStream in = crset.getUnicodeStream(2);
    StringBufferInputStream sin = new StringBufferInputStream(value);

    int i = -1;
    while ((i = in.read()) != -1) {
        assertEquals(sin.read(), i);
    }

}
项目:cn1    文件:StreamTokenizerTest.java   
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
@SuppressWarnings("deprecation")
   public void test_ConstructorLjava_io_InputStream() throws IOException {
    st = new StreamTokenizer(new StringBufferInputStream(
            "/comments\n d 8 'h'"));

    assertEquals("the next token returned should be the letter d",
             StreamTokenizer.TT_WORD, st.nextToken());
    assertEquals("the next token returned should be the letter d",
             "d", st.sval);

    assertEquals("the next token returned should be the digit 8",
             StreamTokenizer.TT_NUMBER, st.nextToken());
    assertEquals("the next token returned should be the digit 8",
             8.0, st.nval);

    assertEquals("the next token returned should be the quote character",
             39, st.nextToken());
    assertEquals("the next token returned should be the quote character",
             "h", st.sval);
}
项目:uDig-WPS-plugin    文件:WPSConfig.java   
private synchronized void readObject(java.io.ObjectInputStream oos) throws IOException, ClassNotFoundException
{       
    try
    {
        String wpsConfigXMLBeansAsXml = (String) oos.readObject();
        XmlObject configXmlObject = XmlObject.Factory.parse(wpsConfigXMLBeansAsXml);
        WPSConfigurationDocument configurationDocument = WPSConfigurationDocument.Factory.newInstance();
        configurationDocument.addNewWPSConfiguration().set(configXmlObject);
        wpsConfig = new WPSConfig(new StringBufferInputStream(configurationDocument.xmlText()));
    }
    catch (XmlException e)
    {
        LOGGER.error(e.getMessage());
        throw new IOException(e.getMessage());
    }
}
项目:freeVM    文件:StreamTokenizerTest.java   
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
public void test_ConstructorLjava_io_InputStream() throws IOException {
    st = new StreamTokenizer(new StringBufferInputStream(
            "/comments\n d 8 'h'"));

    assertEquals("the next token returned should be the letter d",
             StreamTokenizer.TT_WORD, st.nextToken());
    assertEquals("the next token returned should be the letter d",
             "d", st.sval);

    assertEquals("the next token returned should be the digit 8",
             StreamTokenizer.TT_NUMBER, st.nextToken());
    assertEquals("the next token returned should be the digit 8",
             8.0, st.nval);

    assertEquals("the next token returned should be the quote character",
             39, st.nextToken());
    assertEquals("the next token returned should be the quote character",
             "h", st.sval);
}
项目:freeVM    文件:CachedRowSetImpl.java   
@SuppressWarnings("deprecation")
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
    Object obj = getObject(columnIndex);
    if (obj == null) {
        return null;
    }
    if (obj instanceof byte[]) {
        return new StringBufferInputStream(new String((byte[]) obj));
    }

    if (obj instanceof String) {
        return new StringBufferInputStream((String) obj);
    }

    if (obj instanceof char[]) {
        return new StringBufferInputStream(new String((char[]) obj));
    }

    // rowset.10=Data Type Mismatch
    throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
}
项目:freeVM    文件:CachedRowSetStreamTest.java   
public void testGetUnicodeStream_Not_Ascii() throws Exception {
    String value = new String("\u548c\u8c10");
    insertRow(100, value, null);
    rs = st.executeQuery("SELECT * FROM STREAM WHERE ID = 100");
    crset = newNoInitialInstance();
    crset.populate(rs);

    crset.next();

    assertTrue(crset.getObject(2) instanceof String);
    assertEquals(value, crset.getString(2));

    InputStream in = crset.getUnicodeStream(2);
    StringBufferInputStream sin = new StringBufferInputStream(value);

    int i = -1;
    while ((i = in.read()) != -1) {
        assertEquals(sin.read(), i);
    }

}
项目:freeVM    文件:StreamTokenizerTest.java   
/**
 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
 */
@SuppressWarnings("deprecation")
   public void test_ConstructorLjava_io_InputStream() throws IOException {
    st = new StreamTokenizer(new StringBufferInputStream(
            "/comments\n d 8 'h'"));

    assertEquals("the next token returned should be the letter d",
             StreamTokenizer.TT_WORD, st.nextToken());
    assertEquals("the next token returned should be the letter d",
             "d", st.sval);

    assertEquals("the next token returned should be the digit 8",
             StreamTokenizer.TT_NUMBER, st.nextToken());
    assertEquals("the next token returned should be the digit 8",
             8.0, st.nval);

    assertEquals("the next token returned should be the quote character",
             39, st.nextToken());
    assertEquals("the next token returned should be the quote character",
             "h", st.sval);
}
项目:jeql    文件:InputSource.java   
private InputStream createStreamUnchecked()
  throws Exception
{
  if (data != null) {
    return new StringBufferInputStream(data);
  }
  // TODO: handle protocols in case-insensitive way
  // TODO: add more protocol checks (or pattern?)
  if (isHTTP()) {
    URL url = new URL(srcName);
    return url.openStream();
  }
  // default: assume srcName refers to file
  return new FileInputStream(srcName);

}
项目:jcliff    文件:ResolveTest.java   
@Test
public void childrenTest() throws Exception {
    StringBufferInputStream is=new StringBufferInputStream("{\"A\"=>{"+
                                                           "\"B\"=>{"+
                                                           " \"c\"=>1L ,"+
                                                           " \"d\"=>2L ,"+
                                                           " \"e\"=>3L ,"+
                                                           " \"f\"=>4L ,"+
                                                           " \"g\"=>5L  } } }");
    ModelNode node=ModelNode.fromStream(is); 
    List<NodePath> allPaths=NodePath.getPaths(node);
    PathExpression p=new PathExpression("A","B");
    List<String> list=Configurable.getChildren(allPaths,p);
    Assert.assertEquals(5,list.size());
    Assert.assertEquals("c",list.get(0));
    Assert.assertEquals("d",list.get(1));
    Assert.assertEquals("e",list.get(2));
    Assert.assertEquals("f",list.get(3));
    Assert.assertEquals("g",list.get(4));
}
项目:jcliff    文件:ResolveTest.java   
@Test
public void loopTest() throws Exception {
    StringBufferInputStream is=new StringBufferInputStream("{\"A\"=>{"+
                                                           "\"B\"=>{"+
                                                           " \"c\"=>1L ,"+
                                                           " \"d\"=>2L ,"+
                                                           " \"e\"=>3L ,"+
                                                           " \"f\"=>4L ,"+
                                                           " \"g\"=>5L  } } }");
    ModelNode node=ModelNode.fromStream(is); 
    ctx.configPaths=NodePath.getPaths(node);

    String[] script=Configurable.resolve(new PathExpression("A","B"),
                                    ctx.configPaths,
                                    "${foreach-cfg (/A/B),(/subsystem=test/do-something:${name(.)},${value(.)}) }",
                                    ctx);
    Assert.assertEquals("/subsystem=test/do-something:c,1L",script[0]);
    Assert.assertEquals("/subsystem=test/do-something:d,2L",script[1]);
    Assert.assertEquals("/subsystem=test/do-something:e,3L",script[2]);
    Assert.assertEquals("/subsystem=test/do-something:f,4L",script[3]);
    Assert.assertEquals("/subsystem=test/do-something:g,5L",script[4]);
}
项目:OpenNotification    文件:AbstractDevice.java   
public static Device createFromXML(String xml) throws NotificationException {
    Device device = null;
    try {
        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new StringBufferInputStream(xml));
        NodeList types = document.getElementsByTagName("type");
        if ((types == null) || (types.getLength()<=0)) {
            throw new NotificationException(NotificationException.NOT_ACCEPTABLE, "Device type not specified");
        }
        String type = types.item(0).getFirstChild().getNodeValue();
        BrokerFactory.getLoggingBroker().logDebug("new type="+type);
        device = (Device)Class.forName(type).newInstance();

        device.readXML(document.getElementsByTagName("settings").item(0));
    } catch (Exception anyExc) {
        BrokerFactory.getLoggingBroker().logError(anyExc);
        throw new NotificationException(NotificationException.FAILED, anyExc.getMessage());
    }

    return device;
}
项目:camunda-task-dispatcher    文件:ExternalTaskRestServiceImplTest.java   
@Before
public void test() throws IOException {
    Mockito.when(objectMapper.writeValueAsString(Mockito.any())).thenReturn("JSON");
    Mockito.when(objectMapper.getTypeFactory()).thenReturn(typeFactory);
    Mockito.when(objectMapper.readValue(Mockito.<InputStream>any(), Mockito.<JavaType>any())).thenReturn(Collections.singletonList(new LockedExternalTaskDto()));

    Mockito.when(httpClient.execute(Mockito.any())).thenReturn(response);

    Mockito.when(response.getEntity()).thenReturn(httpEntity);
    Mockito.when(response.getStatusLine()).thenReturn(statusLine);

    Mockito.when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK);

    Mockito.when(httpEntity.getContent()).thenReturn(new StringBufferInputStream("http response"));

    service = new ExternalTaskRestServiceImpl();

    JavaUtils.setFieldWithoutCheckedException(
            ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "objectMapper")
            , service
            , objectMapper
    );
    JavaUtils.setFieldWithoutCheckedException(
            ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "httpClient")
            , service
            , httpClient
    );
    JavaUtils.setFieldWithoutCheckedException(
            ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "engineUrl")
            , service
            , "someurl"
    );
}
项目:oscm    文件:HttpServletRequestStub.java   
@Override
public ServletInputStream getInputStream() throws IOException {

    if (throwExceptionForISAccess) {
        throw new IOException();
    }
    return new BufferedServletInputStream(new StringBufferInputStream(
            bodyContent));
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntLogicalSysEditor.java   
@Override
public void doSave(IProgressMonitor monitor) {
    try {
        LogicalSystemNode node = (LogicalSystemNode) root.getModel();
        FileEditorInput inp = (FileEditorInput) getEditorInput();
        inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getLogicalSysEditorContent(node)), IFile.FORCE, monitor);
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntFinalAssemblyEditor.java   
@Override
public void doSave(IProgressMonitor monitor) {
    try {
        CompositeNode node = (CompositeNode) root.getModel();
        FileEditorInput inp = (FileEditorInput) getEditorInput();
        inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getIntFinalAssemblyEditorContent(node)), IFile.FORCE, monitor);
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:IntDeploymentEditor.java   
@Override
public void doSave(IProgressMonitor monitor) {
    try {
        DeploymentNode node = (DeploymentNode) root.getModel();
        FileEditorInput inp = (FileEditorInput) getEditorInput();
        inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getIntDeploymentEditorContent(node)), IFile.FORCE, monitor);
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:CompImplEditor.java   
@Override
public void doSave(IProgressMonitor monitor) {
    try {
        ComponentImplementationNode node = (ComponentImplementationNode) root.getModel();
        FileEditorInput inp = (FileEditorInput) getEditorInput();
        inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getCompImplEditorContent(node)), IFile.FORCE, monitor);
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Open_Source_ECOA_Toolset_AS5    文件:InitAssemblyEditor.java   
@Override
public void doSave(IProgressMonitor monitor) {
    try {
        CompositeNode node = (CompositeNode) root.getModel();
        FileEditorInput inp = (FileEditorInput) getEditorInput();
        inp.getFile().setContents(new StringBufferInputStream(ParseUtil.getInitAssemblyEditorContent(node)), IFile.FORCE, monitor);
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:CacheManage    文件:Base64Util.java   
public static boolean check(String str) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(new StringBufferInputStream(str)));
    ByteBuffer buffer = ByteBuffer.allocate(1024);
    String line = null;
    String lastLine = null;

    byte[] lastLineBytes;
    while ((line = br.readLine()) != null) {
        lastLine = line;
        lastLineBytes = line.getBytes();
        tryAllocate(buffer, lastLineBytes.length);
        buffer.put(lastLineBytes);
    }

    lastLineBytes = lastLine.getBytes();
    int equalsNum = 0;

    for (int src = lastLineBytes.length - 1; src >= lastLineBytes.length - 2; --src) {
        if (lastLineBytes[src] == 61) {
            ++equalsNum;
        }
    }

    byte[] var10 = buffer.toString().getBytes();

    for (int i = 0; i < var10.length - equalsNum; ++i) {
        char c = (char) var10[i];
        if ((c < 97 || c > 122) && (c < 65 || c > 90) && (c < 48 || c > 57) && c != 43 && c != 47) {
            return false;
        }
    }

    if ((var10.length - equalsNum) % 4 != 0) {
        return false;
    } else {
        return true;
    }
}
项目:jdk8u-jdk    文件:OverflowInRead.java   
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    try (StringBufferInputStream sbis = new StringBufferInputStream(s)) {
        int len1 = 33;
        byte[] buf1 = new byte[len1];
        if (sbis.read(buf1, 0, len1) != len1)
            throw new Exception("Expected to read " + len1 + " bytes");

        int len2 = Integer.MAX_VALUE - 32;
        byte[] buf2 = new byte[len2];
        int expLen2 = s.length() - len1;
        if (sbis.read(buf2, 0, len2) != expLen2)
            throw new Exception("Expected to read " + expLen2 + " bytes");
    }
}
项目:jdk8u-jdk    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:openjdk-jdk10    文件:OverflowInRead.java   
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    try (StringBufferInputStream sbis = new StringBufferInputStream(s)) {
        int len1 = 33;
        byte[] buf1 = new byte[len1];
        if (sbis.read(buf1, 0, len1) != len1)
            throw new Exception("Expected to read " + len1 + " bytes");

        int len2 = Integer.MAX_VALUE - 32;
        byte[] buf2 = new byte[len2];
        int expLen2 = s.length() - len1;
        if (sbis.read(buf2, 0, len2) != expLen2)
            throw new Exception("Expected to read " + expLen2 + " bytes");
    }
}
项目:openjdk-jdk10    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:openjdk9    文件:ExtensionsWithLDAP.java   
public static X509Certificate loadCertificate(String s)
        throws IOException, CertificateException {

    try (StringBufferInputStream is = new StringBufferInputStream(s)) {
        return (X509Certificate) CertificateFactory.getInstance("X509")
                .generateCertificate(is);
    }
}
项目:openjdk9    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:openjdk9    文件:Bug6573786.java   
void runTest(String xmlString) {
    Bug6573786ErrorHandler handler = new Bug6573786ErrorHandler();
    try {
        InputStream is = new StringBufferInputStream(xmlString);
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        parser.parse(is, handler);
    } catch (Exception e) {
        if (handler.fail) {
            Assert.fail("The value of standalone attribute should be merged into the error message.");
        }
    }

}
项目:Java-education    文件:TestAddTwoNum.java   
@Test
public void WhenPutInFlowIntThanGetItFromFlow() throws IOException {
    AddTwoNum obj = new AddTwoNum();
    System.setIn(new StringBufferInputStream("1"));
    int result = obj.mainFlow(new InputStreamReader(System.in));
    int message = 1;
    Assert.assertThat(result,is(message));
}
项目:delay-tolerant-network    文件:MovementListenerTest.java   
/**
 * Tests whether initialLocation() gets called correctly when settings up
 * a SimScenario
 *
 * @throws Exception
 */
@Test
public void testInitialLocation()
throws Exception {
    // TODO: If more test cases are added that use Settings, they might
    // be run in parallel and break.

    // Setup the settings
    Settings.initFromStream(
            new StringBufferInputStream(INITIAL_LOC_TEST_SETTINGS));
    final DTNSimUI ui = new DTNSimUI() {
        @Override
        protected void runSim() {
            super.done();
        }
    };

    // Set the delegate for MovementListenerTestReport
    MovementListenerTestReport.setDelegate(new MovementReport());

    // Start the DTNSimUI, this will create SimScenario instance with all
    // the nodes and reports based on the configuration.
    ui.start();

    assertEquals("initialLocation() called incorrect number of time.",
            INITIAL_LOC_TEST_NODE_COUNT, INITIAL_LOC_CALL_COUNT);
}