-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55759db
commit b75ddc8
Showing
20 changed files
with
1,024 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
integration-tests/jt400/src/main/java/com/ibm/as400/access/MockAS400.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.as400.access; | ||
|
||
import java.io.IOException; | ||
|
||
public class MockAS400 extends AS400 { | ||
|
||
private final MockAS400ImplRemote as400ImplRemote; | ||
|
||
public MockAS400(MockAS400ImplRemote as400ImplRemote) { | ||
this.as400ImplRemote = as400ImplRemote; | ||
} | ||
|
||
@Override | ||
public AS400Impl getImpl() { | ||
return as400ImplRemote; | ||
} | ||
|
||
@Override | ||
public int getCcsid() { | ||
//ConvTable37 depends on this value | ||
return 37; | ||
} | ||
|
||
@Override | ||
public boolean isConnected(int service) { | ||
//always connected | ||
return true; | ||
} | ||
|
||
@Override | ||
public void connectService(int service, int overridePort) throws AS400SecurityException, IOException { | ||
//connection to real i server is ignored | ||
setSignonInfo(-1, -1, "username"); | ||
} | ||
|
||
@Override | ||
synchronized void signon(boolean keepConnection) throws AS400SecurityException, IOException { | ||
//do nothing | ||
} | ||
|
||
@Override | ||
public int getVRM() throws AS400SecurityException, IOException { | ||
return 1; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
integration-tests/jt400/src/main/java/com/ibm/as400/access/MockAS400ImplRemote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.as400.access; | ||
|
||
import java.io.IOException; | ||
|
||
public class MockAS400ImplRemote extends AS400ImplRemote { | ||
|
||
AS400Server getConnection(int service, boolean forceNewConnection, | ||
boolean skipSignonServer) throws AS400SecurityException, IOException { | ||
return new MockAS400Server(this); | ||
} | ||
|
||
@Override | ||
public String getNLV() { | ||
return "012345678901234567890123456789"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
integration-tests/jt400/src/main/java/com/ibm/as400/access/MockAS400Server.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.as400.access; | ||
|
||
import java.io.IOException; | ||
|
||
public class MockAS400Server extends AS400NoThreadServer { | ||
|
||
MockAS400Server(AS400ImplRemote system) throws IOException { | ||
super(system, 1, new MockSocketContainer(), "job/String/something"); | ||
} | ||
|
||
@Override | ||
public DataStream sendAndReceive(DataStream requestStream) throws IOException { | ||
if (!MockedResponses.isEmpty()) { | ||
return MockedResponses.removeFirst(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
integration-tests/jt400/src/main/java/com/ibm/as400/access/MockSocketContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.as400.access; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.net.Socket; | ||
import java.net.SocketException; | ||
|
||
public class MockSocketContainer extends SocketContainer { | ||
|
||
ByteArrayOutputStream bOutput = new ByteArrayOutputStream(50); | ||
|
||
byte[] _data = new byte[50]; | ||
|
||
public MockSocketContainer() { | ||
|
||
// https://github.com/IBM/JTOpen/blob/98e74fae6d212563a1558abce60ea5c73fcfc0c0/src/main/java/com/ibm/as400/access/ClientAccessDataStream.java#L70 | ||
_data[6] = (byte) 0xE0; | ||
|
||
//sets length to 49 | ||
_data[1] = 0; | ||
_data[2] = 0; | ||
_data[3] = '1'; | ||
|
||
_data[4] = 0; | ||
_data[5] = 0; | ||
_data[7] = 0; | ||
} | ||
|
||
@Override | ||
void setProperties(Socket socket, String serviceName, String systemName, int port, SSLOptions options) throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
void close() throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
InputStream getInputStream() throws IOException { | ||
return new ByteArrayInputStream(_data); | ||
} | ||
|
||
@Override | ||
OutputStream getOutputStream() throws IOException { | ||
return bOutput; | ||
} | ||
|
||
@Override | ||
void setSoTimeout(int timeout) throws SocketException { | ||
|
||
} | ||
|
||
@Override | ||
int getSoTimeout() throws SocketException { | ||
return 0; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
integration-tests/jt400/src/main/java/com/ibm/as400/access/MockedResponses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ibm.as400.access; | ||
|
||
import java.util.LinkedList; | ||
|
||
public class MockedResponses { | ||
|
||
private static LinkedList<DataStream> responses = new LinkedList<>(); | ||
|
||
public static void add(DataStream dataStream) { | ||
responses.add(dataStream); | ||
} | ||
|
||
public static DataStream removeFirst() { | ||
return responses.removeFirst(); | ||
} | ||
|
||
public static boolean isEmpty() { | ||
return responses.isEmpty(); | ||
} | ||
} |
Oops, something went wrong.