inital commit

This commit is contained in:
2021-11-02 13:38:59 -05:00
commit 01dd8525b1
65 changed files with 5267 additions and 0 deletions
@@ -0,0 +1,42 @@
package com.reliancy.dbo;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
public class TerminalTest {
public static class Maps extends DBO{
public static Field map_id=new Field("Map_id",Integer.class);
public static Field map_name=new Field("Map_name",String.class);
static{
Entity.publish(Maps.class);
}
}
/**
* Plain CRUD
* @throws IOException
* @throws SQLException
*/
@Test
public void connection() throws IOException, SQLException{
String url="jdbc:postgresql://postgres:Ramudin99@bigbang:5432/Test";
SQLTerminal t=new SQLTerminal(url);
try(Connection c=t.getConnection()){
System.out.println("Connection:"+c);
try (Statement stmt = c.createStatement()) {
// use stmt here
String sql = "SELECT * from \"dbo\".\"Maps\"";
try (ResultSet resultSet = stmt.executeQuery(sql)) {
// use resultSet here
while (resultSet.next()) {
System.out.println("ROw:"+resultSet.getInt("Map_id")+":"+resultSet.getString("Map_name"));
}
}
}
}
}
}
@@ -0,0 +1,47 @@
package com.reliancy.jabba;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class RouterTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
Pattern p=Pattern.compile("(/hello)|(/hello2(/c))|(/hello3)");
Matcher m=p.matcher("/hello2/c");
if(m.matches()){
for(int i=0;i<m.groupCount();i++){
System.out.println(i+":"+m.group(i));
}
}
assertTrue( true );
}
@Test
public void initRouter()
{
//assertTrue( true );
System.out.println("Test router init...");
Router r=new Router();
RouterEndPoint rep=r.importEndPoints(r);
rep.compile();
//Matcher m=rep.match("GET","/helloPlain");
Matcher m=rep.match("GET","/hello3/45");
//Matcher m=rep.match("GET","/helloP");
if(m!=null){
HashMap<String,String> pms=new HashMap<>();
String rt=rep.evalMatcher(m,pms);
System.out.println(rt);
System.out.println(pms);
}
}
}
@@ -0,0 +1,37 @@
package com.reliancy.rec;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
public class ObjTest {
/**
* Plain CRUD
* @throws IOException
*/
@Test
public void crudVec() throws IOException
{
Obj o=new Obj();
Obj a=new Obj(true);
System.out.println("O1:"+o);
System.out.println("A1:"+a);
a.add(1).add("three");
o.add(1).add("three").set(new Slot("arr"),new String[]{"a","b","c"});
System.out.println("O2meta:"+o.isArray()+"/"+o.meta());
System.out.println("O2:"+o);
System.out.println("A2:"+a);
o.set(o.getSlot("car"),"bar");
System.out.println("O3:"+o);
StringBuilder json=new StringBuilder();
JSON.writes(o,json);
System.out.println("ENC:"+json);
Rec dec=JSON.reads(json);
System.out.println("DEC:"+dec);
}
}